bftsmart.tom.server

## Interface Recoverable

All Known Implementing Classes:
  DefaultRecoverable, DefaultSingleRecoverable, DurabilityCoordinator

    public interface Recoverable

Classes that implement this interface should implement a state transfer protocol. Typically, classes should both implement this interface and one of the executables.

### Method Summary

All Methods Instance Methods Abstract Methods
`bftsmart.statemanagement.ApplicationState` `getState(int cid, boolean sendState)` This method should return a representation of the application state
`bftsmart.statemanagement.StateManager` `getStateManager()` Recoverers implementing this interface will have to chose among different options of state managers like DurableStateManager or StandardStateManager.
`void` `noOp(int CID, MessageContext msgCtx)` This method is invoked by ServiceReplica to indicate that a consensus instance finished without delivering anything to the application (e.g., an instance only decided a single reconfiguration operation.
`void` `Op(int CID, byte[] requests, MessageContext msgCtx)` This method is invoked by ServiceReplica to pass information that was decided in a particular consensus instance.
`void` `setReplicaContext(ReplicaContext replicaContext)`
`int` `setState(bftsmart.statemanagement.ApplicationState state)` Sets the state to the representation obtained in the state transfer protocol

### Method Detail

#### setReplicaContext

    void setReplicaContext(ReplicaContext replicaContext)

#### getState

    bftsmart.statemanagement.ApplicationState getState(int cid,
                                                       boolean sendState)

This method should return a representation of the application state

Parameters:
  `cid` - Consensus up to which the application should return an Application state
  `sendState` - true if the replica should send a complete representation of the state instead of only the hash. False otherwise
Returns:
  A representation of the application state

#### setState

    int setState(bftsmart.statemanagement.ApplicationState state)

Sets the state to the representation obtained in the state transfer protocol

Parameters:
  `state` - State obtained in the state transfer protocol
Returns:

#### getStateManager

    bftsmart.statemanagement.StateManager getStateManager()

Recoverers implementing this interface will have to chose among different options of state managers like DurableStateManager or StandardStateManager. The recoverer class can also define a new strategy to manage the state and return it in this method.

Returns:
  the implementation of state manager that suplies the strategy defined

#### Op

    void Op(int CID,
            byte[] requests,
            MessageContext msgCtx)

This method is invoked by ServiceReplica to pass information that was decided in a particular consensus instance. This method is always invoked before the executor. However, multiple invocations for the same consensus ID may occur, so developers must take this behavior into consideration when developing their own logging and checkpointing. If there is no information to be passed to the application, noOp(...) is invoked instead.

Parameters:
  `CID` - the consensus instance ID associated with the request
  `requests` - A request decided in CID
  `msgCtx` - Message context associated with the client request and the consensus instance where it was ordered. msgCtx.getConsensusId() will be equal to CID.

#### noOp

    void noOp(int CID,
              MessageContext msgCtx)

This method is invoked by ServiceReplica to indicate that a consensus instance finished without delivering anything to the application (e.g., an instance only decided a single reconfiguration operation. or an instance where the client operation was not delivered because its view was outdated). To allow the underlying state transfer protocol to execute correctly, it needs to be notified of this special case In the current protocols included, it suffices to register a NOOP operation in the logs used within the state transfer, but never deliver it to the application

Parameters:
  `CID` - the consensus instance where the aforementioned condition occurred
  `msgCtx` - Message context associated with the consensus instance. furthermore msgCtx.getConsensusId() will be equal to CID.