@Override public ActorFuture<Void> closeAppender() { appenderFuture = null; writeBufferFuture = null; appender = null; writeBuffer = null; return serviceContext.removeService(logStorageAppenderRootService(logName)); }
@Override public ActorFuture<Void> closeAppender() { appenderFuture = null; writeBufferFuture = null; appender = null; writeBuffer = null; return serviceContext.removeService(logStorageAppenderRootService(logName)); }
private void leaveState(final BiConsumer<Void, Throwable> whenLeftCallback) { final ActorFuture<Void> whenPrevStateLeft; if (currentStateServiceName != null) { whenPrevStateLeft = serviceContext.removeService(currentStateServiceName); } else { whenPrevStateLeft = CompletableActorFuture.completed(null); } actor.runOnCompletion(whenPrevStateLeft, whenLeftCallback); }
private void leaveState(final BiConsumer<Void, Throwable> whenLeftCallback) { final ActorFuture<Void> whenPrevStateLeft; if (currentStateServiceName != null) { whenPrevStateLeft = serviceContext.removeService(currentStateServiceName); } else { whenPrevStateLeft = CompletableActorFuture.completed(null); } actor.runOnCompletion(whenPrevStateLeft, whenLeftCallback); }
private void removeFollowerPartitionService(final Raft raft) { final ServiceName<Partition> partitionServiceName = followerPartitionServiceName(raft.getName()); if (startContext.hasService(partitionServiceName)) { LOG.debug("Removing follower partition service for partition {}", partitionInfo); startContext.removeService(partitionServiceName); } }
private void removeFollowerPartitionService(final Raft raft) { final ServiceName<Partition> partitionServiceName = followerPartitionServiceName(raft.getName()); if (startContext.hasService(partitionServiceName)) { LOG.debug("Removing follower partition service for partition {}", partitionInfo); startContext.removeService(partitionServiceName); } }
@Override public ActorFuture<Void> onMemberLeaving(final Raft raft, final Collection<Integer> nodeIds) { final ServiceName<Partition> partitionServiceName = leaderPartitionServiceName(raft.getName()); final int raftMemberSize = nodeIds.size() + 1; // raft does not count itself as member final int replicationFactor = partitionInfo.getReplicationFactor(); ActorFuture<Void> leaveHandledFuture = CompletableActorFuture.completed(null); if (startContext.hasService(partitionServiceName)) { if (raftMemberSize < replicationFactor) { LOG.debug( "Removing partition service for {}. Replication factor not reached, got {}/{}.", partitionInfo, raftMemberSize, replicationFactor); leaveHandledFuture = startContext.removeService(partitionServiceName); } else { LOG.debug( "Not removing partition {}, replication factor still reached, got {}/{}.", partitionInfo, raftMemberSize, replicationFactor); } } return leaveHandledFuture; }
@Override public ActorFuture<Void> onMemberLeaving(final Raft raft, final Collection<Integer> nodeIds) { final ServiceName<Partition> partitionServiceName = leaderPartitionServiceName(raft.getName()); final int raftMemberSize = nodeIds.size() + 1; // raft does not count itself as member final int replicationFactor = partitionInfo.getReplicationFactor(); ActorFuture<Void> leaveHandledFuture = CompletableActorFuture.completed(null); if (startContext.hasService(partitionServiceName)) { if (raftMemberSize < replicationFactor) { LOG.debug( "Removing partition service for {}. Replication factor not reached, got {}/{}.", partitionInfo, raftMemberSize, replicationFactor); leaveHandledFuture = startContext.removeService(partitionServiceName); } else { LOG.debug( "Not removing partition {}, replication factor still reached, got {}/{}.", partitionInfo, raftMemberSize, replicationFactor); } } return leaveHandledFuture; }
public ActorFuture<Boolean> memberLeaves(final int nodeId) { final CompletableActorFuture<Boolean> leaveFuture = new CompletableActorFuture<>(); LOG.debug("Member {} leaving the cluster", nodeId); if (raftMembers.hasMember(nodeId)) { final List<Integer> listWithoutMemberThatIsLeaving = raftMembers.getMemberIds(); listWithoutMemberThatIsLeaving.removeIf(member -> member.equals(nodeId)); actor.runOnCompletion( notifyMemberLeavingListeners(listWithoutMemberThatIsLeaving), (t) -> { if (state.getState() == RaftState.LEADER) { raftMembers.removeMember(nodeId); // stop replication serviceContext.removeService( replicateLogConrollerServiceName(raftName, getTerm(), nodeId)); leaveFuture.complete(true); } else { leaveFuture.complete(false); } }); } else { leaveFuture.complete(false); } return leaveFuture; }
public ActorFuture<Boolean> memberLeaves(final int nodeId) { final CompletableActorFuture<Boolean> leaveFuture = new CompletableActorFuture<>(); LOG.debug("Member {} leaving the cluster", nodeId); if (raftMembers.hasMember(nodeId)) { final List<Integer> listWithoutMemberThatIsLeaving = raftMembers.getMemberIds(); listWithoutMemberThatIsLeaving.removeIf(member -> member.equals(nodeId)); actor.runOnCompletion( notifyMemberLeavingListeners(listWithoutMemberThatIsLeaving), (t) -> { if (state.getState() == RaftState.LEADER) { raftMembers.removeMember(nodeId); // stop replication serviceContext.removeService( replicateLogConrollerServiceName(raftName, getTerm(), nodeId)); leaveFuture.complete(true); } else { leaveFuture.complete(false); } }); } else { leaveFuture.complete(false); } return leaveFuture; }