Interface ColumnarStateStore
- All Known Implementing Classes:
FileColumnarStateStore
A group runner saves a partition's snapshots when the partition is revoked and
loads them when it is assigned, so stateful operators survive rebalances and
restarts. That rebalance state uses LIVE_EPOCH. A runner that aligns on a
barrier group also saves a snapshot under the epoch of each cut it reaches, and
ColumnarRunner.GroupRunner.restoreToEpoch reads it back. Snapshots are keyed
by operator name inside the map, which is why node names should stay stable across
application versions. FileColumnarStateStore persists to local files;
none() disables persistence.
Example
var stateStore = new FileColumnarStateStore(Path.of("/var/lib/app/state"));
var runner = ColumnarRunner.group(
topology, consumer, producer,
ColumnarErrorPolicy.fail(), stateStore, new ColumnarMetrics());
Map<String, byte[]> live = stateStore.load(0, ColumnarStateStore.LIVE_EPOCH);
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA closeable snapshot-retention lease without checked exceptions. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe epoch of the running state, which no barrier cut owns. -
Method Summary
Modifier and TypeMethodDescriptionload(int partition, long epoch) Loads the stored snapshots for a partition and epoch.static ColumnarStateStorenone()Returns a store that keeps nothing.default ColumnarStateStore.EpochLeaseretain(long epoch) Prevents an epoch from being reclaimed while a restore is reading it.retainedEpochs(int partition) Lists the barrier epochs currently available for a partition.voidStores the snapshots for a partition and epoch, replacing what was stored before.
-
Field Details
-
LIVE_EPOCH
static final long LIVE_EPOCHThe epoch of the running state, which no barrier cut owns.Rebalance saves and loads use it. A barrier epoch is never negative, so the two never collide.
- See Also:
-
-
Method Details
-
load
Loads the stored snapshots for a partition and epoch.- Parameters:
partition- the logical partition numberepoch- the barrier epoch, orLIVE_EPOCHfor the running state- Returns:
- operator name to snapshot bytes; empty when nothing is stored
-
save
Stores the snapshots for a partition and epoch, replacing what was stored before.- Parameters:
partition- the logical partition numberepoch- the barrier epoch, orLIVE_EPOCHfor the running statesnapshot- operator name to snapshot bytes
-
retainedEpochs
Lists the barrier epochs currently available for a partition.An empty optional means the store cannot enumerate epochs.
- Parameters:
partition- the logical partition number- Returns:
- the retained epochs in ascending order, when enumeration is supported
-
retain
Prevents an epoch from being reclaimed while a restore is reading it.- Parameters:
epoch- the barrier epoch in use- Returns:
- a lease that releases the epoch when closed
-
none
Returns a store that keeps nothing.Loads are empty and saves are discarded, so operator state is ephemeral and lost on rebalance or restart.
- Returns:
- the no-op store
-