Skip to content

Commit fdff8ef

Browse files
ZhaoBQinfraio
authored andcommitted
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>
1 parent 9769e3f commit fdff8ef

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private List<Pair<List<RegionInfo>, List<ServerName>>> generateGroupAssignments(
247247
}
248248
if (!fallbackRegions.isEmpty()) {
249249
List<ServerName> candidates = null;
250-
if (fallbackEnabled) {
250+
if (isFallbackEnabled()) {
251251
candidates = getFallBackCandidates(servers);
252252
}
253253
candidates = (candidates == null || candidates.isEmpty()) ?
@@ -383,6 +383,9 @@ public boolean isOnline() {
383383
return this.rsGroupInfoManager.isOnline();
384384
}
385385

386+
public boolean isFallbackEnabled() {
387+
return fallbackEnabled;
388+
}
386389

387390
@Override
388391
public void regionOnline(RegionInfo regionInfo, ServerName sn) {
@@ -394,7 +397,12 @@ public void regionOffline(RegionInfo regionInfo) {
394397

395398
@Override
396399
public void onConfigurationChange(Configuration conf) {
397-
//DO nothing for now
400+
boolean newFallbackEnabled = conf.getBoolean(FALLBACK_GROUP_ENABLE_KEY, false);
401+
if (fallbackEnabled != newFallbackEnabled) {
402+
LOG.info("Changing the value of {} from {} to {}", FALLBACK_GROUP_ENABLE_KEY,
403+
fallbackEnabled, newFallbackEnabled);
404+
fallbackEnabled = newFallbackEnabled;
405+
}
398406
}
399407

400408
@Override

hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/master/balancer/TestRSGroupBasedLoadBalancer.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.hadoop.hbase.master.balancer;
1919

2020
import static org.junit.Assert.assertEquals;
21+
import static org.junit.Assert.assertFalse;
2122
import static org.junit.Assert.assertTrue;
2223

2324
import java.util.ArrayList;
@@ -186,4 +187,21 @@ public void testRoundRobinAssignment() throws Exception {
186187
.roundRobinAssignment(regions, onlineServers);
187188
assertEquals(bogusRegion, assignments.get(LoadBalancer.BOGUS_SERVER_NAME).size());
188189
}
190+
191+
@Test
192+
public void testOnConfigurationChange() {
193+
// fallbackEnabled default is false
194+
assertFalse(loadBalancer.isFallbackEnabled());
195+
196+
// change FALLBACK_GROUP_ENABLE_KEY from false to true
197+
Configuration conf = loadBalancer.getConf();
198+
conf.setBoolean(RSGroupBasedLoadBalancer.FALLBACK_GROUP_ENABLE_KEY, true);
199+
loadBalancer.onConfigurationChange(conf);
200+
assertTrue(loadBalancer.isFallbackEnabled());
201+
202+
// restore
203+
conf.setBoolean(RSGroupBasedLoadBalancer.FALLBACK_GROUP_ENABLE_KEY, false);
204+
loadBalancer.onConfigurationChange(conf);
205+
assertFalse(loadBalancer.isFallbackEnabled());
206+
}
189207
}

src/main/asciidoc/_chapters/configuration.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,7 @@ Here are those configurations:
13831383
| hbase.master.balancer.stochastic.tableSkewCost
13841384
| hbase.master.regions.recovery.check.interval
13851385
| hbase.regions.recovery.store.file.ref.count
1386+
| hbase.rsgroup.fallback.enable
13861387
|===
13871388

13881389
ifdef::backend-docbook[]

0 commit comments

Comments
 (0)