-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,17 +48,18 @@ public Server choose(ILoadBalancer lb, Object key) { | |
List<Server> upList = lb.getReachableServers(); | ||
List<Server> allList = lb.getAllServers(); | ||
|
||
int upCount = upList.size(); | ||
int serverCount = allList.size(); | ||
if (serverCount == 0) { | ||
if (serverCount == 0 || upCount == 0) { | ||
/* | ||
* No servers. End regardless of pass, because subsequent passes | ||
* No servers or No servers available. End regardless of pass, because subsequent passes | ||
* 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 commentThe reason will be displayed to describe this comment to others. Learn more. Server should not be selected on upList ?
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() |
||
|
||
if (server == null) { | ||
/* | ||
|
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