org.infinispan.transaction
Class AbstractCacheTransaction

java.lang.Object
  extended by org.infinispan.transaction.AbstractCacheTransaction
All Implemented Interfaces:
CacheTransaction
Direct Known Subclasses:
LocalTransaction, RemoteTransaction

public abstract class AbstractCacheTransaction
extends Object
implements CacheTransaction

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

Field Summary
protected  Set<Object> affectedKeys
           
protected  Set<Object> backupKeyLocks
           
protected  Set<Object> lockedKeys
           
protected  HashMap<Object,CacheEntry> lookedUpEntries
           
protected  List<WriteCommand> modifications
           
protected  boolean prepared
           
protected  GlobalTransaction tx
           
 
Constructor Summary
AbstractCacheTransaction(GlobalTransaction tx, int viewId)
           
 
Method Summary
 void addAffectedKey(Object key)
           
 void addAllAffectedKeys(Collection<Object> keys)
           
 void addBackupLockForKey(Object key)
           
 void addReadKey(Object key)
           
 void clearLockedKeys()
           
 void clearLookedUpEntries()
           
 Set<Object> getAffectedKeys()
           
 GlobalTransaction getGlobalTransaction()
          Returns the transaction identifier.
 Set<Object> getLockedKeys()
           
 Map<Object,CacheEntry> getLookedUpEntries()
           
 List<WriteCommand> getModifications()
          Returns the modifications visible within the current transaction.
 EntryVersionsMap getUpdatedEntryVersions()
           
 int getViewId()
           
 boolean keyRead(Object key)
           
 CacheEntry lookupEntry(Object key)
           
 void notifyOnTransactionFinished()
           
 boolean ownsLock(Object key)
           
 void registerLockedKey(Object key)
           
 void removeLookedUpEntry(Object key)
           
 void setModifications(WriteCommand[] modifications)
           
 void setUpdatedEntryVersions(EntryVersionsMap updatedEntryVersions)
           
 boolean waitForLockRelease(Object key, long lockAcquisitionTimeout)
           
 
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
putLookedUpEntries, putLookedUpEntry
 

Field Detail

tx

protected final GlobalTransaction tx

modifications

protected List<WriteCommand> modifications

lookedUpEntries

protected HashMap<Object,CacheEntry> lookedUpEntries

affectedKeys

protected Set<Object> affectedKeys

lockedKeys

protected Set<Object> lockedKeys

backupKeyLocks

protected Set<Object> backupKeyLocks

prepared

protected volatile boolean prepared
Constructor Detail

AbstractCacheTransaction

public AbstractCacheTransaction(GlobalTransaction tx,
                                int viewId)
Method Detail

getGlobalTransaction

public GlobalTransaction getGlobalTransaction()
Description copied from interface: CacheTransaction
Returns the transaction identifier.

Specified by:
getGlobalTransaction in interface CacheTransaction

getModifications

public List<WriteCommand> getModifications()
Description copied from interface: CacheTransaction
Returns the modifications visible within the current transaction.

Specified by:
getModifications in interface CacheTransaction

setModifications

public void setModifications(WriteCommand[] modifications)

getLookedUpEntries

public Map<Object,CacheEntry> getLookedUpEntries()
Specified by:
getLookedUpEntries in interface CacheTransaction

lookupEntry

public CacheEntry lookupEntry(Object key)
Specified by:
lookupEntry in interface CacheTransaction

removeLookedUpEntry

public void removeLookedUpEntry(Object key)
Specified by:
removeLookedUpEntry in interface CacheTransaction

clearLookedUpEntries

public void clearLookedUpEntries()
Specified by:
clearLookedUpEntries in interface CacheTransaction

ownsLock

public boolean ownsLock(Object key)
Specified by:
ownsLock in interface CacheTransaction

notifyOnTransactionFinished

public void notifyOnTransactionFinished()
Specified by:
notifyOnTransactionFinished in interface CacheTransaction
See Also:
AbstractTxLockingInterceptor.lockKeyAndCheckOwnership(org.infinispan.context.InvocationContext, Object)

waitForLockRelease

public boolean waitForLockRelease(Object key,
                                  long lockAcquisitionTimeout)
                           throws InterruptedException
Specified by:
waitForLockRelease in interface CacheTransaction
Throws:
InterruptedException
See Also:
AbstractTxLockingInterceptor.lockKeyAndCheckOwnership(org.infinispan.context.InvocationContext, Object)

getViewId

public int getViewId()
Specified by:
getViewId in interface CacheTransaction

addBackupLockForKey

public void addBackupLockForKey(Object key)
Specified by:
addBackupLockForKey in interface CacheTransaction

registerLockedKey

public void registerLockedKey(Object key)

getLockedKeys

public Set<Object> getLockedKeys()
Specified by:
getLockedKeys in interface CacheTransaction

clearLockedKeys

public void clearLockedKeys()
Specified by:
clearLockedKeys in interface CacheTransaction

getAffectedKeys

public Set<Object> getAffectedKeys()

addAffectedKey

public void addAffectedKey(Object key)

addAllAffectedKeys

public void addAllAffectedKeys(Collection<Object> keys)

getUpdatedEntryVersions

public EntryVersionsMap getUpdatedEntryVersions()
Specified by:
getUpdatedEntryVersions in interface CacheTransaction

setUpdatedEntryVersions

public void setUpdatedEntryVersions(EntryVersionsMap updatedEntryVersions)
Specified by:
setUpdatedEntryVersions in interface CacheTransaction

addReadKey

public void addReadKey(Object key)
Specified by:
addReadKey in interface CacheTransaction

keyRead

public boolean keyRead(Object key)
Specified by:
keyRead in interface CacheTransaction

-->

Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.