diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java index d72c528ef70..3e9ffca3f3a 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java @@ -47,10 +47,22 @@ public class RSGroupInfo { private final Map configuration; public RSGroupInfo(String name) { - this(name, new TreeSet<>(), new TreeSet<>()); + this(name, new TreeSet
(), new TreeSet()); } - RSGroupInfo(String name, SortedSet
servers, SortedSet tables) { + RSGroupInfo(String name, Set
servers) { + this.name = name; + this.servers = servers == null ? new TreeSet<>() : new TreeSet<>(servers); + this.tables = new TreeSet<>(); + configuration = new HashMap<>(); + } + + /** + * @deprecated Since 3.0.0, will be removed in 4.0.0. The rsgroup information for a table will be + * stored in the configuration of a table so this will be removed. + */ + @Deprecated + RSGroupInfo(String name, Set
servers, Set tables) { this.name = name; this.servers = (servers == null) ? new TreeSet<>() : new TreeSet<>(servers); this.tables = (tables == null) ? new TreeSet<>() : new TreeSet<>(tables); diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java index f9c437c219a..bc59438dfae 100644 --- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java +++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java @@ -664,7 +664,7 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase { return getTableRegionMap().get(tableName).size() >= tableRegionCount; }); long startTime = EnvironmentEdgeManager.currentTime(); - rsGroupAdmin.moveTables(Sets.newHashSet(tableName), newGroup.getName()); + rsGroupAdmin.moveServers(Sets.newHashSet(newGroup.getServers().iterator().next()), newGroup.getName()); long timeTaken = EnvironmentEdgeManager.currentTime() - startTime; String msg = "Should not take mote than 15000 ms to move a table with 100 regions. Time taken =" diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java index 8dc4dfe1f5f..ebb23665fcb 100644 --- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java +++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java @@ -17,10 +17,14 @@ */ package org.apache.hadoop.hbase.rsgroup; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import java.util.stream.Collectors; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.util.JVMClusterUtil; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -85,7 +89,36 @@ public class TestUpdateRSGroupConfiguration extends TestRSGroupsBase { @Test @Ignore public void testCustomOnlineConfigChangeInRSGroup() throws Exception { - // Test contents removed on branch-2.5 and branch-2. + // Check the default configuration of the RegionServers + TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().forEach(thread -> { + Configuration conf = thread.getRegionServer().getConfiguration(); + assertEquals(0, conf.getInt("hbase.custom.config", 0)); + }); + + replaceHBaseSiteXML(); + RSGroupInfo testRSGroup = addGroup(TEST_GROUP, 1); + RSGroupInfo test2RSGroup = addGroup(TEST2_GROUP, 1); + rsGroupAdmin.updateConfiguration(TEST_GROUP); + + // Check the configuration of the RegionServer in test rsgroup, should be update + Configuration regionServerConfiguration = TEST_UTIL.getMiniHBaseCluster() + .getLiveRegionServerThreads().stream().map(JVMClusterUtil.RegionServerThread::getRegionServer) + .filter(regionServer -> (regionServer.getServerName().getAddress() + .equals(testRSGroup.getServers().iterator().next()))) + .collect(Collectors.toList()).get(0).getConfiguration(); + int custom = regionServerConfiguration.getInt("hbase.custom.config", 0); + assertEquals(1000, custom); + + // Check the configuration of the RegionServer in test2 rsgroup, should not be update + regionServerConfiguration = TEST_UTIL.getMiniHBaseCluster().getLiveRegionServerThreads() + .stream().map(JVMClusterUtil.RegionServerThread::getRegionServer) + .filter(regionServer -> (regionServer.getServerName().getAddress() + .equals(test2RSGroup.getServers().iterator().next()))) + .collect(Collectors.toList()).get(0).getConfiguration(); + custom = regionServerConfiguration.getInt("hbase.custom.config", 0); + assertEquals(0, custom); + + restoreHBaseSiteXML(); } }