Package io.camunda.zeebe.snapshots.impl
Class FileBasedSnapshotStore
java.lang.Object
io.camunda.zeebe.scheduler.Actor
io.camunda.zeebe.snapshots.impl.FileBasedSnapshotStore
- All Implemented Interfaces:
AsyncClosable,ConcurrencyControl,ConstructableSnapshotStore,PersistedSnapshotStore,ReceivableSnapshotStore,RestorableSnapshotStore,CloseableSilently,AutoCloseable,Executor
public final class FileBasedSnapshotStore
extends Actor
implements ConstructableSnapshotStore, ReceivableSnapshotStore, RestorableSnapshotStore
-
Nested Class Summary
Nested classes/interfaces inherited from class io.camunda.zeebe.scheduler.Actor
Actor.ActorBuilder -
Field Summary
FieldsFields inherited from class io.camunda.zeebe.scheduler.Actor
actor, ACTOR_PROP_NAME, ACTOR_PROP_PARTITION_ID -
Constructor Summary
ConstructorsConstructorDescriptionFileBasedSnapshotStore(int partitionId, Path root) FileBasedSnapshotStore(int partitionId, Path root, ChecksumProvider checksumProvider) -
Method Summary
Modifier and TypeMethodDescriptionaddSnapshotListener(PersistedSnapshotListener listener) Adds anPersistedSnapshotListenerto the store, which is notified when a newPersistedSnapshotis persisted at this store.delete()Deletes aPersistedSnapshotStorefrom disk.Returns a set of all available snapshots.Returns the lowest compaction bound of all available snapshots.longgetName()getPath()booleanhasSnapshotId(String id) Returns true if the given identifier is equal to the snapshot id of the current persisted snapshot, false otherwise.newReceivedSnapshot(String snapshotId) Starts a new received volatile snapshot which can be persisted later.newTransientSnapshot(long index, long term, long processedPosition, long exportedPosition) Starts a new transient snapshot which can be persisted after the snapshot was taken.protected voidprotected voidPurges all ongoing pending/transient/volatile snapshots.Removes an registeredPersistedSnapshotListenerfrom the store.voidRestores the snapshot by moving the snapshotFiles to the snapshotDirectory.toString()Methods inherited from class io.camunda.zeebe.scheduler.Actor
buildActorName, call, close, closeAsync, getContext, handleFailure, isActorClosed, newActor, onActorClosed, onActorCloseRequested, onActorFailed, onActorStarted, run, runOnCompletion, schedule, wrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.camunda.zeebe.util.CloseableSilently
closeMethods inherited from interface io.camunda.zeebe.scheduler.ConcurrencyControl
createCompletedFuture, createFuture, execute
-
Field Details
-
SNAPSHOTS_DIRECTORY
- See Also:
-
PENDING_DIRECTORY
- See Also:
-
-
Constructor Details
-
FileBasedSnapshotStore
-
FileBasedSnapshotStore
-
-
Method Details
-
createContext
- Overrides:
createContextin classActor
-
getName
-
onActorStarting
protected void onActorStarting()- Overrides:
onActorStartingin classActor
-
onActorClosing
protected void onActorClosing()- Overrides:
onActorClosingin classActor
-
hasSnapshotId
Description copied from interface:PersistedSnapshotStoreReturns true if the given identifier is equal to the snapshot id of the current persisted snapshot, false otherwise.- Specified by:
hasSnapshotIdin interfacePersistedSnapshotStore- Parameters:
id- the snapshot Id to look for- Returns:
- true if the current snapshot has the equal Id, false otherwise
- See Also:
-
getLatestSnapshot
- Specified by:
getLatestSnapshotin interfacePersistedSnapshotStore- Returns:
- the latest
PersistedSnapshotif exists
-
getAvailableSnapshots
Description copied from interface:PersistedSnapshotStoreReturns a set of all available snapshots.- Specified by:
getAvailableSnapshotsin interfacePersistedSnapshotStore
-
getCompactionBound
Description copied from interface:PersistedSnapshotStoreReturns the lowest compaction bound of all available snapshots.- Specified by:
getCompactionBoundin interfacePersistedSnapshotStore
-
purgePendingSnapshots
Description copied from interface:PersistedSnapshotStorePurges all ongoing pending/transient/volatile snapshots.- Specified by:
purgePendingSnapshotsin interfacePersistedSnapshotStore- Returns:
- future which will be completed when all pending snapshots are deleted
-
addSnapshotListener
Description copied from interface:PersistedSnapshotStoreAdds anPersistedSnapshotListenerto the store, which is notified when a newPersistedSnapshotis persisted at this store.- Specified by:
addSnapshotListenerin interfacePersistedSnapshotStore- Parameters:
listener- the listener which should be added and notified later
-
removeSnapshotListener
Description copied from interface:PersistedSnapshotStoreRemoves an registeredPersistedSnapshotListenerfrom the store. The listener will no longer called when a newPersistedSnapshotis persisted at this store.- Specified by:
removeSnapshotListenerin interfacePersistedSnapshotStore- Parameters:
listener- the listener which should be removed
-
getCurrentSnapshotIndex
public long getCurrentSnapshotIndex()- Specified by:
getCurrentSnapshotIndexin interfacePersistedSnapshotStore- Returns:
- the snapshot index of the latest
PersistedSnapshot - See Also:
-
delete
Description copied from interface:PersistedSnapshotStoreDeletes aPersistedSnapshotStorefrom disk.The snapshot store will be deleted by simply reading
snapshotfile names from disk and deleting snapshot files directly. Deleting the snapshot store does not involve reading any snapshot files into memory.- Specified by:
deletein interfacePersistedSnapshotStore
-
getPath
- Specified by:
getPathin interfacePersistedSnapshotStore
-
newReceivedSnapshot
Description copied from interface:ReceivableSnapshotStoreStarts a new received volatile snapshot which can be persisted later.- Specified by:
newReceivedSnapshotin interfaceReceivableSnapshotStore- Parameters:
snapshotId- the snapshot id which is defined asindex-term-timestamp-processedposition-exportedposition- Returns:
- the new volatile received snapshot
-
newTransientSnapshot
public Either<SnapshotException,TransientSnapshot> newTransientSnapshot(long index, long term, long processedPosition, long exportedPosition) Description copied from interface:ConstructableSnapshotStoreStarts a new transient snapshot which can be persisted after the snapshot was taken.- Specified by:
newTransientSnapshotin interfaceConstructableSnapshotStore- Parameters:
index- the index to which the snapshot corresponds toterm- the term to which the snapshots corresponds toprocessedPosition- the processed position in the snapshotexportedPosition- the exported position in the snapshot- Returns:
- either an exception or transientSnapshot, if it was taken successfully.
-
toString
-
restore
Description copied from interface:RestorableSnapshotStoreRestores the snapshot by moving the snapshotFiles to the snapshotDirectory.WARN. Implementation of this method can be not thread safe.
- Specified by:
restorein interfaceRestorableSnapshotStore- Parameters:
snapshotId-snapshotFiles-- Throws:
IOException
-