You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2022/06/01 16:38:46 UTC

[hbase] branch branch-2.5 updated: HBASE-27082 Change the return value of RSGroupInfo.getServers from SortedSet to Set to keep compatibility (#4480)

This is an automated email from the ASF dual-hosted git repository.

apurtell pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.5 by this push:
     new 267e9fa48a3 HBASE-27082 Change the return value of RSGroupInfo.getServers from SortedSet to Set to keep compatibility (#4480)
267e9fa48a3 is described below

commit 267e9fa48a31401a947bf8f6fa2f72317c96ed49
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Wed Jun 1 23:30:52 2022 +0800

    HBASE-27082 Change the return value of RSGroupInfo.getServers from SortedSet to Set to keep compatibility (#4480)
    
    Signed-off-by: Andrew Purtell <ap...@apache.org>
    
    Conflicts:
            hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java
            hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java
            hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java
---
 .../apache/hadoop/hbase/rsgroup/RSGroupInfo.java   | 16 ++++++++--
 .../hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java   |  2 +-
 .../rsgroup/TestUpdateRSGroupConfiguration.java    | 35 +++++++++++++++++++++-
 3 files changed, 49 insertions(+), 4 deletions(-)

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<String, String> configuration;
 
   public RSGroupInfo(String name) {
-    this(name, new TreeSet<>(), new TreeSet<>());
+    this(name, new TreeSet<Address>(), new TreeSet<TableName>());
   }
 
-  RSGroupInfo(String name, SortedSet<Address> servers, SortedSet<TableName> tables) {
+  RSGroupInfo(String name, Set<Address> 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<Address> servers, Set<TableName> 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();
   }
 
 }