diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/CacheAwareLoadBalancer.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/CacheAwareLoadBalancer.java index 30e4b5212bfb..867c6f8aadb2 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/CacheAwareLoadBalancer.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/CacheAwareLoadBalancer.java @@ -23,12 +23,11 @@ * periodically and restores the cache when it is restarted. This balancer implements a mechanism * where it maintains the amount by which a region is cached on a region server. During balancer * run, a region plan is generated that takes into account this cache information and tries to - * move the regions so that the cache minimally impacted. + * move the regions so that the cache is minimally impacted. */ import static org.apache.hadoop.hbase.HConstants.BUCKET_CACHE_PERSISTENT_PATH_KEY; -import java.text.DecimalFormat; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; @@ -130,7 +129,7 @@ private void updateRegionLoad() { int regionSizeMB = (int) rm.getRegionSizeMB().get(Size.Unit.MEGABYTE); rload.add(new BalancerRegionLoad(rm)); - // Maintain a map of region and it's total size. This is needed to calculate the cache + // Maintain a map of region and its total size. This is needed to calculate the cache // ratios for the regions cached on old region servers regionCacheRatioOnCurrentServerMap.put(regionEncodedName, new Pair<>(sn, regionSizeMB)); loads.put(regionEncodedName, rload); @@ -285,9 +284,6 @@ private boolean moveRegionToOldServer(BalancerClusterState cluster, int regionIn return false; } - DecimalFormat df = new DecimalFormat("#"); - df.setMaximumFractionDigits(4); - float cacheRatioDiffThreshold = 0.6f; // Conditions for moving the region @@ -307,7 +303,7 @@ private boolean moveRegionToOldServer(BalancerClusterState cluster, int regionIn LOG.debug( "Region {} moved from {} to {} as the region is cached {} equally on both servers", cluster.regions[regionIndex].getEncodedName(), cluster.servers[currentServerIndex], - cluster.servers[oldServerIndex], df.format(cacheRatioOnCurrentServer)); + cluster.servers[oldServerIndex], cacheRatioOnCurrentServer); } return true; } @@ -324,8 +320,7 @@ private boolean moveRegionToOldServer(BalancerClusterState cluster, int regionIn "Region {} moved from {} to {} as region cache ratio {} is better than the current " + "cache ratio {}", cluster.regions[regionIndex].getEncodedName(), cluster.servers[currentServerIndex], - cluster.servers[oldServerIndex], cacheRatioOnCurrentServer, - df.format(cacheRatioOnCurrentServer)); + cluster.servers[oldServerIndex], cacheRatioOnOldServer, cacheRatioOnCurrentServer); } return true; } @@ -334,8 +329,7 @@ private boolean moveRegionToOldServer(BalancerClusterState cluster, int regionIn LOG.debug( "Region {} not moved from {} to {} with current cache ratio {} and old cache ratio {}", cluster.regions[regionIndex], cluster.servers[currentServerIndex], - cluster.servers[oldServerIndex], cacheRatioOnCurrentServer, - df.format(cacheRatioOnCurrentServer)); + cluster.servers[oldServerIndex], cacheRatioOnCurrentServer, cacheRatioOnOldServer); } return false; } @@ -391,7 +385,7 @@ BalanceAction pickRandomRegions(BalancerClusterState cluster, int thisServer, in if (LOG.isDebugEnabled()) { LOG.debug( "CacheAwareSkewnessCandidateGenerator: Region {} moved from {} to {} as it " - + "was hosted their earlier", + + "was hosted there earlier", regionEncodedName, cluster.servers[thisServer].getHostname(), cluster.servers[otherServer].getHostname()); }