-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RandomRule policy modification #393
base: master
Are you sure you want to change the base?
Conversation
@qiangdavidliu Could you please review? |
* only get more restrictive. | ||
*/ | ||
return null; | ||
} | ||
|
||
int index = chooseRandomInt(serverCount); | ||
server = upList.get(index); | ||
server = allList.get(index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Server should not be selected on upList ?
int index = chooseRandomInt(upCount);
server = upList.get(index);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, server should be selected on upList, but the index should not be chosen from serverCount, it may be greater than upList.size()
int serverCount = allList.size(); | ||
if (serverCount == 0) { | ||
if (serverCount == 0 || upCount == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check upCount isn't sufficient ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the server that is reachable is down, then the upCount is 0
just use reachable servers.
|
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.