K - key typeV - value type.public abstract class TransactionalMapParticipant<K,V> extends Object implements org.onosproject.store.service.TransactionalMap<K,V>, TransactionParticipant
TransactionalMap.
This class provides the basic functionality required by transactional map participants and provides methods for defining operations specific to individual isolation levels.
| Modifier and Type | Field and Description |
|---|---|
protected org.onosproject.store.service.ConsistentMap<K,V> |
backingMap |
protected Set<K> |
deleteSet |
protected org.onosproject.store.service.Version |
lock |
protected Transaction<org.onosproject.store.primitives.MapUpdate<K,V>> |
transaction |
protected Map<K,V> |
writeCache |
| Modifier | Constructor and Description |
|---|---|
protected |
TransactionalMapParticipant(org.onosproject.store.service.ConsistentMap<K,V> backingMap,
Transaction<org.onosproject.store.primitives.MapUpdate<K,V>> transaction) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Void> |
commit()
Attempts to execute the commit phase for previously prepared transaction.
|
boolean |
containsKey(K key) |
V |
get(K key) |
protected List<org.onosproject.store.primitives.MapUpdate<K,V>> |
log(org.onosproject.store.service.Version lockVersion)
Returns a list of updates performed within this map partition.
|
CompletableFuture<Boolean> |
prepare()
Executes the prepare phase.
|
CompletableFuture<Boolean> |
prepareAndCommit()
Executes the prepare and commit phases atomically.
|
V |
put(K key,
V value) |
V |
putIfAbsent(K key,
V value) |
protected abstract V |
read(K key)
Executes a get operation based on the transaction isolation level.
|
protected abstract Stream<org.onosproject.store.primitives.MapUpdate<K,V>> |
records(org.onosproject.store.service.Version lockVersion)
Returns a stream of updates performed within this map partition.
|
V |
remove(K key) |
boolean |
remove(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
CompletableFuture<Void> |
rollback()
Attempts to execute the rollback phase for previously prepared transaction.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waithasPendingUpdatesprotected final Transaction<org.onosproject.store.primitives.MapUpdate<K,V>> transaction
protected volatile org.onosproject.store.service.Version lock
protected TransactionalMapParticipant(org.onosproject.store.service.ConsistentMap<K,V> backingMap, Transaction<org.onosproject.store.primitives.MapUpdate<K,V>> transaction)
protected abstract V read(K key)
key - the key to look uppublic boolean containsKey(K key)
public CompletableFuture<Boolean> prepare()
TransactionParticipantprepare in interface TransactionParticipanttrue is successful; false otherwisepublic CompletableFuture<Void> commit()
TransactionParticipantcommit in interface TransactionParticipantpublic CompletableFuture<Boolean> prepareAndCommit()
TransactionParticipantprepareAndCommit in interface TransactionParticipanttrue is successful; false otherwisepublic CompletableFuture<Void> rollback()
TransactionParticipantrollback in interface TransactionParticipantprotected List<org.onosproject.store.primitives.MapUpdate<K,V>> log(org.onosproject.store.service.Version lockVersion)
lockVersion - the global transaction lock versionprotected abstract Stream<org.onosproject.store.primitives.MapUpdate<K,V>> records(org.onosproject.store.service.Version lockVersion)
lockVersion - the global transaction lock version