org.jboss.cache
Class CacheImpl<K,V>

java.lang.Object
  extended by org.jboss.cache.CacheImpl<K,V>
All Implemented Interfaces:
Cache<K,V>, CacheSPI<K,V>

public class CacheImpl<K,V>
extends java.lang.Object
implements CacheSPI<K,V>

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

Nested Class Summary
protected  class CacheImpl.MembershipListenerAdaptor
           
protected  class CacheImpl.MessageListenerAdaptor
           
 
Field Summary
protected  org.jgroups.Channel channel
          The JGroups JChannel in use.
 
Constructor Summary
protected CacheImpl()
          Constructs an uninitialized CacheImpl.
 
Method Summary
 void _addChild(GlobalTransaction gtx, Fqn parent_fqn, java.lang.Object child_name, Node cn, boolean undoOps)
          Compensating method to _remove(GlobalTransaction,Fqn,boolean).
 void _block()
           
 java.util.List _clusteredGet(MethodCall methodCall, java.lang.Boolean searchBackupSubtrees)
          A 'clustered get' call, called from a remote ClusteredCacheLoader.
 void _dataGravitationCleanup(GlobalTransaction gtx, Fqn primary, Fqn backup)
           
 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<K,V> _get(Fqn<?> fqn)
          Returns the raw data of the node; called externally internally.
 V _get(Fqn<?> fqn, K key, boolean sendNodeEvent)
           
<E> java.util.Set<E>
_getChildrenNames(Fqn<E> fqn)
           
 java.util.Map _getData(Fqn<?> fqn)
          Returns the raw data of the node; called externally internally.
 java.util.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
 java.lang.String _print(Fqn fqn)
          Finds and returns the string value for the Fqn.
 java.lang.Object _put(GlobalTransaction tx, Fqn fqn, K key, V value, boolean create_undo_ops)
          Internal put method.
 java.lang.Object _put(GlobalTransaction tx, Fqn fqn, K key, V value, boolean create_undo_ops, DataVersion dv)
           
 void _put(GlobalTransaction tx, Fqn fqn, java.util.Map<K,V> data, boolean create_undo_ops)
          Internal put method.
 void _put(GlobalTransaction tx, Fqn fqn, java.util.Map<K,V> data, boolean create_undo_ops, boolean erase_contents)
          Internal put method.
 void _put(GlobalTransaction tx, Fqn fqn, java.util.Map<K,V> data, boolean create_undo_ops, boolean erase_contents, DataVersion dv)
           
 void _put(GlobalTransaction tx, Fqn fqn, java.util.Map<K,V> data, boolean create_undo_ops, DataVersion dv)
           
 java.lang.Object _put(GlobalTransaction tx, java.lang.String fqn, K key, V value, boolean create_undo_ops)
          Internal put method.
 void _put(GlobalTransaction tx, java.lang.String fqn, java.util.Map<K,V> data, boolean create_undo_ops)
          Internal put method.
 void _putForExternalRead(GlobalTransaction gtx, Fqn fqn, K key, V value)
           
 void _putForExternalRead(GlobalTransaction gtx, Fqn fqn, K key, V value, DataVersion dv)
           
 void _releaseAllLocks(Fqn fqn)
          Releases all locks for a FQN.
 void _remoteAnnounceBuddyPoolName(org.jgroups.Address address, java.lang.String buddyPoolName)
           
 void _remoteAssignToBuddyGroup(BuddyGroup group, java.util.Map<Fqn,byte[]> state)
           
 void _remoteRemoveFromBuddyGroup(java.lang.String groupName)
           
 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 sendNodeEvent, boolean eviction, DataVersion version)
          Internal method to remove a node.
 boolean _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, DataVersion dv)
           
 V _remove(GlobalTransaction tx, Fqn fqn, K key, boolean create_undo_ops)
          Internal method to remove a key.
 java.lang.Object _remove(GlobalTransaction tx, Fqn fqn, K key, boolean create_undo_ops, DataVersion dv)
           
 void _remove(GlobalTransaction tx, java.lang.String fqn, boolean create_undo_ops)
          Internal remove method.
 V _remove(GlobalTransaction tx, java.lang.String fqn, K 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, java.lang.String fqn, boolean create_undo_ops)
          Internal method to remove data from a node.
 void _replicate(java.util.List<MethodCall> methodCalls)
          Replicates a list of method calls.
 java.lang.Object _replicate(MethodCall method_call)
          Replicates changes across to other nodes in the cluster.
 void _unblock()
           
 void addCacheListener(Fqn<?> region, java.lang.Object listener)
          Adds a CacheListener to a given region.
 void addCacheListener(java.lang.Object listener)
          Adds a CacheListener to the entire cache.
 void addInterceptor(Interceptor i, int position)
          Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the chain is at position 0 and the last one at getInterceptorChain().size() - 1.
 void addUndoOperation(GlobalTransaction gtx, MethodCall undo_op)
          Adds an undo operatoin to the transaction table.
 java.util.List callRemoteMethods(java.util.List<org.jgroups.Address> mbrs, MethodCall method_call, boolean synchronous, boolean exclude_self, long timeout)
          Deprecated. Note this is due to be moved to an interceptor.
 java.util.List callRemoteMethods(java.util.List<org.jgroups.Address> mbrs, MethodCall method_call, int mode, boolean exclude_self, long timeout)
          Deprecated. Note this is due to be moved to an interceptor.
 java.util.List callRemoteMethods(java.util.List<org.jgroups.Address> members, java.lang.reflect.Method method, java.lang.Object[] args, boolean synchronous, boolean exclude_self, long timeout)
          Deprecated. Note this is due to be moved to an interceptor.
 java.util.List callRemoteMethods(java.util.Vector<org.jgroups.Address> members, java.lang.String method_name, java.lang.Class[] types, java.lang.Object[] args, boolean synchronous, boolean exclude_self, long timeout)
          Deprecated. Note this is due to be moved to an interceptor.
 void commit(GlobalTransaction tx)
          Throws UnsupportedOperationException.
 void create()
          Lifecycle method.
protected  void createEvictionPolicy()
           
protected  Node createSubtreeRootNode(Fqn<?> subtree)
          Creates a subtree in the local cache.
 void destroy()
          Lifecycle method.
 java.lang.String dumpTransactionTable()
          Returns the contents of the TransactionTable as a string.
 void evict(Fqn fqn)
          Called by eviction policy provider.
 void evict(Fqn<?> fqn, boolean recursive)
          Eviction call that evicts the specified Node from memory.
 boolean exists(Fqn<?> fqn)
          Checks whether a given node exists in current in-memory state of the cache.
 boolean exists(Fqn<?> fqn, java.lang.Object key)
          Checks whether a given key exists in the given node.
 boolean exists(java.lang.String fqn)
          Checks whether a given node exists in current in-memory state of the cache.
 boolean exists(java.lang.String fqn, java.lang.Object key)
           
 void fetchState(long timeout)
          Fetches the group state from the current coordinator.
protected  void fetchStateOnStartup()
           
 NodeSPI<K,V> findNode(Fqn fqn)
          Finds a node given a fully qualified name.
 Node<K,V> get(Fqn<?> fqn)
          Returns a DataNode corresponding to the fully qualified name or null if does not exist.
 V get(Fqn<?> fqn, K key)
          Finds a node given its name and returns the value associated with a given key in its data map.
protected  V get(Fqn<?> fqn, K key, boolean sendNodeEvent)
           
 Node get(java.lang.String fqn)
           
 V get(java.lang.String fqn, K key)
          Finds a node given its name and returns the value associated with a given key in its data map.
 BuddyManager getBuddyManager()
          Retrieves the Buddy Manager configured.
 java.util.Set<java.lang.Object> getCacheListeners()
          Retrieves an immutable List of objects annotated as CacheListeners attached to the cache.
 java.util.Set<java.lang.Object> getCacheListeners(Fqn<?> region)
          Retrieves an immutable List of objects annotated as CacheListeners attached to a specific region.
 CacheLoader getCacheLoader()
          Returns the underlying cache loader in use.
 CacheLoaderManager getCacheLoaderManager()
          Returns the CacheLoaderManager.
 CacheStatus getCacheStatus()
          Gets where the cache currently is its lifecycle transitions.
<E> java.util.Set<E>
getChildrenNames(Fqn<E> fqn)
          Returns all children of a given node.
 java.util.Set getChildrenNames(java.lang.String fqn)
          Returns all children of a given node.
 java.lang.String getClusterName()
           
 Configuration getConfiguration()
          Retrieves the configuration of this cache.
 org.jgroups.Address getCoordinator()
          Returns the address of the coordinator or null if there is no coordinator.
 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(javax.transaction.Transaction tx)
          Returns the global transaction for this local transaction.
 GlobalTransaction getCurrentTransaction(javax.transaction.Transaction tx, boolean createIfNotExists)
          Returns the global transaction for this local transaction.
protected  java.lang.String getDefaultProperties()
          Returns the default JGroup properties.
 java.lang.String getEvictionInterceptorClass()
           
 java.util.List<Interceptor> getInterceptorChain()
           
 java.util.List<Interceptor> getInterceptors()
           
 java.util.Set<Fqn> getInternalFqns()
          Returns a Set of Fqns of the topmost node of internal regions that should not included in standard state transfers.
 InvocationContext getInvocationContext()
           
 java.util.Set<K> getKeys(Fqn<?> fqn)
          Returns a set of attribute keys for the Fqn.
 java.util.Set getKeys(java.lang.String fqn)
          Returns a set of attribute keys for the Fqn.
 org.jgroups.Address getLocalAddress()
          Returns the local channel address.
protected  javax.transaction.Transaction getLocalTransaction()
          Returns the transaction associated with the current thread.
 java.util.Map<java.lang.Thread,java.util.List<NodeLock>> getLockTable()
          Returns the lock table.
 Marshaller getMarshaller()
          Retrieves an instance of a Marshaller, which is capable of converting Java objects to bytestreams and back in an efficient manner, which is also interoperable with bytestreams produced/consumed by other versions of JBoss Cache.
 java.util.List<org.jgroups.Address> getMembers()
          Returns the members as a List.
 Notifier getNotifier()
           
 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  java.lang.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)
          Retrieves a Region for a given Fqn.
 RegionManager getRegionManager()
           
 ReplicationQueue getReplicationQueue()
          Returns the replication queue.
 NodeSPI<K,V> getRoot()
          Returns the root node.
 RPCManager getRPCManager()
          Gets a handle of the RPC manager.
 StateTransferManager getStateTransferManager()
           
 javax.transaction.TransactionManager getTransactionManager()
          Returns the transaction manager in use.
 TransactionTable getTransactionTable()
          Returns the transaction table.
 java.lang.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.
protected  java.lang.Object invokeMethod(MethodCall m, boolean originLocal)
          Invokes a method against this object.
 boolean isCoordinator()
          Returns true if this node is the group coordinator.
 boolean isStarted()
           
 void killChannel()
          Kills the JGroups channel; an unclean channel disconnect
 void load(java.lang.String fqn)
          Loads the indicated Fqn, plus all parents recursively from the CacheLoader.
 void move(Fqn<?> nodeToMove, Fqn<?> newParent)
          New API to efficiently relocate a node
 void optimisticPrepare(GlobalTransaction gtx, java.util.List modifications, java.util.Map data, org.jgroups.Address address, boolean onePhaseCommit)
          Throws UnsupportedOperationException.
 NodeSPI<K,V> peek(Fqn<?> fqn, boolean includeDeletedNodes)
          Gets node without attempt to load it from CacheLoader if not present
 void prepare(GlobalTransaction global_tx, java.util.List modifications, org.jgroups.Address coord, boolean onePhaseCommit)
          Throws UnsupportedOperationException.
 java.lang.String print(Fqn fqn)
          Prints a representation of the node defined by fqn.
 java.lang.String print(java.lang.String fqn)
          Prints a representation of the node defined by fqn.
 java.lang.String printDetails()
          Prints information about the contents of the nodes in the cache's current in-memory state.
 java.lang.String printLockInfo()
          Returns lock information.
 void purgeCacheLoaders()
          Purges the contents of all configured CacheLoaders
 V put(Fqn<?> fqn, K key, V value)
          Adds a key and value to a given node.
 void put(Fqn<?> fqn, java.util.Map<K,V> data)
          Sets a node's data.
 void put(Fqn<?> fqn, java.util.Map<K,V> data, boolean erase)
           
 V put(java.lang.String fqn, K key, V value)
          Adds a key and value to a given node.
 void put(java.lang.String fqn, java.util.Map data)
          Adds a new node to the cache and sets its data.
 void putForExternalRead(Fqn<?> fqn, K key, V value)
          Under special operating behavior, associates the value with the specified key for a node identified by the Fqn passed in.
 boolean realRemove(Fqn f, boolean skipMarkerCheck)
          Internal method; not to be used externally.
 void releaseAllLocks(Fqn fqn)
          Releases all locks for this node and the entire node subtree.
 void releaseAllLocks(java.lang.String fqn)
          Releases all locks for this node and the entire node subtree.
 boolean remove(Fqn fqn)
          Removes the node from the cache.
 V remove(Fqn<?> fqn, K key)
          Removes key from the node's hashmap
 void remove(java.lang.String fqn)
          Removes the node from the cache.
 V remove(java.lang.String fqn, K key)
          Removes key from the node's hashmap
 void removeCacheListener(Fqn<?> region, java.lang.Object listener)
          Removes a CacheListener from a given region.
 void removeCacheListener(java.lang.Object listener)
          Removes a CacheListener from the cache.
 void removeData(Fqn fqn)
          Removes the keys and properties from a named node.
 void removeData(java.lang.String fqn)
          Removes the keys and properties from a node.
 void removeInterceptor(int position)
          Removes the interceptor at a specified position, where the first interceptor in the chain is at position 0 and the last one at getInterceptorChain().size() - 1.
 boolean removeNode(Fqn<?> fqn)
          Removes a Node indicated by absolute Fqn.
 boolean removeRegion(Fqn<?> fqn)
          Removes a region denoted by the Fqn passed in.
 void rollback(GlobalTransaction tx)
          Throws UnsupportedOperationException.
 void setCacheLoader(CacheLoader loader)
          Deprecated. only provided for backward compat
 void setCacheLoaderManager(CacheLoaderManager cacheLoaderManager)
          Sets the CacheLoaderManager.
 void setConfiguration(Configuration configuration)
           
 void setInterceptorChain(Interceptor i)
          Used for testing only - sets the interceptor chain.
 void setInvocationContext(InvocationContext ctx)
          Sets the passed in InvocationContext as current.
protected  void setMessageListener(CacheImpl.MessageListenerAdaptor ml)
           
 void setStateTransferManager(StateTransferManager manager)
           
 void setTransactionManagerLookup(TransactionManagerLookup l)
          Sets the TransactionManagerLookup object
protected  boolean shouldFetchStateOnStartup()
           
 void start()
          Lifecyle method.
 void stop()
          Lifecycle method.
 java.lang.String toString()
          Returns a debug string with few details.
 java.lang.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
 

Field Detail

channel

protected org.jgroups.Channel channel
The JGroups JChannel in use.

Constructor Detail

CacheImpl

protected CacheImpl()
             throws java.lang.Exception
Constructs an uninitialized CacheImpl.

Throws:
java.lang.Exception
Method Detail

getStateTransferManager

public StateTransferManager getStateTransferManager()
Specified by:
getStateTransferManager in interface CacheSPI<K,V>
Returns:
the current StateTransferManager

setStateTransferManager

public void setStateTransferManager(StateTransferManager manager)

getConfiguration

public Configuration getConfiguration()
Description copied from interface: Cache
Retrieves the configuration of this cache.

Specified by:
getConfiguration in interface Cache<K,V>
Returns:
the configuration.

getVersion

public java.lang.String getVersion()
Returns the CacheImpl implementation version.

Specified by:
getVersion in interface Cache<K,V>
Returns:
the version string of the cache.
See Also:
Version.printVersion()

getRoot

public NodeSPI<K,V> getRoot()
Returns the root node.

Specified by:
getRoot in interface Cache<K,V>
Specified by:
getRoot in interface CacheSPI<K,V>
Returns:
the root node

getLocalAddress

public org.jgroups.Address getLocalAddress()
Returns the local channel address.

Specified by:
getLocalAddress in interface Cache<K,V>
Returns:
the local address of this cache in a cluster, or null if running in local mode.

getMembers

public java.util.List<org.jgroups.Address> getMembers()
Returns the members as a List. This list may be concurrently modified.

Specified by:
getMembers in interface Cache<K,V>
Returns:
a List of members in the cluster, or null if running in local mode.

isCoordinator

public boolean isCoordinator()
Returns true if this node is the group coordinator.


getTransactionTable

public TransactionTable getTransactionTable()
Returns the transaction table.

Specified by:
getTransactionTable in interface CacheSPI<K,V>
Returns:
the current TransactionTable

getLockTable

public java.util.Map<java.lang.Thread,java.util.List<NodeLock>> getLockTable()
Returns the lock table.

Specified by:
getLockTable in interface CacheSPI<K,V>
Returns:
lock table.

dumpTransactionTable

public java.lang.String dumpTransactionTable()
Returns the contents of the TransactionTable as a string.


setInterceptorChain

public void setInterceptorChain(Interceptor i)
Used for testing only - sets the interceptor chain.


getInterceptors

public java.util.List<Interceptor> getInterceptors()
Returns:
the list of interceptors.

getCacheLoader

public CacheLoader getCacheLoader()
Returns the underlying cache loader in use.


getEvictionInterceptorClass

public java.lang.String getEvictionInterceptorClass()

getReplicationQueue

public ReplicationQueue getReplicationQueue()
Returns the replication queue.


setTransactionManagerLookup

public void setTransactionManagerLookup(TransactionManagerLookup l)
Sets the TransactionManagerLookup object


getTransactionManager

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

Specified by:
getTransactionManager in interface CacheSPI<K,V>
Returns:
a TransactionManager

fetchState

public void fetchState(long timeout)
                throws org.jgroups.ChannelClosedException,
                       org.jgroups.ChannelNotConnectedException
Fetches the group state from the current coordinator. If successful, this will trigger JChannel setState() call.

Throws:
org.jgroups.ChannelClosedException
org.jgroups.ChannelNotConnectedException

create

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

Specified by:
create in interface Cache<K,V>
Throws:
java.lang.Exception
CacheException - if there are creation problems

shouldFetchStateOnStartup

protected boolean shouldFetchStateOnStartup()

start

public void start()
           throws CacheException
Lifecyle method.

Specified by:
start in interface Cache<K,V>
Throws:
CacheException

destroy

public void destroy()
Lifecycle method.

Specified by:
destroy in interface Cache<K,V>

stop

public void stop()
Lifecycle method.

Specified by:
stop in interface Cache<K,V>

getCacheStatus

public CacheStatus getCacheStatus()
Description copied from interface: Cache
Gets where the cache currently is its lifecycle transitions.

Specified by:
getCacheStatus in interface Cache<K,V>
Returns:
the CacheStatus. Will not return null.

getBuddyManager

public BuddyManager getBuddyManager()
Retrieves the Buddy Manager configured.

Specified by:
getBuddyManager in interface CacheSPI<K,V>
Returns:
null if buddy replication is not enabled.

getInternalFqns

public java.util.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.

createEvictionPolicy

protected void createEvictionPolicy()

load

public void load(java.lang.String fqn)
          throws java.lang.Exception
Loads the indicated Fqn, plus all parents recursively from the CacheLoader. If no CacheLoader is present, this is a no-op

Parameters:
fqn -
Throws:
java.lang.Exception

getCoordinator

public org.jgroups.Address getCoordinator()
Returns the address of the coordinator or null if there is no coordinator. Waits until the membership view is updated.


createSubtreeRootNode

protected Node createSubtreeRootNode(Fqn<?> subtree)
                              throws CacheException
Creates a subtree in the local cache. Returns the DataNode created.

Throws:
CacheException

_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

fetchStateOnStartup

protected void fetchStateOnStartup()
                            throws java.lang.Exception
Throws:
java.lang.Exception

get

public Node get(java.lang.String fqn)
         throws CacheException
Parameters:
fqn - fqn String name to retrieve from cache
Returns:
DataNode corresponding to the fqn. Null if does not exist. No guarantees wrt replication, cache loading are given if the underlying node is modified
Throws:
CacheException

get

public Node<K,V> get(Fqn<?> fqn)
              throws CacheException
Returns a DataNode corresponding to the fully qualified name or null if does not exist. No guarantees wrt replication, cache loading are given if the underlying node is modified

Parameters:
fqn - name of the DataNode to retreive
Throws:
CacheException

_get

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

Throws:
CacheException

_getData

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


getKeys

public java.util.Set getKeys(java.lang.String fqn)
                      throws CacheException
Returns a set of attribute keys for the Fqn. Returns null if the node is not found, otherwise a Set. The set is a copy of the actual keys for this node.

Parameters:
fqn - name of the node
Throws:
CacheException

getKeys

public java.util.Set<K> getKeys(Fqn<?> fqn)
                         throws CacheException
Returns a set of attribute keys for the Fqn. Returns null if the node is not found, otherwise a Set. The set is a copy of the actual keys for this node.

Parameters:
fqn - name of the node
Throws:
CacheException

_getKeys

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

get

public V get(java.lang.String fqn,
             K key)
      throws CacheException
Finds a node given its name and returns the value associated with a given key in its data map. Returns null if the node was not found in the cache or the key was not found in the hashmap.

Parameters:
fqn - The fully qualified name of the node.
key - The key.
Throws:
CacheException

get

public V get(Fqn<?> fqn,
             K key)
      throws CacheException
Finds a node given its name and returns the value associated with a given key in its data map. Returns null if the node was not found in the cache or the key was not found in the hashmap.

Specified by:
get in interface Cache<K,V>
Parameters:
fqn - The fully qualified name of the node.
key - The key.
Returns:
returns data held under specified key in Node denoted by specified Fqn.
Throws:
CacheException

_get

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

get

protected V get(Fqn<?> fqn,
                K key,
                boolean sendNodeEvent)
         throws CacheException
Throws:
CacheException

exists

public boolean exists(java.lang.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<K,V> peek(Fqn<?> fqn,
                         boolean includeDeletedNodes)
Gets node without attempt to load it from CacheLoader if not present

Specified by:
peek in interface CacheSPI<K,V>
Parameters:
fqn -
includeDeletedNodes - if you intend to see nodes marked as deleted within the current tx, set this to true
Returns:
a node if one exists or null

exists

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

exists

public boolean exists(Fqn<?> fqn,
                      java.lang.Object key)
Checks whether a given key exists in the given node. Does not interact with CacheLoader, so the behavior is different from get(Fqn,Object)

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

put

public void put(java.lang.String fqn,
                java.util.Map data)
         throws CacheException
Adds a new node to the cache and sets its data. If the node doesn not yet exist, it will be created. Also, parent nodes will be created if not existent. If the node already has data, then the new data will override the old one. If the node already existed, a nodeModified() notification will be generated. Otherwise a nodeCreated() motification will be emitted.

Parameters:
fqn - The fully qualified name of the new node
data - The new data. May be null if no data should be set in the node.
Throws:
CacheException

put

public void put(Fqn<?> fqn,
                java.util.Map<K,V> data)
         throws CacheException
Sets a node's data. If the node does not yet exist, it will be created. Also, parent nodes will be created if not existent. If the node already has data, then the new data will override the old one. If the node already existed, a nodeModified() notification will be generated. Otherwise a nodeCreated() motification will be emitted.

Specified by:
put in interface Cache<K,V>
Parameters:
fqn - The fully qualified name of the new node
data - The new data. May be null if no data should be set in the node.
Throws:
CacheException

put

public void put(Fqn<?> fqn,
                java.util.Map<K,V> data,
                boolean erase)
         throws CacheException
Throws:
CacheException

put

public V put(java.lang.String fqn,
             K key,
             V value)
      throws CacheException
Adds a key and value to a given node. If the node doesn't exist, it will be created. If the node already existed, a nodeModified() notification will be generated. Otherwise a nodeCreated() motification will be emitted.

Parameters:
fqn - The fully qualified name of the node
key - The key
value - The value
Returns:
Object The previous value (if any), if node was present
Throws:
CacheException

put

public V put(Fqn<?> fqn,
             K key,
             V value)
      throws CacheException
Adds a key and value to a given node. If the node doesn't exist, it will be created. If the node already existed, a nodeModified() notification will be generated. Otherwise a nodeCreated() motification will be emitted.

Specified by:
put in interface Cache<K,V>
Parameters:
fqn - The fully qualified name of the node
key - The key
value - The value
Returns:
Object The previous value (if any), if node was present
Throws:
CacheException

remove

public void remove(java.lang.String fqn)
            throws CacheException
Removes the node from the cache.

Parameters:
fqn - The fully qualified name of the node.
Throws:
CacheException

remove

public boolean remove(Fqn fqn)
               throws CacheException
Removes the node from the cache.

Parameters:
fqn - The fully qualified name of the node.
Throws:
CacheException

evict

public void evict(Fqn fqn)
           throws CacheException
Called by eviction policy provider. Note that eviction is done only in local mode, that is, it doesn't replicate the node removal. This will cause the replication nodes to not be synchronizing, which is fine since the value will be fetched again when get(java.lang.String) returns null. After that, the contents will be in sync.

Parameters:
fqn - Will remove everythign assoicated with this fqn.
Throws:
CacheException

remove

public V remove(java.lang.String fqn,
                K key)
         throws CacheException
Removes key from the node's hashmap

Parameters:
fqn - The fullly qualified name of the node
key - The key to be removed
Returns:
The previous value, or null if none was associated with the given key
Throws:
CacheException

remove

public V remove(Fqn<?> fqn,
                K key)
         throws CacheException
Removes key from the node's hashmap

Specified by:
remove in interface Cache<K,V>
Parameters:
fqn - The fullly qualified name of the node
key - The key to be removed
Returns:
The previous value, or null if none was associated with the given key
Throws:
CacheException

removeData

public void removeData(java.lang.String fqn)
                throws CacheException
Removes the keys and properties from a node.

Throws:
CacheException

removeData

public void removeData(Fqn fqn)
                throws CacheException
Removes the keys and properties from a named node.

Throws:
CacheException

releaseAllLocks

public void releaseAllLocks(java.lang.String fqn)
Releases all locks for this node and the entire node subtree.


releaseAllLocks

public void releaseAllLocks(Fqn fqn)
Releases all locks for this node and the entire node subtree.


print

public java.lang.String print(java.lang.String fqn)
Prints a representation of the node defined by fqn. Output includes name, fqn and data.


print

public java.lang.String print(Fqn fqn)
Prints a representation of the node defined by fqn. Output includes name, fqn and data.


getChildrenNames

public java.util.Set getChildrenNames(java.lang.String fqn)
                               throws CacheException
Returns all children of a given node. Returns null of the parent node was not found, or if there are no children. The set is unmodifiable.

Parameters:
fqn - The fully qualified name of the node
Returns:
Set A list of child names (as Strings)
Throws:
CacheException
See Also:
getChildrenNames(Fqn)

getChildrenNames

public <E> java.util.Set<E> getChildrenNames(Fqn<E> fqn)
                                  throws CacheException
Returns all children of a given node. Returns an empty set if there are no children. The set is unmodifiable.

Parameters:
fqn - The fully qualified name of the node
Returns:
Set an unmodifiable set of children names, Object.
Throws:
CacheException

_getChildrenNames

public <E> java.util.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 java.lang.String toString()
Returns a debug string with few details.

Overrides:
toString in class java.lang.Object

toString

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


printDetails

public java.lang.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 java.lang.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

Specified by:
getNumberOfNodes in interface CacheSPI<K,V>
Returns:
the number of nodes in the cache.

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

Specified by:
getNumberOfAttributes in interface CacheSPI<K,V>
Returns:
the number of attributes in the cache.

getNumberOfAttributes

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

See Also:
getNumberOfAttributes()

callRemoteMethods

@Deprecated
public java.util.List callRemoteMethods(java.util.List<org.jgroups.Address> mbrs,
                                                   MethodCall method_call,
                                                   boolean synchronous,
                                                   boolean exclude_self,
                                                   long timeout)
                                 throws java.lang.Exception
Deprecated. Note this is due to be moved to an interceptor.

Parameters:
mbrs -
method_call -
synchronous -
exclude_self -
timeout -
Returns:
Throws:
java.lang.Exception

callRemoteMethods

@Deprecated
public java.util.List callRemoteMethods(java.util.List<org.jgroups.Address> mbrs,
                                                   MethodCall method_call,
                                                   int mode,
                                                   boolean exclude_self,
                                                   long timeout)
                                 throws java.lang.Exception
Deprecated. Note this is due to be moved to an interceptor.

Overloaded to allow a finer grained control over JGroups mode

Parameters:
mbrs -
method_call -
mode -
exclude_self -
timeout -
Returns:
Throws:
java.lang.Exception

callRemoteMethods

@Deprecated
public java.util.List callRemoteMethods(java.util.List<org.jgroups.Address> members,
                                                   java.lang.reflect.Method method,
                                                   java.lang.Object[] args,
                                                   boolean synchronous,
                                                   boolean exclude_self,
                                                   long timeout)
                                 throws java.lang.Exception
Deprecated. Note this is due to be moved to an interceptor.

Parameters:
members -
method -
args -
synchronous -
exclude_self -
timeout -
Returns:
Throws:
java.lang.Exception

callRemoteMethods

@Deprecated
public java.util.List callRemoteMethods(java.util.Vector<org.jgroups.Address> members,
                                                   java.lang.String method_name,
                                                   java.lang.Class[] types,
                                                   java.lang.Object[] args,
                                                   boolean synchronous,
                                                   boolean exclude_self,
                                                   long timeout)
                                 throws java.lang.Exception
Deprecated. Note this is due to be moved to an interceptor.

Parameters:
members -
method_name -
types -
args -
synchronous -
exclude_self -
timeout -
Returns:
Throws:
java.lang.Exception

_putForExternalRead

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

_put

public void _put(GlobalTransaction tx,
                 Fqn fqn,
                 java.util.Map<K,V> data,
                 boolean create_undo_ops,
                 DataVersion dv)
          throws CacheException
Throws:
CacheException

_put

public void _put(GlobalTransaction tx,
                 Fqn fqn,
                 java.util.Map<K,V> data,
                 boolean create_undo_ops,
                 boolean erase_contents,
                 DataVersion dv)
          throws CacheException
Throws:
CacheException

_put

public java.lang.Object _put(GlobalTransaction tx,
                             Fqn fqn,
                             K key,
                             V 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 java.lang.Object _remove(GlobalTransaction tx,
                                Fqn fqn,
                                K 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,
                 java.lang.String fqn,
                 java.util.Map<K,V> 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,
                 java.util.Map<K,V> 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,
                 java.util.Map<K,V> 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 java.lang.Object _put(GlobalTransaction tx,
                             java.lang.String fqn,
                             K key,
                             V value,
                             boolean create_undo_ops)
                      throws CacheException
Internal put method.

Returns:
Previous value (if any)
Throws:
CacheException

_put

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

Returns:
Previous value (if any)
Throws:
CacheException

_remove

public void _remove(GlobalTransaction tx,
                    java.lang.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 sendNodeEvent,
                       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 -
sendNodeEvent -
eviction -
version -
Returns:
true if the node was removed, false if not found
Throws:
CacheException

_remove

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

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

_remove

public V _remove(GlobalTransaction tx,
                 Fqn fqn,
                 K 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,
                        java.lang.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

_addChild

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

Throws:
CacheException

_replicate

public java.lang.Object _replicate(MethodCall method_call)
                            throws java.lang.Throwable
Replicates changes across to other nodes in the cluster. Invoked by the ReplicationInterceptor. Calls need to be forwarded to the ReplicationInterceptor in this interceptor chain. This method will later be moved entirely into the ReplicationInterceptor.

Throws:
java.lang.Throwable

_replicate

public void _replicate(java.util.List<MethodCall> methodCalls)
                throws java.lang.Throwable
Replicates a list of method calls.

Throws:
java.lang.Throwable

_clusteredGet

public java.util.List _clusteredGet(MethodCall methodCall,
                                    java.lang.Boolean searchBackupSubtrees)
A 'clustered get' call, called from a remote ClusteredCacheLoader.

Returns:
a List containing 2 elements: (true or false) and a value (Object). If buddy replication is used one further element is added - an Fqn of the backup subtree in which this node may be found.

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.

Specified by:
gravitateData in interface CacheSPI<K,V>
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

_remoteAssignToBuddyGroup

public void _remoteAssignToBuddyGroup(BuddyGroup group,
                                      java.util.Map<Fqn,byte[]> state)
                               throws java.lang.Exception
Throws:
java.lang.Exception

_remoteRemoveFromBuddyGroup

public void _remoteRemoveFromBuddyGroup(java.lang.String groupName)
                                 throws BuddyNotInitException
Throws:
BuddyNotInitException

_remoteAnnounceBuddyPoolName

public void _remoteAnnounceBuddyPoolName(org.jgroups.Address address,
                                         java.lang.String buddyPoolName)

_dataGravitationCleanup

public void _dataGravitationCleanup(GlobalTransaction gtx,
                                    Fqn primary,
                                    Fqn backup)
                             throws java.lang.Exception
Throws:
java.lang.Exception

_releaseAllLocks

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


_print

public java.lang.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,
                              java.util.List modifications,
                              java.util.Map data,
                              org.jgroups.Address address,
                              boolean onePhaseCommit)
Throws UnsupportedOperationException.


prepare

public void prepare(GlobalTransaction global_tx,
                    java.util.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.


getCacheLoaderManager

public CacheLoaderManager getCacheLoaderManager()
Returns the CacheLoaderManager.

Specified by:
getCacheLoaderManager in interface CacheSPI<K,V>
Returns:
Retrieves a reference to the currently configured CacheLoaderManager if one or more cache loaders are configured, null otherwise.

setCacheLoaderManager

public void setCacheLoaderManager(CacheLoaderManager cacheLoaderManager)
Sets the CacheLoaderManager.


setConfiguration

public void setConfiguration(Configuration configuration)

getNotifier

public Notifier getNotifier()
Specified by:
getNotifier in interface CacheSPI<K,V>
Returns:
an instance of Notifier which has been configured with this instance of CacheImpl.

getInvocationContext

public InvocationContext getInvocationContext()
Specified by:
getInvocationContext in interface Cache<K,V>
Returns:
the current invocation context for the current invocation and cache instance.
See Also:
InvocationContext

setInvocationContext

public void setInvocationContext(InvocationContext ctx)
Description copied from interface: Cache
Sets the passed in InvocationContext as current.

Specified by:
setInvocationContext in interface Cache<K,V>
Parameters:
ctx - invocation context to use

move

public void move(Fqn<?> nodeToMove,
                 Fqn<?> newParent)
New API to efficiently relocate a node

Specified by:
move in interface Cache<K,V>
Parameters:
nodeToMove - the Fqn of the node to move.
newParent - new location under which to attach the node being moved.
Since:
2.0.0

_move

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

Parameters:
newParentFqn -
nodeToMoveFqn -

_block

public void _block()

_unblock

public void _unblock()

killChannel

public void killChannel()
Kills the JGroups channel; an unclean channel disconnect


getLocalTransaction

protected javax.transaction.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(javax.transaction.Transaction tx)
Returns the global transaction for this local transaction.


getCurrentTransaction

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

Specified by:
getCurrentTransaction in interface CacheSPI<K,V>
Parameters:
createIfNotExists - if true, if a global transaction is not found; one is created
tx - the current transaction
Returns:
a GlobalTransaction

invokeMethod

protected java.lang.Object invokeMethod(MethodCall m,
                                        boolean originLocal)
                                 throws CacheException
Invokes a method against this object. Contains the logger_ic for handling the various use cases, e.g. mode (local, repl_async, repl_sync), transaction (yes or no) and locking (yes or no).

Only sets originLocal on the invocation context IF this is explicitly passed in as false If passed in as true then it is not set; but whatever default exists in the invocation context is used. For example, it may be set prior to calling invokeMethod()

Throws:
CacheException

getOwnerForLock

protected java.lang.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<K,V> 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 -

getRegionManager

public RegionManager getRegionManager()
Specified by:
getRegionManager in interface CacheSPI<K,V>
Returns:
the RegionManager

getMarshaller

public Marshaller getMarshaller()
Description copied from interface: CacheSPI
Retrieves an instance of a Marshaller, which is capable of converting Java objects to bytestreams and back in an efficient manner, which is also interoperable with bytestreams produced/consumed by other versions of JBoss Cache.

The use of this marshaller is the recommended way of creating efficient, compatible, byte streams from objects.

Specified by:
getMarshaller in interface CacheSPI<K,V>
Returns:
an instance of Marshaller

getDefaultProperties

protected java.lang.String getDefaultProperties()
Returns the default JGroup properties. Subclasses may wish to override this method.


setCacheLoader

@Deprecated
public void setCacheLoader(CacheLoader loader)
Deprecated. only provided for backward compat

Sets the CacheLoader to use. Provided for backwards compatibility.

Parameters:
loader -

purgeCacheLoaders

public void purgeCacheLoaders()
                       throws java.lang.Exception
Purges the contents of all configured CacheLoaders

Throws:
java.lang.Exception

getInterceptorChain

public java.util.List<Interceptor> getInterceptorChain()
Specified by:
getInterceptorChain in interface CacheSPI<K,V>
Returns:
an immutable List of Interceptors configured for this cache, or null if create() has not been invoked and the interceptors thus do not exist.

addCacheListener

public void addCacheListener(java.lang.Object listener)
Description copied from interface: Cache
Adds a CacheListener to the entire cache. The object passed in needs to be properly annotated with the @org.jboss.cache.notifications.annotation.CacheListener annotation otherwise an IncorrectCacheListenerException will be thrown.

Specified by:
addCacheListener in interface Cache<K,V>
Parameters:
listener - listener to add

addCacheListener

public void addCacheListener(Fqn<?> region,
                             java.lang.Object listener)
Description copied from interface: Cache
Adds a CacheListener to a given region. The object passed in needs to be properly annotated with the @org.jboss.cache.notifications.annotation.CacheListener annotation otherwise an IncorrectCacheListenerException will be thrown.

Specified by:
addCacheListener in interface Cache<K,V>
Parameters:
region - region to add listener to
listener - listener to add

removeCacheListener

public void removeCacheListener(java.lang.Object listener)
Description copied from interface: Cache
Removes a CacheListener from the cache. The object passed in needs to be properly annotated with the @org.jboss.cache.notifications.annotation.CacheListener annotation otherwise an IncorrectCacheListenerException will be thrown.

Specified by:
removeCacheListener in interface Cache<K,V>
Parameters:
listener - listener to remove

removeCacheListener

public void removeCacheListener(Fqn<?> region,
                                java.lang.Object listener)
Description copied from interface: Cache
Removes a CacheListener from a given region. The object passed in needs to be properly annotated with the @org.jboss.cache.notifications.annotation.CacheListener annotation otherwise an IncorrectCacheListenerException will be thrown.

Specified by:
removeCacheListener in interface Cache<K,V>
Parameters:
region - region from which to remove listener
listener - listener to remove

getCacheListeners

public java.util.Set<java.lang.Object> getCacheListeners()
Description copied from interface: Cache
Retrieves an immutable List of objects annotated as CacheListeners attached to the cache.

Specified by:
getCacheListeners in interface Cache<K,V>
Returns:
an immutable List of objects annotated as CacheListeners attached to the cache.

getCacheListeners

public java.util.Set<java.lang.Object> getCacheListeners(Fqn<?> region)
Description copied from interface: Cache
Retrieves an immutable List of objects annotated as CacheListeners attached to a specific region.

Specified by:
getCacheListeners in interface Cache<K,V>
Returns:
an immutable List of objects annotated as CacheListeners attached to a specific region.

addInterceptor

public void addInterceptor(Interceptor i,
                           int position)
Description copied from interface: CacheSPI
Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the chain is at position 0 and the last one at getInterceptorChain().size() - 1.

Specified by:
addInterceptor in interface CacheSPI<K,V>
Parameters:
i - the interceptor to add
position - the position to add the interceptor

removeInterceptor

public void removeInterceptor(int position)
Description copied from interface: CacheSPI
Removes the interceptor at a specified position, where the first interceptor in the chain is at position 0 and the last one at getInterceptorChain().size() - 1.

Specified by:
removeInterceptor in interface CacheSPI<K,V>
Parameters:
position - the position at which to remove an interceptor

getRPCManager

public RPCManager getRPCManager()
Description copied from interface: CacheSPI
Gets a handle of the RPC manager.

Specified by:
getRPCManager in interface CacheSPI<K,V>
Returns:
the RPCManager configured.

getClusterName

public java.lang.String getClusterName()
Specified by:
getClusterName in interface CacheSPI<K,V>
Returns:
the name of the cluster. Null if running in local mode.

evict

public void evict(Fqn<?> fqn,
                  boolean recursive)
Description copied from interface: Cache
Eviction call that evicts the specified Node from memory.

Specified by:
evict in interface Cache<K,V>
Parameters:
fqn - absolute Fqn to the Node to be evicted.
recursive - evicts children as well

getRegion

public Region getRegion(Fqn<?> fqn,
                        boolean createIfAbsent)
Description copied from interface: Cache
Retrieves a Region for a given Fqn. If the region does not exist, and
  • createIfAbsent
  • is true, then one is created.

    If not, parent Fqns will be consulted in turn for registered regions, gradually working up to Fqn.ROOT. If no regions are defined in any of the parents either, a null is returned.

    Specified by:
    getRegion in interface Cache<K,V>
    Parameters:
    fqn - Fqn that is contained in a region.
    createIfAbsent - If true, will create a new associated region if not found.
    Returns:
    a MarshRegion. Null if none is found.
    See Also:
    Region

    removeRegion

    public boolean removeRegion(Fqn<?> fqn)
    Description copied from interface: Cache
    Removes a region denoted by the Fqn passed in.

    Specified by:
    removeRegion in interface Cache<K,V>
    Parameters:
    fqn - of the region to remove
    Returns:
    true if a region did exist and was removed; false otherwise.

    removeNode

    public boolean removeNode(Fqn<?> fqn)
    Description copied from interface: Cache
    Removes a Node indicated by absolute Fqn.

    Specified by:
    removeNode in interface Cache<K,V>
    Parameters:
    fqn - Node to remove
    Returns:
    true if the node was removed, false if the node was not found

    putForExternalRead

    public void putForExternalRead(Fqn<?> fqn,
                                   K key,
                                   V value)
    Description copied from interface: Cache
    Under special operating behavior, associates the value with the specified key for a node identified by the Fqn passed in. This method is for caching data that has an external representation in storage, where, concurrent modification and transactions are not a consideration, and failure to put the data in the cache should be treated as a 'suboptimal outcome' rather than a 'failing outcome'.

    An example of when this method is useful is when data is read from, for example, a legacy datastore, and is cached before returning the data to the caller. Subsequent calls would prefer to get the data from the cache and if the data doesn't exist in the cache, fetch again from the legacy datastore.

    See JBCACHE-848 for details around this feature.

    Specified by:
    putForExternalRead in interface Cache<K,V>
    Parameters:
    fqn - absolute Fqn to the Node to be accessed.
    key - key with which the specified value is to be associated.
    value - value to be associated with the specified key.

    _putForExternalRead

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

    isStarted

    public boolean isStarted()

    setMessageListener

    protected void setMessageListener(CacheImpl.MessageListenerAdaptor ml)