=clu #18345 Support local address in cluster commands

* and clarify the doc sample for leave
This commit is contained in:
Patrik Nordwall 2015-09-04 08:53:36 +02:00
parent 4cbfe3d682
commit f98b4c1f5e
6 changed files with 113 additions and 7 deletions

View file

@ -261,7 +261,13 @@ class Cluster(val system: ExtendedActorSystem) extends Extension {
* cluster or to join the same cluster again.
*/
def join(address: Address): Unit =
clusterCore ! ClusterUserAction.JoinTo(address)
clusterCore ! ClusterUserAction.JoinTo(fillLocal(address))
private def fillLocal(address: Address): Address = {
// local address might be used if grabbed from actorRef.path.address
if (address.hasLocalScope && address.system == selfAddress.system) selfAddress
else address
}
/**
* Join the specified seed nodes without defining them in config.
@ -272,7 +278,7 @@ class Cluster(val system: ExtendedActorSystem) extends Extension {
* cluster or to join the same cluster again.
*/
def joinSeedNodes(seedNodes: immutable.Seq[Address]): Unit =
clusterCore ! InternalClusterAction.JoinSeedNodes(seedNodes.toVector)
clusterCore ! InternalClusterAction.JoinSeedNodes(seedNodes.toVector.map(fillLocal))
/**
* Java API
@ -300,7 +306,7 @@ class Cluster(val system: ExtendedActorSystem) extends Extension {
* still be necessary to set the nodes status to Down in order to complete the removal.
*/
def leave(address: Address): Unit =
clusterCore ! ClusterUserAction.Leave(address)
clusterCore ! ClusterUserAction.Leave(fillLocal(address))
/**
* Send command to DOWN the node specified by 'address'.
@ -311,7 +317,7 @@ class Cluster(val system: ExtendedActorSystem) extends Extension {
* this method.
*/
def down(address: Address): Unit =
clusterCore ! ClusterUserAction.Down(address)
clusterCore ! ClusterUserAction.Down(fillLocal(address))
/**
* The supplied thunk will be run, once, when current cluster member is `Up`.