You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2021/08/24 15:05:14 UTC
[hbase] branch master updated: HBASE-26173 Return only a sub set of
region servers as bootstrap nodes (#3599)
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 2ce2f93 HBASE-26173 Return only a sub set of region servers as bootstrap nodes (#3599)
2ce2f93 is described below
commit 2ce2f9336f1b2021715814bc8f5d9a0d412e7fc4
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Tue Aug 24 23:04:34 2021 +0800
HBASE-26173 Return only a sub set of region servers as bootstrap nodes (#3599)
Signed-off-by: Bharath Vissapragada <bh...@apache.org>
---
.../apache/hadoop/hbase/regionserver/RSRpcServices.java | 11 ++++++++++-
.../hadoop/hbase/client/TestRpcConnectionRegistry.java | 14 ++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
index 9a2394a..2d2f57a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
@@ -41,6 +41,7 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
@@ -320,6 +321,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
*/
private static final boolean DEFAULT_REJECT_BATCH_ROWS_OVER_THRESHOLD = false;
+ public static final String CLIENT_BOOTSTRAP_NODE_LIMIT = "hbase.client.bootstrap.node.limit";
+
+ public static final int DEFAULT_CLIENT_BOOTSTRAP_NODE_LIMIT = 10;
+
// Request counter. (Includes requests that are not serviced by regions.)
// Count only once for requests with multiple actions like multi/caching-scan/replayBatch
final LongAdder requestCount = new LongAdder();
@@ -4124,8 +4129,12 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
@Override
public final GetBootstrapNodesResponse getBootstrapNodes(RpcController controller,
GetBootstrapNodesRequest request) throws ServiceException {
+ List<ServerName> bootstrapNodes = new ArrayList<>(regionServer.getRegionServers());
+ Collections.shuffle(bootstrapNodes, ThreadLocalRandom.current());
+ int maxNodeCount = regionServer.getConfiguration().getInt(CLIENT_BOOTSTRAP_NODE_LIMIT,
+ DEFAULT_CLIENT_BOOTSTRAP_NODE_LIMIT);
GetBootstrapNodesResponse.Builder builder = GetBootstrapNodesResponse.newBuilder();
- regionServer.getRegionServers().stream().map(ProtobufUtil::toServerName)
+ bootstrapNodes.stream().limit(maxNodeCount).map(ProtobufUtil::toServerName)
.forEach(builder::addServerName);
return builder.build();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRpcConnectionRegistry.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRpcConnectionRegistry.java
index 7068373..69c08b6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRpcConnectionRegistry.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestRpcConnectionRegistry.java
@@ -31,6 +31,7 @@ import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.master.HMaster;
+import org.apache.hadoop.hbase.regionserver.RSRpcServices;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.junit.After;
@@ -78,6 +79,15 @@ public class TestRpcConnectionRegistry {
Closeables.close(registry, true);
}
+ private void setMaxNodeCount(int count) {
+ UTIL.getMiniHBaseCluster().getMasterThreads().stream()
+ .map(t -> t.getMaster().getConfiguration())
+ .forEach(conf -> conf.setInt(RSRpcServices.CLIENT_BOOTSTRAP_NODE_LIMIT, count));
+ UTIL.getMiniHBaseCluster().getRegionServerThreads().stream()
+ .map(t -> t.getRegionServer().getConfiguration())
+ .forEach(conf -> conf.setInt(RSRpcServices.CLIENT_BOOTSTRAP_NODE_LIMIT, count));
+ }
+
@Test
public void testRegistryRPCs() throws Exception {
HMaster activeMaster = UTIL.getHBaseCluster().getMaster();
@@ -99,5 +109,9 @@ public class TestRpcConnectionRegistry {
Collections.sort(metaLocations);
Collections.sort(actualMetaLocations);
assertEquals(actualMetaLocations, metaLocations);
+
+ // test that the node count config works
+ setMaxNodeCount(1);
+ UTIL.waitFor(10000, () -> registry.getParsedServers().size() == 1);
}
}