@ThreadSafe public class JournalStateMachine extends org.apache.ratis.statemachine.impl.BaseStateMachine
upgrade()
. Once the state machine is upgraded,
it will ignore all entries appended by Ratis because those entries are applied to primary
master state before being written to Rati.Constructor and Description |
---|
JournalStateMachine(Map<String,RaftJournal> journals,
RaftJournalSystem journalSystem) |
Modifier and Type | Method and Description |
---|---|
void |
applyJournalEntryCommand(org.apache.ratis.statemachine.TransactionContext commit)
Applies a journal entry commit to the state machine.
|
CompletableFuture<org.apache.ratis.protocol.Message> |
applyTransaction(org.apache.ratis.statemachine.TransactionContext trx) |
CatchupFuture |
catchup(long sequence)
Initiates catching up of masters to given sequence.
|
void |
close() |
long |
getLastAppliedSequenceNumber() |
long |
getLastPrimaryStartSequenceNumber() |
org.apache.ratis.statemachine.SnapshotInfo |
getLatestSnapshot() |
SnapshotReplicationManager |
getSnapshotReplicationManager() |
org.apache.ratis.statemachine.StateMachineStorage |
getStateMachineStorage() |
void |
initialize(org.apache.ratis.server.RaftServer server,
org.apache.ratis.protocol.RaftGroupId groupId,
org.apache.ratis.server.storage.RaftStorage raftStorage) |
boolean |
isSnapshotting() |
boolean |
isSuspended() |
CompletableFuture<org.apache.ratis.server.protocol.TermIndex> |
notifyInstallSnapshotFromLeader(org.apache.ratis.proto.RaftProtos.RoleInfoProto roleInfoProto,
org.apache.ratis.server.protocol.TermIndex firstTermIndexInLog) |
void |
notifyLeaderChanged(org.apache.ratis.protocol.RaftGroupMemberId groupMemberId,
org.apache.ratis.protocol.RaftPeerId raftPeerId) |
void |
notifyNotLeader(Collection<org.apache.ratis.statemachine.TransactionContext> pendingEntries) |
void |
pause() |
CompletableFuture<org.apache.ratis.protocol.Message> |
query(org.apache.ratis.protocol.Message request) |
void |
reinitialize() |
void |
resume()
Resumes applying to masters.
|
void |
suspend(Runnable interruptCallback)
Suspends applying to masters.
|
long |
takeLocalSnapshot()
Takes a snapshot of local state machine.
|
long |
takeSnapshot() |
void |
unpause()
Unpause the StateMachine.
|
long |
upgrade()
Upgrades the journal state machine to primary mode.
|
applyTransactionSerial, cancelTransaction, getGroupId, getId, getLastAppliedTermIndex, getLifeCycle, getLifeCycleState, getServer, notifyIndexUpdate, preAppendTransaction, queryStale, recordTime, setLastAppliedTermIndex, startTransaction, toString, updateLastAppliedTermIndex
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public JournalStateMachine(Map<String,RaftJournal> journals, RaftJournalSystem journalSystem)
journals
- master journals; these journals are still owned by the caller, not by the
journal state machinejournalSystem
- the raft journal systempublic void initialize(org.apache.ratis.server.RaftServer server, org.apache.ratis.protocol.RaftGroupId groupId, org.apache.ratis.server.storage.RaftStorage raftStorage) throws IOException
initialize
in interface org.apache.ratis.statemachine.StateMachine
initialize
in class org.apache.ratis.statemachine.impl.BaseStateMachine
IOException
public void reinitialize() throws IOException
reinitialize
in interface org.apache.ratis.statemachine.StateMachine
reinitialize
in class org.apache.ratis.statemachine.impl.BaseStateMachine
IOException
public long takeSnapshot()
takeSnapshot
in interface org.apache.ratis.statemachine.StateMachine
takeSnapshot
in class org.apache.ratis.statemachine.impl.BaseStateMachine
public org.apache.ratis.statemachine.SnapshotInfo getLatestSnapshot()
getLatestSnapshot
in interface org.apache.ratis.statemachine.StateMachine
getLatestSnapshot
in class org.apache.ratis.statemachine.impl.BaseStateMachine
public org.apache.ratis.statemachine.StateMachineStorage getStateMachineStorage()
getStateMachineStorage
in interface org.apache.ratis.statemachine.StateMachine
getStateMachineStorage
in class org.apache.ratis.statemachine.impl.BaseStateMachine
public CompletableFuture<org.apache.ratis.protocol.Message> query(org.apache.ratis.protocol.Message request)
query
in interface org.apache.ratis.statemachine.StateMachine
query
in class org.apache.ratis.statemachine.impl.BaseStateMachine
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class org.apache.ratis.statemachine.impl.BaseStateMachine
public CompletableFuture<org.apache.ratis.protocol.Message> applyTransaction(org.apache.ratis.statemachine.TransactionContext trx)
applyTransaction
in interface org.apache.ratis.statemachine.StateMachine
applyTransaction
in class org.apache.ratis.statemachine.impl.BaseStateMachine
public void notifyNotLeader(Collection<org.apache.ratis.statemachine.TransactionContext> pendingEntries)
notifyNotLeader
in interface org.apache.ratis.statemachine.StateMachine
notifyNotLeader
in class org.apache.ratis.statemachine.impl.BaseStateMachine
public CompletableFuture<org.apache.ratis.server.protocol.TermIndex> notifyInstallSnapshotFromLeader(org.apache.ratis.proto.RaftProtos.RoleInfoProto roleInfoProto, org.apache.ratis.server.protocol.TermIndex firstTermIndexInLog)
public void pause()
pause
in interface org.apache.ratis.statemachine.StateMachine
pause
in class org.apache.ratis.statemachine.impl.BaseStateMachine
public void unpause()
public void applyJournalEntryCommand(org.apache.ratis.statemachine.TransactionContext commit)
commit
- the commitpublic long takeLocalSnapshot()
RaftLog.INVALID_LOG_INDEX
if it failspublic void suspend(Runnable interruptCallback) throws IOException
interruptCallback
- a callback function to be called when the suspend is interruptedIOException
public void resume() throws IOException
IOException
public CatchupFuture catchup(long sequence)
sequence
- the target sequencepublic long upgrade()
public long getLastAppliedSequenceNumber()
public long getLastPrimaryStartSequenceNumber()
public boolean isSnapshotting()
public void notifyLeaderChanged(org.apache.ratis.protocol.RaftGroupMemberId groupMemberId, org.apache.ratis.protocol.RaftPeerId raftPeerId)
public SnapshotReplicationManager getSnapshotReplicationManager()
public boolean isSuspended()
Copyright © 2023. All Rights Reserved.