HBASE-25726 MoveCostFunction is not included in the list of cost functions for StochasticLoadBalancer (#3116)
Signed-off-by: Andrew Purtell <apurtell@apache.org> Conflicts: hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java
This commit is contained in:
parent
d07ef8fbcb
commit
616c5bbec5
|
@ -1238,6 +1238,10 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
|
|||
this.conf = conf;
|
||||
// What percent of the number of regions a single run of the balancer can move.
|
||||
maxMovesPercent = conf.getFloat(MAX_MOVES_PERCENT_KEY, DEFAULT_MAX_MOVE_PERCENT);
|
||||
|
||||
// Initialize the multiplier so that addCostFunction will add this cost function.
|
||||
// It may change during later evaluations, due to OffPeakHours.
|
||||
this.setMultiplier(conf.getFloat(MOVE_COST_KEY, DEFAULT_MOVE_COST));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.util.Queue;
|
|||
import java.util.TimeZone;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
@ -55,8 +56,8 @@ import org.apache.hadoop.hbase.testclassification.FlakeyTests;
|
|||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.EnvironmentEdge;
|
||||
import org.junit.Ignore;
|
||||
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
|
@ -716,7 +717,7 @@ public class TestStochasticLoadBalancer extends BalancerTestBase {
|
|||
@Test
|
||||
public void testAdditionalCostFunction() {
|
||||
conf.set(StochasticLoadBalancer.COST_FUNCTIONS_COST_FUNCTIONS_KEY,
|
||||
DummyCostFunction.class.getName());
|
||||
DummyCostFunction.class.getName());
|
||||
|
||||
loadBalancer.setConf(conf);
|
||||
System.out.println(Arrays.toString(loadBalancer.getCostFunctionNames()));
|
||||
|
@ -725,6 +726,27 @@ public class TestStochasticLoadBalancer extends BalancerTestBase {
|
|||
contains(DummyCostFunction.class.getSimpleName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultCostFunctionList() {
|
||||
List<String> expected = Arrays.asList(
|
||||
StochasticLoadBalancer.RegionCountSkewCostFunction.class.getSimpleName(),
|
||||
StochasticLoadBalancer.PrimaryRegionCountSkewCostFunction.class.getSimpleName(),
|
||||
StochasticLoadBalancer.MoveCostFunction.class.getSimpleName(),
|
||||
StochasticLoadBalancer.RackLocalityCostFunction.class.getSimpleName(),
|
||||
StochasticLoadBalancer.TableSkewCostFunction.class.getSimpleName(),
|
||||
StochasticLoadBalancer.RegionReplicaHostCostFunction.class.getSimpleName(),
|
||||
StochasticLoadBalancer.RegionReplicaRackCostFunction.class.getSimpleName(),
|
||||
StochasticLoadBalancer.ReadRequestCostFunction.class.getSimpleName(),
|
||||
StochasticLoadBalancer.WriteRequestCostFunction.class.getSimpleName(),
|
||||
StochasticLoadBalancer.MemstoreSizeCostFunction.class.getSimpleName(),
|
||||
StochasticLoadBalancer.StoreFileCostFunction.class.getSimpleName()
|
||||
);
|
||||
|
||||
List<String> actual = Arrays.asList(loadBalancer.getCostFunctionNames());
|
||||
assertTrue("ExpectedCostFunctions: " + expected + " ActualCostFunctions: " + actual,
|
||||
CollectionUtils.isEqualCollection(expected, actual));
|
||||
}
|
||||
|
||||
private boolean needsBalanceIdleRegion(int[] clusters) {
|
||||
boolean b1 = false;
|
||||
boolean b2 = false;
|
||||
|
|
Loading…
Reference in New Issue