Interface TransactionContext
-
- All Superinterfaces:
DistributedPrimitive
public interface TransactionContext extends DistributedPrimitive
Provides a context for transactional operations.A transaction context is a vehicle for grouping operations into a unit with the properties of atomicity, isolation, and durability. Transactions also provide the ability to maintain an application's invariants or integrity constraints, supporting the property of consistency. Together these properties are known as ACID.
A transaction context provides a boundary within which transactions are run. It also is a place where all modifications made within a transaction are cached until the point when the transaction commits or aborts. It thus ensures isolation of work happening with in the transaction boundary. Within a transaction context isolation level is REPEATABLE_READS i.e. only data that is committed can be read. The only uncommitted data that can be read is the data modified by the current transaction.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.onosproject.store.service.DistributedPrimitive
DistributedPrimitive.Status, DistributedPrimitive.Type
-
-
Field Summary
-
Fields inherited from interface org.onosproject.store.service.DistributedPrimitive
DEFAULT_OPERATION_TIMEOUT_MILLIS
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
abort()
Aborts any changes made in this transaction context and discarding all locally cached updates.void
begin()
Starts a new transaction.CompletableFuture<CommitStatus>
commit()
Commits a transaction that was previously started thereby making its changes permanent and externally visible.<K,V>
TransactionalMap<K,V>getTransactionalMap(String mapName, Serializer serializer)
Returns a transactional map data structure with the specified name.boolean
isOpen()
Returns if this transaction context is open.default DistributedPrimitive.Type
primitiveType()
Returns the type of primitive.TransactionId
transactionId()
Returns the transaction identifier.-
Methods inherited from interface org.onosproject.store.service.DistributedPrimitive
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
-
-
-
-
Method Detail
-
primitiveType
default DistributedPrimitive.Type primitiveType()
Description copied from interface:DistributedPrimitive
Returns the type of primitive.- Specified by:
primitiveType
in interfaceDistributedPrimitive
- Returns:
- primitive type
-
transactionId
TransactionId transactionId()
Returns the transaction identifier.- Returns:
- transaction id
-
isOpen
boolean isOpen()
Returns if this transaction context is open.- Returns:
- true if open, false otherwise
-
begin
void begin()
Starts a new transaction.
-
commit
CompletableFuture<CommitStatus> commit()
Commits a transaction that was previously started thereby making its changes permanent and externally visible.- Returns:
- A future that will be completed when the operation completes
-
abort
void abort()
Aborts any changes made in this transaction context and discarding all locally cached updates.
-
getTransactionalMap
<K,V> TransactionalMap<K,V> getTransactionalMap(String mapName, Serializer serializer)
Returns a transactional map data structure with the specified name.- Type Parameters:
K
- key typeV
- value type- Parameters:
mapName
- name of the transactional mapserializer
- serializer to use for encoding/decoding keys and values of the map- Returns:
- Transactional Map
-
-