HBASE-25298 hbase.rsgroup.fallback.enable should support dynamic configuration (#2668)

Signed-off-by: Guanghao Zhang <zghao@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
Baiqiang Zhao 2020-11-19 09:20:01 +08:00 committed by Guanghao Zhang
parent 9769e3fe7b
commit fdff8ef46d
3 changed files with 29 additions and 2 deletions

View File

@ -247,7 +247,7 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer {
}
if (!fallbackRegions.isEmpty()) {
List<ServerName> candidates = null;
if (fallbackEnabled) {
if (isFallbackEnabled()) {
candidates = getFallBackCandidates(servers);
}
candidates = (candidates == null || candidates.isEmpty()) ?
@ -383,6 +383,9 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer {
return this.rsGroupInfoManager.isOnline();
}
public boolean isFallbackEnabled() {
return fallbackEnabled;
}
@Override
public void regionOnline(RegionInfo regionInfo, ServerName sn) {
@ -394,7 +397,12 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer {
@Override
public void onConfigurationChange(Configuration conf) {
//DO nothing for now
boolean newFallbackEnabled = conf.getBoolean(FALLBACK_GROUP_ENABLE_KEY, false);
if (fallbackEnabled != newFallbackEnabled) {
LOG.info("Changing the value of {} from {} to {}", FALLBACK_GROUP_ENABLE_KEY,
fallbackEnabled, newFallbackEnabled);
fallbackEnabled = newFallbackEnabled;
}
}
@Override

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.master.balancer;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
@ -186,4 +187,21 @@ public class TestRSGroupBasedLoadBalancer extends RSGroupableBalancerTestBase {
.roundRobinAssignment(regions, onlineServers);
assertEquals(bogusRegion, assignments.get(LoadBalancer.BOGUS_SERVER_NAME).size());
}
@Test
public void testOnConfigurationChange() {
// fallbackEnabled default is false
assertFalse(loadBalancer.isFallbackEnabled());
// change FALLBACK_GROUP_ENABLE_KEY from false to true
Configuration conf = loadBalancer.getConf();
conf.setBoolean(RSGroupBasedLoadBalancer.FALLBACK_GROUP_ENABLE_KEY, true);
loadBalancer.onConfigurationChange(conf);
assertTrue(loadBalancer.isFallbackEnabled());
// restore
conf.setBoolean(RSGroupBasedLoadBalancer.FALLBACK_GROUP_ENABLE_KEY, false);
loadBalancer.onConfigurationChange(conf);
assertFalse(loadBalancer.isFallbackEnabled());
}
}

View File

@ -1383,6 +1383,7 @@ Here are those configurations:
| hbase.master.balancer.stochastic.tableSkewCost
| hbase.master.regions.recovery.check.interval
| hbase.regions.recovery.store.file.ref.count
| hbase.rsgroup.fallback.enable
|===
ifdef::backend-docbook[]