This is an internal state class, no need to make it an interface. This
should make for faster dispatch, as methods offsets in vtable are fixed.
Change-Id: I3438a17485104b43647c91b7c6272dad5862cbb9
Signed-off-by: Robert Varga <rovarga@cisco.com>
- /**
- * Interface for a server operation FSM state.
- */
- private interface OperationState {
- void onNewOperation(ServerOperationContext<?> operationContext);
-
- void onServerOperationTimeout(ServerOperationTimeout timeout);
-
- void onUnInitializedFollowerSnapshotReply(UnInitializedFollowerSnapshotReply reply);
-
- void onApplyState(ApplyState applyState);
-
- void onSnapshotComplete();
- }
-
/**
* Interface for the initial state for a server operation.
*/
/**
* Interface for the initial state for a server operation.
*/
/**
* Abstract base class for a server operation FSM state. Handles common behavior for all states.
*/
/**
* Abstract base class for a server operation FSM state. Handles common behavior for all states.
*/
- private abstract class AbstractOperationState implements OperationState {
- @Override
- public void onNewOperation(ServerOperationContext<?> operationContext) {
+ private abstract class OperationState {
+ void onNewOperation(ServerOperationContext<?> operationContext) {
// We're currently processing another operation so queue it to be processed later.
LOG.debug("{}: Server operation already in progress - queueing {}", raftContext.getId(),
// We're currently processing another operation so queue it to be processed later.
LOG.debug("{}: Server operation already in progress - queueing {}", raftContext.getId(),
pendingOperationsQueue.add(operationContext);
}
pendingOperationsQueue.add(operationContext);
}
- @Override
- public void onServerOperationTimeout(ServerOperationTimeout timeout) {
+ void onServerOperationTimeout(ServerOperationTimeout timeout) {
LOG.debug("onServerOperationTimeout should not be called in state {}", this);
}
LOG.debug("onServerOperationTimeout should not be called in state {}", this);
}
- @Override
- public void onUnInitializedFollowerSnapshotReply(UnInitializedFollowerSnapshotReply reply) {
+ void onUnInitializedFollowerSnapshotReply(UnInitializedFollowerSnapshotReply reply) {
LOG.debug("onUnInitializedFollowerSnapshotReply was called in state {}", this);
}
LOG.debug("onUnInitializedFollowerSnapshotReply was called in state {}", this);
}
- @Override
- public void onApplyState(ApplyState applyState) {
+ void onApplyState(ApplyState applyState) {
LOG.debug("onApplyState was called in state {}", this);
}
LOG.debug("onApplyState was called in state {}", this);
}
- @Override
- public void onSnapshotComplete() {
+ void onSnapshotComplete() {
+
}
protected void persistNewServerConfiguration(ServerOperationContext<?> operationContext){
}
protected void persistNewServerConfiguration(ServerOperationContext<?> operationContext){
/**
* The state when no server operation is in progress. It immediately initiates new server operations.
*/
/**
* The state when no server operation is in progress. It immediately initiates new server operations.
*/
- private class Idle extends AbstractOperationState {
+ private final class Idle extends OperationState {
@Override
public void onNewOperation(ServerOperationContext<?> operationContext) {
operationContext.newInitialOperationState(RaftActorServerConfigurationSupport.this).initiate();
@Override
public void onNewOperation(ServerOperationContext<?> operationContext) {
operationContext.newInitialOperationState(RaftActorServerConfigurationSupport.this).initiate();
/**
* The state when a new server configuration is being persisted and replicated.
*/
/**
* The state when a new server configuration is being persisted and replicated.
*/
- private class Persisting extends AbstractOperationState {
+ private final class Persisting extends OperationState {
private final ServerOperationContext<?> operationContext;
private final Cancellable timer;
private boolean timedOut = false;
private final ServerOperationContext<?> operationContext;
private final Cancellable timer;
private boolean timedOut = false;
/**
* Abstract base class for an AddServer operation state.
*/
/**
* Abstract base class for an AddServer operation state.
*/
- private abstract class AddServerState extends AbstractOperationState {
+ private abstract class AddServerState extends OperationState {
private final AddServerContext addServerContext;
AddServerState(AddServerContext addServerContext) {
private final AddServerContext addServerContext;
AddServerState(AddServerContext addServerContext) {
* The initial state for the AddServer operation. It adds the new follower as a peer and initiates
* snapshot capture, if necessary.
*/
* The initial state for the AddServer operation. It adds the new follower as a peer and initiates
* snapshot capture, if necessary.
*/
- private class InitialAddServerState extends AddServerState implements InitialOperationState {
+ private final class InitialAddServerState extends AddServerState implements InitialOperationState {
InitialAddServerState(AddServerContext addServerContext) {
super(addServerContext);
}
InitialAddServerState(AddServerContext addServerContext) {
super(addServerContext);
}
* The AddServer operation state for when the catch-up snapshot is being installed. It handles successful
* reply or timeout.
*/
* The AddServer operation state for when the catch-up snapshot is being installed. It handles successful
* reply or timeout.
*/
- private class InstallingSnapshot extends AddServerState {
+ private final class InstallingSnapshot extends AddServerState {
private final Cancellable installSnapshotTimer;
InstallingSnapshot(AddServerContext addServerContext, Cancellable installSnapshotTimer) {
private final Cancellable installSnapshotTimer;
InstallingSnapshot(AddServerContext addServerContext, Cancellable installSnapshotTimer) {
* The AddServer operation state for when there is a snapshot already in progress. When the current
* snapshot completes, it initiates an install snapshot.
*/
* The AddServer operation state for when there is a snapshot already in progress. When the current
* snapshot completes, it initiates an install snapshot.
*/
- private class WaitingForPriorSnapshotComplete extends AddServerState {
+ private final class WaitingForPriorSnapshotComplete extends AddServerState {
private final Cancellable snapshotTimer;
WaitingForPriorSnapshotComplete(AddServerContext addServerContext, Cancellable snapshotTimer) {
private final Cancellable snapshotTimer;
WaitingForPriorSnapshotComplete(AddServerContext addServerContext, Cancellable snapshotTimer) {
- private abstract class RemoveServerState extends AbstractOperationState {
+ private abstract class RemoveServerState extends OperationState {
private final RemoveServerContext removeServerContext;
private final RemoveServerContext removeServerContext;
protected RemoveServerState(RemoveServerContext removeServerContext) {
this.removeServerContext = Preconditions.checkNotNull(removeServerContext);
protected RemoveServerState(RemoveServerContext removeServerContext) {
this.removeServerContext = Preconditions.checkNotNull(removeServerContext);
- private class InitialRemoveServerState extends RemoveServerState implements InitialOperationState{
+ private final class InitialRemoveServerState extends RemoveServerState implements InitialOperationState{
protected InitialRemoveServerState(RemoveServerContext removeServerContext) {
super(removeServerContext);
protected InitialRemoveServerState(RemoveServerContext removeServerContext) {
super(removeServerContext);