-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29835: Fix typos and inconsistencies in CacheAwareLoadBalancer #7644
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
Merged
+6
−12
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
|
Member
Author
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. Note that it would log |
||
| 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()); | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note that it would log current ratio twice