This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2.3
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.3 by this push:
     new 7d7af44  HBASE-25838 Use double instead of Double in 
StochasticLoadBalancer (#3221)
7d7af44 is described below

commit 7d7af449e7e9f631ff75aa92619989e6e108ddc2
Author: Duo Zhang <[email protected]>
AuthorDate: Tue May 4 09:04:47 2021 +0800

    HBASE-25838 Use double instead of Double in StochasticLoadBalancer (#3221)
    
    Signed-off-by: Yulin Niu <[email protected]>
---
 .../master/balancer/StochasticLoadBalancer.java      | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
index f167587..cbfe794 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
@@ -145,9 +145,9 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
   private List<CostFunction> costFunctions; // FindBugs: Wants this protected; 
IS2_INCONSISTENT_SYNC
 
   // to save and report costs to JMX
-  private Double curOverallCost = 0d;
-  private Double[] tempFunctionCosts;
-  private Double[] curFunctionCosts;
+  private double curOverallCost = 0d;
+  private double[] tempFunctionCosts;
+  private double[] curFunctionCosts;
 
   // Keep locality based picker and cost function to alert them
   // when new services are offered
@@ -217,8 +217,8 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
     addCostFunction(regionLoadFunctions[3]);
     loadCustomCostFunctions(conf);
 
-    curFunctionCosts = new Double[costFunctions.size()];
-    tempFunctionCosts = new Double[costFunctions.size()];
+    curFunctionCosts = new double[costFunctions.size()];
+    tempFunctionCosts = new double[costFunctions.size()];
 
     LOG.info("Loaded config; maxSteps=" + maxSteps + ", stepsPerRegion=" + 
stepsPerRegion +
             ", maxRunningTime=" + maxRunningTime + ", isByTable=" + isByTable 
+ ", CostFunctions=" +
@@ -493,8 +493,10 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
   /**
    * update costs to JMX
    */
-  private void updateStochasticCosts(TableName tableName, Double overall, 
Double[] subCosts) {
-    if (tableName == null) return;
+  private void updateStochasticCosts(TableName tableName, double overall, 
double[] subCosts) {
+    if (tableName == null) {
+      return;
+    }
 
     // check if the metricsBalancer is MetricsStochasticBalancer before casting
     if (metricsBalancer instanceof MetricsStochasticBalancer) {
@@ -507,7 +509,7 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
       for (int i = 0; i < costFunctions.size(); i++) {
         CostFunction costFunction = costFunctions.get(i);
         String costFunctionName = costFunction.getClass().getSimpleName();
-        Double costPercent = (overall == 0) ? 0 : (subCosts[i] / overall);
+        double costPercent = (overall == 0) ? 0 : (subCosts[i] / overall);
         // TODO: cost function may need a specific description
         balancer.updateStochasticCost(tableName.getNameAsString(), 
costFunctionName,
           "The percent of " + costFunctionName, costPercent);
@@ -639,7 +641,7 @@ public class StochasticLoadBalancer extends 
BaseLoadBalancer {
       }
 
       Float multiplier = c.getMultiplier();
-      Double cost = c.cost();
+      double cost = c.cost();
 
       this.tempFunctionCosts[i] = multiplier*cost;
       total += this.tempFunctionCosts[i];

Reply via email to