Created
November 3, 2012 00:30
-
-
Save helena/4005230 to your computer and use it in GitHub Desktop.
Akka 2.1 Cluster API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val system = ActorSystem("ClusterSystem") | |
system.actorOf(Props(new Actor with ActorLogging { | |
val cluster = Cluster(context.system) | |
override def preStart(): Unit = | |
cluster.subscribe(self, classOf[ClusterDomainEvent]) | |
def receive = { | |
case state: CurrentClusterState => | |
log.info("Current members: {}", state.members) | |
case MemberJoined(member) => | |
log.info("Member joined: {}", member) | |
case MemberUp(member) => | |
log.info("Member is Up: {}", member) | |
case MemberUnreachable(member) => | |
log.info("Member detected as unreachable: {}", member) | |
case MemberDowned(m) => | |
log.info("Member detected as downed: {}", member) | |
case MemberRemoved(m) => | |
log.info("Member removed: {}", member) | |
case _: ClusterDomainEvent => // ignore | |
} | |
override def postStop: Unit = cluster unsubscribe self | |
}), name = "clusterSampleListener") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment