Interface StateChangelogWriter<Handle extends ChangelogStateHandle>
- All Superinterfaces:
AutoCloseable
@Internal
public interface StateChangelogWriter<Handle extends ChangelogStateHandle>
extends AutoCloseable
Allows to write data to the log. Scoped to a single writer (e.g. state backend).
-
Method Summary
Modifier and TypeMethodDescriptionvoidappend(int keyGroup, byte[] value) Appends the provided data to this log.voidappendMeta(byte[] value) Appends the provided **metadata** to this log.voidclose()Close this log.voidconfirm(SequenceNumber from, SequenceNumber to, long checkpointId) Mark the given state changes as confirmed by the JM.Get the initialSequenceNumberthat is used for the first element.GetSequenceNumberto be used for the next element added byappend.persist(SequenceNumber from, long checkpointId) Durably persist previouslyappendeddata starting from the providedSequenceNumberand up to the latest change added.voidreset(SequenceNumber from, SequenceNumber to, long checkpointId) Reset the state the given state changes.voidTruncate this state changelog to free up the resources and collect any garbage.voidTruncate the tail of log and close it.
-
Method Details
-
initialSequenceNumber
SequenceNumber initialSequenceNumber()Get the initialSequenceNumberthat is used for the first element. -
nextSequenceNumber
SequenceNumber nextSequenceNumber()GetSequenceNumberto be used for the next element added byappend. -
appendMeta
Appends the provided **metadata** to this log. No persistency guarantees.- Throws:
IOException
-
append
Appends the provided data to this log. No persistency guarantees.- Throws:
IOException
-
persist
CompletableFuture<SnapshotResult<Handle>> persist(SequenceNumber from, long checkpointId) throws IOException Durably persist previouslyappendeddata starting from the providedSequenceNumberand up to the latest change added. After this call, one ofconfirm,reset, ortruncateeventually must be called for the corresponding change set. with reset/truncate/confirm methods?- Parameters:
from- inclusivecheckpointId- to persist- Throws:
IOException
-
truncate
Truncate this state changelog to free up the resources and collect any garbage. That means:- Discard the written state changes - in the provided range [from; to)
- Truncate the in-memory view of this changelog - in the range [0; to)
WARNING: the range [from; to) must not include any range that is included into any checkpoint that is not subsumed or aborted.
- Parameters:
to- exclusive
-
confirm
Mark the given state changes as confirmed by the JM.- Parameters:
from- inclusiveto- exclusivecheckpointId- to confirm
-
reset
Reset the state the given state changes. Called upon abortion so that if requested later then these changes will be re-uploaded. -
truncateAndClose
Truncate the tail of log and close it. No new appends will be possible. Any appended but not persisted records will be lost.- Parameters:
from-SequenceNumberfrom which to truncate the changelog, inclusive
-
close
void close()Close this log. No new appends will be possible. Any appended but not persisted records will be lost.- Specified by:
closein interfaceAutoCloseable
-