public abstract class AbstractCacheTransaction extends Object implements CacheTransaction
CacheTransaction.TransactionCompletedListener| Modifier and Type | Field and Description |
|---|---|
protected Set<Object> |
affectedKeys
Holds all the locked keys that were acquired by the transaction allover the cluster.
|
protected Map<Object,CacheEntry> |
lookedUpEntries |
protected List<WriteCommand> |
modifications |
protected int |
topologyId |
protected GlobalTransaction |
tx |
| Constructor and Description |
|---|
AbstractCacheTransaction(GlobalTransaction tx,
int topologyId,
long txCreationTime) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAffectedKey(Object key) |
void |
addAllAffectedKeys(Collection<?> keys) |
void |
addBackupLockForKey(Object key) |
void |
addListener(CacheTransaction.TransactionCompletedListener listener) |
void |
addVersionRead(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(Consumer<Object> consumer)
Invokes the
Consumer with each backup lock. |
void |
forEachLock(Consumer<Object> consumer)
Invokes the
Consumer with each lock. |
void |
freezeModifications()
Prevent new modifications after prepare or commit started.
|
Set<Object> |
getAffectedKeys() |
List<WriteCommand> |
getAllModifications()
Returns all the modifications visible within the current transaction, including those using Flag#CACHE_MODE_LOCAL.
|
Set<Object> |
getBackupLockedKeys() |
long |
getCreationTime() |
GlobalTransaction |
getGlobalTransaction()
Returns the transaction identifier.
|
Set<Object> |
getLockedKeys() |
Map<Object,CacheEntry> |
getLookedUpEntries() |
List<WriteCommand> |
getModifications()
Returns the modifications visible within the current transaction.
|
CompletableFuture<Void> |
getReleaseFutureForKey(Object key)
It returns a
CompletableFuture that completes when the lock for the key is released. |
Map<Object,CompletableFuture<Void>> |
getReleaseFutureForKeys(Collection<Object> keys)
Same as
CacheTransaction.getReleaseFutureForKey(Object) but it returns a pair with the key and the future. |
Flag |
getStateTransferFlag() |
int |
getTopologyId() |
Map<Object,IncrementableEntryVersion> |
getUpdatedEntryVersions() |
Map<Object,IncrementableEntryVersion> |
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 |
isFromStateTransfer() |
boolean |
isMarkedForRollback() |
CacheEntry |
lookupEntry(Object key) |
void |
markForRollback(boolean markForRollback) |
void |
notifyOnTransactionFinished() |
boolean |
ownsLock(Object key) |
void |
registerLockedKey(Object key) |
void |
removeBackupLock(Object key)
It cleans up the backup for
key. |
void |
removeBackupLocks(Collection<?> keys)
It cleans up the backup lock for the
keys. |
void |
removeLookedUpEntry(Object key) |
void |
setModifications(List<WriteCommand> modifications) |
abstract void |
setStateTransferFlag(Flag stateTransferFlag) |
void |
setUpdatedEntryVersions(Map<Object,IncrementableEntryVersion> updatedEntryVersions) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitputLookedUpEntries, putLookedUpEntryprotected final GlobalTransaction tx
protected volatile List<WriteCommand> modifications
protected Map<Object,CacheEntry> lookedUpEntries
protected Set<Object> affectedKeys
protected final int topologyId
public AbstractCacheTransaction(GlobalTransaction tx, int topologyId, long txCreationTime)
public final boolean isMarkedForRollback()
isMarkedForRollback in interface CacheTransactionpublic void markForRollback(boolean markForRollback)
markForRollback in interface CacheTransactionpublic GlobalTransaction getGlobalTransaction()
CacheTransactiongetGlobalTransaction in interface CacheTransactionpublic final List<WriteCommand> getModifications()
CacheTransactiongetModifications in interface CacheTransactionpublic final List<WriteCommand> getAllModifications()
CacheTransactiongetAllModifications in interface CacheTransactionpublic final void setModifications(List<WriteCommand> modifications)
public final boolean hasModification(Class<?> modificationClass)
CacheTransactionhasModification in interface CacheTransactionmodificationClass - the modification type to look forpublic void freezeModifications()
CacheTransactionfreezeModifications in interface CacheTransactionpublic Map<Object,CacheEntry> getLookedUpEntries()
getLookedUpEntries in interface CacheTransactionpublic CacheEntry lookupEntry(Object key)
lookupEntry in interface CacheTransactionpublic void removeLookedUpEntry(Object key)
removeLookedUpEntry in interface CacheTransactionpublic void clearLookedUpEntries()
clearLookedUpEntries in interface CacheTransactionpublic boolean ownsLock(Object key)
ownsLock in interface CacheTransactionpublic void notifyOnTransactionFinished()
notifyOnTransactionFinished in interface CacheTransactionAbstractTxLockingInterceptor.checkPendingAndLockKey(TxInvocationContext, VisitableCommand, Object, long)public int getTopologyId()
getTopologyId in interface CacheTransactionpublic void addBackupLockForKey(Object key)
addBackupLockForKey in interface CacheTransactionpublic void registerLockedKey(Object key)
public Set<Object> getLockedKeys()
getLockedKeys in interface CacheTransactionpublic void clearLockedKeys()
clearLockedKeys in interface CacheTransactionpublic void addAffectedKey(Object key)
public void addAllAffectedKeys(Collection<?> keys)
public Map<Object,IncrementableEntryVersion> getUpdatedEntryVersions()
getUpdatedEntryVersions in interface CacheTransactionpublic void setUpdatedEntryVersions(Map<Object,IncrementableEntryVersion> updatedEntryVersions)
setUpdatedEntryVersions in interface CacheTransactionpublic void addVersionRead(Object key, EntryVersion version)
CacheTransactionaddVersionRead in interface CacheTransactionpublic Map<Object,IncrementableEntryVersion> getVersionsRead()
CacheTransactiongetVersionsRead in interface CacheTransactionpublic final boolean isFromStateTransfer()
public final Flag getStateTransferFlag()
public abstract void setStateTransferFlag(Flag stateTransferFlag)
public long getCreationTime()
getCreationTime in interface CacheTransactionpublic final void addListener(CacheTransaction.TransactionCompletedListener listener)
addListener in interface CacheTransactionpublic CompletableFuture<Void> getReleaseFutureForKey(Object key)
CacheTransactionCompletableFuture that completes when the lock for the key is released.
If the key is not locked by this transaction, it returns null.getReleaseFutureForKey in interface CacheTransactionkey - the key.CompletableFuture or null if the key is not locked by this transaction.public Map<Object,CompletableFuture<Void>> getReleaseFutureForKeys(Collection<Object> keys)
CacheTransactionCacheTransaction.getReleaseFutureForKey(Object) but it returns a pair with the key and the future.getReleaseFutureForKeys in interface CacheTransactionpublic void cleanupBackupLocks()
CacheTransactioncleanupBackupLocks in interface CacheTransactionpublic void removeBackupLocks(Collection<?> keys)
CacheTransactionkeys.removeBackupLocks in interface CacheTransactionkeys - The keys to clean up the backup lock.public void removeBackupLock(Object key)
CacheTransactionkey.removeBackupLock in interface CacheTransactionkey - The key to clean up the backup lock.public void forEachLock(Consumer<Object> consumer)
CacheTransactionConsumer with each lock.forEachLock in interface CacheTransactionconsumer - The backup lock Consumerpublic void forEachBackupLock(Consumer<Object> consumer)
CacheTransactionConsumer with each backup lock.forEachBackupLock in interface CacheTransactionconsumer - The backup lock ConsumerCopyright © 2021 JBoss by Red Hat. All rights reserved.