Package org.infinispan.transaction.impl
Class AbstractCacheTransaction
java.lang.Object
org.infinispan.transaction.impl.AbstractCacheTransaction
- All Implemented Interfaces:
CacheTransaction
- Direct Known Subclasses:
LocalTransaction,RemoteTransaction
Base class for local and remote transaction. Impl note: The aggregated modification list and lookedUpEntries are not
instantiated here but in subclasses. This is done in order to take advantage of the fact that, for remote
transactions we already know the size of the modifications list at creation time.
- Since:
- 4.2
- Author:
- Mircea.Markus@jboss.com, Galder ZamarreƱo
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.infinispan.transaction.xa.CacheTransaction
CacheTransaction.TransactionCompletedListener -
Field Summary
FieldsModifier and TypeFieldDescriptionHolds all the locked keys that were acquired by the transaction allover the cluster.protected Map<Object,CacheEntry> protected ModificationListprotected final intprotected final GlobalTransaction -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCacheTransaction(GlobalTransaction tx, int topologyId, long txCreationTime) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAffectedKey(Object key) voidaddAllAffectedKeys(Collection<?> keys) voidfinal voidvoidaddVersionRead(Object key, EntryVersion version) Sets the version read for this key.protected final voidvoidIt cleans up the backup locks for this transaction.voidvoidvoidforEachBackupLock(Consumer<Object> consumer) Invokes theConsumerwith each backup lock.voidforEachLock(Consumer<Object> consumer) Invokes theConsumerwith each lock.voidPrevent new modifications after prepare or commit started.final List<org.infinispan.commands.write.WriteCommand>Returns all the modifications visible within the current transaction, including those using Flag#CACHE_MODE_LOCAL.longReturns the transaction identifier.final List<org.infinispan.commands.write.WriteCommand>Returns the modifications visible within the current transaction.It returns aCompletableFuturethat completes when the lock for thekeyis released.Same asCacheTransaction.getReleaseFutureForKey(Object)but it returns a pair with the key and the future.final FlagintNote: used in Repeatable Read + Write Skew + Clustering + Versioning.final booleanfinal booleanfinal booleanlookupEntry(Object key) voidmarkForRollback(boolean markForRollback) voidbooleanvoidregisterLockedKey(Object key) voidremoveBackupLock(Object key) It cleans up the backup forkey.voidremoveBackupLocks(Collection<?> keys) It cleans up the backup lock for thekeys.voidfinal voidsetModifications(List<org.infinispan.commands.write.WriteCommand> modifications) abstract voidsetStateTransferFlag(Flag stateTransferFlag) voidsetUpdatedEntryVersions(Map<Object, IncrementableEntryVersion> updatedEntryVersions) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.infinispan.transaction.xa.CacheTransaction
hasModification, putLookedUpEntries, putLookedUpEntry
-
Field Details
-
tx
-
modifications
-
lookedUpEntries
-
affectedKeys
Holds all the locked keys that were acquired by the transaction allover the cluster. -
topologyId
protected final int topologyId
-
-
Constructor Details
-
AbstractCacheTransaction
-
-
Method Details
-
isMarkedForRollback
public final boolean isMarkedForRollback()- Specified by:
isMarkedForRollbackin interfaceCacheTransaction
-
markForRollback
public void markForRollback(boolean markForRollback) - Specified by:
markForRollbackin interfaceCacheTransaction
-
getGlobalTransaction
Description copied from interface:CacheTransactionReturns the transaction identifier.- Specified by:
getGlobalTransactionin interfaceCacheTransaction
-
getModifications
Description copied from interface:CacheTransactionReturns the modifications visible within the current transaction. Any modifications using Flag#CACHE_MODE_LOCAL are excluded. The returned list is never null.- Specified by:
getModificationsin interfaceCacheTransaction
-
getAllModifications
Description copied from interface:CacheTransactionReturns all the modifications visible within the current transaction, including those using Flag#CACHE_MODE_LOCAL. The returned list is never null.- Specified by:
getAllModificationsin interfaceCacheTransaction
-
setModifications
-
hasModifications
public final boolean hasModifications() -
freezeModifications
public void freezeModifications()Description copied from interface:CacheTransactionPrevent new modifications after prepare or commit started.- Specified by:
freezeModificationsin interfaceCacheTransaction
-
getLookedUpEntries
- Specified by:
getLookedUpEntriesin interfaceCacheTransaction
-
lookupEntry
- Specified by:
lookupEntryin interfaceCacheTransaction
-
removeLookedUpEntry
- Specified by:
removeLookedUpEntryin interfaceCacheTransaction
-
clearLookedUpEntries
public void clearLookedUpEntries()- Specified by:
clearLookedUpEntriesin interfaceCacheTransaction
-
ownsLock
- Specified by:
ownsLockin interfaceCacheTransaction
-
notifyOnTransactionFinished
public void notifyOnTransactionFinished()- Specified by:
notifyOnTransactionFinishedin interfaceCacheTransaction- See Also:
-
AbstractTxLockingInterceptor.checkPendingAndLockKey(TxInvocationContext, VisitableCommand, Object, long)
-
getTopologyId
public int getTopologyId()- Specified by:
getTopologyIdin interfaceCacheTransaction
-
addBackupLockForKey
- Specified by:
addBackupLockForKeyin interfaceCacheTransaction
-
registerLockedKey
-
getLockedKeys
- Specified by:
getLockedKeysin interfaceCacheTransaction
-
getBackupLockedKeys
-
clearLockedKeys
public void clearLockedKeys()- Specified by:
clearLockedKeysin interfaceCacheTransaction
-
getAffectedKeys
-
addAffectedKey
-
addAllAffectedKeys
-
getUpdatedEntryVersions
- Specified by:
getUpdatedEntryVersionsin interfaceCacheTransaction
-
setUpdatedEntryVersions
- Specified by:
setUpdatedEntryVersionsin interfaceCacheTransaction
-
addVersionRead
Description copied from interface:CacheTransactionSets 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.- Specified by:
addVersionReadin interfaceCacheTransaction
-
getVersionsRead
Description copied from interface:CacheTransactionNote: used in Repeatable Read + Write Skew + Clustering + Versioning.- Specified by:
getVersionsReadin interfaceCacheTransaction- 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.
-
isFromStateTransfer
public final boolean isFromStateTransfer() -
getStateTransferFlag
-
setStateTransferFlag
-
getCreationTime
public long getCreationTime()- Specified by:
getCreationTimein interfaceCacheTransaction
-
addListener
- Specified by:
addListenerin interfaceCacheTransaction
-
getReleaseFutureForKey
Description copied from interface:CacheTransactionIt returns aCompletableFuturethat completes when the lock for thekeyis released. If thekeyis not locked by this transaction, it returnsnull.- Specified by:
getReleaseFutureForKeyin interfaceCacheTransaction- Parameters:
key- the key.- Returns:
- the
CompletableFutureornullif the key is not locked by this transaction.
-
getReleaseFutureForKeys
Description copied from interface:CacheTransactionSame asCacheTransaction.getReleaseFutureForKey(Object)but it returns a pair with the key and the future.- Specified by:
getReleaseFutureForKeysin interfaceCacheTransaction
-
cleanupBackupLocks
public void cleanupBackupLocks()Description copied from interface:CacheTransactionIt cleans up the backup locks for this transaction.- Specified by:
cleanupBackupLocksin interfaceCacheTransaction
-
removeBackupLocks
Description copied from interface:CacheTransactionIt cleans up the backup lock for thekeys.- Specified by:
removeBackupLocksin interfaceCacheTransaction- Parameters:
keys- The keys to clean up the backup lock.
-
removeBackupLock
Description copied from interface:CacheTransactionIt cleans up the backup forkey.- Specified by:
removeBackupLockin interfaceCacheTransaction- Parameters:
key- The key to clean up the backup lock.
-
forEachLock
Description copied from interface:CacheTransactionInvokes theConsumerwith each lock.- Specified by:
forEachLockin interfaceCacheTransaction- Parameters:
consumer- The backup lockConsumer
-
forEachBackupLock
Description copied from interface:CacheTransactionInvokes theConsumerwith each backup lock.- Specified by:
forEachBackupLockin interfaceCacheTransaction- Parameters:
consumer- The backup lockConsumer
-
checkIfRolledBack
protected final void checkIfRolledBack()
-