HBASE-25726 MoveCostFunction is not included in the list of cost functions for StochasticLoadBalancer (#3116)
Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
parent
446f22f05c
commit
7a31557c51
|
@ -900,6 +900,10 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
// What percent of the number of regions a single run of the balancer can move.
|
// 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);
|
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
|
@Override
|
||||||
|
|
|
@ -54,6 +54,7 @@ import org.apache.hadoop.hbase.testclassification.MasterTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
||||||
|
import org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.junit.ClassRule;
|
import org.junit.ClassRule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
@ -506,13 +507,40 @@ public class TestStochasticLoadBalancer extends BalancerTestBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAdditionalCostFunction() {
|
public void testAdditionalCostFunction() {
|
||||||
conf.set(StochasticLoadBalancer.COST_FUNCTIONS_COST_FUNCTIONS_KEY,
|
try {
|
||||||
DummyCostFunction.class.getName());
|
conf.set(StochasticLoadBalancer.COST_FUNCTIONS_COST_FUNCTIONS_KEY,
|
||||||
|
DummyCostFunction.class.getName());
|
||||||
|
|
||||||
loadBalancer.setConf(conf);
|
loadBalancer.setConf(conf);
|
||||||
assertTrue(Arrays.
|
assertTrue(Arrays.
|
||||||
asList(loadBalancer.getCostFunctionNames()).
|
asList(loadBalancer.getCostFunctionNames()).
|
||||||
contains(DummyCostFunction.class.getSimpleName()));
|
contains(DummyCostFunction.class.getSimpleName()));
|
||||||
|
} finally {
|
||||||
|
conf.unset(StochasticLoadBalancer.COST_FUNCTIONS_COST_FUNCTIONS_KEY);
|
||||||
|
loadBalancer.setConf(conf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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.CPRequestCostFunction.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[] cluster){
|
private boolean needsBalanceIdleRegion(int[] cluster){
|
||||||
|
|
Loading…
Reference in New Issue