ragarkar commented on code in PR #4799:
URL: https://github.com/apache/hbase/pull/4799#discussion_r1106703131


##########
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerClusterState.java:
##########
@@ -553,6 +558,61 @@ enum LocalityType {
     RACK
   }
 
+  public float getOrComputeWeightedPrefetchRatio(int region, int server) {
+    return getRegionSizeMB(region) * 
getOrComputeRegionPrefetchRatio()[region][server];
+  }
+
+  private float[][] getOrComputeRegionPrefetchRatio() {
+    if (regionServerWithBestPrefetchRatio == null || regionServerPrefetchRatio 
== null) {
+      computeRegionServerPrefetchRatio();
+    }
+    return regionServerPrefetchRatio;
+  }
+
+  public int[] getOrComputeServerWithBestPrefetchRatio() {
+    if (regionServerWithBestPrefetchRatio == null || regionServerPrefetchRatio 
== null) {
+      computeRegionServerPrefetchRatio();
+    }
+    return regionServerWithBestPrefetchRatio;
+  }
+
+  private void computeRegionServerPrefetchRatio() {
+    regionServerPrefetchRatio = new float[numRegions][numServers];
+    regionServerWithBestPrefetchRatio = new int[numRegions];
+
+    for (int region = 0; region < numRegions; region++) {
+      float bestPrefetchRatio = 0.0f;
+      int serverWithBestPrefetchRatio = 0;
+      for (int server = 0; server < numServers; server++) {

Review Comment:
   We are iterating through the regions first instead of servers because, we 
also need to find out if the region was previously hosted on that region 
server. If we go the other way i.e. iterate through the servers and then 
iterate through the regions hosted on that server, we will have to iterate 
through all the servers again to find out if this region was previously hosted 
on any of these region servers. Hence, IMO, it's better to iterate through the 
regions before iterating through servers. This way, in the same iteration, we 
can find out whether is region is currently hosted on the given region server 
or if it was previously hosted on this region server.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@hbase.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to