diff --git a/akka-remote/src/main/scala/remote/Cluster.scala b/akka-remote/src/main/scala/remote/Cluster.scala index 8a5864a51b..01cb988924 100644 --- a/akka-remote/src/main/scala/remote/Cluster.scala +++ b/akka-remote/src/main/scala/remote/Cluster.scala @@ -35,6 +35,11 @@ trait Cluster { * The order of application is undefined and may vary */ def foreach(f: (RemoteAddress) => Unit): Unit + + /** + * Returns all the endpoints in the cluster. + */ + def endpoints: Array[RemoteAddress] } /** @@ -196,6 +201,11 @@ abstract class BasicClusterActor extends ClusterActor with Logging { * Applies the given function to all remote addresses known */ def foreach(f: (RemoteAddress) => Unit): Unit = remotes.valuesIterator.toList.flatMap(_.endpoints).foreach(f) + + /** + * Returns all the endpoints in the cluster. + */ + def endpoints: Array[RemoteAddress] = remotes.toArray.asInstanceOf[Array[RemoteAddress]] } /** @@ -211,7 +221,7 @@ object Cluster extends Cluster with Logging { lazy val DEFAULT_CLUSTER_ACTOR_CLASS_NAME = classOf[JGroupsClusterActor].getName @volatile private[remote] var clusterActorRef: Option[ActorRef] = None - @volatile private[akka] var classLoader : Option[ClassLoader] = Some(getClass.getClassLoader) + @volatile private[akka] var classLoader: Option[ClassLoader] = Some(getClass.getClassLoader) private[remote] def createClusterActor(): Option[ActorRef] = { val name = config.getString("akka.remote.cluster.actor", DEFAULT_CLUSTER_ACTOR_CLASS_NAME) @@ -233,7 +243,7 @@ object Cluster extends Cluster with Logging { RestartStrategy(OneForOne, 5, 1000, List(classOf[Exception])), Supervise(actor, LifeCycle(Permanent)) :: Nil))) - private[this] def clusterActor = if(clusterActorRef.isEmpty) None else Some(clusterActorRef.get.actor.asInstanceOf[ClusterActor]) + private[this] def clusterActor = if (clusterActorRef.isEmpty) None else Some(clusterActorRef.get.actor.asInstanceOf[ClusterActor]) def name = clusterActor.map(_.name).getOrElse("No cluster") @@ -257,6 +267,8 @@ object Cluster extends Cluster with Logging { def foreach(f: (RemoteAddress) => Unit): Unit = clusterActor.foreach(_.foreach(f)) + def endpoints: Array[RemoteAddress] = clusterActor.end + def start(): Unit = start(None) def start(serializerClassLoader: Option[ClassLoader]): Unit = synchronized { diff --git a/akka-remote/src/main/scala/serialization/SerializationProtocol.scala b/akka-remote/src/main/scala/serialization/SerializationProtocol.scala index 7e812bbae8..7da001edab 100644 --- a/akka-remote/src/main/scala/serialization/SerializationProtocol.scala +++ b/akka-remote/src/main/scala/serialization/SerializationProtocol.scala @@ -67,7 +67,7 @@ trait SerializerBasedActorFormat[T <: Actor] extends Format[T] { } /** - * Module for local actor serialization + * Module for local actor serialization. */ object ActorSerialization {