From 99e4e3ea3e2e924b32ade4463892a8d5eacb0725 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Wed, 1 Jun 2022 23:30:52 +0800 Subject: [PATCH] HBASE-27082 Change the return value of RSGroupInfo.getServers from SortedSet to Set to keep compatibility (#4480) Signed-off-by: Andrew Purtell --- .../java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java | 7 ++++--- .../apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java | 2 +- .../hbase/rsgroup/TestUpdateRSGroupConfiguration.java | 4 ++-- 3 files changed, 7 insertions(+), 6 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 e490fbeb5b8..0d1b9fd2ed7 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 @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; import org.apache.hadoop.hbase.TableName; @@ -55,7 +56,7 @@ public class RSGroupInfo { this(name, new TreeSet
(), new TreeSet()); } - RSGroupInfo(String name, SortedSet
servers) { + RSGroupInfo(String name, Set
servers) { this.name = name; this.servers = servers == null ? new TreeSet<>() : new TreeSet<>(servers); this.tables = new TreeSet<>(); @@ -67,7 +68,7 @@ public class RSGroupInfo { * stored in the configuration of a table so this will be removed. */ @Deprecated - RSGroupInfo(String name, SortedSet
servers, SortedSet tables) { + 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); @@ -110,7 +111,7 @@ public class RSGroupInfo { /** * Get list of servers. */ - public SortedSet
getServers() { + public Set
getServers() { return servers; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java index f44cd90d883..d58667b89d5 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java @@ -718,7 +718,7 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase { ADMIN.addRSGroup(rsGroup2); long startTime = EnvironmentEdgeManager.currentTime(); - ADMIN.moveServersToRSGroup(Sets.newHashSet(newGroup.getServers().first()), rsGroup2); + ADMIN.moveServersToRSGroup(Sets.newHashSet(newGroup.getServers().iterator().next()), rsGroup2); 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-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java index bf7917699f3..86bb50e5592 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestUpdateRSGroupConfiguration.java @@ -100,7 +100,7 @@ public class TestUpdateRSGroupConfiguration extends TestRSGroupsBase { Configuration regionServerConfiguration = TEST_UTIL.getMiniHBaseCluster() .getLiveRegionServerThreads().stream().map(JVMClusterUtil.RegionServerThread::getRegionServer) .filter(regionServer -> (regionServer.getServerName().getAddress() - .equals(testRSGroup.getServers().first()))) + .equals(testRSGroup.getServers().iterator().next()))) .collect(Collectors.toList()).get(0).getConfiguration(); int custom = regionServerConfiguration.getInt("hbase.custom.config", 0); assertEquals(1000, custom); @@ -109,7 +109,7 @@ public class TestUpdateRSGroupConfiguration extends TestRSGroupsBase { regionServerConfiguration = TEST_UTIL.getMiniHBaseCluster().getLiveRegionServerThreads() .stream().map(JVMClusterUtil.RegionServerThread::getRegionServer) .filter(regionServer -> (regionServer.getServerName().getAddress() - .equals(test2RSGroup.getServers().first()))) + .equals(test2RSGroup.getServers().iterator().next()))) .collect(Collectors.toList()).get(0).getConfiguration(); custom = regionServerConfiguration.getInt("hbase.custom.config", 0); assertEquals(0, custom);