HBASE-18252 Resolve BaseLoadBalancer bad practice warnings

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
QilinCao 2017-06-21 18:34:29 +08:00 committed by tedyu
parent 83be50c2ab
commit 00f657fbeb
1 changed files with 2 additions and 10 deletions

View File

@ -914,7 +914,7 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
private Comparator<Integer> numRegionsComparator = new Comparator<Integer>() { private Comparator<Integer> numRegionsComparator = new Comparator<Integer>() {
@Override @Override
public int compare(Integer integer, Integer integer2) { public int compare(Integer integer, Integer integer2) {
return Integer.valueOf(getNumRegions(integer)).compareTo(getNumRegions(integer2)); return Integer.compare(getNumRegions(integer), getNumRegions(integer2));
} }
}; };
@ -929,15 +929,7 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
private Comparator<Integer> localityComparator = new Comparator<Integer>() { private Comparator<Integer> localityComparator = new Comparator<Integer>() {
@Override @Override
public int compare(Integer integer, Integer integer2) { public int compare(Integer integer, Integer integer2) {
float locality1 = getLocality(integer); return Float.compare(getLocality(integer), getLocality(integer2));
float locality2 = getLocality(integer2);
if (locality1 < locality2) {
return -1;
} else if (locality1 > locality2) {
return 1;
} else {
return 0;
}
} }
}; };