Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that it would log current ratio twice

df.format(cacheRatioOnCurrentServer));
cluster.servers[oldServerIndex], cacheRatioOnOldServer, cacheRatioOnCurrentServer);
}
return true;
}
Expand All @@ -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,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that it would log current server ratio twice.

df.format(cacheRatioOnCurrentServer));
cluster.servers[oldServerIndex], cacheRatioOnCurrentServer, cacheRatioOnOldServer);
}
return false;
}
Expand Down Expand Up @@ -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());
}
Expand Down