import java.util.Queue;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
+import javax.annotation.Nullable;
import org.opendaylight.controller.cluster.raft.ServerConfigurationPayload.ServerInfo;
import org.opendaylight.controller.cluster.raft.base.messages.ApplyState;
import org.opendaylight.controller.cluster.raft.base.messages.SnapshotComplete;
newConfig.add(new ServerInfo(raftContext.getId(), true));
- LOG.debug("{}: New server configuration : {}", raftContext.getId(), newConfig);
+ LOG.debug("{}: Persisting new server configuration : {}", raftContext.getId(), newConfig);
ServerConfigurationPayload payload = new ServerConfigurationPayload(newConfig);
raftActor.persistData(operationContext.getClientRequestor(), operationContext.getContextId(), payload);
currentOperationState = new Persisting(operationContext);
+
+ sendReply(raftActor, operationContext, ServerChangeStatus.OK);
}
protected void operationComplete(RaftActor raftActor, ServerOperationContext<?> operationContext,
- ServerChangeStatus status) {
-
- LOG.debug("{}: Returning {} for operation {}", raftContext.getId(), status, operationContext.getOperation());
-
- operationContext.getClientRequestor().tell(operationContext.newReply(status, raftActor.getLeaderId()),
- raftActor.self());
+ @Nullable ServerChangeStatus replyStatus) {
+ if(replyStatus != null) {
+ sendReply(raftActor, operationContext, replyStatus);
+ }
currentOperationState = IDLE;
}
}
+ private void sendReply(RaftActor raftActor, ServerOperationContext<?> operationContext,
+ ServerChangeStatus status) {
+ LOG.debug("{}: Returning {} for operation {}", raftContext.getId(), status, operationContext.getOperation());
+
+ operationContext.getClientRequestor().tell(operationContext.newReply(status, raftActor.getLeaderId()),
+ raftActor.self());
+ }
+
@Override
public String toString() {
return getClass().getSimpleName();
LOG.info("{}: {} has been successfully replicated to a majority of followers",
applyState.getReplicatedLogEntry().getData());
- operationComplete(raftActor, operationContext, ServerChangeStatus.OK);
+ operationComplete(raftActor, operationContext, null);
}
}
}