Skip to content

Commit

Permalink
Merge pull request #46 from qdaxb/fix_localfirst_bug
Browse files Browse the repository at this point in the history
fix bug of localfirst loadbalance, fix #42
  • Loading branch information
half-dead committed May 12, 2016
2 parents 706f1ca + a80c0ba commit e1e2e3a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected void doSelectToHolder(Request request, List<Referer<T>> refersHolder)

List<Referer<T>> localReferers = searchLocalReferer(referers, NetUtils.getLocalAddress().getHostAddress());

if (localReferers.isEmpty()) {
if (!localReferers.isEmpty()) {
Collections.sort(localReferers, new LowActivePriorityComparator<T>());
refersHolder.addAll(localReferers);
}
Expand Down Expand Up @@ -131,8 +131,8 @@ protected void doSelectToHolder(Request request, List<Referer<T>> refersHolder)

private List<Referer<T>> searchLocalReferer(List<Referer<T>> referers, String localhost) {
List<Referer<T>> localReferers = new ArrayList<Referer<T>>();
long local = ipToLong(localhost);
for (Referer<T> referer : referers) {
long local = ipToLong(localhost);
long tmp = ipToLong(referer.getUrl().getHost());
if (local != 0 && local == tmp) {
if (referer.isAvailable()) {
Expand Down

0 comments on commit e1e2e3a

Please sign in to comment.