public interface AtomicKVStore extends KVStore
KVStore
interface for implementations that support atomic, batched reads and writes.
Atomic batch reads are available via snapshot()
, which returns a consistent point-in-time views of the KVStore
.
Atomic batch writes are available via mutate()
, which applies a set of mutations in an "all or none" fashion.
Modifier and Type | Method and Description |
---|---|
void |
mutate(Mutations mutations,
boolean sync)
Apply a set of mutations to this instance atomically.
|
CloseableKVStore |
snapshot()
Acquire a read-only, snapshot view of this instance based on the current state.
|
void |
start()
Start this instance.
|
void |
stop()
Stop this instance.
|
adjustCounter, apply, decodeCounter, encodeCounter, get, getAtLeast, getAtMost, getRange, getRange, getRange, put, remove, removeRange, removeRange
void start()
This method is idempotent: if this instance is already started, nothing happens.
Whether an instance that has been started and stopped can be restarted is implementation-dependent.
IllegalStateException
- if this instance is not properly configuredvoid stop()
Any open snapshot()
's should be close()
'd before invoking this method;
the behavior of those that are not is undefined.
This method is idempotent: if this instance has not been started, or is already stopped, nothing happens.
CloseableKVStore snapshot()
The returned KVStore
view should remain constant even if this instance is subsequently mutated.
Note: callers are required to close
the returned instance when no longer in use.
StaleTransactionException
- if an underlying transaction is no longer usableRetryTransactionException
- if an underlying transaction must be retried and is no longer usableIllegalStateException
- if this instance is not start()
edvoid mutate(Mutations mutations, boolean sync)
If this method returns normally, all of the given mutations will have been applied. If this method returns abnormally, then none of the given mutations will have been applied.
In any case, other threads observing this instance will never see a partial application of the given mutations.
This method is required to apply the mutations in this order: removes, puts, adjusts.
If sync
is true, the implementation must durably persist the changes before returning.
mutations
- the mutations to applysync
- if true, caller requires that the changes be durably persistedStaleTransactionException
- if an underlying transaction is no longer usableRetryTransactionException
- if an underlying transaction must be retried and is no longer usableUnsupportedOperationException
- if sync
is true and this implementation cannot guarantee durabilityIllegalArgumentException
- if mutations
is nullIllegalStateException
- if this instance is not start()
edCopyright © 2019. All rights reserved.