public interface TransactionContext
TransactionContext can be created from
either the StateMachine or the state machine updater.
In the first case, the StateMachine is a leader. When it receives
a StateMachine.startTransaction(RaftClientRequest) request, it returns
a TransactionContext with the changes from the StateMachine.
The same context will be passed back to the StateMachine
via the StateMachine.applyTransaction(TransactionContext) call
or the StateMachine.notifyNotLeader(java.util.Collection) call.
In the second case, the StateMachine is a follower.
The TransactionContext will be a committed entry coming from
the RAFT log from the leader.| Modifier and Type | Interface and Description |
|---|---|
static class |
TransactionContext.Builder |
org.apache.ratis.proto.RaftProtos.RaftPeerRole getServerRole()
RaftClientRequest getClientRequest()
RaftClientRequestRaftClientRequestorg.apache.ratis.proto.RaftProtos.StateMachineLogEntryProto getStateMachineLogEntry()
StateMachineStateMachineTransactionContext setException(Exception exception)
Exception getException()
StateMachine or the logStateMachine or the logTransactionContext setStateMachineContext(Object stateMachineContext)
StateMachine the TransactionContext is specific to, the method would
not create a new transaction context, it updates the StateMachine it associates withstateMachineContext - state machine contextStateMachineObject getStateMachineContext()
StateMachine the current TransactionContext specific toStateMachine the current TransactionContext specific toorg.apache.ratis.proto.RaftProtos.LogEntryProto initLogEntry(long term, long index)
RaftProtos.LogEntryProto using the internal RaftProtos.StateMachineLogEntryProto.term - The current term.index - The index of the log entry.RaftProtos.LogEntryProtoTransactionContext setStateMachineLogEntryProto(org.apache.ratis.proto.RaftProtos.StateMachineLogEntryProto smLogEntryProto)
StateMachinesmLogEntryProto - data from StateMachineTransactionContext itselforg.apache.ratis.proto.RaftProtos.LogEntryProto getLogEntry()
TransactionContext setShouldCommit(boolean shouldCommit)
shouldCommit - true if the transaction is supposed to be committed to the RAFT logTransactionContext itselfboolean shouldCommit()
TransactionContext preAppendTransaction() throws IOException
IOExceptionTransactionContext cancelTransaction() throws IOException
IOExceptionstatic TransactionContext.Builder newBuilder()
Copyright © 2017–2020 The Apache Software Foundation. All rights reserved.