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
Modifier and TypeFieldDescriptionHolds all the locked keys that were acquired by the transaction allover the cluster.protected Map
<Object, CacheEntry> protected ModificationList
protected final int
protected final GlobalTransaction
-
Constructor Summary
ConstructorDescriptionAbstractCacheTransaction
(GlobalTransaction tx, int topologyId, long txCreationTime) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAffectedKey
(Object key) void
addAllAffectedKeys
(Collection<?> keys) void
final void
void
addVersionRead
(Object key, EntryVersion version) Sets the version read for this key.protected final void
void
It cleans up the backup locks for this transaction.void
void
void
forEachBackupLock
(Consumer<Object> consumer) Invokes theConsumer
with each backup lock.void
forEachLock
(Consumer<Object> consumer) Invokes theConsumer
with each lock.void
Prevent 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.long
Returns the transaction identifier.final List
<org.infinispan.commands.write.WriteCommand> Returns the modifications visible within the current transaction.It returns aCompletableFuture
that completes when the lock for thekey
is released.Same asCacheTransaction.getReleaseFutureForKey(Object)
but it returns a pair with the key and the future.final Flag
int
Note: used in Repeatable Read + Write Skew + Clustering + Versioning.final boolean
final boolean
final boolean
lookupEntry
(Object key) void
markForRollback
(boolean markForRollback) void
boolean
void
registerLockedKey
(Object key) void
removeBackupLock
(Object key) It cleans up the backup forkey
.void
removeBackupLocks
(Collection<?> keys) It cleans up the backup lock for thekeys
.void
final void
setModifications
(List<org.infinispan.commands.write.WriteCommand> modifications) abstract void
setStateTransferFlag
(Flag stateTransferFlag) void
setUpdatedEntryVersions
(Map<Object, IncrementableEntryVersion> updatedEntryVersions) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
isMarkedForRollback
in interfaceCacheTransaction
-
markForRollback
public void markForRollback(boolean markForRollback) - Specified by:
markForRollback
in interfaceCacheTransaction
-
getGlobalTransaction
Description copied from interface:CacheTransaction
Returns the transaction identifier.- Specified by:
getGlobalTransaction
in interfaceCacheTransaction
-
getModifications
Description copied from interface:CacheTransaction
Returns the modifications visible within the current transaction. Any modifications using Flag#CACHE_MODE_LOCAL are excluded. The returned list is never null.- Specified by:
getModifications
in interfaceCacheTransaction
-
getAllModifications
Description copied from interface:CacheTransaction
Returns all the modifications visible within the current transaction, including those using Flag#CACHE_MODE_LOCAL. The returned list is never null.- Specified by:
getAllModifications
in interfaceCacheTransaction
-
setModifications
-
hasModifications
public final boolean hasModifications() -
freezeModifications
public void freezeModifications()Description copied from interface:CacheTransaction
Prevent new modifications after prepare or commit started.- Specified by:
freezeModifications
in interfaceCacheTransaction
-
getLookedUpEntries
- Specified by:
getLookedUpEntries
in interfaceCacheTransaction
-
lookupEntry
- Specified by:
lookupEntry
in interfaceCacheTransaction
-
removeLookedUpEntry
- Specified by:
removeLookedUpEntry
in interfaceCacheTransaction
-
clearLookedUpEntries
public void clearLookedUpEntries()- Specified by:
clearLookedUpEntries
in interfaceCacheTransaction
-
ownsLock
- Specified by:
ownsLock
in interfaceCacheTransaction
-
notifyOnTransactionFinished
public void notifyOnTransactionFinished()- Specified by:
notifyOnTransactionFinished
in interfaceCacheTransaction
- See Also:
-
getTopologyId
public int getTopologyId()- Specified by:
getTopologyId
in interfaceCacheTransaction
-
addBackupLockForKey
- Specified by:
addBackupLockForKey
in interfaceCacheTransaction
-
registerLockedKey
-
getLockedKeys
- Specified by:
getLockedKeys
in interfaceCacheTransaction
-
getBackupLockedKeys
-
clearLockedKeys
public void clearLockedKeys()- Specified by:
clearLockedKeys
in interfaceCacheTransaction
-
getAffectedKeys
-
addAffectedKey
-
addAllAffectedKeys
-
getUpdatedEntryVersions
- Specified by:
getUpdatedEntryVersions
in interfaceCacheTransaction
-
setUpdatedEntryVersions
- Specified by:
setUpdatedEntryVersions
in interfaceCacheTransaction
-
addVersionRead
Description copied from interface:CacheTransaction
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.- Specified by:
addVersionRead
in interfaceCacheTransaction
-
getVersionsRead
Description copied from interface:CacheTransaction
Note: used in Repeatable Read + Write Skew + Clustering + Versioning.- Specified by:
getVersionsRead
in 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:
getCreationTime
in interfaceCacheTransaction
-
addListener
- Specified by:
addListener
in interfaceCacheTransaction
-
getReleaseFutureForKey
Description copied from interface:CacheTransaction
It returns aCompletableFuture
that completes when the lock for thekey
is released. If thekey
is not locked by this transaction, it returnsnull
.- Specified by:
getReleaseFutureForKey
in interfaceCacheTransaction
- Parameters:
key
- the key.- Returns:
- the
CompletableFuture
ornull
if the key is not locked by this transaction.
-
getReleaseFutureForKeys
Description copied from interface:CacheTransaction
Same asCacheTransaction.getReleaseFutureForKey(Object)
but it returns a pair with the key and the future.- Specified by:
getReleaseFutureForKeys
in interfaceCacheTransaction
-
cleanupBackupLocks
public void cleanupBackupLocks()Description copied from interface:CacheTransaction
It cleans up the backup locks for this transaction.- Specified by:
cleanupBackupLocks
in interfaceCacheTransaction
-
removeBackupLocks
Description copied from interface:CacheTransaction
It cleans up the backup lock for thekeys
.- Specified by:
removeBackupLocks
in interfaceCacheTransaction
- Parameters:
keys
- The keys to clean up the backup lock.
-
removeBackupLock
Description copied from interface:CacheTransaction
It cleans up the backup forkey
.- Specified by:
removeBackupLock
in interfaceCacheTransaction
- Parameters:
key
- The key to clean up the backup lock.
-
forEachLock
Description copied from interface:CacheTransaction
Invokes theConsumer
with each lock.- Specified by:
forEachLock
in interfaceCacheTransaction
- Parameters:
consumer
- The backup lockConsumer
-
forEachBackupLock
Description copied from interface:CacheTransaction
Invokes theConsumer
with each backup lock.- Specified by:
forEachBackupLock
in interfaceCacheTransaction
- Parameters:
consumer
- The backup lockConsumer
-
checkIfRolledBack
protected final void checkIfRolledBack()
-