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 Default Methods Deprecated Methods Modifier and Type Method Description void
addBackupLockForKey(Object key)
void
addListener(CacheTransaction.TransactionCompletedListener listener)
default void
addReadKey(Object key)
Deprecated.since 9.1 UseMVCCEntry.setRead()
insteadvoid
addVersionRead(Object key, EntryVersion version)
Sets the version read for this key.boolean
areLocksReleased()
Deprecated.void
cleanupBackupLocks()
It cleans up the backup locks for this transaction.void
clearLockedKeys()
void
clearLookedUpEntries()
boolean
containsLockOrBackupLock(Object key)
Deprecated.Object
findAnyLockedOrBackupLocked(Collection<Object> keys)
Deprecated.void
forEachBackupLock(Consumer<Object> consumer)
Invokes theConsumer
with each backup lock.void
freezeModifications()
Prevent new modifications after prepare or commit started.List<org.infinispan.commands.write.WriteCommand>
getAllModifications()
Returns all the modifications visible within the current transaction, including those using Flag#CACHE_MODE_LOCAL.Set<Object>
getBackupLockedKeys()
Deprecated.Since 9.3, please useforEachBackupLock(Consumer)
long
getCreationTime()
GlobalTransaction
getGlobalTransaction()
Returns the transaction identifier.Set<Object>
getLockedKeys()
Map<Object,CacheEntry>
getLookedUpEntries()
default EntryVersion
getLookedUpRemoteVersion(Object key)
Deprecated.since 9.0List<org.infinispan.commands.write.WriteCommand>
getModifications()
Returns the modifications visible within the current transaction.CompletableFuture<Void>
getReleaseFutureForKey(Object key)
It returns aCompletableFuture
that completes when the lock for thekey
is released.Map<Object,CompletableFuture<Void>>
getReleaseFutureForKeys(Collection<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(Class<?> modificationClass)
Checks if a modification of the given class (or subclass) is present in this transaction.boolean
isMarkedForRollback()
default boolean
keyRead(Object key)
Deprecated.since 9.1 UseMVCCEntry.isRead()
insteadCacheEntry
lookupEntry(Object key)
void
markForRollback(boolean markForRollback)
void
notifyOnTransactionFinished()
boolean
ownsLock(Object key)
void
putLookedUpEntries(Map<Object,CacheEntry> entries)
void
putLookedUpEntry(Object key, CacheEntry e)
default void
putLookedUpRemoteVersion(Object key, EntryVersion version)
Deprecated.since 9.0void
removeBackupLock(Object key)
It cleans up the backup forkey
.void
removeBackupLocks(Collection<?> keys)
It cleans up the backup lock for thekeys
.void
removeLookedUpEntry(Object key)
default void
replaceVersionRead(Object key, EntryVersion version)
Deprecated.since 9.0void
setUpdatedEntryVersions(EntryVersionsMap updatedEntryVersions)
boolean
waitForLockRelease(long lockAcquisitionTimeout)
Deprecated.
-
-
-
Method Detail
-
getGlobalTransaction
GlobalTransaction getGlobalTransaction()
Returns the transaction identifier.
-
getModifications
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
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(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(Object key)
-
getLookedUpEntries
Map<Object,CacheEntry> getLookedUpEntries()
-
putLookedUpEntry
void putLookedUpEntry(Object key, CacheEntry e)
-
putLookedUpEntries
void putLookedUpEntries(Map<Object,CacheEntry> entries)
-
removeLookedUpEntry
void removeLookedUpEntry(Object key)
-
clearLookedUpEntries
void clearLookedUpEntries()
-
ownsLock
boolean ownsLock(Object key)
-
clearLockedKeys
void clearLockedKeys()
-
getTopologyId
int getTopologyId()
-
getBackupLockedKeys
@Deprecated Set<Object> getBackupLockedKeys()
Deprecated.Since 9.3, please useforEachBackupLock(Consumer)
testing purpose only!
-
addBackupLockForKey
void addBackupLockForKey(Object key)
-
notifyOnTransactionFinished
void notifyOnTransactionFinished()
-
waitForLockRelease
@Deprecated boolean waitForLockRelease(long lockAcquisitionTimeout) throws InterruptedException
Deprecated.Checks if this transaction holds a lock on the given key and then waits until the transaction completes or until the timeout expires and returnstrue
if the transaction is complete orfalse
otherwise. If the key is not locked or if the transaction is already completed it returnstrue
immediately. This method is subject to spurious returns in a way similar toObject.wait()
. It can sometimes return before the specified time has elapsed and without guaranteeing that this transaction is complete. The caller is responsible to call the method again if transaction completion was not reached and the time budget was not spent.
-
containsLockOrBackupLock
@Deprecated boolean containsLockOrBackupLock(Object key)
Deprecated.
-
findAnyLockedOrBackupLocked
@Deprecated Object findAnyLockedOrBackupLocked(Collection<Object> keys)
Deprecated.
-
areLocksReleased
@Deprecated boolean areLocksReleased()
Deprecated.
-
getUpdatedEntryVersions
EntryVersionsMap getUpdatedEntryVersions()
-
setUpdatedEntryVersions
void setUpdatedEntryVersions(EntryVersionsMap updatedEntryVersions)
-
putLookedUpRemoteVersion
@Deprecated default void putLookedUpRemoteVersion(Object key, EntryVersion version)
Deprecated.since 9.0
-
getLookedUpRemoteVersion
@Deprecated default EntryVersion getLookedUpRemoteVersion(Object key)
Deprecated.since 9.0
-
keyRead
@Deprecated default boolean keyRead(Object key)
Deprecated.since 9.1 UseMVCCEntry.isRead()
instead
-
addReadKey
@Deprecated default void addReadKey(Object key)
Deprecated.since 9.1 UseMVCCEntry.setRead()
instead
-
isMarkedForRollback
boolean isMarkedForRollback()
-
markForRollback
void markForRollback(boolean markForRollback)
-
addVersionRead
void addVersionRead(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.
-
replaceVersionRead
@Deprecated default void replaceVersionRead(Object key, EntryVersion version)
Deprecated.since 9.0Sets the version read fr this key, replacing the old version if it exists, i.e each invocation updates the version of the key. This method is used when a remote get is performed for the key. 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
CompletableFuture<Void> getReleaseFutureForKey(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
Map<Object,CompletableFuture<Void>> getReleaseFutureForKeys(Collection<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(Collection<?> keys)
It cleans up the backup lock for thekeys
.- Parameters:
keys
- The keys to clean up the backup lock.
-
removeBackupLock
void removeBackupLock(Object key)
It cleans up the backup forkey
.- Parameters:
key
- The key to clean up the backup lock.
-
-