Skip to content

Commit

Permalink
consolidate DotNetty to use single threadpool
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed Dec 17, 2020
1 parent d14bb5b commit 5fd1b81
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/core/Akka.Remote/Transport/DotNetty/DotNettyTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ internal abstract class DotNettyTransport : Transport
protected volatile Address LocalAddress;
protected internal volatile IChannel ServerChannel;

private readonly IEventLoopGroup _serverEventLoopGroup;
private readonly IEventLoopGroup _clientEventLoopGroup;
private readonly IEventLoopGroup _eventLoopGroup;

protected DotNettyTransport(ActorSystem system, Config config)
{
Expand All @@ -141,8 +140,7 @@ protected DotNettyTransport(ActorSystem system, Config config)

Settings = DotNettyTransportSettings.Create(config);
Log = Logging.GetLogger(System, GetType());
_serverEventLoopGroup = new MultithreadEventLoopGroup(Settings.ServerSocketWorkerPoolSize);
_clientEventLoopGroup = new MultithreadEventLoopGroup(Settings.ClientSocketWorkerPoolSize);
_eventLoopGroup = new MultithreadEventLoopGroup(Settings.ServerSocketWorkerPoolSize);
ConnectionGroup = new ConcurrentSet<IChannel>();
AssociationListenerPromise = new TaskCompletionSource<IAssociationEventListener>();

Expand Down Expand Up @@ -255,8 +253,7 @@ public override async Task<bool> Shutdown()
// free all of the connection objects we were holding onto
ConnectionGroup.Clear();
#pragma warning disable 4014 // shutting down the worker groups can take up to 10 seconds each. Let that happen asnychronously.
_clientEventLoopGroup.ShutdownGracefullyAsync();
_serverEventLoopGroup.ShutdownGracefullyAsync();
_eventLoopGroup.ShutdownGracefullyAsync();
#pragma warning restore 4014
}
}
Expand All @@ -269,7 +266,7 @@ protected Bootstrap ClientFactory(Address remoteAddress)
var addressFamily = Settings.DnsUseIpv6 ? AddressFamily.InterNetworkV6 : AddressFamily.InterNetwork;

var client = new Bootstrap()
.Group(_clientEventLoopGroup)
.Group(_eventLoopGroup)
.Option(ChannelOption.SoReuseaddr, Settings.TcpReuseAddr)
.Option(ChannelOption.SoKeepalive, Settings.TcpKeepAlive)
.Option(ChannelOption.TcpNodelay, Settings.TcpNoDelay)
Expand Down Expand Up @@ -381,7 +378,7 @@ private ServerBootstrap ServerFactory()
var addressFamily = Settings.DnsUseIpv6 ? AddressFamily.InterNetworkV6 : AddressFamily.InterNetwork;

var server = new ServerBootstrap()
.Group(_serverEventLoopGroup)
.Group(_eventLoopGroup)
.Option(ChannelOption.SoReuseaddr, Settings.TcpReuseAddr)
.Option(ChannelOption.SoKeepalive, Settings.TcpKeepAlive)
.Option(ChannelOption.TcpNodelay, Settings.TcpNoDelay)
Expand Down

0 comments on commit 5fd1b81

Please sign in to comment.