private void onRemoveServer(RemoveServer removeServer, ActorRef sender) {
LOG.debug("{}: onRemoveServer: {}, state: {}", raftContext.getId(), removeServer, currentOperationState);
boolean isSelf = removeServer.getServerId().equals(raftActor.getId());
- if(!isSelf && !raftContext.getPeerIds().contains(removeServer.getServerId())) {
+ if(isSelf && !raftContext.hasFollowers()) {
+ sender.tell(new RemoveServerReply(ServerChangeStatus.NOT_SUPPORTED, raftActor.getLeaderId()),
+ raftActor.getSelf());
+ } else if(!isSelf && !raftContext.getPeerIds().contains(removeServer.getServerId())) {
sender.tell(new RemoveServerReply(ServerChangeStatus.DOES_NOT_EXIST, raftActor.getLeaderId()),
raftActor.getSelf());
} else {
@Override
public void initiate() {
- raftContext.removePeer(getRemoveServerContext().getOperation().getServerId());
+ String serverId = getRemoveServerContext().getOperation().getServerId();
+ raftContext.removePeer(serverId);
+ ((AbstractLeader)raftActor.getCurrentBehavior()).removeFollower(serverId);
+
persistNewServerConfiguration(getRemoveServerContext());
}
}