parent
5da7dc6c19
commit
e0db5f4e64
2 changed files with 4 additions and 7 deletions
|
|
@ -406,7 +406,8 @@ class Cluster(val system: ExtendedActorSystem) extends Extension {
|
|||
/**
|
||||
* The supplied thunk will be run, once, when current cluster member is `Removed`.
|
||||
* If the cluster has already been shutdown the thunk will run on the caller thread immediately.
|
||||
* Typically used together `cluster.leave(cluster.selfAddress)` and then `system.terminate()`.
|
||||
* If this is called "at the same time" as `shutdown()` there is a possibility that the the thunk
|
||||
* is not invoked. It's often better to use [[akka.actor.CoordinatedShutdown]] for this purpose.
|
||||
*/
|
||||
def registerOnMemberRemoved[T](code: => T): Unit =
|
||||
registerOnMemberRemoved(new Runnable { override def run(): Unit = code })
|
||||
|
|
@ -414,7 +415,8 @@ class Cluster(val system: ExtendedActorSystem) extends Extension {
|
|||
/**
|
||||
* Java API: The supplied thunk will be run, once, when current cluster member is `Removed`.
|
||||
* If the cluster has already been shutdown the thunk will run on the caller thread immediately.
|
||||
* Typically used together `cluster.leave(cluster.selfAddress)` and then `system.terminate()`.
|
||||
* If this is called "at the same time" as `shutdown()` there is a possibility that the the thunk
|
||||
* is not invoked. It's often better to use [[akka.actor.CoordinatedShutdown]] for this purpose.
|
||||
*/
|
||||
def registerOnMemberRemoved(callback: Runnable): Unit = {
|
||||
if (_isTerminated.get())
|
||||
|
|
|
|||
|
|
@ -137,17 +137,12 @@ class ClusterSpec extends AkkaSpec(ClusterSpec.config) with ImplicitSender {
|
|||
|
||||
// this should be the last test step, since the cluster is shutdown
|
||||
"publish MemberRemoved when shutdown" in {
|
||||
val callbackProbe = TestProbe()
|
||||
cluster.registerOnMemberRemoved(callbackProbe.ref ! "OnMemberRemoved")
|
||||
|
||||
cluster.subscribe(testActor, classOf[ClusterEvent.MemberRemoved])
|
||||
// first, is in response to the subscription
|
||||
expectMsgClass(classOf[ClusterEvent.CurrentClusterState])
|
||||
|
||||
cluster.shutdown()
|
||||
expectMsgType[ClusterEvent.MemberRemoved].member.address should ===(selfAddress)
|
||||
|
||||
callbackProbe.expectMsg("OnMemberRemoved")
|
||||
}
|
||||
|
||||
"allow join and leave with local address" in {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue