From 95791ce4c5c14bc8ed6162fd21802989b77d461c Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Fri, 2 Dec 2011 18:08:13 +0100 Subject: [PATCH] #1424 - RemoteSupport is now instantiated from the config, so now anyone can write their own Akka transport layer for remote actors --- .../src/main/scala/akka/cluster/Cluster.scala | 2 +- akka-remote/src/main/resources/reference.conf | 2 +- .../src/main/scala/akka/remote/Remote.scala | 16 +++++++++++----- .../scala/akka/remote/RemoteConfigSpec.scala | 2 +- akka-spring/src/test/resources/akka-test.conf | 2 +- .../test/scala/TypedActorSpringFeatureTest.scala | 2 +- .../scala/UntypedActorSpringFeatureTest.scala | 2 +- 7 files changed, 17 insertions(+), 11 deletions(-) diff --git a/akka-cluster/src/main/scala/akka/cluster/Cluster.scala b/akka-cluster/src/main/scala/akka/cluster/Cluster.scala index 274ac6e9dc..356a4461bd 100644 --- a/akka-cluster/src/main/scala/akka/cluster/Cluster.scala +++ b/akka-cluster/src/main/scala/akka/cluster/Cluster.scala @@ -297,7 +297,7 @@ class DefaultClusterNode private[akka] ( :: Nil)).start() lazy val remoteService: RemoteSupport = { - val remote = new akka.cluster.netty.NettyRemoteSupport + val remote = new akka.remote.netty.NettyRemoteSupport remote.start(hostname, port) remote.register(RemoteClusterDaemon.Address, remoteDaemon) remote.addListener(RemoteFailureDetector.sender) diff --git a/akka-remote/src/main/resources/reference.conf b/akka-remote/src/main/resources/reference.conf index a80c4fa6a7..41eaf2e117 100644 --- a/akka-remote/src/main/resources/reference.conf +++ b/akka-remote/src/main/resources/reference.conf @@ -8,7 +8,7 @@ akka { remote { - transport = "akka.cluster.netty.NettyRemoteSupport" + transport = "akka.remote.netty.NettyRemoteSupport" use-compression = off diff --git a/akka-remote/src/main/scala/akka/remote/Remote.scala b/akka-remote/src/main/scala/akka/remote/Remote.scala index 82daeaf820..e5854e03a3 100644 --- a/akka-remote/src/main/scala/akka/remote/Remote.scala +++ b/akka-remote/src/main/scala/akka/remote/Remote.scala @@ -71,13 +71,19 @@ class Remote(val system: ActorSystemImpl, val nodename: String) { lazy val eventStream = new NetworkEventStream(system) lazy val server: RemoteSupport = { - val remote = new akka.remote.netty.NettyRemoteSupport(system) - remote.start() //TODO Any application loader here? + //new akka.remote.netty.NettyRemoteSupport(system) + ReflectiveAccess.createInstance[RemoteSupport](remoteExtension.RemoteTransport, Array[Class[_]](classOf[ActorSystem]), Array[AnyRef](system)) match { + case Left(problem) ⇒ + log.error(problem, "Could not load remote transport layer") + throw problem + case Right(remote) ⇒ + remote.start(None) //TODO Any application loader here? - system.eventStream.subscribe(eventStream.sender, classOf[RemoteLifeCycleEvent]) - system.eventStream.subscribe(remoteClientLifeCycleHandler, classOf[RemoteLifeCycleEvent]) + system.eventStream.subscribe(eventStream.sender, classOf[RemoteLifeCycleEvent]) + system.eventStream.subscribe(remoteClientLifeCycleHandler, classOf[RemoteLifeCycleEvent]) - remote + remote + } } def start(): Unit = { diff --git a/akka-remote/src/test/scala/akka/remote/RemoteConfigSpec.scala b/akka-remote/src/test/scala/akka/remote/RemoteConfigSpec.scala index d11d07ddd3..87a213e0eb 100644 --- a/akka-remote/src/test/scala/akka/remote/RemoteConfigSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/RemoteConfigSpec.scala @@ -12,7 +12,7 @@ class RemoteConfigSpec extends AkkaSpec("akka.cluster.nodename = node1") { import config._ //akka.remote - getString("akka.remote.transport") must equal("akka.cluster.netty.NettyRemoteSupport") + getString("akka.remote.transport") must equal("akka.remote.netty.NettyRemoteSupport") getString("akka.remote.secure-cookie") must equal("") getBoolean("akka.remote.use-passive-connections") must equal(true) // getMilliseconds("akka.remote.remote-daemon-ack-timeout") must equal(30 * 1000) diff --git a/akka-spring/src/test/resources/akka-test.conf b/akka-spring/src/test/resources/akka-test.conf index e6c019e24c..806783d217 100644 --- a/akka-spring/src/test/resources/akka-test.conf +++ b/akka-spring/src/test/resources/akka-test.conf @@ -128,7 +128,7 @@ akka { # secure-cookie = "050E0A0D0D06010A00000900040D060F0C09060B" # generate your own with '$AKKA_HOME/scripts/generate_secure_cookie.sh' or using 'Crypt.generateSecureCookie' secure-cookie = "" - layer = "akka.cluster.netty.NettyRemoteSupport" + layer = "akka.remote.netty.NettyRemoteSupport" server { hostname = "localhost" # The hostname or IP that clients should connect to diff --git a/akka-spring/src/test/scala/TypedActorSpringFeatureTest.scala b/akka-spring/src/test/scala/TypedActorSpringFeatureTest.scala index 9b9f428d3d..f2cc5a288d 100644 --- a/akka-spring/src/test/scala/TypedActorSpringFeatureTest.scala +++ b/akka-spring/src/test/scala/TypedActorSpringFeatureTest.scala @@ -15,7 +15,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext import org.springframework.core.io.{ ClassPathResource, Resource } import org.scalatest.{ BeforeAndAfterAll, FeatureSpec } import java.util.concurrent.CountDownLatch -import akka.cluster.netty.NettyRemoteSupport +import akka.remote.netty.NettyRemoteSupport import akka.actor._ import akka.actor.Actor._ diff --git a/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala b/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala index 6c7a0156e7..66ca68dba7 100644 --- a/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala +++ b/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala @@ -9,7 +9,7 @@ import org.scalatest.matchers.ShouldMatchers import org.scalatest.junit.JUnitRunner import org.junit.runner.RunWith import org.springframework.context.support.ClassPathXmlApplicationContext -import akka.cluster.netty.NettyRemoteSupport +import akka.remote.netty.NettyRemoteSupport import org.scalatest.{ BeforeAndAfterAll, FeatureSpec } import java.util.concurrent.CountDownLatch