@Override protected synchronized void removeRegistration() { if (listenerRegistrationActor != null) { listenerRegistrationActor.tell( CloseDataTreeChangeListenerRegistration.getInstance(), ActorRef.noSender()); listenerRegistrationActor = null; } dataChangeListenerActor.tell(PoisonPill.getInstance(), ActorRef.noSender()); }
private void setListenerRegistrationActor(final ActorSelection actor) { if (actor == null) { LOG.debug("Ignoring null actor on {}", this); return; } synchronized (this) { if (!isClosed()) { this.listenerRegistrationActor = actor; return; } } // This registration has already been closed, notify the actor actor.tell(CloseDataTreeChangeListenerRegistration.getInstance(), null); }
private void sendAppendEntriesToFollower( ActorSelection followerActor, long followerNextIndex, List<ReplicatedLogEntry> entries, String followerId) { AppendEntries appendEntries = new AppendEntries( currentTerm(), context.getId(), prevLogIndex(followerNextIndex), prevLogTerm(followerNextIndex), entries, context.getCommitIndex(), super.getReplicatedToAllIndex(), context.getPayloadVersion()); if (!entries.isEmpty() || LOG.isTraceEnabled()) { LOG.debug( "{}: Sending AppendEntries to follower {}: {}", logName(), followerId, appendEntries); } followerActor.tell(appendEntries.toSerializable(), actor()); }
/** * Sends a snapshot chunk to a given follower InstallSnapshot should qualify as a heartbeat too. */ private void sendSnapshotChunk(ActorSelection followerActor, String followerId) { try { if (snapshot.isPresent()) { ByteString nextSnapshotChunk = getNextSnapshotChunk(followerId, snapshot.get().getSnapshotBytes()); // Note: the previous call to getNextSnapshotChunk has the side-effect of adding // followerId to the followerToSnapshot map. FollowerToSnapshot followerToSnapshot = mapFollowerToSnapshot.get(followerId); followerActor.tell( new InstallSnapshot( currentTerm(), context.getId(), snapshot.get().getLastIncludedIndex(), snapshot.get().getLastIncludedTerm(), nextSnapshotChunk, followerToSnapshot.incrementChunkIndex(), followerToSnapshot.getTotalChunks(), Optional.of(followerToSnapshot.getLastChunkHashCode())) .toSerializable(), actor()); if (LOG.isDebugEnabled()) { LOG.debug( "{}: InstallSnapshot sent to follower {}, Chunk: {}/{}", logName(), followerActor.path(), followerToSnapshot.getChunkIndex(), followerToSnapshot.getTotalChunks()); } } } catch (IOException e) { LOG.error("{}: InstallSnapshot failed for Leader.", logName(), e); } }
{ ActorSelection selection = getContext().actorSelection("/user/another"); selection.tell(new Identify(identifyId), getSelf()); }