Class StateControllerImpl
- java.lang.Object
-
- io.camunda.zeebe.broker.system.partitions.impl.StateControllerImpl
-
- All Implemented Interfaces:
StateController,PersistedSnapshotListener,AutoCloseable
public class StateControllerImpl extends Object implements StateController, PersistedSnapshotListener
Controls how snapshot/recovery operations are performed
-
-
Constructor Summary
Constructors Constructor Description StateControllerImpl(int partitionId, ZeebeDbFactory zeebeDbFactory, ConstructableSnapshotStore constructableSnapshotStore, ReceivableSnapshotStore receivableSnapshotStore, Path runtimeDirectory, SnapshotReplication replication, AtomixRecordEntrySupplier entrySupplier, ToLongFunction<ZeebeDb> exporterPositionSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidconsumeReplicatedSnapshots()Registers to consumes replicated snapshots.intgetValidSnapshotsCount()Returns the current number of valid snapshots.voidonNewSnapshot(PersistedSnapshot newPersistedSnapshot)ZeebeDbopenDb()Opens the database from the latest snapshot.voidrecover()Recovers the state from the latest snapshot.Optional<TransientSnapshot>takeTransientSnapshot(long lowerBoundSnapshotPosition)Takes a snapshot based on the given position.
-
-
-
Constructor Detail
-
StateControllerImpl
public StateControllerImpl(int partitionId, ZeebeDbFactory zeebeDbFactory, ConstructableSnapshotStore constructableSnapshotStore, ReceivableSnapshotStore receivableSnapshotStore, Path runtimeDirectory, SnapshotReplication replication, AtomixRecordEntrySupplier entrySupplier, ToLongFunction<ZeebeDb> exporterPositionSupplier)
-
-
Method Detail
-
takeTransientSnapshot
public Optional<TransientSnapshot> takeTransientSnapshot(long lowerBoundSnapshotPosition)
Description copied from interface:StateControllerTakes a snapshot based on the given position. The position is a last processed lower bound event position.- Specified by:
takeTransientSnapshotin interfaceStateController- Parameters:
lowerBoundSnapshotPosition- the lower bound snapshot position- Returns:
- a pending snapshot, or nothing if the operation fails
-
consumeReplicatedSnapshots
public void consumeReplicatedSnapshots()
Description copied from interface:StateControllerRegisters to consumes replicated snapshots.- Specified by:
consumeReplicatedSnapshotsin interfaceStateController
-
recover
public void recover() throws ExceptionDescription copied from interface:StateControllerRecovers the state from the latest snapshot.- Specified by:
recoverin interfaceStateController- Throws:
Exception
-
openDb
public ZeebeDb openDb()
Description copied from interface:StateControllerOpens the database from the latest snapshot.- Specified by:
openDbin interfaceStateController- Returns:
- an opened database
-
getValidSnapshotsCount
public int getValidSnapshotsCount()
Description copied from interface:StateControllerReturns the current number of valid snapshots.- Specified by:
getValidSnapshotsCountin interfaceStateController- Returns:
- valid snapshots count
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
onNewSnapshot
public void onNewSnapshot(PersistedSnapshot newPersistedSnapshot)
- Specified by:
onNewSnapshotin interfacePersistedSnapshotListener
-
-