akka.cluster.ClusterEvent Java Examples
The following examples show how to use
akka.cluster.ClusterEvent.
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: SshClusterManagerActor.java From java-11-examples with Apache License 2.0 | 5 votes |
@Override public void preStart() { LOG.info("preStart"); cluster.subscribe(getSelf(), ClusterEvent.initialStateAsEvents(), ClusterEvent.LeaderChanged.class, ClusterEvent.MemberUp.class, ClusterEvent.MemberExited.class, ClusterEvent.MemberJoined.class, ClusterEvent.MemberLeft.class, ClusterEvent.MemberRemoved.class, ClusterEvent.MemberWeaklyUp.class); }
Example #2
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 #3
Source File: SimpleClusterListener.java From akka-kubernetes-example with Apache License 2.0 | 5 votes |
@Override public void preStart() { //#subscribe cluster.subscribe(getSelf(), ClusterEvent.initialStateAsEvents(), MemberEvent.class, UnreachableMember.class); //#subscribe }
Example #4
Source File: PubUpdater.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Override public Receive createReceive() { return ReceiveBuilder.create() .match(ClusterEvent.MemberRemoved.class, this::removeMember) .matchAny(this::logUnhandled) .build(); }
Example #5
Source File: ClientActor.java From usergrid with Apache License 2.0 | 5 votes |
@Override public void preStart() { logger.debug("{} role {} address {}:{} starting up, subscribing to cluster events...", name, cluster.getSelfRoles().iterator().next(), cluster.readView().selfAddress().host(), cluster.readView().selfAddress().hostPort()); cluster.subscribe(getSelf(), ClusterEvent.MemberEvent.class, ClusterEvent.ReachabilityEvent.class); }
Example #6
Source File: ClusterListener.java From usergrid with Apache License 2.0 | 5 votes |
@Override public void preStart() { // subscribe to all cluster events that we might take action/logging on cluster.subscribe(getSelf(), ClusterEvent.initialStateAsEvents(), ClusterEvent.MemberEvent.class, ClusterEvent.UnreachableMember.class, ClusterEvent.MemberUp.class, ClusterEvent.MemberWeaklyUp.class); }
Example #7
Source File: SshClusterManagerActor.java From java-11-examples with Apache License 2.0 | 4 votes |
@Override public void onReceive(Object message) throws Throwable { if (message instanceof ClusterEvent.LeaderChanged) { ClusterEvent.LeaderChanged leaderChanged = (ClusterEvent.LeaderChanged) message; sshClusterManager.setLeaderAddress(leaderChanged.getLeader().toString()); } else if (message instanceof ClusterEvent.MemberUp) { ClusterEvent.MemberUp memberUp = (ClusterEvent.MemberUp)message; sshClusterManager.addMember(memberUp.member().address().toString(), "UP"); } else if (message instanceof ClusterEvent.MemberExited) { ClusterEvent.MemberExited memberExited = (ClusterEvent.MemberExited)message; sshClusterManager.removeMember(memberExited.member().address().toString(), "EXITED"); } else if (message instanceof ClusterEvent.MemberJoined) { ClusterEvent.MemberJoined memberJoined = (ClusterEvent.MemberJoined)message; sshClusterManager.addMember(memberJoined.member().address().toString(), "JOINED"); } else if (message instanceof ClusterEvent.MemberLeft) { ClusterEvent.MemberLeft memberLeft = (ClusterEvent.MemberLeft)message; sshClusterManager.removeMember(memberLeft.member().address().toString(), "LEFT"); } else if (message instanceof ClusterEvent.MemberRemoved) { ClusterEvent.MemberRemoved memberRemoved = (ClusterEvent.MemberRemoved)message; sshClusterManager.removeMember(memberRemoved.member().address().toString(), "REMOVED"); } else if (message instanceof ClusterEvent.MemberWeaklyUp) { ClusterEvent.MemberWeaklyUp memberWeaklyUp = (ClusterEvent.MemberWeaklyUp)message; sshClusterManager.removeMember(memberWeaklyUp.member().address().toString(), "WEAKLY_UP"); } else if (message instanceof SessionCreateRequest) { SessionCreateRequest sessionCreateRequest = (SessionCreateRequest)message; sshClusterManager.onSessionCreateRequest(sessionCreateRequest); } else if (message instanceof SessionCreateResponse) { SessionCreateResponse sessionCreateResponse = (SessionCreateResponse)message; sshClusterManager.onSessionCreateResponse(sessionCreateResponse); } else if (message instanceof SessionCloseRequest) { SessionCloseRequest sessionCloseRequest = (SessionCloseRequest) message; sshClusterManager.onSessionCloseRequest(sessionCloseRequest); } else if (message instanceof SessionCloseResponse) { SessionCloseResponse sessionCloseResponse = (SessionCloseResponse) message; sshClusterManager.onSessionCloseResponse(sessionCloseResponse); } else if (message instanceof GetActiveSessionsResponse) { GetActiveSessionsResponse getActiveSessionsResponse = (GetActiveSessionsResponse)message; sshClusterManager.onActiveSessionsResponse(getActiveSessionsResponse); } else if (message instanceof SessionCreateError) { SessionCreateError sessionCreateError = (SessionCreateError)message; sshClusterManager.onSessionCreateError(sessionCreateError); } else { LOG.info("onReceive: {}", message.getClass().getName()); } }
Example #8
Source File: ClusterStatusObserver.java From java-11-examples with Apache License 2.0 | 4 votes |
public void onLeaderChanged(ClusterEvent.LeaderChanged leaderChangedEvent) { hasLeader.set(leaderChangedEvent.leader().nonEmpty()); }
Example #9
Source File: ClusterStatusObserverActor.java From java-11-examples with Apache License 2.0 | 4 votes |
@Override public void preStart() throws Exception { cluster.subscribe(getSelf(), ClusterEvent.initialStateAsEvents(), ClusterEvent.MemberUp.class, ClusterEvent.LeaderChanged.class); }
Example #10
Source File: AkkaClusterListener.java From servicecomb-pack with Apache License 2.0 | 4 votes |
@Override public void preStart() { cluster.subscribe(getSelf(), ClusterEvent.initialStateAsEvents(), MemberEvent.class, UnreachableMember.class); }
Example #11
Source File: PubUpdater.java From ditto with Eclipse Public License 2.0 | 4 votes |
@SuppressWarnings("unused") private PubUpdater(final DDataWriter<?> ddataWriter) { this.ddataWriter = ddataWriter; Cluster.get(getContext().getSystem()).subscribe(getSelf(), ClusterEvent.MemberRemoved.class); }
Example #12
Source File: PubUpdater.java From ditto with Eclipse Public License 2.0 | 4 votes |
private void removeMember(final ClusterEvent.MemberRemoved memberRemoved) { // publisher detected unreachable remote. remove it from local ORMap. final Address address = memberRemoved.member().address(); log.info("Removing subscribers on removed member <{}>", address); ddataWriter.removeAddress(address, Replicator.writeLocal()); }
Example #13
Source File: ClusterListener.java From flux with Apache License 2.0 | 4 votes |
/** * Overridden super class method. Sets up subscription for cluster membership changes * @see akka.actor.UntypedActor#preStart() */ public void preStart() { cluster.subscribe(getSelf(), ClusterEvent.initialStateAsEvents(), MemberEvent.class, UnreachableMember.class); }
Example #14
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); } }