Package bftsmart.tom.server.durability
Class DurabilityCoordinator
- java.lang.Object
-
- bftsmart.tom.server.durability.DurabilityCoordinator
-
- All Implemented Interfaces:
BatchExecutable
,Executable
,Recoverable
public abstract class DurabilityCoordinator extends java.lang.Object implements Recoverable, BatchExecutable
Implements the Collaborative State Transfer protocol. In this protocol, instead of all replicas send the state and log, or state and hash of the log, the replicas are divided into three groups. One group sends the state, another group sends the lower half of the log and the third group sends the upper portion of the log. The replica that receives the state, logs and hashes validates the state and install it. The details of the protocol are described in the paper "On the Efficiency of Durable State Machine Replication".
-
-
Constructor Summary
Constructors Constructor Description DurabilityCoordinator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract byte[][]
appExecuteBatch(byte[][] commands, MessageContext[] msgCtxs)
Execute a batch of ordered requestsabstract byte[]
appExecuteUnordered(byte[] command, MessageContext msgCtx)
Execute an unordered requestbyte[][]
executeBatch(byte[][] commands, MessageContext[] msgCtxs)
Execute a batch of requests.byte[]
executeUnordered(byte[] command, MessageContext msgCtx)
Method called to execute a request totally ordered.byte[]
getCurrentStateHash()
abstract byte[]
getSnapshot()
Returns a serialized snapshot of the application stateApplicationState
getState(int cid, boolean sendState)
This method should return a representation of the application stateCSTState
getState(CSTRequest cstRequest)
StateManager
getStateManager()
Recoverers implementing this interface will have to chose among different options of state managers like DurableStateManager or StandardStateManager.abstract void
installSnapshot(byte[] state)
Given a snapshot received from the state transfer protocol, install itvoid
noOp(int CID, byte[][] operations, MessageContext[] msgCtxs)
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).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)
Sets the replica contextint
setState(ApplicationState recvState)
Sets the state to the representation obtained in the state transfer protocol-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface bftsmart.tom.server.BatchExecutable
executeBatch
-
Methods inherited from interface bftsmart.tom.server.Executable
executeUnordered, getTOMMessage
-
Methods inherited from interface bftsmart.tom.server.Recoverable
setClientsManager
-
-
-
-
Method Detail
-
executeBatch
public byte[][] executeBatch(byte[][] commands, MessageContext[] msgCtxs)
Description copied from interface:BatchExecutable
Execute a batch of requests.- Specified by:
executeBatch
in interfaceBatchExecutable
- Parameters:
commands
- The batch of requestsmsgCtxs
- The context associated to each request- Returns:
-
getState
public ApplicationState getState(int cid, boolean sendState)
Description copied from interface:Recoverable
This method should return a representation of the application state- Specified by:
getState
in interfaceRecoverable
- Parameters:
cid
- Consensus up to which the application should return an Application statesendState
- 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
public int setState(ApplicationState recvState)
Description copied from interface:Recoverable
Sets the state to the representation obtained in the state transfer protocol- Specified by:
setState
in interfaceRecoverable
- Parameters:
recvState
- State obtained in the state transfer protocol- Returns:
-
getState
public CSTState getState(CSTRequest cstRequest)
-
setReplicaContext
public void setReplicaContext(ReplicaContext replicaContext)
Description copied from interface:Recoverable
Sets the replica context- Specified by:
setReplicaContext
in interfaceRecoverable
- Parameters:
replicaContext
- The replica context
-
getStateManager
public StateManager getStateManager()
Description copied from interface:Recoverable
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.- Specified by:
getStateManager
in interfaceRecoverable
- Returns:
- the implementation of state manager that suplies the strategy defined
-
getCurrentStateHash
public byte[] getCurrentStateHash()
-
executeUnordered
public byte[] executeUnordered(byte[] command, MessageContext msgCtx)
Description copied from interface:Executable
Method called to execute a request totally ordered. The message context contains some useful information such as the command sender.- Specified by:
executeUnordered
in interfaceExecutable
- Parameters:
command
- the command issue by the clientmsgCtx
- information related with the command- Returns:
- the reply for the request issued by the client
-
Op
public void Op(int CID, byte[] requests, MessageContext msgCtx)
Description copied from interface:Recoverable
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.- Specified by:
Op
in interfaceRecoverable
- Parameters:
CID
- the consensus instance ID associated with the requestrequests
- A request decided in CIDmsgCtx
- Message context associated with the client request and the consensus instance where it was ordered. msgCtx.getConsensusId() will be equal to CID.
-
noOp
public void noOp(int CID, byte[][] operations, MessageContext[] msgCtxs)
Description copied from interface:Recoverable
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- Specified by:
noOp
in interfaceRecoverable
- Parameters:
CID
- the consensus instance where the aforementioned condition occurredoperations
- Operations decided in CIDmsgCtxs
- Message context associated with the consensus instance. furthermore msgCtx.getConsensusId() will be equal to CID.
-
installSnapshot
public abstract void installSnapshot(byte[] state)
Given a snapshot received from the state transfer protocol, install it- Parameters:
state
- The serialized snapshot
-
getSnapshot
public abstract byte[] getSnapshot()
Returns a serialized snapshot of the application state- Returns:
- A serialized snapshot of the application state
-
appExecuteBatch
public abstract byte[][] appExecuteBatch(byte[][] commands, MessageContext[] msgCtxs)
Execute a batch of ordered requests- Parameters:
commands
- The batch of requestsmsgCtxs
- The context associated to each request- Returns:
- the respective replies for each request
-
appExecuteUnordered
public abstract byte[] appExecuteUnordered(byte[] command, MessageContext msgCtx)
Execute an unordered request- Parameters:
command
- The unordered requestmsgCtx
- The context associated to the request- Returns:
- the reply for the request issued by the client
-
-