public class StateLog
extends java.lang.Object
Constructor and Description |
---|
StateLog(byte[] initialState,
byte[] initialHash) |
StateLog(int k)
Constructs a State log
|
StateLog(int k,
byte[] initialState,
byte[] initialHash)
Constructs a State log
|
Modifier and Type | Method and Description |
---|---|
void |
addMessageBatch(byte[][] commands,
int round,
int leader,
int lastConsensusId)
Adds a message batch to the log.
|
DefaultApplicationState |
getApplicationState(int eid,
boolean setState)
Constructs a TransferableState using this log information
|
int |
getLastCheckpointEid()
Retrieves the execution ID for the last checkpoint
|
int |
getLastCheckpointLeader()
Retrieves the leader for the last checkpoint
|
int |
getLastCheckpointRound()
Retrieves the decision round for the last checkpoint
|
int |
getLastEid()
Retrieves the execution ID for the last messages batch delivered to the application
|
CommandsInfo |
getMessageBatch(int eid)
Returns a batch of messages, given its correspondent execution ID
|
CommandsInfo[] |
getMessageBatches()
Retrieves all the stored batches kept since the last checkpoint
|
int |
getNumBatches()
Retrieves the total number of stored batches kept since the last checkpoint
|
byte[] |
getState()
Retrieves the state associated with the last checkpoint
|
byte[] |
getStateHash()
Retrieves the hash of the state associated with the last checkpoint
|
void |
newCheckpoint(byte[] state,
byte[] stateHash,
int lastConsensusId)
Sets the state associated with the last checkpoint, and updates the execution ID associated with it
|
void |
setLastCheckpointEid(int lastCheckpointEid)
Sets the execution ID for the last checkpoint
|
void |
setLastCheckpointLeader(int lastCheckpointLeader)
Sets the leader for the last checkpoint
|
void |
setLastCheckpointRound(int lastCheckpointRound)
Sets the decision round for the last checkpoint
|
void |
setLastEid(int lastEid)
Sets the execution ID for the last messages batch delivered to the application
|
void |
update(DefaultApplicationState transState)
Updates this log, according to the information contained in the TransferableState object
|
public StateLog(int k, byte[] initialState, byte[] initialHash)
k
- The chekpoint periodpublic StateLog(int k)
k
- The chekpoint periodpublic StateLog(byte[] initialState, byte[] initialHash)
public void newCheckpoint(byte[] state, byte[] stateHash, int lastConsensusId)
state
- State associated with the last checkpointpublic void setLastCheckpointEid(int lastCheckpointEid)
lastCheckpointEid
- Execution ID for the last checkpointpublic int getLastCheckpointEid()
public void setLastCheckpointRound(int lastCheckpointRound)
lastCheckpointRound
- Decision round for the last checkpointpublic int getLastCheckpointRound()
public void setLastCheckpointLeader(int lastCheckpointLeader)
lastCheckpointLeader
- Leader for the last checkpointpublic int getLastCheckpointLeader()
public void setLastEid(int lastEid)
lastEid
- the execution ID for the last messages batch delivered to the applicationpublic int getLastEid()
public byte[] getState()
public byte[] getStateHash()
public void addMessageBatch(byte[][] commands, int round, int leader, int lastConsensusId)
commands
- The batch of messages to be kept.round
- the round in which the messages were orderedleader
- the leader by the moment the messages were orderedpublic CommandsInfo getMessageBatch(int eid)
eid
- Execution ID associated with the batch to be fetchedpublic CommandsInfo[] getMessageBatches()
public int getNumBatches()
public DefaultApplicationState getApplicationState(int eid, boolean setState)
eid
- Execution ID correspondent to desired statepublic void update(DefaultApplicationState transState)
transState
- TransferableState object containing the information which is used to updated this log