org.jboss.cache
Class CacheImpl

java.lang.Object
  extended by org.jboss.cache.CacheImpl

public class CacheImpl
extends Object

The default implementation class of Cache and CacheSPI. This class has its roots in the legacy (JBoss Cache 1.x.x) org.jboss.cache.TreeCache class.

You should not use this class directly, or attempt to cast Cache or CacheSPI interfaces directly to this class.

Author:
Bela Ban, Ben Wang, Manik Surtani (manik@jboss.org), Brian Stansberry, Daniel Huang (dhuang@jboss.org)
See Also:
Cache

Constructor Summary
protected CacheImpl()
          Constructs an uninitialized CacheImpl.
protected CacheImpl(Configuration configuration)
          Constructs an uninitialized CacheImpl.
 
Method Summary
 void _addChild(GlobalTransaction gtx, Fqn parent_fqn, Object child_name, Node cn, boolean undoOps)
          Compensating method to _remove(GlobalTransaction,Fqn,boolean).
 void _block()
           
 boolean _evict(Fqn fqn)
          Internal evict method called by eviction policy provider.
 boolean _evict(Fqn fqn, DataVersion version)
          Internal evict method called by eviction policy provider.
protected  void _evictSubtree(Fqn subtree)
          Evicts the node at subtree along with all descendant nodes.
 Node _get(Fqn<?> fqn)
          Returns the raw data of the node; called externally internally.
 Object _get(Fqn<?> fqn, Object key, boolean sendNodeEvent)
           
 Map _getData(Fqn<?> fqn)
          Returns the raw data of the node; called externally internally.
<E> Set<E>
_getChildrenNames(Fqn<E> fqn)
           
 Set _getKeys(Fqn<?> fqn)
           
 void _lock(Fqn fqn, NodeLock.LockType lock_type, boolean recursive)
          Should not be called.
 void _move(Fqn nodeToMoveFqn, Fqn newParentFqn)
          Called by reflection
 String _print(Fqn fqn)
          Finds and returns the string value for the Fqn.
 void _put(GlobalTransaction tx, Fqn fqn, Map data, boolean create_undo_ops)
          Internal put method.
 void _put(GlobalTransaction tx, Fqn fqn, Map data, boolean create_undo_ops, boolean erase_contents)
          Internal put method.
 void _put(GlobalTransaction tx, Fqn fqn, Map data, boolean create_undo_ops, boolean erase_contents, DataVersion dv)
           
 void _put(GlobalTransaction tx, Fqn fqn, Map data, boolean create_undo_ops, DataVersion dv)
           
 Object _put(GlobalTransaction tx, Fqn fqn, Object key, Object value, boolean create_undo_ops)
          Internal put method.
 Object _put(GlobalTransaction tx, Fqn fqn, Object key, Object value, boolean create_undo_ops, DataVersion dv)
           
 void _put(GlobalTransaction tx, String fqn, Map data, boolean create_undo_ops)
          Internal put method.
 Object _put(GlobalTransaction tx, String fqn, Object key, Object value, boolean create_undo_ops)
          Internal put method.
 void _putForExternalRead(GlobalTransaction gtx, Fqn fqn, Object key, Object value)
           
 void _putForExternalRead(GlobalTransaction gtx, Fqn fqn, Object key, Object value, DataVersion dv)
           
 void _releaseAllLocks(Fqn fqn)
          Releases all locks for a FQN.
 boolean _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops)
          Internal remove method.
 boolean _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent)
           
 boolean _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent, boolean eviction)
          Internal method to remove a node.
 boolean _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean skipSendingNodeEvents, boolean eviction, DataVersion version)
          Internal method to remove a node.
 boolean _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, DataVersion dv)
           
 Object _remove(GlobalTransaction tx, Fqn fqn, Object key, boolean create_undo_ops)
          Internal method to remove a key.
 Object _remove(GlobalTransaction tx, Fqn fqn, Object key, boolean create_undo_ops, DataVersion dv)
           
 void _remove(GlobalTransaction tx, String fqn, boolean create_undo_ops)
          Internal remove method.
 Object _remove(GlobalTransaction tx, String fqn, Object key, boolean create_undo_ops)
          Internal method to remove a key.
 void _removeData(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops)
          Internal method to remove data from a node.
 void _removeData(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent)
          Internal method to remove data from a node.
 void _removeData(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent, boolean eviction)
          Internal method to remove data from a node.
 void _removeData(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent, boolean eviction, DataVersion version)
          Internal method to remove data from a node.
 void _removeData(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, DataVersion dv)
           
 void _removeData(GlobalTransaction tx, String fqn, boolean create_undo_ops)
          Internal method to remove data from a node.
 void _unblock()
           
 void addInterceptor(Interceptor i, Class<? extends Interceptor> afterInterceptor)
           
 void addInterceptor(Interceptor i, int position)
           
 void addUndoOperation(GlobalTransaction gtx, MethodCall undo_op)
          Adds an undo operatoin to the transaction table.
 void commit(GlobalTransaction tx)
          Throws UnsupportedOperationException.
 void create()
          Lifecycle method.
 void destroy()
          Lifecycle method.
 boolean exists(Fqn<?> fqn)
          Checks whether a given node exists in current in-memory state of the cache.
 boolean exists(Fqn<?> fqn, Object key)
          Checks whether a given key exists in the given node.
 boolean exists(String fqn)
          Checks whether a given node exists in current in-memory state of the cache.
 boolean exists(String fqn, Object key)
           
 NodeSPI findNode(Fqn fqn)
          Finds a node given a fully qualified name.
 CacheStatus getCacheStatus()
           
 String getClusterName()
           
protected  ComponentRegistry getComponentRegistry()
           
 Configuration getConfiguration()
           
 GlobalTransaction getCurrentTransaction()
          Returns the transaction associated with the current thread.
 GlobalTransaction getCurrentTransaction(boolean createIfNotExists)
          Returns the transaction associated with the thread; optionally creating it if is does not exist.
 GlobalTransaction getCurrentTransaction(Transaction tx)
          Returns the global transaction for this local transaction.
 GlobalTransaction getCurrentTransaction(Transaction tx, boolean createIfNotExists)
          Returns the global transaction for this local transaction.
 List<Interceptor> getInterceptorChain()
           
 Set<Fqn> getInternalFqns()
          Returns a Set of Fqns of the topmost node of internal regions that should not included in standard state transfers.
protected  Transaction getLocalTransaction()
          Returns the transaction associated with the current thread.
 int getNumberOfAttributes()
          Returns an approximation of the total number of attributes in the cache.
 int getNumberOfAttributes(Fqn fqn)
          Returns an approximation of the total number of attributes in this sub cache.
 int getNumberOfLocksHeld()
          Returns the number of read or write locks held across the entire cache.
 int getNumberOfNodes()
          Returns an approximation of the total number of nodes in the cache.
protected  Object getOwnerForLock()
          Returns an object suitable for use in node locking, either the current transaction or the current thread if there is no transaction.
 Region getRegion(Fqn<?> fqn, boolean createIfAbsent)
           
 NodeSPI getRoot()
          Returns the root node.
 RPCManager getRPCManager()
           
 TransactionManager getTransactionManager()
          Returns the transaction manager in use.
 TransactionTable getTransactionTable()
          Returns the transaction table.
 String getVersion()
          Returns the CacheImpl implementation version.
 GravitateResult gravitateData(Fqn fqn, boolean searchSubtrees)
          Used with buddy replication's data gravitation interceptor.
 boolean hasChild(Fqn fqn)
          Returns true if the FQN exists and the node has children.
 void invalidate(Fqn fqn, DataVersion versionToInvalidate)
          Very much like an evict(), except that regardless of whether there is a child present, this call will never remove the node from memory - just remove its contents.
 void optimisticPrepare(GlobalTransaction gtx, List modifications, Map data, org.jgroups.Address address, boolean onePhaseCommit)
          Throws UnsupportedOperationException.
 NodeSPI peek(Fqn<?> fqn, boolean includeDeletedNodes)
           
 NodeSPI peek(Fqn<?> fqn, boolean includeDeletedNodes, boolean includeInvalidNodes)
           
 void prepare(GlobalTransaction global_tx, List modifications, org.jgroups.Address coord, boolean onePhaseCommit)
          Throws UnsupportedOperationException.
 String printDetails()
          Prints information about the contents of the nodes in the cache's current in-memory state.
 String printLockInfo()
          Returns lock information.
 boolean realRemove(Fqn f, boolean skipMarkerCheck)
          Internal method; not to be used externally.
 void removeInterceptor(Class<? extends Interceptor> interceptorType)
           
 void removeInterceptor(int position)
           
 boolean removeRegion(Fqn<?> fqn)
           
 void rollback(GlobalTransaction tx)
          Throws UnsupportedOperationException.
 void start()
          Lifecyle method.
 void stop()
          Lifecycle method.
 String toString()
          Returns a debug string with few details.
 String toString(boolean details)
          Returns a debug string with optional details of contents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheImpl

protected CacheImpl()
Constructs an uninitialized CacheImpl.


CacheImpl

protected CacheImpl(Configuration configuration)
Constructs an uninitialized CacheImpl.

Method Detail

getComponentRegistry

protected ComponentRegistry getComponentRegistry()

getConfiguration

public Configuration getConfiguration()

getVersion

public String getVersion()
Returns the CacheImpl implementation version.


getRoot

public NodeSPI getRoot()
Returns the root node.


getTransactionTable

public TransactionTable getTransactionTable()
Returns the transaction table.


getTransactionManager

public TransactionManager getTransactionManager()
Returns the transaction manager in use.


create

public void create()
            throws CacheException
Lifecycle method. This is like initialize.

Throws:
Exception
CacheException

start

public void start()
           throws CacheException
Lifecyle method.

Throws:
CacheException

destroy

public void destroy()
Lifecycle method.


stop

public void stop()
Lifecycle method.


getCacheStatus

public CacheStatus getCacheStatus()

getInternalFqns

public Set<Fqn> getInternalFqns()
Returns a Set of Fqns of the topmost node of internal regions that should not included in standard state transfers. Will include BuddyManager.BUDDY_BACKUP_SUBTREE if buddy replication is enabled.

Returns:
an unmodifiable Set. Will not return null.

_evictSubtree

protected void _evictSubtree(Fqn subtree)
                      throws CacheException
Evicts the node at subtree along with all descendant nodes.

Parameters:
subtree - Fqn indicating the uppermost node in the portion of the cache that should be evicted.
Throws:
CacheException

_get

public Node _get(Fqn<?> fqn)
          throws CacheException
Returns the raw data of the node; called externally internally.

Throws:
CacheException

_getData

public Map _getData(Fqn<?> fqn)
Returns the raw data of the node; called externally internally.


_getKeys

public Set _getKeys(Fqn<?> fqn)
             throws CacheException
Throws:
CacheException

_get

public Object _get(Fqn<?> fqn,
                   Object key,
                   boolean sendNodeEvent)
            throws CacheException
Throws:
CacheException

exists

public boolean exists(String fqn)
Checks whether a given node exists in current in-memory state of the cache. Does not acquire any locks in doing so (result may be dirty read). Does not attempt to load nodes from a cache loader (may return false if a node has been evicted).

Parameters:
fqn - The fully qualified name of the node
Returns:
boolean Whether or not the node exists

exists

public boolean exists(Fqn<?> fqn)
Checks whether a given node exists in current in-memory state of the cache. Does not acquire any locks in doing so (result may be dirty read). Does not attempt to load nodes from a cache loader (may return false if a node has been evicted).

Parameters:
fqn - The fully qualified name of the node
Returns:
boolean Whether or not the node exists

peek

public NodeSPI peek(Fqn<?> fqn,
                    boolean includeDeletedNodes)

peek

public NodeSPI peek(Fqn<?> fqn,
                    boolean includeDeletedNodes,
                    boolean includeInvalidNodes)

exists

public boolean exists(String fqn,
                      Object key)
Parameters:
fqn -
key -

exists

public boolean exists(Fqn<?> fqn,
                      Object key)
Checks whether a given key exists in the given node. Does not interact with the interceptor stack.

Parameters:
fqn - The fully qualified name of the node
key -
Returns:
boolean Whether or not the node exists

_getChildrenNames

public <E> Set<E> _getChildrenNames(Fqn<E> fqn)
                         throws CacheException
Throws:
CacheException

hasChild

public boolean hasChild(Fqn fqn)
Returns true if the FQN exists and the node has children.


toString

public String toString()
Returns a debug string with few details.

Overrides:
toString in class Object

toString

public String toString(boolean details)
Returns a debug string with optional details of contents.


printDetails

public String printDetails()
Prints information about the contents of the nodes in the cache's current in-memory state. Does not load any previously evicted nodes from a cache loader, so evicted nodes will not be included.


printLockInfo

public String printLockInfo()
Returns lock information.


getNumberOfLocksHeld

public int getNumberOfLocksHeld()
Returns the number of read or write locks held across the entire cache.


getNumberOfNodes

public int getNumberOfNodes()
Returns an approximation of the total number of nodes in the cache. Since this method doesn't acquire any locks, the number might be incorrect, or the method might even throw a ConcurrentModificationException


getNumberOfAttributes

public int getNumberOfAttributes()
Returns an approximation of the total number of attributes in the cache. Since this method doesn't acquire any locks, the number might be incorrect, or the method might even throw a ConcurrentModificationException


getNumberOfAttributes

public int getNumberOfAttributes(Fqn fqn)
Returns an approximation of the total number of attributes in this sub cache.

See Also:
getNumberOfAttributes()

_putForExternalRead

public void _putForExternalRead(GlobalTransaction gtx,
                                Fqn fqn,
                                Object key,
                                Object value,
                                DataVersion dv)
                         throws CacheException
Throws:
CacheException

_put

public void _put(GlobalTransaction tx,
                 Fqn fqn,
                 Map data,
                 boolean create_undo_ops,
                 DataVersion dv)
          throws CacheException
Throws:
CacheException

_put

public void _put(GlobalTransaction tx,
                 Fqn fqn,
                 Map data,
                 boolean create_undo_ops,
                 boolean erase_contents,
                 DataVersion dv)
          throws CacheException
Throws:
CacheException

_put

public Object _put(GlobalTransaction tx,
                   Fqn fqn,
                   Object key,
                   Object value,
                   boolean create_undo_ops,
                   DataVersion dv)
            throws CacheException
Throws:
CacheException

_remove

public boolean _remove(GlobalTransaction tx,
                       Fqn fqn,
                       boolean create_undo_ops,
                       DataVersion dv)
                throws CacheException
Throws:
CacheException

_remove

public Object _remove(GlobalTransaction tx,
                      Fqn fqn,
                      Object key,
                      boolean create_undo_ops,
                      DataVersion dv)
               throws CacheException
Throws:
CacheException

_removeData

public void _removeData(GlobalTransaction tx,
                        Fqn fqn,
                        boolean create_undo_ops,
                        DataVersion dv)
                 throws CacheException
Throws:
CacheException

_put

public void _put(GlobalTransaction tx,
                 String fqn,
                 Map data,
                 boolean create_undo_ops)
          throws CacheException
Internal put method. Does the real work. Needs to acquire locks if accessing nodes, depending on the value of locking. If run inside a transaction, needs to (a) add newly acquired locks to TransactionEntry's lock list, (b) add nodes that were created to TransactionEntry's node list and (c) create Modifications and add them to TransactionEntry's modification list and (d) create compensating modifications to undo the changes in case of a rollback

Parameters:
fqn -
data -
create_undo_ops - If true, undo operations will be created (default is true). Otherwise they will not be created (used by rollback()).
Throws:
CacheException

_put

public void _put(GlobalTransaction tx,
                 Fqn fqn,
                 Map data,
                 boolean create_undo_ops)
          throws CacheException
Internal put method. Does the real work. Needs to acquire locks if accessing nodes, depending on the value of locking. If run inside a transaction, needs to (a) add newly acquired locks to TransactionEntry's lock list, (b) add nodes that were created to TransactionEntry's node list and (c) create Modifications and add them to TransactionEntry's modification list and (d) create compensating modifications to undo the changes in case of a rollback

Parameters:
fqn -
data -
create_undo_ops - If true, undo operations will be created (default is true). Otherwise they will not be created (used by rollback()).
Throws:
CacheException

_put

public void _put(GlobalTransaction tx,
                 Fqn fqn,
                 Map data,
                 boolean create_undo_ops,
                 boolean erase_contents)
          throws CacheException
Internal put method. Does the real work. Needs to acquire locks if accessing nodes, depending on the value of locking. If run inside a transaction, needs to (a) add newly acquired locks to TransactionEntry's lock list, (b) add nodes that were created to TransactionEntry's node list and (c) create Modifications and add them to TransactionEntry's modification list and (d) create compensating modifications to undo the changes in case of a rollback

Parameters:
fqn -
data -
create_undo_ops - If true, undo operations will be created (default is true).
erase_contents - Clear the existing hashmap before putting the new data into it Otherwise they will not be created (used by rollback()).
Throws:
CacheException

_put

public Object _put(GlobalTransaction tx,
                   String fqn,
                   Object key,
                   Object value,
                   boolean create_undo_ops)
            throws CacheException
Internal put method.

Returns:
Previous value (if any)
Throws:
CacheException

_put

public Object _put(GlobalTransaction tx,
                   Fqn fqn,
                   Object key,
                   Object value,
                   boolean create_undo_ops)
            throws CacheException
Internal put method.

Returns:
Previous value (if any)
Throws:
CacheException

_remove

public void _remove(GlobalTransaction tx,
                    String fqn,
                    boolean create_undo_ops)
             throws CacheException
Internal remove method.

Throws:
CacheException

_remove

public boolean _remove(GlobalTransaction tx,
                       Fqn fqn,
                       boolean create_undo_ops)
                throws CacheException
Internal remove method.

Throws:
CacheException

_remove

public boolean _remove(GlobalTransaction tx,
                       Fqn fqn,
                       boolean create_undo_ops,
                       boolean sendNodeEvent)
                throws CacheException
Throws:
CacheException

_remove

public boolean _remove(GlobalTransaction tx,
                       Fqn fqn,
                       boolean create_undo_ops,
                       boolean sendNodeEvent,
                       boolean eviction)
                throws CacheException
Internal method to remove a node.

Parameters:
tx -
fqn -
create_undo_ops -
sendNodeEvent -
Throws:
CacheException

_remove

public boolean _remove(GlobalTransaction tx,
                       Fqn fqn,
                       boolean create_undo_ops,
                       boolean skipSendingNodeEvents,
                       boolean eviction,
                       DataVersion version)
                throws CacheException
Internal method to remove a node. Performs a remove on a node, passing in a DataVersion which is used with optimistically locked nodes. Pass in a null if optimistic locking is not used.

Parameters:
tx -
fqn -
create_undo_ops -
skipSendingNodeEvents -
eviction -
version -
Returns:
true if the node was removed, false if not found
Throws:
CacheException

_remove

public Object _remove(GlobalTransaction tx,
                      String fqn,
                      Object key,
                      boolean create_undo_ops)
               throws CacheException
Internal method to remove a key.

Parameters:
fqn -
key -
Returns:
Object
Throws:
CacheException

_remove

public Object _remove(GlobalTransaction tx,
                      Fqn fqn,
                      Object key,
                      boolean create_undo_ops)
               throws CacheException
Internal method to remove a key.

Parameters:
fqn -
key -
Returns:
Object
Throws:
CacheException

_removeData

public void _removeData(GlobalTransaction tx,
                        String fqn,
                        boolean create_undo_ops)
                 throws CacheException
Internal method to remove data from a node.

Throws:
CacheException

_removeData

public void _removeData(GlobalTransaction tx,
                        Fqn fqn,
                        boolean create_undo_ops)
                 throws CacheException
Internal method to remove data from a node.

Throws:
CacheException

_removeData

public void _removeData(GlobalTransaction tx,
                        Fqn fqn,
                        boolean create_undo_ops,
                        boolean sendNodeEvent)
                 throws CacheException
Internal method to remove data from a node.

Throws:
CacheException

_removeData

public void _removeData(GlobalTransaction tx,
                        Fqn fqn,
                        boolean create_undo_ops,
                        boolean sendNodeEvent,
                        boolean eviction)
                 throws CacheException
Internal method to remove data from a node.

Throws:
CacheException

_removeData

public void _removeData(GlobalTransaction tx,
                        Fqn fqn,
                        boolean create_undo_ops,
                        boolean sendNodeEvent,
                        boolean eviction,
                        DataVersion version)
                 throws CacheException
Internal method to remove data from a node.

Throws:
CacheException

_evict

public boolean _evict(Fqn fqn)
               throws CacheException
Internal evict method called by eviction policy provider.

Parameters:
fqn - removes everything assoicated with this FQN
Returns:
true if the node has been completely removed, false if only the data map was removed, due to the presence of children
Throws:
CacheException

_evict

public boolean _evict(Fqn fqn,
                      DataVersion version)
               throws CacheException
Internal evict method called by eviction policy provider.

Parameters:
fqn -
version -
Returns:
true if the node has been completely removed, false if only the data map was removed, due to the presence of children
Throws:
CacheException

invalidate

public void invalidate(Fqn fqn,
                       DataVersion versionToInvalidate)
Very much like an evict(), except that regardless of whether there is a child present, this call will never remove the node from memory - just remove its contents.

Also, potentially throws a cache exception if data versioning is used and the node in memory has a newer data version than what is passed in.

Finally, the data version of the in-memory node is updated to the version being evicted to prevent versions going out of sync.


_addChild

public void _addChild(GlobalTransaction gtx,
                      Fqn parent_fqn,
                      Object child_name,
                      Node cn,
                      boolean undoOps)
               throws CacheException
Compensating method to _remove(GlobalTransaction,Fqn,boolean).

Throws:
CacheException

gravitateData

public GravitateResult gravitateData(Fqn fqn,
                                     boolean searchSubtrees)
                              throws CacheException
Used with buddy replication's data gravitation interceptor. If marshalling is necessary, ensure that the cache is configured to use Configuration.useRegionBasedMarshalling and the Region pertaining to the Fqn passed in is activated, and has an appropriate ClassLoader.

Parameters:
fqn - the fqn to gravitate
searchSubtrees - if true, buddy backup subtrees are searched and if false, they are not.
Returns:
a GravitateResult which contains the data for the gravitation
Throws:
CacheException

_releaseAllLocks

public void _releaseAllLocks(Fqn fqn)
Releases all locks for a FQN.


_print

public String _print(Fqn fqn)
Finds and returns the string value for the Fqn. Returns null if not found or upon error.


_lock

public void _lock(Fqn fqn,
                  NodeLock.LockType lock_type,
                  boolean recursive)
           throws TimeoutException,
                  LockingException
Should not be called.

Throws:
TimeoutException
LockingException

optimisticPrepare

public void optimisticPrepare(GlobalTransaction gtx,
                              List modifications,
                              Map data,
                              org.jgroups.Address address,
                              boolean onePhaseCommit)
Throws UnsupportedOperationException.


prepare

public void prepare(GlobalTransaction global_tx,
                    List modifications,
                    org.jgroups.Address coord,
                    boolean onePhaseCommit)
Throws UnsupportedOperationException.


commit

public void commit(GlobalTransaction tx)
Throws UnsupportedOperationException.


rollback

public void rollback(GlobalTransaction tx)
Throws UnsupportedOperationException.


addUndoOperation

public void addUndoOperation(GlobalTransaction gtx,
                             MethodCall undo_op)
Adds an undo operatoin to the transaction table.


_move

public void _move(Fqn nodeToMoveFqn,
                  Fqn newParentFqn)
Called by reflection

Parameters:
newParentFqn -
nodeToMoveFqn -

_block

public void _block()

_unblock

public void _unblock()

getLocalTransaction

protected Transaction getLocalTransaction()
Returns the transaction associated with the current thread. We get the initial context and a reference to the TransactionManager to get the transaction. This method is used by getCurrentTransaction()


getCurrentTransaction

public GlobalTransaction getCurrentTransaction()
Returns the transaction associated with the current thread. If a local transaction exists, but doesn't yet have a mapping to a GlobalTransaction, a new GlobalTransaction will be created and mapped to the local transaction. Note that if a local transaction exists, but is not ACTIVE or PREPARING, null is returned.

Returns:
A GlobalTransaction, or null if no (local) transaction was associated with the current thread

getCurrentTransaction

public GlobalTransaction getCurrentTransaction(boolean createIfNotExists)
Returns the transaction associated with the thread; optionally creating it if is does not exist.


getCurrentTransaction

public GlobalTransaction getCurrentTransaction(Transaction tx)
Returns the global transaction for this local transaction.


getCurrentTransaction

public GlobalTransaction getCurrentTransaction(Transaction tx,
                                               boolean createIfNotExists)
Returns the global transaction for this local transaction.

Parameters:
createIfNotExists - if true, if a global transaction is not found; one is created

getOwnerForLock

protected Object getOwnerForLock()
Returns an object suitable for use in node locking, either the current transaction or the current thread if there is no transaction.


findNode

public NodeSPI findNode(Fqn fqn)
Finds a node given a fully qualified name. Whenever nodes are created, and the global transaction is not null, the created nodes have to be added to the transaction's TransactionEntry field.
When a lock is acquired on a node, a reference to the lock has to be added to the list of locked nodes in the TransactionEntry.

This operation will also apply different locking to the cache nodes, depending on operation_type. If it is read type, all nodes will be acquired with read lock. Otherwise, the operation is write type, all parent nodes will be acquired with read lock while the destination node acquires write lock.

Parameters:
fqn - Fully qualified name for the corresponding node.
Returns:
DataNode

realRemove

public boolean realRemove(Fqn f,
                          boolean skipMarkerCheck)
Internal method; not to be used externally. Returns true if the node was found, false if not.

Parameters:
f -

getInterceptorChain

public List<Interceptor> getInterceptorChain()

addInterceptor

public void addInterceptor(Interceptor i,
                           int position)

removeInterceptor

public void removeInterceptor(int position)

removeInterceptor

public void removeInterceptor(Class<? extends Interceptor> interceptorType)

addInterceptor

public void addInterceptor(Interceptor i,
                           Class<? extends Interceptor> afterInterceptor)

getRPCManager

public RPCManager getRPCManager()

getClusterName

public String getClusterName()

getRegion

public Region getRegion(Fqn<?> fqn,
                        boolean createIfAbsent)

removeRegion

public boolean removeRegion(Fqn<?> fqn)

_putForExternalRead

public void _putForExternalRead(GlobalTransaction gtx,
                                Fqn fqn,
                                Object key,
                                Object value)


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