Skip to content

Commit

Permalink
HBASE-15504 Fix Balancer in 1.3 not moving regions off overloaded reg…
Browse files Browse the repository at this point in the history
…ionserver
  • Loading branch information
elliottneilclark committed Apr 14, 2016
1 parent 0bb18de commit 5a7c8dc
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
private RegionReplicaRackCostFunction regionReplicaRackCostFunction;
private boolean isByTable = false;
private TableName tableName = null;

/**
* The constructor that pass a MetricsStochasticBalancer to BaseLoadBalancer to replace its
* default MetricsBalancer
Expand Down Expand Up @@ -200,7 +200,7 @@ public synchronized void setConf(Configuration conf) {
regionLoadFunctions[2],
regionLoadFunctions[3],
};

curFunctionCosts= new Double[costFunctions.length];
tempFunctionCosts= new Double[costFunctions.length];

Expand Down Expand Up @@ -230,7 +230,7 @@ public synchronized void setClusterStatus(ClusterStatus st) {
LOG.error("failed to get the size of all tables, exception = " + e.getMessage());
}
}

/**
* Update the number of metrics that are reported to JMX
*/
Expand Down Expand Up @@ -263,7 +263,7 @@ public synchronized List<RegionPlan> balanceCluster(TableName tableName, Map<Ser
this.tableName = tableName;
return balanceCluster(clusterState);
}

/**
* Given the cluster state this will try and approach an optimal balance. This
* should always approach the optimal state given enough steps.
Expand Down Expand Up @@ -371,7 +371,7 @@ public synchronized List<RegionPlan> balanceCluster(Map<ServerName,
+ plans.size() + " regions; Going from a computed cost of "
+ initCost + " to a new cost of " + currentCost);
}

return plans;
}
if (LOG.isDebugEnabled()) {
Expand All @@ -381,7 +381,7 @@ public synchronized List<RegionPlan> balanceCluster(Map<ServerName,
}
return null;
}

/**
* update costs to JMX
*/
Expand All @@ -392,7 +392,7 @@ private void updateStochasticCosts(TableName tableName, Double overall, Double[]
if (metricsBalancer instanceof MetricsStochasticBalancer) {
MetricsStochasticBalancer balancer = (MetricsStochasticBalancer) metricsBalancer;
// overall cost
balancer.updateStochasticCost(tableName.getNameAsString(),
balancer.updateStochasticCost(tableName.getNameAsString(),
"Overall", "Overall cost", overall);

// each cost function
Expand Down Expand Up @@ -512,7 +512,7 @@ protected double computeCost(Cluster cluster, double previousCost) {
for (int i = 0; i < costFunctions.length; i++) {
CostFunction c = costFunctions[i];
this.tempFunctionCosts[i] = 0.0;

if (c.getMultiplier() <= 0) {
continue;
}
Expand All @@ -527,7 +527,7 @@ protected double computeCost(Cluster cluster, double previousCost) {
break;
}
}

return total;
}

Expand Down Expand Up @@ -996,7 +996,7 @@ static class MoveCostFunction extends CostFunction {
private static final String MOVE_COST_KEY = "hbase.master.balancer.stochastic.moveCost";
private static final String MAX_MOVES_PERCENT_KEY =
"hbase.master.balancer.stochastic.maxMovePercent";
private static final float DEFAULT_MOVE_COST = 100;
private static final float DEFAULT_MOVE_COST = 7;
private static final int DEFAULT_MAX_MOVES = 600;
private static final float DEFAULT_MAX_MOVE_PERCENT = 0.25f;

Expand Down Expand Up @@ -1430,7 +1430,7 @@ static class RegionReplicaRackCostFunction extends RegionReplicaHostCostFunction

public RegionReplicaRackCostFunction(Configuration conf) {
super(conf);
this.setMultiplier(conf.getFloat(REGION_REPLICA_RACK_COST_KEY,
this.setMultiplier(conf.getFloat(REGION_REPLICA_RACK_COST_KEY,
DEFAULT_REGION_REPLICA_RACK_COST_KEY));
}

Expand Down Expand Up @@ -1503,7 +1503,7 @@ protected double getCostFromRl(RegionLoad rl) {
return rl.getStorefileSizeMB();
}
}

/**
* A helper function to compose the attribute name from tablename and costfunction name
*/
Expand Down

0 comments on commit 5a7c8dc

Please sign in to comment.