+
+ @Override
+ void operationComplete(RaftActor raftActor, ServerChangeStatus serverChangeStatus) {
+
+ }
+ }
+
+ private abstract class RemoveServerState extends AbstractOperationState {
+ private final RemoveServerContext removeServerContext;
+
+
+ protected RemoveServerState(RemoveServerContext removeServerContext) {
+ this.removeServerContext = Preconditions.checkNotNull(removeServerContext);
+
+ }
+
+ public RemoveServerContext getRemoveServerContext() {
+ return removeServerContext;
+ }
+
+ }
+
+ private class InitialRemoveServerState extends RemoveServerState implements InitialOperationState{
+
+ protected InitialRemoveServerState(RemoveServerContext removeServerContext) {
+ super(removeServerContext);
+ }
+
+ @Override
+ public void initiate(RaftActor raftActor) {
+ raftContext.removePeer(getRemoveServerContext().getOperation().getServerId());
+ persistNewServerConfiguration(raftActor, getRemoveServerContext());
+ }
+ }
+
+ private static class RemoveServerContext extends ServerOperationContext<RemoveServer> {
+ private final String peerAddress;
+
+ RemoveServerContext(RemoveServer operation, String peerAddress, ActorRef clientRequestor) {
+ super(operation, clientRequestor);
+ this.peerAddress = peerAddress;
+ }
+
+ @Override
+ Object newReply(ServerChangeStatus status, String leaderId) {
+ return new RemoveServerReply(status, leaderId);
+ }
+
+ @Override
+ InitialOperationState newInitialOperationState(RaftActorServerConfigurationSupport support) {
+ return support.new InitialRemoveServerState(this);
+ }
+
+ @Override
+ void operationComplete(RaftActor raftActor, ServerChangeStatus serverChangeStatus) {
+ if(peerAddress != null) {
+ raftActor.context().actorSelection(peerAddress).tell(new ServerRemoved(getOperation().getServerId()), raftActor.getSelf());
+ }
+ }
+