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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidappend(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.SequenceNumberinitialSequenceNumber()Get the initialSequenceNumberthat is used for the first element.SequenceNumbernextSequenceNumber()GetSequenceNumberto be used for the next element added byappend.CompletableFuture<SnapshotResult<Handle>>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(SequenceNumber to)Truncate this state changelog to free up the resources and collect any garbage.voidtruncateAndClose(SequenceNumber from)Truncate the tail of log and close it.
-
-
-
Method Detail
-
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
void appendMeta(byte[] value) throws IOExceptionAppends the provided **metadata** to this log. No persistency guarantees.- Throws:
IOException
-
append
void append(int keyGroup, byte[] value) throws IOExceptionAppends 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
void truncate(SequenceNumber to)
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
void confirm(SequenceNumber from, SequenceNumber to, long checkpointId)
Mark the given state changes as confirmed by the JM.- Parameters:
from- inclusiveto- exclusivecheckpointId- to confirm
-
reset
void reset(SequenceNumber from, SequenceNumber to, long checkpointId)
Reset the state the given state changes. Called upon abortion so that if requested later then these changes will be re-uploaded.
-
truncateAndClose
void truncateAndClose(SequenceNumber from)
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
-
-