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:
parent
2b61b99668
commit
8c1e4763b3
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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[]
|
||||
|
|
Loading…
Reference in New Issue