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 GitHub
parent 2b61b99668
commit 8c1e4763b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 2 deletions

View File

@ -250,7 +250,7 @@ public class RSGroupBasedLoadBalancer implements LoadBalancer {
}
if (!fallbackRegions.isEmpty()) {
List<ServerName> candidates = null;
if (fallbackEnabled) {
if (isFallbackEnabled()) {
candidates = getFallBackCandidates(servers);
}
candidates = (candidates == null || candidates.isEmpty()) ?
@ -385,6 +385,9 @@ public class RSGroupBasedLoadBalancer implements LoadBalancer {
return this.rsGroupInfoManager.isOnline();
}
public boolean isFallbackEnabled() {
return fallbackEnabled;
}
@Override
public void regionOnline(RegionInfo regionInfo, ServerName sn) {
@ -396,7 +399,12 @@ public class RSGroupBasedLoadBalancer implements LoadBalancer {
@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;
@ -185,4 +186,21 @@ public class TestRSGroupBasedLoadBalancer extends RSGroupableBalancerTestBase {
loadBalancer.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

@ -1355,6 +1355,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[]