minor cleanup of cluster.subscribe usage

This commit is contained in:
Patrik Nordwall 2016-11-08 15:08:32 +01:00
parent 72925ba392
commit d9e873644e
2 changed files with 4 additions and 3 deletions

View file

@ -21,6 +21,7 @@ import akka.cluster.ddata.Replicator._
import akka.dispatch.ExecutionContexts
import akka.pattern.{ AskTimeoutException, pipe }
import akka.persistence._
import akka.cluster.ClusterEvent
/**
* @see [[ClusterSharding$ ClusterSharding extension]]
@ -840,7 +841,7 @@ class DDataShardCoordinator(typeName: String, settings: ClusterShardingSettings,
val CoordinatorStateKey = LWWRegisterKey[State](s"${typeName}CoordinatorState")
val initEmptyState = State.empty.withRememberEntities(settings.rememberEntities)
node.subscribe(self, ClusterShuttingDown.getClass)
node.subscribe(self, ClusterEvent.InitialStateAsEvents, ClusterShuttingDown.getClass)
// get state from ddata replicator, repeat until GetSuccess
getState()

View file

@ -24,6 +24,7 @@ import akka.cluster.MemberStatus
import akka.AkkaException
import akka.actor.NoSerializationVerificationNeeded
import akka.cluster.UniqueAddress
import akka.cluster.ClusterEvent
object ClusterSingletonManagerSettings {
@ -432,7 +433,7 @@ class ClusterSingletonManager(
require(!cluster.isTerminated, "Cluster node must not be terminated")
// subscribe to cluster changes, re-subscribe when restart
cluster.subscribe(self, classOf[MemberExited], classOf[MemberRemoved])
cluster.subscribe(self, ClusterEvent.InitialStateAsEvents, classOf[MemberExited], classOf[MemberRemoved])
setTimer(CleanupTimer, Cleanup, 1.minute, repeat = true)
@ -712,7 +713,6 @@ class ClusterSingletonManager(
}
whenUnhandled {
case Event(_: CurrentClusterState, _) stay
case Event(MemberExited(m), _)
if (m.uniqueAddress == cluster.selfUniqueAddress) {
selfExited = true