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 2020/03/14 05:47:58 UTC
[hbase] branch master updated: HBASE-23987
NettyRpcClientConfigHelper will not share event loop by default which is
incorrect (#1288)
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 ba3f026 HBASE-23987 NettyRpcClientConfigHelper will not share event loop by default which is incorrect (#1288)
ba3f026 is described below
commit ba3f02629a9fd2951f777074b810f3a082649f09
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Sat Mar 14 13:47:41 2020 +0800
HBASE-23987 NettyRpcClientConfigHelper will not share event loop by default which is incorrect (#1288)
Signed-off-by: stack <st...@apache.org>
---
.../hbase/ipc/NettyRpcClientConfigHelper.java | 31 ++++++++++++++++++----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcClientConfigHelper.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcClientConfigHelper.java
index 6107183..a8c9937 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcClientConfigHelper.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcClientConfigHelper.java
@@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.yetus.audience.InterfaceAudience;
+
import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
import org.apache.hbase.thirdparty.io.netty.channel.Channel;
import org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup;
@@ -73,20 +74,40 @@ public final class NettyRpcClientConfigHelper {
}
/**
- * The {@code AsyncRpcClient} will create its own {@code NioEventLoopGroup}.
+ * The {@link NettyRpcClient} will create its own {@code NioEventLoopGroup}.
*/
public static void createEventLoopPerClient(Configuration conf) {
conf.set(EVENT_LOOP_CONFIG, "");
EVENT_LOOP_CONFIG_MAP.clear();
}
+ private static volatile Pair<EventLoopGroup, Class<? extends Channel>> DEFAULT_EVENT_LOOP;
+
+ private static Pair<EventLoopGroup, Class<? extends Channel>>
+ getDefaultEventLoopConfig(Configuration conf) {
+ Pair<EventLoopGroup, Class<? extends Channel>> eventLoop = DEFAULT_EVENT_LOOP;
+ if (eventLoop != null) {
+ return eventLoop;
+ }
+ synchronized (NettyRpcClientConfigHelper.class) {
+ eventLoop = DEFAULT_EVENT_LOOP;
+ if (eventLoop != null) {
+ return eventLoop;
+ }
+ int threadCount = conf.getInt(HBASE_NETTY_EVENTLOOP_RPCCLIENT_THREADCOUNT_KEY, 0);
+ eventLoop = new Pair<>(
+ new NioEventLoopGroup(threadCount,
+ new DefaultThreadFactory("RPCClient-NioEventLoopGroup", true, Thread.NORM_PRIORITY)),
+ NioSocketChannel.class);
+ DEFAULT_EVENT_LOOP = eventLoop;
+ }
+ return eventLoop;
+ }
+
static Pair<EventLoopGroup, Class<? extends Channel>> getEventLoopConfig(Configuration conf) {
String name = conf.get(EVENT_LOOP_CONFIG);
if (name == null) {
- int threadCount = conf.getInt(HBASE_NETTY_EVENTLOOP_RPCCLIENT_THREADCOUNT_KEY, 0);
- return new Pair<>(new NioEventLoopGroup(threadCount,
- new DefaultThreadFactory("RPCClient-NioEventLoopGroup", true,
- Thread.NORM_PRIORITY)), NioSocketChannel.class);
+ return getDefaultEventLoopConfig(conf);
}
if (StringUtils.isBlank(name)) {
return null;