public class TransactionContextImpl extends Object implements TransactionContext
TransactionContext
This is a private API. Applications should use TransactionContext and TransactionContext.Builder.TransactionContext.Builder| Constructor and Description |
|---|
TransactionContextImpl(org.apache.ratis.proto.RaftProtos.RaftPeerRole serverRole,
StateMachine stateMachine,
org.apache.ratis.proto.RaftProtos.LogEntryProto logEntry)
Construct a
TransactionContext from a RaftProtos.LogEntryProto. |
TransactionContextImpl(StateMachine stateMachine,
RaftClientRequest clientRequest,
org.apache.ratis.proto.RaftProtos.StateMachineLogEntryProto smLogEntryProto,
Object stateMachineContext)
Construct a
TransactionContext from a client request. |
| Modifier and Type | Method and Description |
|---|---|
TransactionContext |
cancelTransaction()
Called to notify the state machine that the Transaction passed cannot be appended (or synced).
|
RaftClientRequest |
getClientRequest()
Returns the original request from the
RaftClientRequest |
Exception |
getException()
Returns the exception from the
StateMachine or the log |
org.apache.ratis.proto.RaftProtos.LogEntryProto |
getLogEntry()
Returns the committed log entry
|
org.apache.ratis.proto.RaftProtos.RaftPeerRole |
getServerRole() |
Object |
getStateMachineContext()
Returns the
StateMachine the current TransactionContext specific to |
org.apache.ratis.proto.RaftProtos.StateMachineLogEntryProto |
getStateMachineLogEntry()
Returns the data from the
StateMachine |
org.apache.ratis.proto.RaftProtos.LogEntryProto |
initLogEntry(long term,
long index)
Initialize
RaftProtos.LogEntryProto using the internal RaftProtos.StateMachineLogEntryProto. |
TransactionContext |
preAppendTransaction()
This is called before the transaction passed from the StateMachine is appended to the raft log.
|
TransactionContext |
setException(Exception ioe)
Set exception in case of failure.
|
TransactionContext |
setShouldCommit(boolean sCommit)
Sets whether to commit the transaction to the RAFT log or not
|
TransactionContext |
setStateMachineContext(Object context)
Sets the
StateMachine the TransactionContext is specific to, the method would
not create a new transaction context, it updates the StateMachine it associates with |
TransactionContext |
setStateMachineLogEntryProto(org.apache.ratis.proto.RaftProtos.StateMachineLogEntryProto logEntryProto)
Sets the data from the
StateMachine |
boolean |
shouldCommit()
It indicates if the transaction should be committed to the RAFT log
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnewBuilderpublic TransactionContextImpl(StateMachine stateMachine, RaftClientRequest clientRequest, org.apache.ratis.proto.RaftProtos.StateMachineLogEntryProto smLogEntryProto, Object stateMachineContext)
TransactionContext from a client request.
Used by the state machine to start a transaction
and send the Log entry representing the transaction data
to be applied to the raft log.public TransactionContextImpl(org.apache.ratis.proto.RaftProtos.RaftPeerRole serverRole, StateMachine stateMachine, org.apache.ratis.proto.RaftProtos.LogEntryProto logEntry)
TransactionContext from a RaftProtos.LogEntryProto.
Used by followers for applying committed entries to the state machine.logEntry - the log entry to be appliedpublic org.apache.ratis.proto.RaftProtos.RaftPeerRole getServerRole()
getServerRole in interface TransactionContextpublic RaftClientRequest getClientRequest()
TransactionContextRaftClientRequestgetClientRequest in interface TransactionContextRaftClientRequestpublic org.apache.ratis.proto.RaftProtos.StateMachineLogEntryProto getStateMachineLogEntry()
TransactionContextStateMachinegetStateMachineLogEntry in interface TransactionContextStateMachinepublic Exception getException()
TransactionContextStateMachine or the loggetException in interface TransactionContextStateMachine or the logpublic TransactionContext setStateMachineContext(Object context)
TransactionContextStateMachine the TransactionContext is specific to, the method would
not create a new transaction context, it updates the StateMachine it associates withsetStateMachineContext in interface TransactionContextcontext - state machine contextStateMachinepublic Object getStateMachineContext()
TransactionContextStateMachine the current TransactionContext specific togetStateMachineContext in interface TransactionContextStateMachine the current TransactionContext specific topublic org.apache.ratis.proto.RaftProtos.LogEntryProto initLogEntry(long term, long index)
TransactionContextRaftProtos.LogEntryProto using the internal RaftProtos.StateMachineLogEntryProto.initLogEntry in interface TransactionContextterm - The current term.index - The index of the log entry.RaftProtos.LogEntryProtopublic TransactionContext setStateMachineLogEntryProto(org.apache.ratis.proto.RaftProtos.StateMachineLogEntryProto logEntryProto)
TransactionContextStateMachinesetStateMachineLogEntryProto in interface TransactionContextlogEntryProto - data from StateMachineTransactionContext itselfpublic org.apache.ratis.proto.RaftProtos.LogEntryProto getLogEntry()
TransactionContextgetLogEntry in interface TransactionContextpublic TransactionContext setException(Exception ioe)
TransactionContextsetException in interface TransactionContextpublic TransactionContext setShouldCommit(boolean sCommit)
TransactionContextsetShouldCommit in interface TransactionContextsCommit - true if the transaction is supposed to be committed to the RAFT logTransactionContext itselfpublic boolean shouldCommit()
TransactionContextshouldCommit in interface TransactionContextpublic TransactionContext preAppendTransaction() throws IOException
TransactionContextpreAppendTransaction in interface TransactionContextIOExceptionpublic TransactionContext cancelTransaction() throws IOException
TransactionContextcancelTransaction in interface TransactionContextIOExceptionCopyright © 2017–2020 The Apache Software Foundation. All rights reserved.