public abstract class AbstractCacheTransaction extends Object implements CacheTransaction
| 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 Set<Object> |
backupKeyLocks
Holds all the locks for which the local node is a secondary data owner.
|
protected boolean |
hasLocalOnlyModifications |
protected Equivalence<Object> |
keyEquivalence
Equivalence function to compare keys that are stored in temporary
collections used in the cache transaction to keep track of locked keys,
looked up keys...etc.
|
protected Set<Object> |
lockedKeys
Holds all the keys that were actually locked on the local node.
|
protected Map<Object,CacheEntry> |
lookedUpEntries |
protected List<WriteCommand> |
modifications |
protected int |
topologyId |
protected GlobalTransaction |
tx |
| Constructor and Description |
|---|
AbstractCacheTransaction(GlobalTransaction tx,
int topologyId,
Equivalence<Object> keyEquivalence) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAffectedKey(Object key) |
void |
addAllAffectedKeys(Collection<Object> keys) |
void |
addBackupLockForKey(Object key) |
void |
addReadKey(Object key) |
void |
addVersionRead(Object key,
EntryVersion version)
Sets the version read for this key.
|
void |
clearLockedKeys() |
void |
clearLookedUpEntries() |
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() |
GlobalTransaction |
getGlobalTransaction()
Returns the transaction identifier.
|
Set<Object> |
getLockedKeys() |
Map<Object,CacheEntry> |
getLookedUpEntries() |
EntryVersion |
getLookedUpRemoteVersion(Object key) |
List<WriteCommand> |
getModifications()
Returns the modifications visible within the current transaction.
|
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() |
boolean |
keyRead(Object key) |
CacheEntry |
lookupEntry(Object key) |
void |
markForRollback(boolean markForRollback) |
void |
notifyOnTransactionFinished() |
boolean |
ownsLock(Object key) |
void |
putLookedUpRemoteVersion(Object key,
EntryVersion version) |
void |
registerLockedKey(Object key) |
void |
removeLookedUpEntry(Object key) |
void |
replaceVersionRead(Object key,
EntryVersion version)
Sets the version read fr this key, replacing the old version if it exists, i.e each invocation updates the version
of the key.
|
void |
setModifications(List<WriteCommand> modifications) |
void |
setUpdatedEntryVersions(EntryVersionsMap updatedEntryVersions) |
boolean |
waitForLockRelease(Object key,
long lockAcquisitionTimeout)
Checks if this transaction holds a lock on the given key and then waits until the transaction completes or until
the timeout expires and returns
true if the transaction is complete or false otherwise. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitputLookedUpEntries, putLookedUpEntryprotected final GlobalTransaction tx
protected volatile boolean hasLocalOnlyModifications
protected volatile List<WriteCommand> modifications
protected Map<Object,CacheEntry> lookedUpEntries
protected Set<Object> affectedKeys
protected volatile Set<Object> lockedKeys
protected volatile Set<Object> backupKeyLocks
protected final int topologyId
protected final Equivalence<Object> keyEquivalence
public AbstractCacheTransaction(GlobalTransaction tx, int topologyId, Equivalence<Object> keyEquivalence)
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 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 CacheTransactionorg.infinispan.interceptors.locking.AbstractTxLockingInterceptor#lockKeyAndCheckOwnership(org.infinispan.context.InvocationContext, Object)public boolean waitForLockRelease(Object key, long lockAcquisitionTimeout) throws InterruptedException
CacheTransactiontrue if the transaction is complete or false otherwise.
If the key is not locked or if the transaction is already completed it returns true immediately.
This method is subject to spurious returns in a way similar to Object.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.waitForLockRelease in interface CacheTransactionInterruptedExceptionorg.infinispan.interceptors.locking.AbstractTxLockingInterceptor#lockKeyAndCheckOwnership(org.infinispan.context.InvocationContext, Object)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 Set<Object> getBackupLockedKeys()
getBackupLockedKeys in interface CacheTransactionpublic void clearLockedKeys()
clearLockedKeys in interface CacheTransactionpublic void addAffectedKey(Object key)
public void addAllAffectedKeys(Collection<Object> keys)
public EntryVersionsMap getUpdatedEntryVersions()
getUpdatedEntryVersions in interface CacheTransactionpublic void setUpdatedEntryVersions(EntryVersionsMap updatedEntryVersions)
setUpdatedEntryVersions in interface CacheTransactionpublic EntryVersion getLookedUpRemoteVersion(Object key)
getLookedUpRemoteVersion in interface CacheTransactionpublic void putLookedUpRemoteVersion(Object key, EntryVersion version)
putLookedUpRemoteVersion in interface CacheTransactionpublic void addReadKey(Object key)
addReadKey in interface CacheTransactionpublic boolean keyRead(Object key)
keyRead in interface CacheTransactionpublic void addVersionRead(Object key, EntryVersion version)
CacheTransactionaddVersionRead in interface CacheTransactionpublic void replaceVersionRead(Object key, EntryVersion version)
CacheTransactionreplaceVersionRead in interface CacheTransactionpublic EntryVersionsMap getVersionsRead()
CacheTransactiongetVersionsRead in interface CacheTransactionCopyright © 2013 JBoss, a division of Red Hat. All rights reserved.