This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 8f11fc9 Merge 3.0.6-release branch and prepare for next release
(#9743)
8f11fc9 is described below
commit 8f11fc96333d4abdbd73f80987d6cb43e46639d3
Author: ken.lj <[email protected]>
AuthorDate: Mon Mar 7 15:28:38 2022 +0800
Merge 3.0.6-release branch and prepare for next release (#9743)
* modify CHANGES.md
* bump version 3.0.6
* netty4_extend (#9725)
* netty4_extend
* fix compile error
Co-authored-by: Owen.Cai <[email protected]>
---
CHANGES.md | 2 +
.../remoting/transport/netty4/NettyClient.java | 18 +++++++-
.../remoting/transport/netty4/NettyServer.java | 54 ++++++++++++++++++----
3 files changed, 64 insertions(+), 10 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 075116b..625906f 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,7 @@
# Release Notes
+Please refer to https://github.com/apache/dubbo/releases for notes of future
releases.
+
## 2.7.6
### Features
diff --git
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java
index e7b30d0..9c79404 100644
---
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java
+++
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java
@@ -96,8 +96,16 @@ public class NettyClient extends AbstractClient {
*/
@Override
protected void doOpen() throws Throwable {
- final NettyClientHandler nettyClientHandler = new
NettyClientHandler(getUrl(), this);
+ final NettyClientHandler nettyClientHandler =
createNettyClientHandler();
bootstrap = new Bootstrap();
+ initBootstrap(nettyClientHandler);
+ }
+
+ protected NettyClientHandler createNettyClientHandler() {
+ return new NettyClientHandler(getUrl(), this);
+ }
+
+ protected void initBootstrap(NettyClientHandler nettyClientHandler) {
bootstrap.group(EVENT_LOOP_GROUP.get())
.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.TCP_NODELAY, true)
@@ -229,4 +237,12 @@ public class NettyClient extends AbstractClient {
public boolean canHandleIdle() {
return true;
}
+
+ protected EventLoopGroup getEventLoopGroup() {
+ return EVENT_LOOP_GROUP.get();
+ }
+
+ protected Bootstrap getBootstrap() {
+ return bootstrap;
+ }
}
diff --git
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServer.java
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServer.java
index eea977e..4be34e1 100644
---
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServer.java
+++
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServer.java
@@ -98,14 +98,36 @@ public class NettyServer extends AbstractServer {
protected void doOpen() throws Throwable {
bootstrap = new ServerBootstrap();
- bossGroup = NettyEventLoopFactory.eventLoopGroup(1,
EVENT_LOOP_BOSS_POOL_NAME);
- workerGroup = NettyEventLoopFactory.eventLoopGroup(
+ bossGroup = createBossGroup();
+ workerGroup = createWorkerGroup();
+
+ final NettyServerHandler nettyServerHandler =
createNettyServerHandler();
+ channels = nettyServerHandler.getChannels();
+
+ initServerBootstrap(nettyServerHandler);
+
+ // bind
+ ChannelFuture channelFuture = bootstrap.bind(getBindAddress());
+ channelFuture.syncUninterruptibly();
+ channel = channelFuture.channel();
+
+ }
+
+ protected EventLoopGroup createBossGroup() {
+ return NettyEventLoopFactory.eventLoopGroup(1,
EVENT_LOOP_BOSS_POOL_NAME);
+ }
+
+ protected EventLoopGroup createWorkerGroup() {
+ return NettyEventLoopFactory.eventLoopGroup(
getUrl().getPositiveParameter(IO_THREADS_KEY,
Constants.DEFAULT_IO_THREADS),
EVENT_LOOP_WORKER_POOL_NAME);
+ }
- final NettyServerHandler nettyServerHandler = new
NettyServerHandler(getUrl(), this);
- channels = nettyServerHandler.getChannels();
+ protected NettyServerHandler createNettyServerHandler() {
+ return new NettyServerHandler(getUrl(), this);
+ }
+ protected void initServerBootstrap(NettyServerHandler nettyServerHandler) {
boolean keepalive = getUrl().getParameter(KEEP_ALIVE_KEY,
Boolean.FALSE);
bootstrap.group(bossGroup, workerGroup)
@@ -130,11 +152,6 @@ public class NettyServer extends AbstractServer {
.addLast("handler", nettyServerHandler);
}
});
- // bind
- ChannelFuture channelFuture = bootstrap.bind(getBindAddress());
- channelFuture.syncUninterruptibly();
- channel = channelFuture.channel();
-
}
@Override
@@ -205,4 +222,23 @@ public class NettyServer extends AbstractServer {
return channel.isActive();
}
+ protected EventLoopGroup getBossGroup() {
+ return bossGroup;
+ }
+
+ protected EventLoopGroup getWorkerGroup() {
+ return workerGroup;
+ }
+
+ protected ServerBootstrap getServerBootstrap() {
+ return bootstrap;
+ }
+
+ protected io.netty.channel.Channel getBossChannel() {
+ return channel;
+ }
+
+ protected Map<String, Channel> getServerChannels() {
+ return channels;
+ }
}