+clu #17870 add Java api for joinSeedNodes
This commit is contained in:
parent
afa9549307
commit
75c5810970
3 changed files with 43 additions and 4 deletions
|
|
@ -12,6 +12,7 @@ import akka.ConfigurationException
|
||||||
import akka.actor._
|
import akka.actor._
|
||||||
import akka.dispatch.MonitorableThreadFactory
|
import akka.dispatch.MonitorableThreadFactory
|
||||||
import akka.event.{ Logging, LoggingAdapter }
|
import akka.event.{ Logging, LoggingAdapter }
|
||||||
|
import akka.japi.Util
|
||||||
import akka.pattern._
|
import akka.pattern._
|
||||||
import akka.remote.{ DefaultFailureDetectorRegistry, FailureDetector, _ }
|
import akka.remote.{ DefaultFailureDetectorRegistry, FailureDetector, _ }
|
||||||
import com.typesafe.config.{ Config, ConfigFactory }
|
import com.typesafe.config.{ Config, ConfigFactory }
|
||||||
|
|
@ -265,13 +266,23 @@ class Cluster(val system: ExtendedActorSystem) extends Extension {
|
||||||
* An actor system can only join a cluster once. Additional attempts will be ignored.
|
* An actor system can only join a cluster once. Additional attempts will be ignored.
|
||||||
* When it has successfully joined it must be restarted to be able to join another
|
* When it has successfully joined it must be restarted to be able to join another
|
||||||
* cluster or to join the same cluster again.
|
* cluster or to join the same cluster again.
|
||||||
*
|
|
||||||
* JAVA API: Use akka.japi.Util.immutableSeq to convert a java.lang.Iterable
|
|
||||||
* to the type needed for the seedNodes parameter.
|
|
||||||
*/
|
*/
|
||||||
def joinSeedNodes(seedNodes: immutable.Seq[Address]): Unit =
|
def joinSeedNodes(seedNodes: immutable.Seq[Address]): Unit =
|
||||||
clusterCore ! InternalClusterAction.JoinSeedNodes(seedNodes.toVector)
|
clusterCore ! InternalClusterAction.JoinSeedNodes(seedNodes.toVector)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Java API
|
||||||
|
*
|
||||||
|
* Join the specified seed nodes without defining them in config.
|
||||||
|
* Especially useful from tests when Addresses are unknown before startup time.
|
||||||
|
*
|
||||||
|
* An actor system can only join a cluster once. Additional attempts will be ignored.
|
||||||
|
* When it has successfully joined it must be restarted to be able to join another
|
||||||
|
* cluster or to join the same cluster again.
|
||||||
|
*/
|
||||||
|
def joinSeedNodes(seedNodes: java.util.List[Address]): Unit =
|
||||||
|
joinSeedNodes(Util.immutableSeq(seedNodes))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send command to issue state transition to LEAVING for the node specified by 'address'.
|
* Send command to issue state transition to LEAVING for the node specified by 'address'.
|
||||||
* The member will go through the status changes [[MemberStatus]] `Leaving` (not published to
|
* The member will go through the status changes [[MemberStatus]] `Leaving` (not published to
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package akka.cluster
|
package akka.cluster
|
||||||
|
|
||||||
|
import akka.actor.Address
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
import akka.remote.testkit.MultiNodeConfig
|
import akka.remote.testkit.MultiNodeConfig
|
||||||
import akka.remote.testkit.MultiNodeSpec
|
import akka.remote.testkit.MultiNodeSpec
|
||||||
|
|
@ -45,7 +46,8 @@ abstract class SingletonClusterSpec(multiNodeConfig: SingletonClusterMultiNodeCo
|
||||||
|
|
||||||
"become singleton cluster when started with seed-nodes" taggedAs LongRunningTest in {
|
"become singleton cluster when started with seed-nodes" taggedAs LongRunningTest in {
|
||||||
runOn(first) {
|
runOn(first) {
|
||||||
cluster.joinSeedNodes(Vector(first))
|
val nodes: immutable.IndexedSeq[Address] = Vector(first) //
|
||||||
|
cluster.joinSeedNodes(nodes)
|
||||||
awaitMembersUp(1)
|
awaitMembersUp(1)
|
||||||
clusterView.isSingletonCluster should ===(true)
|
clusterView.isSingletonCluster should ===(true)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
/**
|
||||||
|
* Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
package akka.cluster;
|
||||||
|
|
||||||
|
import akka.actor.ActorSystem;
|
||||||
|
import akka.actor.Address;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
// Doc code, compile only
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
public class ClusterJavaCompileTest {
|
||||||
|
|
||||||
|
final ActorSystem system = null;
|
||||||
|
final Cluster cluster = null;
|
||||||
|
|
||||||
|
|
||||||
|
public void compileJoinSeedNodesInJava() {
|
||||||
|
final List<Address> addresses = Collections.singletonList(new Address("akka.tcp", "MySystem"));
|
||||||
|
cluster.joinSeedNodes(addresses);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue