Package org.infinispan.transaction.xa
Interface CacheTransaction
-
- All Known Subinterfaces:
RecoveryAwareTransaction
- All Known Implementing Classes:
org.infinispan.transaction.impl.AbstractCacheTransaction
,org.infinispan.transaction.impl.LocalTransaction
,LocalXaTransaction
,RecoveryAwareLocalTransaction
,RecoveryAwareRemoteTransaction
,org.infinispan.transaction.impl.RemoteTransaction
,SyncLocalTransaction
public interface CacheTransaction
Defines the state a infinispan transaction should have.- Since:
- 4.0
- Author:
- Mircea.Markus@jboss.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
CacheTransaction.TransactionCompletedListener
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addBackupLockForKey(java.lang.Object key)
void
addListener(CacheTransaction.TransactionCompletedListener listener)
void
addVersionRead(java.lang.Object key, EntryVersion version)
Sets the version read for this key.void
cleanupBackupLocks()
It cleans up the backup locks for this transaction.void
clearLockedKeys()
void
clearLookedUpEntries()
void
forEachBackupLock(java.util.function.Consumer<java.lang.Object> consumer)
Invokes theConsumer
with each backup lock.void
forEachLock(java.util.function.Consumer<java.lang.Object> consumer)
Invokes theConsumer
with each lock.void
freezeModifications()
Prevent new modifications after prepare or commit started.java.util.List<org.infinispan.commands.write.WriteCommand>
getAllModifications()
Returns all the modifications visible within the current transaction, including those using Flag#CACHE_MODE_LOCAL.long
getCreationTime()
GlobalTransaction
getGlobalTransaction()
Returns the transaction identifier.java.util.Set<java.lang.Object>
getLockedKeys()
java.util.Map<java.lang.Object,CacheEntry>
getLookedUpEntries()
java.util.List<org.infinispan.commands.write.WriteCommand>
getModifications()
Returns the modifications visible within the current transaction.java.util.concurrent.CompletableFuture<java.lang.Void>
getReleaseFutureForKey(java.lang.Object key)
It returns aCompletableFuture
that completes when the lock for thekey
is released.java.util.Map<java.lang.Object,java.util.concurrent.CompletableFuture<java.lang.Void>>
getReleaseFutureForKeys(java.util.Collection<java.lang.Object> keys)
Same asgetReleaseFutureForKey(Object)
but it returns a pair with the key and the future.int
getTopologyId()
EntryVersionsMap
getUpdatedEntryVersions()
EntryVersionsMap
getVersionsRead()
Note: used in Repeatable Read + Write Skew + Clustering + Versioning.boolean
hasModification(java.lang.Class<?> modificationClass)
Checks if a modification of the given class (or subclass) is present in this transaction.boolean
isMarkedForRollback()
CacheEntry
lookupEntry(java.lang.Object key)
void
markForRollback(boolean markForRollback)
void
notifyOnTransactionFinished()
boolean
ownsLock(java.lang.Object key)
void
putLookedUpEntries(java.util.Map<java.lang.Object,CacheEntry> entries)
void
putLookedUpEntry(java.lang.Object key, CacheEntry e)
void
removeBackupLock(java.lang.Object key)
It cleans up the backup forkey
.void
removeBackupLocks(java.util.Collection<?> keys)
It cleans up the backup lock for thekeys
.void
removeLookedUpEntry(java.lang.Object key)
void
setUpdatedEntryVersions(EntryVersionsMap updatedEntryVersions)
-
-
-
Method Detail
-
getGlobalTransaction
GlobalTransaction getGlobalTransaction()
Returns the transaction identifier.
-
getModifications
java.util.List<org.infinispan.commands.write.WriteCommand> getModifications()
Returns the modifications visible within the current transaction. Any modifications using Flag#CACHE_MODE_LOCAL are excluded. The returned list is never null.
-
getAllModifications
java.util.List<org.infinispan.commands.write.WriteCommand> getAllModifications()
Returns all the modifications visible within the current transaction, including those using Flag#CACHE_MODE_LOCAL. The returned list is never null.
-
hasModification
boolean hasModification(java.lang.Class<?> modificationClass)
Checks if a modification of the given class (or subclass) is present in this transaction. Any modifications using Flag#CACHE_MODE_LOCAL are ignored.- Parameters:
modificationClass
- the modification type to look for- Returns:
- true if found, false otherwise
-
lookupEntry
CacheEntry lookupEntry(java.lang.Object key)
-
getLookedUpEntries
java.util.Map<java.lang.Object,CacheEntry> getLookedUpEntries()
-
putLookedUpEntry
void putLookedUpEntry(java.lang.Object key, CacheEntry e)
-
putLookedUpEntries
void putLookedUpEntries(java.util.Map<java.lang.Object,CacheEntry> entries)
-
removeLookedUpEntry
void removeLookedUpEntry(java.lang.Object key)
-
clearLookedUpEntries
void clearLookedUpEntries()
-
ownsLock
boolean ownsLock(java.lang.Object key)
-
clearLockedKeys
void clearLockedKeys()
-
getLockedKeys
java.util.Set<java.lang.Object> getLockedKeys()
-
getTopologyId
int getTopologyId()
-
addBackupLockForKey
void addBackupLockForKey(java.lang.Object key)
-
notifyOnTransactionFinished
void notifyOnTransactionFinished()
-
getUpdatedEntryVersions
EntryVersionsMap getUpdatedEntryVersions()
-
setUpdatedEntryVersions
void setUpdatedEntryVersions(EntryVersionsMap updatedEntryVersions)
-
isMarkedForRollback
boolean isMarkedForRollback()
-
markForRollback
void markForRollback(boolean markForRollback)
-
addVersionRead
void addVersionRead(java.lang.Object key, EntryVersion version)
Sets the version read for this key. The version is only set at the first time, i.e. multiple invocation of this method will not change the state. Note: used in Repeatable Read + Write Skew + Clustering + Versioning.
-
getVersionsRead
EntryVersionsMap getVersionsRead()
Note: used in Repeatable Read + Write Skew + Clustering + Versioning.- Returns:
- a non-null map between key and version. The map represents the version read for that key. If no version exists, the key has not been read.
-
getCreationTime
long getCreationTime()
-
addListener
void addListener(CacheTransaction.TransactionCompletedListener listener)
-
freezeModifications
void freezeModifications()
Prevent new modifications after prepare or commit started.
-
getReleaseFutureForKey
java.util.concurrent.CompletableFuture<java.lang.Void> getReleaseFutureForKey(java.lang.Object key)
It returns aCompletableFuture
that completes when the lock for thekey
is released. If thekey
is not locked by this transaction, it returnsnull
.- Parameters:
key
- the key.- Returns:
- the
CompletableFuture
ornull
if the key is not locked by this transaction.
-
getReleaseFutureForKeys
java.util.Map<java.lang.Object,java.util.concurrent.CompletableFuture<java.lang.Void>> getReleaseFutureForKeys(java.util.Collection<java.lang.Object> keys)
Same asgetReleaseFutureForKey(Object)
but it returns a pair with the key and the future.
-
cleanupBackupLocks
void cleanupBackupLocks()
It cleans up the backup locks for this transaction.
-
removeBackupLocks
void removeBackupLocks(java.util.Collection<?> keys)
It cleans up the backup lock for thekeys
.- Parameters:
keys
- The keys to clean up the backup lock.
-
removeBackupLock
void removeBackupLock(java.lang.Object key)
It cleans up the backup forkey
.- Parameters:
key
- The key to clean up the backup lock.
-
forEachLock
void forEachLock(java.util.function.Consumer<java.lang.Object> consumer)
Invokes theConsumer
with each lock.- Parameters:
consumer
- The backup lockConsumer
-
forEachBackupLock
void forEachBackupLock(java.util.function.Consumer<java.lang.Object> consumer)
Invokes theConsumer
with each backup lock.- Parameters:
consumer
- The backup lockConsumer
-
-