hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecl...@apache.org
Subject svn commit: r1467517 - /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
Date Fri, 12 Apr 2013 23:43:18 GMT
Author: eclark
Date: Fri Apr 12 23:43:17 2013
New Revision: 1467517

URL: http://svn.apache.org/r1467517
Log:
HBASE-8339 Make sure the StochasticLoadBalancer doesn't run a cost function when not needed

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java?rev=1467517&r1=1467516&r2=1467517&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
Fri Apr 12 23:43:17 2013
@@ -370,37 +370,50 @@ public class StochasticLoadBalancer exte
    * @return a double of a cost associated with the proposed
    */
   protected double computeCost(Cluster cluster) {
-
-    double moveCost = moveCostMultiplier * computeMoveCost(cluster);
-
-    double regionCountSkewCost = loadMultiplier * computeSkewLoadCost(cluster);
-    double tableSkewCost = tableMultiplier * computeTableSkewLoadCost(cluster);
-    double localityCost =
-        localityMultiplier * computeDataLocalityCost(cluster);
+    double moveCost = (moveCostMultiplier > 0) ?
+      (moveCostMultiplier * computeMoveCost(cluster)) :
+      0;
+
+    double regionCountSkewCost = (loadMultiplier > 0) ?
+      (loadMultiplier * computeSkewLoadCost(cluster)) :
+      0;
+
+    double tableSkewCost = (tableMultiplier > 0) ?
+      (tableMultiplier * computeTableSkewLoadCost(cluster)) :
+      0;
+
+    double localityCost = (localityMultiplier > 0) ?
+      (localityMultiplier * computeDataLocalityCost(cluster)) :
+      0;
 
     double memstoreSizeCost =
-        memStoreSizeMultiplier
-            * computeRegionLoadCost(cluster, RegionLoadCostType.MEMSTORE_SIZE);
-    double storefileSizeCost =
-        storeFileSizeMultiplier
-            * computeRegionLoadCost(cluster, RegionLoadCostType.STOREFILE_SIZE);
+      (memStoreSizeMultiplier > 0) ?
+      (memStoreSizeMultiplier * computeRegionLoadCost(cluster, RegionLoadCostType.MEMSTORE_SIZE))
:
+      0;
 
+    double storefileSizeCost =
+      (storeFileSizeMultiplier > 0) ?
+      (storeFileSizeMultiplier * computeRegionLoadCost(cluster, RegionLoadCostType.STOREFILE_SIZE)):
+      0;
 
     double readRequestCost =
-        readRequestMultiplier
-            * computeRegionLoadCost(cluster, RegionLoadCostType.READ_REQUEST);
+      (readRequestMultiplier > 0) ?
+      (readRequestMultiplier * computeRegionLoadCost(cluster, RegionLoadCostType.READ_REQUEST))
:
+      0;
+
     double writeRequestCost =
-        writeRequestMultiplier
-            * computeRegionLoadCost(cluster, RegionLoadCostType.WRITE_REQUEST);
+      (writeRequestMultiplier > 0) ?
+      (writeRequestMultiplier * computeRegionLoadCost(cluster, RegionLoadCostType.WRITE_REQUEST))
:
+      0;
 
     double total =
-        moveCost + regionCountSkewCost + tableSkewCost + localityCost + memstoreSizeCost
-            + storefileSizeCost + readRequestCost + writeRequestCost;
+      moveCost + regionCountSkewCost + tableSkewCost + localityCost + memstoreSizeCost
+        + storefileSizeCost + readRequestCost + writeRequestCost;
     if (LOG.isTraceEnabled()) {
       LOG.trace("Computed weights for a potential balancing total = " + total + " moveCost
= "
-          + moveCost + " regionCountSkewCost = " + regionCountSkewCost + " tableSkewCost
= "
-          + tableSkewCost + " localityCost = " + localityCost + " memstoreSizeCost = "
-          + memstoreSizeCost + " storefileSizeCost = " + storefileSizeCost);
+        + moveCost + " regionCountSkewCost = " + regionCountSkewCost + " tableSkewCost =
"
+        + tableSkewCost + " localityCost = " + localityCost + " memstoreSizeCost = "
+        + memstoreSizeCost + " storefileSizeCost = " + storefileSizeCost);
     }
     return total;
   }



Mime
View raw message