Load Cluster extension from ClusterActorRefProvider, see #2704

This commit is contained in:
Patrik Nordwall 2012-12-04 17:54:17 +01:00
parent 86a85f8605
commit 1673ccd51c
5 changed files with 12 additions and 21 deletions

View file

@ -37,6 +37,10 @@ import akka.cluster.routing.MetricsSelector
/** /**
* INTERNAL API * INTERNAL API
*
* The `ClusterActorRefProvider` will load the [[akka.cluster.Cluster]]
* extension, i.e. the cluster will automatically be started when
* the `ClusterActorRefProvider` is used.
*/ */
class ClusterActorRefProvider( class ClusterActorRefProvider(
_systemName: String, _systemName: String,
@ -51,6 +55,9 @@ class ClusterActorRefProvider(
override def init(system: ActorSystemImpl): Unit = { override def init(system: ActorSystemImpl): Unit = {
super.init(system) super.init(system)
// initialize/load the Cluster extension
Cluster(system)
remoteDeploymentWatcher = system.systemActorOf(Props[RemoteDeploymentWatcher], "RemoteDeploymentWatcher") remoteDeploymentWatcher = system.systemActorOf(Props[RemoteDeploymentWatcher], "RemoteDeploymentWatcher")
} }

View file

@ -18,21 +18,9 @@ import akka.testkit.ImplicitSender
import akka.actor.ActorRef import akka.actor.ActorRef
import akka.testkit.TestProbe import akka.testkit.TestProbe
object ClusterDomainEventPublisherSpec {
val config = """
akka.cluster.auto-join = off
akka.actor.provider = "akka.cluster.ClusterActorRefProvider"
akka.remote.log-remote-lifecycle-events = off
akka.remote.netty.port = 0
"""
case class GossipTo(address: Address)
}
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner]) @org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
class ClusterDomainEventPublisherSpec extends AkkaSpec(ClusterDomainEventPublisherSpec.config) class ClusterDomainEventPublisherSpec extends AkkaSpec
with BeforeAndAfterEach with ImplicitSender { with BeforeAndAfterEach with ImplicitSender {
import ClusterDomainEventPublisherSpec._
var publisher: ActorRef = _ var publisher: ActorRef = _
val a1 = Member(Address("akka", "sys", "a", 2552), Up) val a1 = Member(Address("akka", "sys", "a", 2552), Up)

View file

@ -31,7 +31,7 @@ A Simple Cluster Example
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
The following small program together with its configuration starts an ``ActorSystem`` The following small program together with its configuration starts an ``ActorSystem``
with the Cluster extension enabled. It joins the cluster and logs some membership events. with the Cluster enabled. It joins the cluster and logs some membership events.
Try it out: Try it out:
@ -42,8 +42,7 @@ Try it out:
To enable cluster capabilities in your Akka project you should, at a minimum, add the :ref:`remoting-java` To enable cluster capabilities in your Akka project you should, at a minimum, add the :ref:`remoting-java`
settings, but with ``akka.cluster.ClusterActorRefProvider``. settings, but with ``akka.cluster.ClusterActorRefProvider``.
The ``akka.cluster.seed-nodes`` and cluster extension should normally also be added to your The ``akka.cluster.seed-nodes`` should normally also be added to your ``application.conf`` file.
``application.conf`` file.
The seed nodes are configured contact points for initial, automatic, join of the cluster. The seed nodes are configured contact points for initial, automatic, join of the cluster.

View file

@ -25,7 +25,7 @@ A Simple Cluster Example
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
The following small program together with its configuration starts an ``ActorSystem`` The following small program together with its configuration starts an ``ActorSystem``
with the Cluster extension enabled. It joins the cluster and logs some membership events. with the Cluster enabled. It joins the cluster and logs some membership events.
Try it out: Try it out:
@ -36,8 +36,7 @@ Try it out:
To enable cluster capabilities in your Akka project you should, at a minimum, add the :ref:`remoting-scala` To enable cluster capabilities in your Akka project you should, at a minimum, add the :ref:`remoting-scala`
settings, but with ``akka.cluster.ClusterActorRefProvider``. settings, but with ``akka.cluster.ClusterActorRefProvider``.
The ``akka.cluster.seed-nodes`` and cluster extension should normally also be added to your The ``akka.cluster.seed-nodes`` should normally also be added to your ``application.conf`` file.
``application.conf`` file.
The seed nodes are configured contact points for initial, automatic, join of the cluster. The seed nodes are configured contact points for initial, automatic, join of the cluster.

View file

@ -12,8 +12,6 @@ akka {
} }
} }
extensions = ["akka.cluster.Cluster"]
cluster { cluster {
seed-nodes = [ seed-nodes = [
"akka://ClusterSystem@127.0.0.1:2551", "akka://ClusterSystem@127.0.0.1:2551",