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 void
append(int keyGroup, byte[] value)
Appends the provided data to this log.void
appendMeta(byte[] value)
Appends the provided **metadata** to this log.void
close()
Close this log.void
confirm(SequenceNumber from, SequenceNumber to, long checkpointId)
Mark the given state changes as confirmed by the JM.SequenceNumber
initialSequenceNumber()
Get the initialSequenceNumber
that is used for the first element.SequenceNumber
nextSequenceNumber()
GetSequenceNumber
to be used for the next element added byappend
.CompletableFuture<SnapshotResult<Handle>>
persist(SequenceNumber from, long checkpointId)
Durably persist previouslyappended
data starting from the providedSequenceNumber
and up to the latest change added.void
reset(SequenceNumber from, SequenceNumber to, long checkpointId)
Reset the state the given state changes.void
truncate(SequenceNumber to)
Truncate this state changelog to free up the resources and collect any garbage.void
truncateAndClose(SequenceNumber from)
Truncate the tail of log and close it.
-
-
-
Method Detail
-
initialSequenceNumber
SequenceNumber initialSequenceNumber()
Get the initialSequenceNumber
that is used for the first element.
-
nextSequenceNumber
SequenceNumber nextSequenceNumber()
GetSequenceNumber
to be used for the next element added byappend
.
-
appendMeta
void appendMeta(byte[] value) throws IOException
Appends the provided **metadata** to this log. No persistency guarantees.- Throws:
IOException
-
append
void append(int keyGroup, byte[] value) throws IOException
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 previouslyappended
data starting from the providedSequenceNumber
and up to the latest change added. After this call, one ofconfirm
,reset
, ortruncate
eventually 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
-SequenceNumber
from 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:
close
in interfaceAutoCloseable
-
-