Java Code Examples for akka.cluster.ClusterEvent#MemberEvent
The following examples show how to use
akka.cluster.ClusterEvent#MemberEvent .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClusterStatusObserverActor.java From java-11-examples with Apache License 2.0 | 5 votes |
@Override public void onReceive(Object message) throws Throwable { if (message instanceof ClusterEvent.MemberEvent) { Member member = ((ClusterEvent.MemberEvent) message).member(); LOG.info("memberEvent: " + member.address().toString()); clusterStatusObserver.updateMember(member); } else if (message instanceof ClusterEvent.LeaderChanged) { ClusterEvent.LeaderChanged leaderChangedEvent = (ClusterEvent.LeaderChanged)message; clusterStatusObserver.onLeaderChanged(leaderChangedEvent); LOG.info("leaderChanged: " + leaderChangedEvent.getLeader().toString()); } else { LOG.info("onReceive: " + message.getClass().getName()); } }
Example 2
Source File: ClientActor.java From usergrid with Apache License 2.0 | 4 votes |
/** * Process messages about nodes up, down, reachable and unreachable. */ private void processAsClusterEvent(Object message) { if (message instanceof ClusterEvent.CurrentClusterState) { ClusterEvent.CurrentClusterState state = (ClusterEvent.CurrentClusterState) message; nodes.clear(); for (Member member : state.getMembers()) { if (member.hasRole("io") && member.status().equals( MemberStatus.up())) { nodes.add(member.address()); logger.debug("RequestActor {} received cluster-state member-up for {}", name, member.address()); } } } else if (message instanceof ClusterEvent.MemberUp) { ClusterEvent.MemberUp mUp = (ClusterEvent.MemberUp) message; if (mUp.member().hasRole("io")) { nodes.add( mUp.member().address() ); } logger.debug("{} received member-up for {}", name, mUp.member().address()); } else if (message instanceof ClusterEvent.MemberEvent) { ClusterEvent.MemberEvent other = (ClusterEvent.MemberEvent) message; nodes.remove(other.member().address()); } else if (message instanceof ClusterEvent.UnreachableMember) { ClusterEvent.UnreachableMember unreachable = (ClusterEvent.UnreachableMember) message; nodes.remove(unreachable.member().address()); logger.debug("{} received un-reachable for {}", name, unreachable.member().address()); } else if (message instanceof ClusterEvent.ReachableMember) { ClusterEvent.ReachableMember reachable = (ClusterEvent.ReachableMember) message; if (reachable.member().hasRole("io")) { nodes.add( reachable.member().address() ); } logger.debug("{} received reachable for {}", name, reachable.member().address()); } else { logger.error("{}: unhandled message: {}", name, message.toString()); unhandled(message); } }