virajjasani commented on a change in pull request #3024:
URL: https://github.com/apache/hbase/pull/3024#discussion_r589188142



##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/CandidateGenerator.java
##########
@@ -23,15 +23,17 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.hadoop.hbase.BaseConfigurable;
 import org.apache.hadoop.hbase.client.RegionInfo;
 
 import org.apache.yetus.audience.InterfaceAudience;
+import static 
org.apache.hadoop.hbase.HConstants.HBASE_MASTER_BALANCER_RANDOM_PICK_REGIONS_WITH_CONSIDER_COUNT_BALANCE;
 
 /**
  * Generates a candidate action to be applied to the cluster for cost function 
search
  */
 @InterfaceAudience.Private
-abstract class CandidateGenerator {
+abstract class CandidateGenerator extends BaseConfigurable {

Review comment:
       If we directly make changes in test, we can avoid this

##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/CandidateGenerator.java
##########
@@ -104,14 +106,19 @@ int pickOtherRandomRack(BaseLoadBalancer.Cluster cluster, 
int rackIndex) {
     if (thisServer < 0 || otherServer < 0) {
       return BaseLoadBalancer.Cluster.NullAction;
     }
-
-    // Decide who is most likely to need another region
-    int thisRegionCount = cluster.getNumRegions(thisServer);
-    int otherRegionCount = cluster.getNumRegions(otherServer);
-
-    // Assign the chance based upon the above
-    double thisChance = (thisRegionCount > otherRegionCount) ? 0 : 0.5;
-    double otherChance = (thisRegionCount <= otherRegionCount) ? 0 : 0.5;
+    double thisChance = 0.5;
+    double otherChance = 0.5;
+    if (getConf() == null || getConf().getBoolean(
+      HBASE_MASTER_BALANCER_RANDOM_PICK_REGIONS_WITH_CONSIDER_COUNT_BALANCE, 
true)) {

Review comment:
       Is it possible to avoid this logic to resolve test failures? Maybe we 
can make changes in test cases to accommodate this logic rather and avoid using 
this config




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to