remote cleanup: include feedback from Viktor and Patrik
- re-label Client/Server to Inbound/Outbound for netty settings description - move to just using exactly one class loader for all reflective activities of the ActorSystem, which is either the context class loader or the one which loaded the ActorSystem’s class; document that putting Akka on boot class path will not work - be more careful with initializing the Client- and ServerBootstrap - rename Port to DesiredPortFromConfig to discourage misuse - write test for NettySettings - various small fixes
This commit is contained in:
parent
2bebf29c1c
commit
4fb0858e55
19 changed files with 141 additions and 83 deletions
|
|
@ -29,28 +29,29 @@ class NettyRemoteServer(val netty: NettyRemoteTransport) {
|
|||
val ip = InetAddress.getByName(settings.Hostname)
|
||||
|
||||
private val factory = new NioServerSocketChannelFactory(
|
||||
Executors.newCachedThreadPool(netty.threadFactory),
|
||||
Executors.newCachedThreadPool(netty.threadFactory))
|
||||
|
||||
private val bootstrap = new ServerBootstrap(factory)
|
||||
Executors.newCachedThreadPool(netty.system.threadFactory),
|
||||
Executors.newCachedThreadPool(netty.system.threadFactory))
|
||||
|
||||
private val executionHandler = new ExecutionHandler(netty.executor)
|
||||
|
||||
// group of open channels, used for clean-up
|
||||
private val openChannels: ChannelGroup = new DefaultDisposableChannelGroup("akka-remote-server")
|
||||
|
||||
val pipelineFactory = new RemoteServerPipelineFactory(openChannels, executionHandler, netty)
|
||||
bootstrap.setPipelineFactory(pipelineFactory)
|
||||
bootstrap.setOption("backlog", settings.Backlog)
|
||||
bootstrap.setOption("tcpNoDelay", true)
|
||||
bootstrap.setOption("child.keepAlive", true)
|
||||
bootstrap.setOption("reuseAddress", true)
|
||||
private val bootstrap = {
|
||||
val b = new ServerBootstrap(factory)
|
||||
b.setPipelineFactory(new RemoteServerPipelineFactory(openChannels, executionHandler, netty))
|
||||
b.setOption("backlog", settings.Backlog)
|
||||
b.setOption("tcpNoDelay", true)
|
||||
b.setOption("child.keepAlive", true)
|
||||
b.setOption("reuseAddress", true)
|
||||
b
|
||||
}
|
||||
|
||||
@volatile
|
||||
private[akka] var channel: Channel = _
|
||||
|
||||
def start(): Unit = {
|
||||
channel = bootstrap.bind(new InetSocketAddress(ip, settings.Port))
|
||||
channel = bootstrap.bind(new InetSocketAddress(ip, settings.DesiredPortFromConfig))
|
||||
openChannels.add(channel)
|
||||
netty.notifyListeners(RemoteServerStarted(netty))
|
||||
}
|
||||
|
|
@ -62,7 +63,7 @@ class NettyRemoteServer(val netty: NettyRemoteTransport) {
|
|||
b.setOrigin(RemoteProtocol.AddressProtocol.newBuilder
|
||||
.setSystem(settings.systemName)
|
||||
.setHostname(settings.Hostname)
|
||||
.setPort(settings.Port)
|
||||
.setPort(settings.DesiredPortFromConfig)
|
||||
.build)
|
||||
if (settings.SecureCookie.nonEmpty)
|
||||
b.setCookie(settings.SecureCookie.get)
|
||||
|
|
@ -139,6 +140,7 @@ class RemoteServerHandler(
|
|||
|
||||
private var addressToSet = true
|
||||
|
||||
// TODO look into moving that into onBind or similar, but verify that that is guaranteed to be the first to be called
|
||||
override def handleUpstream(ctx: ChannelHandlerContext, event: ChannelEvent) = {
|
||||
if (addressToSet) {
|
||||
netty.setAddressFromChannel(event.getChannel)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue