1
0
mirror of https://github.com/apache/dubbo.git synced 2024-10-23 07:04:37 +08:00

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 <89424516@qq.com>
This commit is contained in:
ken.lj 2022-03-07 15:28:38 +08:00 committed by GitHub
parent b7b4993635
commit 8f11fc9633
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 11 deletions

View File

@ -1,5 +1,7 @@
# Release Notes
Please refer to https://github.com/apache/dubbo/releases for notes of future releases.
## 2.7.6
### Features

View File

@ -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;
}
}

View File

@ -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(
getUrl().getPositiveParameter(IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS),
EVENT_LOOP_WORKER_POOL_NAME);
bossGroup = createBossGroup();
workerGroup = createWorkerGroup();
final NettyServerHandler nettyServerHandler = new NettyServerHandler(getUrl(), this);
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);
}
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;
}
}