Open
Conversation
Author
|
@qiangdavidliu Could you please review? |
yyvess
reviewed
Dec 26, 2018
|
|
||
| int index = chooseRandomInt(serverCount); | ||
| server = upList.get(index); | ||
| server = allList.get(index); |
There was a problem hiding this comment.
Server should not be selected on upList ?
int index = chooseRandomInt(upCount);
server = upList.get(index);
Author
There was a problem hiding this comment.
Yes, server should be selected on upList, but the index should not be chosen from serverCount, it may be greater than upList.size()
yyvess
reviewed
Dec 26, 2018
| int upCount = upList.size(); | ||
| int serverCount = allList.size(); | ||
| if (serverCount == 0) { | ||
| if (serverCount == 0 || upCount == 0) { |
Author
There was a problem hiding this comment.
If the server that is reachable is down, then the upCount is 0
|
just use reachable servers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the RandomRule's choose method, it use upList to get server, the index of the server come from "ThreadLocalRandom.current().nextInt(serverCount)", so the serverCount is the number of all server. But to get the reachable server is to use upList like this:

It seems to happen that the index(come from index = ThreadLocalRandom.current().nextInt(serverCount) ) is larger than the upList's size.