org.jboss.cache
Class TreeCache

java.lang.Object
  |
  +--org.jboss.mx.util.JBossNotificationBroadcasterSupport
        |
        +--org.jboss.system.ServiceMBeanSupport
              |
              +--org.jboss.cache.TreeCache
All Implemented Interfaces:
java.lang.Cloneable, javax.management.MBeanRegistration, org.jgroups.MembershipListener, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, org.jboss.system.Service, org.jboss.system.ServiceMBean, TreeCacheMBean
Direct Known Subclasses:
MarshalledTreeCache, RpcTreeCache, TreeCacheAop

public class TreeCache
extends org.jboss.system.ServiceMBeanSupport
implements TreeCacheMBean, java.lang.Cloneable, org.jgroups.MembershipListener

A tree-like structure that is replicated across several members. Updates will be multicast to all group members reliably and in the same order. User has the option to set transaction isolation level now (e.g., SERIALIZABLE, or REPEATABLE_READ.

Version:
$Id: TreeCache.java,v 1.56.2.11.4.6 2006/02/21 18:33:13 bstansberry Exp $

Author:
Bela Ban, Ben Wang, Manik Surtani (manik@jboss.org), Brian Stansberry

Field Summary
protected  java.util.Set activationChangeNodes
          Set of Fqns of nodes that are currently being processed by activateReqion or inactivateRegion.
static java.lang.reflect.Method addChildMethodLocal
           
protected  CacheLoader cache_loader
          A reference to the CacheLoader.
protected  boolean cache_loader_asynchronous
          specifies whether the cache loader needs to be wrapped in the AsyncCacheLoader decorator
protected  java.lang.String cache_loader_class
          The fully qualified name of the CacheLoader (has to implement the CacheLoader interface)
protected  java.util.Properties cache_loader_config
          The properties from which to configure the CacheLoader
protected  boolean cache_loader_fetch_persistent_state
          Fetches the entire persistent state from the underlying CacheLoader.
protected  boolean cache_loader_fetch_transient_state
          Fetches the transient state.
protected  boolean cache_loader_passivate
          Will the cache loader passivate on eviction or persist?
protected  java.util.List cache_loader_preload
          List of nodes to preload (if cache loader is enabled)
protected  boolean cache_loader_shared
          Are the CacheLoaders sharing the same resource or not ?
protected  int cache_mode
           
protected  org.jgroups.JChannel channel
           
protected  java.lang.String cluster_name
           
protected  java.lang.String cluster_props
           
static java.lang.reflect.Method commitMethod
           
protected  boolean coordinator
          Am I the coordinator ?
protected  boolean deadlockDetection
           
static short DEFAULT_REPLICATION_VERSION
           
protected  org.jgroups.blocks.RpcDispatcher disp
           
static java.lang.reflect.Method enqueueMethodCallMethod
           
protected  org.w3c.dom.Element evictConfig_
          Eviction policy configuration in xml Element
protected  java.lang.String eviction_policy_class
           
protected  TreeCacheListener eviction_policy_provider
           
static java.lang.reflect.Method evictNodeMethodLocal
           
protected  boolean fetch_state_on_startup
           
static java.lang.reflect.Method getChildrenNamesMethodLocal
           
static java.lang.reflect.Method getKeysMethodLocal
           
static java.lang.reflect.Method getKeyValueMethodLocal
           
static java.lang.reflect.Method getNodeMethodLocal
           
static java.lang.reflect.Method getPartialStateMethod
           
protected  boolean inactiveOnStartup
           
protected  Interceptor interceptor_chain
          invokeMethod(MethodCall) will dispatch to this chain of interceptors.
protected  IsolationLevel isolationLevel
           
protected  boolean isStateSet
           
static int LOCAL
          Entries in the cache are by default local; ie.
protected  long lock_acquisition_timeout
           
static java.lang.reflect.Method lockMethodLocal
           
protected static org.apache.commons.logging.Log log
           
protected  TreeCacheMarshaller marshaller_
          Marshaller if register to handle marshalling
protected  java.util.Vector members
           
protected  org.jgroups.MessageListener ml
           
protected  boolean nodeLockingOptimistic
          Determines whether to use optimistic locking or not.
static java.lang.reflect.Method notifyCallOnInactiveMethod
           
static java.lang.reflect.Method optimisticPrepareMethod
           
static java.lang.reflect.Method prepareMethod
           
static java.lang.reflect.Method printMethodLocal
           
static java.lang.reflect.Method putDataEraseMethodLocal
           
static java.lang.reflect.Method putDataMethodLocal
           
static java.lang.reflect.Method putFailFastKeyValueMethodLocal
           
static java.lang.reflect.Method putKeyValMethodLocal
           
protected  java.util.Map region_msg_queues
           
protected  RegionManager regionManager_
          RegionManager used by marshaller and ExtendedCacheLoader
static java.lang.reflect.Method releaseAllLocksMethodLocal
           
static java.lang.reflect.Method removeDataMethodLocal
           
static java.lang.reflect.Method removeKeyMethodLocal
           
static java.lang.reflect.Method removeNodeMethodLocal
           
static int REPL_ASYNC
          Entries in the cache are by default replicated (asynchronously)
protected  ReplicationQueue repl_queue
          Queue used to replicate updates when mode is repl-async
protected  long repl_queue_interval
           
protected  int repl_queue_max_elements
           
static int REPL_SYNC
          Entries in the cache are by default replicated (synchronously)
static java.lang.reflect.Method replicateAllMethod
           
static java.lang.reflect.Method replicateMethod
           
protected  Replicatable replication_handler
          Interceptor which handles invocations of _replicate(MethodCall).
static java.lang.reflect.Method rollbackMethod
           
protected  DataNode root
           
static java.lang.String SEPARATOR
           
protected  java.lang.Exception setStateException
           
protected  long state_fetch_timeout
           
protected  boolean sync_commit_phase
          synchronous or asynchrous commit phase ?
protected  long sync_repl_timeout
           
protected  boolean sync_rollback_phase
          synchronous or asynchrous rollback phase ?
protected  javax.transaction.TransactionManager tm
          Used to get the Transaction associated with the current thread
protected  TransactionManagerLookup tm_lookup
          Method to acquire a TransactionManager.
protected  java.lang.String tm_lookup_class
          Class of the implementation of TransactionManagerLookup
static java.lang.String UNINITIALIZED
           
protected  boolean use_repl_queue
           
protected  boolean useCreateService
           
protected  boolean useMarshalling_
          Check to see if we need to use marshalling
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
TreeCache()
           
TreeCache(org.jgroups.JChannel channel)
          Expects an already connected channel.
TreeCache(java.lang.String cluster_name, java.lang.String props, long state_fetch_timeout)
          Creates a channel with the given properties.
 
Method Summary
 void _addChild(GlobalTransaction tx, Fqn parent_fqn, java.lang.Object child_name, DataNode old_node)
          Compensating method to _remove(GlobalTransaction,Fqn,boolean).
protected  void _createService()
           
 void _enqueueMethodCall(java.lang.String subtree, org.jgroups.blocks.MethodCall call)
           
 void _evict(Fqn fqn)
          Called by eviction policy provider.
protected  void _evictSubtree(Fqn subtree)
          Evicts the node at subtree along with all descendant nodes.
 Node _get(Fqn fqn)
           
 java.lang.Object _get(Fqn fqn, java.lang.Object key, boolean sendNodeEvent)
           
 java.util.Set _getChildrenNames(Fqn fqn)
           
 java.util.Set _getKeys(Fqn fqn)
           
 byte[] _getState(Fqn fqn, long timeout, boolean force, boolean suppressErrors)
          Returns the state for the portion of the tree named by fqn.
 void _lock(Fqn fqn, int lock_type, boolean recursive)
           
 java.lang.String _print(Fqn fqn)
           
 void _put(GlobalTransaction tx, Fqn fqn, java.util.Map data, boolean create_undo_ops)
          Does the real work.
 void _put(GlobalTransaction tx, Fqn fqn, java.util.Map data, boolean create_undo_ops, boolean erase_contents)
          Does the real work.
 java.lang.Object _put(GlobalTransaction tx, Fqn fqn, java.lang.Object key, java.lang.Object value, boolean create_undo_ops)
           
 java.lang.Object _put(GlobalTransaction tx, Fqn fqn, java.lang.Object key, java.lang.Object value, boolean create_undo_ops, long timeout)
           
 void _put(GlobalTransaction tx, java.lang.String fqn, java.util.Map data, boolean create_undo_ops)
          Does the real work.
 java.lang.Object _put(GlobalTransaction tx, java.lang.String fqn, java.lang.Object key, java.lang.Object value, boolean create_undo_ops)
           
 void _releaseAllLocks(Fqn fqn)
           
 void _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops)
           
 void _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent)
           
 void _remove(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent, boolean eviction)
          Remove a node
 java.lang.Object _remove(GlobalTransaction tx, Fqn fqn, java.lang.Object key, boolean create_undo_ops)
           
 void _remove(GlobalTransaction tx, java.lang.String fqn, boolean create_undo_ops)
           
 java.lang.Object _remove(GlobalTransaction tx, java.lang.String fqn, java.lang.Object key, boolean create_undo_ops)
           
 void _removeData(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops)
           
 void _removeData(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent)
           
 void _removeData(GlobalTransaction tx, Fqn fqn, boolean create_undo_ops, boolean sendNodeEvent, boolean eviction)
           
 void _removeData(GlobalTransaction tx, java.lang.String fqn, boolean create_undo_ops)
           
 void _replicate(java.util.List method_calls)
           
 java.lang.Object _replicate(org.jgroups.blocks.MethodCall method_call)
          Invoked by the ReplicationInterceptor of other nodes in the cluster, to replicate their changes across the cluster.
protected  void acquireLocksForStateTransfer(DataNode root, java.lang.Object lockOwner, long timeout, boolean lockChildren, boolean force)
           
 void activateRegion(java.lang.String subtreeFqn)
          Causes the cache to transfer state for the subtree rooted at subtreeFqn and to begin accepting replication messages for that subtree.
 void addNode(GlobalTransaction gtx, Fqn node)
           
 void addTreeCacheListener(TreeCacheListener listener)
           
 void block()
          Block sending and receiving of messages until viewAccepted() is called
protected  void cacheLoaderPreload()
           
 java.util.List callRemoteMethods(java.util.Vector mbrs, org.jgroups.blocks.MethodCall method_call, boolean synchronous, boolean exclude_self, long timeout)
           
 java.util.List callRemoteMethods(java.util.Vector members, java.lang.reflect.Method method, java.lang.Object[] args, boolean synchronous, boolean exclude_self, long timeout)
           
 java.util.List callRemoteMethods(java.util.Vector members, java.lang.String method_name, java.lang.Class[] types, java.lang.Object[] args, boolean synchronous, boolean exclude_self, long timeout)
           
 void commit(GlobalTransaction tx)
           
protected  void createCacheLoader()
          Creates an instance of a CacheLoader if and only if The CacheLoader has not yet been created cache_loader_class is set The CacheLoader is shared and we are not the coordinator (only the coordinator is supposed to have a CacheLoader)
protected  void createInterceptorChain()
           
 void createService()
          Lifecycle method.
protected  DataNode createSubtreeRootNode(Fqn subtree)
           
 void destroyService()
          Lifecycle mthod.
protected  boolean determineCoordinator()
           
 java.lang.String dumpTransactionTable()
          Dumps the contents of the TransactionTable
 void evict(Fqn fqn)
          Called by eviction policy provider.
 boolean exists(Fqn fqn)
          Checks whether a given node exists in the tree.
 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 the tree
 boolean exists(java.lang.String fqn, java.lang.Object key)
           
 void fetchState(long timeout)
          Fetch the group state from the current coordinator.
protected  void fetchStateOnStartup()
           
 Node get(Fqn fqn)
           
 java.lang.Object get(Fqn fqn, java.lang.Object key)
          Finds a node given its name and returns the value associated with a given key in its data map.
protected  java.lang.Object get(Fqn fqn, java.lang.Object key, boolean sendNodeEvent)
           
 Node get(java.lang.String fqn)
           
 java.lang.Object get(java.lang.String fqn, java.lang.Object key)
          Finds a node given its name and returns the value associated with a given key in its data map.
 CacheLoader getCacheLoader()
           
 boolean getCacheLoaderAsynchronous()
           
 java.lang.String getCacheLoaderClass()
           
 java.util.Properties getCacheLoaderConfig()
           
 boolean getCacheLoaderFetchPersistentState()
           
 boolean getCacheLoaderFetchTransientState()
           
 boolean getCacheLoaderPassivation()
           
 java.lang.String getCacheLoaderPreload()
           
 boolean getCacheLoaderShared()
           
 java.lang.String getCacheMode()
          Returns the current caching mode.
 int getCacheModeInternal()
           
 java.util.Set getChildrenNames(Fqn 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()
          Get the name of the replication group
 java.lang.String getClusterProperties()
          Get the cluster properties (e.g.
 org.jgroups.Address getCoordinator()
           
 GlobalTransaction getCurrentTransaction()
          Get the transaction associated with the current thread and maps it onto a GlobalTransaction.
 GlobalTransaction getCurrentTransaction(javax.transaction.Transaction tx)
           
 boolean getDeadlockDetection()
           
protected  java.lang.String getDefaultProperties()
           
 java.lang.String getEvictionPolicyClass()
          Returns the name of the cache eviction policy (must be an implementation of EvictionPolicy)
 org.w3c.dom.Element getEvictionPolicyConfig()
           
 int getEvictionThreadWakeupIntervalSeconds()
          Obtain eviction thread (if any) wake up interval in seconds
 boolean getFetchStateOnStartup()
          Returns whether or not on startup to acquire the initial state from existing members.
 long getInitialStateRetrievalTimeout()
          Get the max time to wait until the initial state is retrieved.
 TreeCache getInstance()
           
 java.lang.String getInterceptorChain()
           
 java.util.List getInterceptors()
           
 java.lang.String getIsolationLevel()
          Returns the transaction isolation level.
 IsolationLevel getIsolationLevelClass()
           
 java.util.Set getKeys(Fqn fqn)
           
 java.util.Set getKeys(java.lang.String fqn)
           
 java.lang.Object getLocalAddress()
           
protected  javax.transaction.Transaction getLocalTransaction()
          Returns the transaction associated with the current thread.
 long getLockAcquisitionTimeout()
          Default max time to wait for a lock.
 java.util.Map getLockTable()
           
 java.util.Vector getMembers()
           
 org.jgroups.MessageListener getMessageListener()
           
 java.lang.String getNodeLockingScheme()
           
 int getNumberOfAttributes()
          Returns an approximation of the total number of attributes in the tree.
 int getNumberOfLocksHeld()
          Gets the number of read or write locks held across the entire tree
 int getNumberOfNodes()
          Returns an approximation of the total number of nodes in the tree.
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.
 Replicatable getReplicationHandler()
           
 java.lang.String getReplicationVersion()
          Gets the format version of the data transferred during an initial state transfer or a call to activateRegion(String).
 short getReplicationVersionShort()
           
 ReplicationQueue getReplQueue()
           
 long getReplQueueInterval()
           
 int getReplQueueMaxElements()
           
 DataNode getRoot()
          Used by interceptors.
 byte[] getStateBytes()
           
 short getStateTransferVersion()
          Gets the format version of the data transferred during an initial state transfer or a call to activateRegion(String).
 boolean getSyncCommitPhase()
           
 long getSyncReplTimeout()
          Returns the default max timeout after which synchronous replication calls return.
 boolean getSyncRollbackPhase()
           
 javax.transaction.TransactionManager getTransactionManager()
           
 java.lang.String getTransactionManagerLookupClass()
           
 TransactionTable getTransactionTable()
           
 java.util.Map getTreeCacheListeners()
          Returns a Map contains the listeners to this tree cache
 boolean getUseMarshalling()
          Gets whether a TreeCacheMarshaller instance should be used to manage different classloaders to use for unmarshalling replicated objects.
 boolean getUseReplQueue()
           
 java.lang.String getVersion()
           
 boolean hasChild(Fqn fqn)
           
 void inactivateRegion(java.lang.String subtreeFqn)
          Causes the cache to stop accepting replication events for the subtree rooted at subtreeFqn and evict all nodes in that subtree.
protected  java.lang.Object invokeMethod(org.jgroups.blocks.MethodCall m)
          Invokes a method against this object.
 boolean isCoordinator()
           
static boolean isCrudMethod(java.lang.reflect.Method m)
           
 boolean isInactiveOnStartup()
          Gets whether the entire tree is inactive upon startup, only responding to replication messages after activateRegion(String) is called to activate one or more parts of the tree.
 boolean isNodeLockingOptimistic()
          returns whether node locking is optimistic.
 void load(java.lang.String fqn)
          Loads the indicated Fqn, plus all parents recursively from the CacheLoader.
protected  java.lang.Class loadClass(java.lang.String classname)
          Loads the specified class using this class's classloader, or, if it is null (i.e.
protected  void notifyAllNodesCreated(DataNode curr)
          Generates NodeAdded notifications for all nodes of the tree.
protected  void notifyCacheStarted()
           
protected  void notifyCacheStopped()
           
 void notifyCallForInactiveSubtree(java.lang.String fqn)
          Method provided to JGroups by TreeCacheMarshaller.objectFromByteBuffer(byte[]) when it receives a replication event for an Fqn that has been marked as inactive.
 void notifyNodeActivate(Fqn fqn, boolean pre)
           
 void notifyNodeCreated(Fqn fqn)
           
protected  void notifyNodeEvict(Fqn fqn, boolean pre)
           
protected  void notifyNodeEvicted(Fqn fqn)
           
 void notifyNodeLoaded(Fqn fqn)
           
protected  void notifyNodeModified(Fqn fqn)
           
protected  void notifyNodeModify(Fqn fqn, boolean pre)
           
 void notifyNodePassivate(Fqn fqn, boolean pre)
           
protected  void notifyNodeRemove(Fqn fqn, boolean pre)
           
protected  void notifyNodeRemoved(Fqn fqn)
           
protected  void notifyNodeVisited(Fqn fqn)
           
protected  void notifyViewChange(org.jgroups.View v)
           
 void optimisticPrepare(GlobalTransaction gtx, java.util.List modifications, java.util.Map data, org.jgroups.Address address, boolean bool)
           
 DataNode peek(Fqn fqn)
           
 java.lang.Object peek(Fqn fqn, java.lang.Object key)
          Like get() method but without triggering a node visit event.
 void prepare(GlobalTransaction global_tx, java.util.List modifications, org.jgroups.Address coord, boolean commit)
           
 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()
           
 java.lang.String printLockInfo()
           
 void put(Fqn fqn, java.util.Map data)
          Adds a new node to the tree and sets its data.
 java.lang.Object put(Fqn fqn, java.lang.Object key, java.lang.Object 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 tree and sets its data.
 java.lang.Object put(java.lang.String fqn, java.lang.Object key, java.lang.Object value)
          Adds a key and value to a given node.
 java.lang.Object putFailFast(Fqn fqn, java.lang.Object key, java.lang.Object value, long timeout)
          Deprecated. This is a kludge created specifically form the Hibernate 3.0 release. This method should not be used by any application. The methodV will likely be removed in a future release
 java.lang.Object putFailFast(java.lang.String fqn, java.lang.Object key, java.lang.Object value, long timeout)
          Deprecated.  
 void registerClassLoader(java.lang.String fqn, java.lang.ClassLoader cl)
          If useMarshalling is true, we will use TreeCacheMarshaller for marshalling.
 void releaseAllLocks(Fqn fqn)
          Force-releases all locks in this node and the entire subtree
 void releaseAllLocks(java.lang.String fqn)
          Force-releases all locks in this node and the entire subtree
protected  void releaseStateTransferLocks(DataNode root, java.lang.Object lockOwner, boolean childrenLocked)
           
 void remove(Fqn fqn)
          Removes the node from the tree.
 java.lang.Object remove(Fqn fqn, java.lang.Object key)
          Removes key from the node's hashmap
 void remove(java.lang.String fqn)
          Removes the node from the tree.
 java.lang.Object remove(java.lang.String fqn, java.lang.Object key)
          Removes key from the node's hashmap
 void removeData(Fqn fqn)
           
 void removeData(java.lang.String fqn)
           
 void removeTreeCacheListener(TreeCacheListener listener)
           
 void rollback(GlobalTransaction tx)
           
 void setCacheLoader(CacheLoader cache_loader)
           
 void setCacheLoaderAsynchronous(boolean b)
           
 void setCacheLoaderClass(java.lang.String cache_loader_class)
           
 void setCacheLoaderConfig(java.util.Properties cache_loader_config)
           
 void setCacheLoaderFetchPersistentState(boolean flag)
           
 void setCacheLoaderFetchTransientState(boolean flag)
           
 void setCacheLoaderPassivation(boolean passivate)
           
 void setCacheLoaderPreload(java.lang.String list)
           
 void setCacheLoaderShared(boolean shared)
           
 void setCacheMode(int mode)
          Sets the default cache mode.
 void setCacheMode(java.lang.String mode)
          Sets the default caching mode)
 void setClusterConfig(org.w3c.dom.Element config)
          Convert a list of elements to the JG property string
 void setClusterName(java.lang.String name)
          Set the name of the replication group
 void setClusterProperties(java.lang.String cluster_props)
          Set the cluster properties.
 void setDeadlockDetection(boolean dt)
           
 void setEvictionPolicyClass(java.lang.String eviction_policy_class)
          Sets the classname of the eviction policy
 void setEvictionPolicyConfig(org.w3c.dom.Element config)
          Setup eviction policy configuration
 void setFetchStateOnStartup(boolean flag)
          Sets whether or not on startup to acquire the initial state from existing members.
 void setInactiveOnStartup(boolean inactiveOnStartup)
          Sets whether the entire tree is inactive upon startup, only responding to replication messages after activateRegion(String) is called to activage one or more parts of the tree.
 void setInitialStateRetrievalTimeout(long timeout)
          Set the initial state transfer timeout (see getInitialStateRetrievalTimeout())
 void setInterceptorChain(Interceptor i)
          Used for unit tests only - to force interceptor chains.
 void setIsolationLevel(IsolationLevel level)
           
 void setIsolationLevel(java.lang.String level)
          Set the transaction isolation level.
 void setLockAcquisitionTimeout(long timeout)
          Set the max time for lock acquisition.
protected  void setNodeLockingOptimistic(boolean b)
          Sets whether to use optimistic locking on the nodes.
 void setNodeLockingScheme(java.lang.String s)
           
 void setReplicationHandler(Replicatable handler)
           
 void setReplicationVersion(java.lang.String versionString)
          Sets the format version of the data transferred during an initial state transfer or a call to activateRegion(String).
 void setReplQueueInterval(long interval)
           
 void setReplQueueMaxElements(int max_elements)
           
 void setStateBytes(byte[] state)
           
 void setStateTransferVersion(short version)
          Sets the format version of the data transferred during an initial state transfer or a call to activateRegion(String).
 void setSyncCommitPhase(boolean sync_commit_phase)
           
 void setSyncReplTimeout(long timeout)
          Sets the default maximum wait time for synchronous replication to receive all results
 void setSyncRollbackPhase(boolean sync_rollback_phase)
           
 void setTransactionManagerLookup(TransactionManagerLookup l)
          Sets the TransactionManagerLookup object
 void setTransactionManagerLookupClass(java.lang.String cl)
          Sets the class of the TransactionManagerLookup impl.
 void setUseMarshalling(boolean isTrue)
          Sets whether a TreeCacheMarshaller instance should be created to manage different classloaders to use for unmarshalling replicated objects.
 void setUseReplQueue(boolean flag)
           
 void startService()
          Lifecyle method.
 void stopService()
          Lifecycle method.
protected  int string2Mode(java.lang.String mode)
           
 void suspect(org.jgroups.Address suspected_mbr)
          Called when a member is suspected
 java.lang.String toString()
           
 java.lang.String toString(boolean details)
           
 void unregisterClassLoader(java.lang.String fqn)
          If useMarshalling is true, we will use unregister this region.
 void viewAccepted(org.jgroups.View new_view)
           
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, destroy, getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Field Detail

DEFAULT_REPLICATION_VERSION

public static final short DEFAULT_REPLICATION_VERSION

root

protected DataNode root

channel

protected org.jgroups.JChannel channel

coordinator

protected boolean coordinator
Am I the coordinator ?


log

protected static final org.apache.commons.logging.Log log

cluster_name

protected java.lang.String cluster_name

cluster_props

protected java.lang.String cluster_props

members

protected final java.util.Vector members

disp

protected org.jgroups.blocks.RpcDispatcher disp

ml

protected org.jgroups.MessageListener ml

state_fetch_timeout

protected long state_fetch_timeout

sync_repl_timeout

protected long sync_repl_timeout

use_repl_queue

protected boolean use_repl_queue

repl_queue_max_elements

protected int repl_queue_max_elements

repl_queue_interval

protected long repl_queue_interval

region_msg_queues

protected java.util.Map region_msg_queues

fetch_state_on_startup

protected boolean fetch_state_on_startup

lock_acquisition_timeout

protected long lock_acquisition_timeout

eviction_policy_class

protected java.lang.String eviction_policy_class

eviction_policy_provider

protected TreeCacheListener eviction_policy_provider

cache_mode

protected int cache_mode

inactiveOnStartup

protected boolean inactiveOnStartup

putDataMethodLocal

public static java.lang.reflect.Method putDataMethodLocal

putDataEraseMethodLocal

public static java.lang.reflect.Method putDataEraseMethodLocal

putKeyValMethodLocal

public static java.lang.reflect.Method putKeyValMethodLocal

putFailFastKeyValueMethodLocal

public static java.lang.reflect.Method putFailFastKeyValueMethodLocal

removeNodeMethodLocal

public static java.lang.reflect.Method removeNodeMethodLocal

removeKeyMethodLocal

public static java.lang.reflect.Method removeKeyMethodLocal

removeDataMethodLocal

public static java.lang.reflect.Method removeDataMethodLocal

evictNodeMethodLocal

public static java.lang.reflect.Method evictNodeMethodLocal

prepareMethod

public static java.lang.reflect.Method prepareMethod

commitMethod

public static java.lang.reflect.Method commitMethod

rollbackMethod

public static java.lang.reflect.Method rollbackMethod

replicateMethod

public static java.lang.reflect.Method replicateMethod

replicateAllMethod

public static java.lang.reflect.Method replicateAllMethod

addChildMethodLocal

public static java.lang.reflect.Method addChildMethodLocal

getKeyValueMethodLocal

public static java.lang.reflect.Method getKeyValueMethodLocal

getNodeMethodLocal

public static java.lang.reflect.Method getNodeMethodLocal

getKeysMethodLocal

public static java.lang.reflect.Method getKeysMethodLocal

getChildrenNamesMethodLocal

public static java.lang.reflect.Method getChildrenNamesMethodLocal

releaseAllLocksMethodLocal

public static java.lang.reflect.Method releaseAllLocksMethodLocal

printMethodLocal

public static java.lang.reflect.Method printMethodLocal

lockMethodLocal

public static java.lang.reflect.Method lockMethodLocal

optimisticPrepareMethod

public static java.lang.reflect.Method optimisticPrepareMethod

getPartialStateMethod

public static java.lang.reflect.Method getPartialStateMethod

enqueueMethodCallMethod

public static java.lang.reflect.Method enqueueMethodCallMethod

notifyCallOnInactiveMethod

public static java.lang.reflect.Method notifyCallOnInactiveMethod

isStateSet

protected boolean isStateSet

setStateException

protected java.lang.Exception setStateException

isolationLevel

protected IsolationLevel isolationLevel

evictConfig_

protected org.w3c.dom.Element evictConfig_
Eviction policy configuration in xml Element


useMarshalling_

protected boolean useMarshalling_
Check to see if we need to use marshalling


marshaller_

protected TreeCacheMarshaller marshaller_
Marshaller if register to handle marshalling


regionManager_

protected RegionManager regionManager_
RegionManager used by marshaller and ExtendedCacheLoader


interceptor_chain

protected Interceptor interceptor_chain
invokeMethod(MethodCall) will dispatch to this chain of interceptors. In the future, this will be replaced with JBossAop. This is a first step towards refactoring JBossCache.


replication_handler

protected Replicatable replication_handler
Interceptor which handles invocations of _replicate(MethodCall). Any such method invocation is forwarded to the invoke_handler.
This will go away in the future, as we're moving replication functionality into the ReplicationInterceptor itself


tm_lookup

protected TransactionManagerLookup tm_lookup
Method to acquire a TransactionManager. By default we use JBossTransactionManagerLookup. Has to be set before calling ServiceMBeanSupport.start()


tm_lookup_class

protected java.lang.String tm_lookup_class
Class of the implementation of TransactionManagerLookup


tm

protected javax.transaction.TransactionManager tm
Used to get the Transaction associated with the current thread


cache_loader_class

protected java.lang.String cache_loader_class
The fully qualified name of the CacheLoader (has to implement the CacheLoader interface)


cache_loader

protected CacheLoader cache_loader
A reference to the CacheLoader. If null, we don't have a CacheLoader


cache_loader_config

protected java.util.Properties cache_loader_config
The properties from which to configure the CacheLoader


cache_loader_shared

protected boolean cache_loader_shared
Are the CacheLoaders sharing the same resource or not ?


cache_loader_passivate

protected boolean cache_loader_passivate
Will the cache loader passivate on eviction or persist?


cache_loader_preload

protected java.util.List cache_loader_preload
List of nodes to preload (if cache loader is enabled)


cache_loader_fetch_transient_state

protected boolean cache_loader_fetch_transient_state
Fetches the transient state. Attribute fetch_cache_on_startup has to be true


cache_loader_fetch_persistent_state

protected boolean cache_loader_fetch_persistent_state
Fetches the entire persistent state from the underlying CacheLoader. Only used if cache_loader_shared=false. Attribute fetch_cache_on_startup has to be true


cache_loader_asynchronous

protected boolean cache_loader_asynchronous
specifies whether the cache loader needs to be wrapped in the AsyncCacheLoader decorator


sync_commit_phase

protected boolean sync_commit_phase
synchronous or asynchrous commit phase ?


sync_rollback_phase

protected boolean sync_rollback_phase
synchronous or asynchrous rollback phase ?


deadlockDetection

protected boolean deadlockDetection

repl_queue

protected ReplicationQueue repl_queue
Queue used to replicate updates when mode is repl-async


SEPARATOR

public static final java.lang.String SEPARATOR
See Also:
Constant Field Values

LOCAL

public static final int LOCAL
Entries in the cache are by default local; ie. not replicated

See Also:
Constant Field Values

REPL_ASYNC

public static final int REPL_ASYNC
Entries in the cache are by default replicated (asynchronously)

See Also:
Constant Field Values

REPL_SYNC

public static final int REPL_SYNC
Entries in the cache are by default replicated (synchronously)

See Also:
Constant Field Values

UNINITIALIZED

public static final java.lang.String UNINITIALIZED
See Also:
Constant Field Values

nodeLockingOptimistic

protected boolean nodeLockingOptimistic
Determines whether to use optimistic locking or not. Disabled by default.


useCreateService

protected boolean useCreateService

activationChangeNodes

protected java.util.Set activationChangeNodes
Set of Fqns of nodes that are currently being processed by activateReqion or inactivateRegion. Requests for these fqns will be ignored by _getState().

Constructor Detail

TreeCache

public TreeCache(java.lang.String cluster_name,
                 java.lang.String props,
                 long state_fetch_timeout)
          throws java.lang.Exception
Creates a channel with the given properties. Connects to the channel, then creates a PullPushAdapter and starts it


TreeCache

public TreeCache()
          throws java.lang.Exception

TreeCache

public TreeCache(org.jgroups.JChannel channel)
          throws java.lang.Exception
Expects an already connected channel. Creates a PullPushAdapter and starts it

Method Detail

getMessageListener

public org.jgroups.MessageListener getMessageListener()

isCrudMethod

public static boolean isCrudMethod(java.lang.reflect.Method m)

getVersion

public java.lang.String getVersion()
Specified by:
getVersion in interface TreeCacheMBean

getRoot

public DataNode getRoot()
Used by interceptors. Don't use as client, will go away: interceptors will use TreeCacheImpl and clients will only be able to use TreeCache (which will become an interface)

Returns:
the root node

getLocalAddress

public java.lang.Object getLocalAddress()
Specified by:
getLocalAddress in interface TreeCacheMBean
Returns:
local address

getMembers

public java.util.Vector getMembers()
Specified by:
getMembers in interface TreeCacheMBean
Returns:
vector of members

isCoordinator

public boolean isCoordinator()
Specified by:
isCoordinator in interface TreeCacheMBean
Returns:
whether the cache is the grp coord

getClusterName

public java.lang.String getClusterName()
Get the name of the replication group

Specified by:
getClusterName in interface TreeCacheMBean

setClusterName

public void setClusterName(java.lang.String name)
Set the name of the replication group

Specified by:
setClusterName in interface TreeCacheMBean

getClusterProperties

public java.lang.String getClusterProperties()
Get the cluster properties (e.g. the protocol stack specification in case of JGroups)

Specified by:
getClusterProperties in interface TreeCacheMBean

setClusterProperties

public void setClusterProperties(java.lang.String cluster_props)
Set the cluster properties. If the cache is to use the new properties, it has to be redeployed

Specified by:
setClusterProperties in interface TreeCacheMBean
Parameters:
cluster_props - The properties for the cluster (JGroups)

getTransactionTable

public TransactionTable getTransactionTable()

getLockTable

public java.util.Map getLockTable()

dumpTransactionTable

public java.lang.String dumpTransactionTable()
Dumps the contents of the TransactionTable

Specified by:
dumpTransactionTable in interface TreeCacheMBean
Returns:

getDeadlockDetection

public boolean getDeadlockDetection()
Specified by:
getDeadlockDetection in interface TreeCacheMBean
Returns:
Whether deadlock detection is enabled

setDeadlockDetection

public void setDeadlockDetection(boolean dt)
Specified by:
setDeadlockDetection in interface TreeCacheMBean
Parameters:
dt -

getInterceptorChain

public java.lang.String getInterceptorChain()
Specified by:
getInterceptorChain in interface TreeCacheMBean
Returns:
the interceptor chain as a str

setInterceptorChain

public void setInterceptorChain(Interceptor i)
Used for unit tests only - to force interceptor chains.

Parameters:
i -

getInterceptors

public java.util.List getInterceptors()
Specified by:
getInterceptors in interface TreeCacheMBean
Returns:
List

getCacheLoaderClass

public java.lang.String getCacheLoaderClass()
Specified by:
getCacheLoaderClass in interface TreeCacheMBean
Returns:

setCacheLoaderClass

public void setCacheLoaderClass(java.lang.String cache_loader_class)
Specified by:
setCacheLoaderClass in interface TreeCacheMBean
Parameters:
cache_loader_class -

getCacheLoaderConfig

public java.util.Properties getCacheLoaderConfig()
Specified by:
getCacheLoaderConfig in interface TreeCacheMBean
Returns:

setCacheLoaderConfig

public void setCacheLoaderConfig(java.util.Properties cache_loader_config)
Specified by:
setCacheLoaderConfig in interface TreeCacheMBean
Parameters:
cache_loader_config -

getCacheLoader

public CacheLoader getCacheLoader()
Specified by:
getCacheLoader in interface TreeCacheMBean
Returns:

setCacheLoader

public void setCacheLoader(CacheLoader cache_loader)
Specified by:
setCacheLoader in interface TreeCacheMBean
Parameters:
cache_loader -

getCacheLoaderShared

public boolean getCacheLoaderShared()
Specified by:
getCacheLoaderShared in interface TreeCacheMBean
Returns:

setCacheLoaderShared

public void setCacheLoaderShared(boolean shared)
Specified by:
setCacheLoaderShared in interface TreeCacheMBean
Parameters:
shared -

getCacheLoaderPassivation

public boolean getCacheLoaderPassivation()
Specified by:
getCacheLoaderPassivation in interface TreeCacheMBean
Returns:

setCacheLoaderPassivation

public void setCacheLoaderPassivation(boolean passivate)
Specified by:
setCacheLoaderPassivation in interface TreeCacheMBean
Parameters:
passivate -

setCacheLoaderPreload

public void setCacheLoaderPreload(java.lang.String list)
Specified by:
setCacheLoaderPreload in interface TreeCacheMBean
Parameters:
list -

getCacheLoaderAsynchronous

public boolean getCacheLoaderAsynchronous()
Specified by:
getCacheLoaderAsynchronous in interface TreeCacheMBean

setCacheLoaderAsynchronous

public void setCacheLoaderAsynchronous(boolean b)
Specified by:
setCacheLoaderAsynchronous in interface TreeCacheMBean

getCacheLoaderPreload

public java.lang.String getCacheLoaderPreload()
Specified by:
getCacheLoaderPreload in interface TreeCacheMBean
Returns:

setCacheLoaderFetchPersistentState

public void setCacheLoaderFetchPersistentState(boolean flag)
Specified by:
setCacheLoaderFetchPersistentState in interface TreeCacheMBean
Parameters:
flag -

getCacheLoaderFetchPersistentState

public boolean getCacheLoaderFetchPersistentState()
Specified by:
getCacheLoaderFetchPersistentState in interface TreeCacheMBean
Returns:

setCacheLoaderFetchTransientState

public void setCacheLoaderFetchTransientState(boolean flag)
Specified by:
setCacheLoaderFetchTransientState in interface TreeCacheMBean
Parameters:
flag -

getCacheLoaderFetchTransientState

public boolean getCacheLoaderFetchTransientState()
Specified by:
getCacheLoaderFetchTransientState in interface TreeCacheMBean
Returns:

isInactiveOnStartup

public boolean isInactiveOnStartup()
Gets whether the entire tree is inactive upon startup, only responding to replication messages after activateRegion(String) is called to activate one or more parts of the tree.

This property is only relevant if getUseMarshalling() is true.

Specified by:
isInactiveOnStartup in interface TreeCacheMBean
Returns:

setInactiveOnStartup

public void setInactiveOnStartup(boolean inactiveOnStartup)
Sets whether the entire tree is inactive upon startup, only responding to replication messages after activateRegion(String) is called to activage one or more parts of the tree.

This property is only relevant if getUseMarshalling() is true.

Specified by:
setInactiveOnStartup in interface TreeCacheMBean

getSyncCommitPhase

public boolean getSyncCommitPhase()
Specified by:
getSyncCommitPhase in interface TreeCacheMBean
Returns:

setSyncCommitPhase

public void setSyncCommitPhase(boolean sync_commit_phase)
Specified by:
setSyncCommitPhase in interface TreeCacheMBean
Parameters:
sync_commit_phase -

getSyncRollbackPhase

public boolean getSyncRollbackPhase()
Specified by:
getSyncRollbackPhase in interface TreeCacheMBean
Returns:

setSyncRollbackPhase

public void setSyncRollbackPhase(boolean sync_rollback_phase)
Specified by:
setSyncRollbackPhase in interface TreeCacheMBean
Parameters:
sync_rollback_phase -

setEvictionPolicyConfig

public void setEvictionPolicyConfig(org.w3c.dom.Element config)
Setup eviction policy configuration

Specified by:
setEvictionPolicyConfig in interface TreeCacheMBean

getEvictionPolicyConfig

public org.w3c.dom.Element getEvictionPolicyConfig()

setClusterConfig

public void setClusterConfig(org.w3c.dom.Element config)
Convert a list of elements to the JG property string

Specified by:
setClusterConfig in interface TreeCacheMBean

getInitialStateRetrievalTimeout

public long getInitialStateRetrievalTimeout()
Get the max time to wait until the initial state is retrieved. This is used in a replicating cache: when a new cache joins the cluster, it needs to acquire the (replicated) state of the other members to initialize itself. If no state has been received within timeout milliseconds, the map will be empty.

Specified by:
getInitialStateRetrievalTimeout in interface TreeCacheMBean
Returns:
long Number of milliseconds to wait for the state. 0 means to wait forever.

setInitialStateRetrievalTimeout

public void setInitialStateRetrievalTimeout(long timeout)
Set the initial state transfer timeout (see getInitialStateRetrievalTimeout())

Specified by:
setInitialStateRetrievalTimeout in interface TreeCacheMBean

getCacheMode

public java.lang.String getCacheMode()
Returns the current caching mode. Valid values are

getCacheModeInternal

public int getCacheModeInternal()

setNodeLockingScheme

public void setNodeLockingScheme(java.lang.String s)
Specified by:
setNodeLockingScheme in interface TreeCacheMBean

getNodeLockingScheme

public java.lang.String getNodeLockingScheme()
Specified by:
getNodeLockingScheme in interface TreeCacheMBean

setNodeLockingOptimistic

protected void setNodeLockingOptimistic(boolean b)
Sets whether to use optimistic locking on the nodes.


isNodeLockingOptimistic

public boolean isNodeLockingOptimistic()
returns whether node locking is optimistic.

Returns:

setCacheMode

public void setCacheMode(java.lang.String mode)
                  throws java.lang.Exception
Sets the default caching mode)

Specified by:
setCacheMode in interface TreeCacheMBean
java.lang.Exception

setCacheMode

public void setCacheMode(int mode)
Sets the default cache mode. Valid arguments are
  1. TreeCache.LOCAL
  2. TreeCache.REPL_ASYNC
  3. TreeCache.REPL_SYNC

Parameters:
mode -

getSyncReplTimeout

public long getSyncReplTimeout()
Returns the default max timeout after which synchronous replication calls return.

Specified by:
getSyncReplTimeout in interface TreeCacheMBean
Returns:
long Number of milliseconds after which a sync repl call must return. 0 means to wait forever

setSyncReplTimeout

public void setSyncReplTimeout(long timeout)
Sets the default maximum wait time for synchronous replication to receive all results

Specified by:
setSyncReplTimeout in interface TreeCacheMBean

getUseReplQueue

public boolean getUseReplQueue()
Specified by:
getUseReplQueue in interface TreeCacheMBean
Returns:

setUseReplQueue

public void setUseReplQueue(boolean flag)
Specified by:
setUseReplQueue in interface TreeCacheMBean
Parameters:
flag -

getReplQueueInterval

public long getReplQueueInterval()
Specified by:
getReplQueueInterval in interface TreeCacheMBean
Returns:

setReplQueueInterval

public void setReplQueueInterval(long interval)
Specified by:
setReplQueueInterval in interface TreeCacheMBean
Parameters:
interval -

getReplQueueMaxElements

public int getReplQueueMaxElements()
Specified by:
getReplQueueMaxElements in interface TreeCacheMBean
Returns:

setReplQueueMaxElements

public void setReplQueueMaxElements(int max_elements)
Specified by:
setReplQueueMaxElements in interface TreeCacheMBean
Parameters:
max_elements -

getReplQueue

public ReplicationQueue getReplQueue()

getIsolationLevel

public java.lang.String getIsolationLevel()
Returns the transaction isolation level.

Specified by:
getIsolationLevel in interface TreeCacheMBean

setIsolationLevel

public void setIsolationLevel(java.lang.String level)
Set the transaction isolation level. This determines the locking strategy to be used

Specified by:
setIsolationLevel in interface TreeCacheMBean

setIsolationLevel

public void setIsolationLevel(IsolationLevel level)
Parameters:
level -

getIsolationLevelClass

public IsolationLevel getIsolationLevelClass()

getFetchStateOnStartup

public boolean getFetchStateOnStartup()
Description copied from interface: TreeCacheMBean
Returns whether or not on startup to acquire the initial state from existing members. Allows for warm/hot caches (true/false). This can be further defined by properties CacheLoaderFetchTransientState and CacheLoaderFetchPersistentState.

Specified by:
getFetchStateOnStartup in interface TreeCacheMBean
Returns:

setFetchStateOnStartup

public void setFetchStateOnStartup(boolean flag)
Description copied from interface: TreeCacheMBean
Sets whether or not on startup to acquire the initial state from existing members.

Specified by:
setFetchStateOnStartup in interface TreeCacheMBean
Parameters:
flag -

getLockAcquisitionTimeout

public long getLockAcquisitionTimeout()
Default max time to wait for a lock. If the lock cannot be acquired within this time, a LockingException will be thrown.

Specified by:
getLockAcquisitionTimeout in interface TreeCacheMBean
Returns:
long Max number of milliseconds to wait for a lock to be acquired

setLockAcquisitionTimeout

public void setLockAcquisitionTimeout(long timeout)
Set the max time for lock acquisition. A value of 0 means to wait forever (not recomended). Note that lock acquisition timeouts may be removed in the future when we have deadlock detection.

Specified by:
setLockAcquisitionTimeout in interface TreeCacheMBean
Parameters:
timeout -

getEvictionPolicyClass

public java.lang.String getEvictionPolicyClass()
Returns the name of the cache eviction policy (must be an implementation of EvictionPolicy)

Specified by:
getEvictionPolicyClass in interface TreeCacheMBean
Returns:
Fully qualified name of a class implementing the EvictionPolicy interface

setEvictionPolicyClass

public void setEvictionPolicyClass(java.lang.String eviction_policy_class)
Sets the classname of the eviction policy

Specified by:
setEvictionPolicyClass in interface TreeCacheMBean

getEvictionThreadWakeupIntervalSeconds

public int getEvictionThreadWakeupIntervalSeconds()
Obtain eviction thread (if any) wake up interval in seconds

Specified by:
getEvictionThreadWakeupIntervalSeconds in interface TreeCacheMBean

setTransactionManagerLookup

public void setTransactionManagerLookup(TransactionManagerLookup l)
Sets the TransactionManagerLookup object

Specified by:
setTransactionManagerLookup in interface TreeCacheMBean
Parameters:
l -

getTransactionManagerLookupClass

public java.lang.String getTransactionManagerLookupClass()
Specified by:
getTransactionManagerLookupClass in interface TreeCacheMBean
Returns:

setTransactionManagerLookupClass

public void setTransactionManagerLookupClass(java.lang.String cl)
                                      throws java.lang.Exception
Sets the class of the TransactionManagerLookup impl. This will attempt to create an instance, and will throw an exception if this fails.

Specified by:
setTransactionManagerLookupClass in interface TreeCacheMBean
Parameters:
cl -
Throws:
java.lang.Exception

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Specified by:
getTransactionManager in interface TreeCacheMBean
Returns:

getInstance

public TreeCache getInstance()
Specified by:
getInstance in interface TreeCacheMBean
Returns:

setReplicationHandler

public void setReplicationHandler(Replicatable handler)

getReplicationHandler

public Replicatable getReplicationHandler()

fetchState

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

Specified by:
fetchState in interface TreeCacheMBean
org.jgroups.ChannelClosedException
org.jgroups.ChannelNotConnectedException

addTreeCacheListener

public void addTreeCacheListener(TreeCacheListener listener)
Specified by:
addTreeCacheListener in interface TreeCacheMBean
Parameters:
listener -

removeTreeCacheListener

public void removeTreeCacheListener(TreeCacheListener listener)
Specified by:
removeTreeCacheListener in interface TreeCacheMBean
Parameters:
listener -

getTreeCacheListeners

public java.util.Map getTreeCacheListeners()
Returns a Map contains the listeners to this tree cache

Returns:
a map contains the listeners to this tree cache

createService

public void createService()
                   throws java.lang.Exception
Lifecycle method. This is like initialize. Same thing as calling create

Specified by:
createService in interface TreeCacheMBean
Overrides:
createService in class org.jboss.system.ServiceMBeanSupport
Throws:
java.lang.Exception

_createService

protected void _createService()
                       throws java.lang.Exception
java.lang.Exception

startService

public void startService()
                  throws java.lang.Exception
Lifecyle method. This is the same thing as calling start

Specified by:
startService in interface TreeCacheMBean
Overrides:
startService in class org.jboss.system.ServiceMBeanSupport
Throws:
java.lang.Exception

destroyService

public void destroyService()
Lifecycle mthod.

Specified by:
destroyService in interface TreeCacheMBean
Overrides:
destroyService in class org.jboss.system.ServiceMBeanSupport

stopService

public void stopService()
Lifecycle method. Same thing as calling stop.

Specified by:
stopService in interface TreeCacheMBean
Overrides:
stopService in class org.jboss.system.ServiceMBeanSupport

createInterceptorChain

protected void createInterceptorChain()
                               throws java.lang.IllegalAccessException,
                                      java.lang.InstantiationException,
                                      java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.ClassNotFoundException

createCacheLoader

protected void createCacheLoader()
                          throws java.lang.Exception
Creates an instance of a CacheLoader if and only if

Throws:
java.lang.Exception

cacheLoaderPreload

protected void cacheLoaderPreload()
                           throws java.lang.Exception
java.lang.Exception

setUseMarshalling

public void setUseMarshalling(boolean isTrue)
Description copied from interface: TreeCacheMBean
Sets whether a TreeCacheMarshaller instance should be created to manage different classloaders to use for unmarshalling replicated objects.

This property must be set to true before any call to TreeCacheMBean.registerClassLoader(String, ClassLoader) or TreeCacheMBean.activateRegion(String)

Specified by:
setUseMarshalling in interface TreeCacheMBean

getUseMarshalling

public boolean getUseMarshalling()
Description copied from interface: TreeCacheMBean
Gets whether a TreeCacheMarshaller instance should be used to manage different classloaders to use for unmarshalling replicated objects.

Specified by:
getUseMarshalling in interface TreeCacheMBean

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

Specified by:
load in interface TreeCacheMBean
Parameters:
fqn -
Throws:
java.lang.Exception

determineCoordinator

protected boolean determineCoordinator()

getCoordinator

public org.jgroups.Address getCoordinator()

getStateBytes

public byte[] getStateBytes()

setStateBytes

public void setStateBytes(byte[] state)

registerClassLoader

public void registerClassLoader(java.lang.String fqn,
                                java.lang.ClassLoader cl)
                         throws RegionNameConflictException
If useMarshalling is true, we will use TreeCacheMarshaller for marshalling. User will register the specific class loader through this api.

Specified by:
registerClassLoader in interface TreeCacheMBean
Parameters:
fqn - The fqn region. Children of this fqn will use this classloader for (un)marshalling.
cl - The class loader to use
Throws:
RegionNameConflictException - If there is a conflict in fqn specification.

unregisterClassLoader

public void unregisterClassLoader(java.lang.String fqn)
                           throws RegionNotFoundException
If useMarshalling is true, we will use unregister this region.

Specified by:
unregisterClassLoader in interface TreeCacheMBean
Parameters:
fqn - The fqn region.
Throws:
RegionNotFoundException - If there is a conflict in fqn specification.

activateRegion

public void activateRegion(java.lang.String subtreeFqn)
                    throws RegionNotEmptyException,
                           RegionNameConflictException,
                           CacheException
Causes the cache to transfer state for the subtree rooted at subtreeFqn and to begin accepting replication messages for that subtree.

NOTE: This method will cause the creation of a node in the local tree at subtreeFqn whether or not that node exists anywhere else in the cluster. If the node does not exist elsewhere, the local node will be empty. The creation of this node will not be replicated.

Specified by:
activateRegion in interface TreeCacheMBean
Parameters:
subtreeFqn - Fqn string indicating the uppermost node in the portion of the tree that should be activated.
Throws:
RegionNotEmptyException - if the node subtreeFqn exists and has either data or children
java.lang.IllegalStateException - if useMarshalling is false
RegionNameConflictException
CacheException

createSubtreeRootNode

protected DataNode createSubtreeRootNode(Fqn subtree)
                                  throws CacheException
CacheException

inactivateRegion

public void inactivateRegion(java.lang.String subtreeFqn)
                      throws RegionNameConflictException,
                             CacheException
Causes the cache to stop accepting replication events for the subtree rooted at subtreeFqn and evict all nodes in that subtree.

Specified by:
inactivateRegion in interface TreeCacheMBean
Parameters:
subtreeFqn - Fqn string indicating the uppermost node in the portion of the tree that should be activated.
Throws:
RegionNameConflictException - if subtreeFqn indicates a node that is part of another subtree that is being specially managed (either by activate/inactiveRegion() or by registerClassLoader())
CacheException - if there is a problem evicting nodes
java.lang.IllegalStateException - if useMarshalling is false

_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 tree that should be evicted.
Throws:
CacheException

_enqueueMethodCall

public void _enqueueMethodCall(java.lang.String subtree,
                               org.jgroups.blocks.MethodCall call)
                        throws java.lang.Throwable
java.lang.Throwable

_getState

public byte[] _getState(Fqn fqn,
                        long timeout,
                        boolean force,
                        boolean suppressErrors)
                 throws java.lang.Throwable
Returns the state for the portion of the tree named by fqn.

State returned is a serialized byte[][], element 0 is the transient state (or null), and element 1 is the persistent state (or null).

Parameters:
fqn - Fqn indicating the uppermost node in the portion of the tree whose state should be returned.
timeout - max number of ms this method should wait to acquire a read lock on the nodes being transferred
force - if a read lock cannot be acquired after timeout ms, should the lock acquisition be forced, and any existing transactions holding locks on the nodes be rolled back? NOTE: In release 1.2.4, this parameter has no effect.
suppressErrors - should any Throwable thrown be suppressed?
Returns:
a serialized byte[][], element 0 is the transient state (or null), and element 1 is the persistent state (or null).
Throws:
java.lang.UnsupportedOperationException - if persistent state transfer is enabled, the requested Fqn is not the root node, and the cache loader does not implement ExtendedCacheLoader.
java.lang.Throwable

getReplicationVersion

public java.lang.String getReplicationVersion()
Description copied from interface: TreeCacheMBean
Gets the format version of the data transferred during an initial state transfer or a call to TreeCacheMBean.activateRegion(String). Different releases of JBossCache may format this data differently; this property identifies the format version being used by this cache instance.

The default value for this property is DEFAULT_REPLICATION_VERSION.

Specified by:
getReplicationVersion in interface TreeCacheMBean
Returns:
a short identifying JBossCache release; e.g. 124 for JBossCache 1.2.4

setReplicationVersion

public void setReplicationVersion(java.lang.String versionString)
Description copied from interface: TreeCacheMBean
Sets the format version of the data transferred during an initial state transfer or a call to TreeCacheMBean.activateRegion(String). Different releases of JBossCache may format this data differently; this property identifies the format version being used by this cache instance. Setting this property to a value other than the default allows a cache instance from a later release to interoperate with a cache instance from an earlier release.

Specified by:
setReplicationVersion in interface TreeCacheMBean
Parameters:
versionString - a short identifying JBossCache release; e.g. 124 for JBossCache 1.2.4

getReplicationVersionShort

public short getReplicationVersionShort()

getStateTransferVersion

public short getStateTransferVersion()
Description copied from interface: TreeCacheMBean
Gets the format version of the data transferred during an initial state transfer or a call to TreeCacheMBean.activateRegion(String). Different releases of JBossCache may format this data differently; this property identifies the format version being used by this cache instance.

The default value for this property is DEFAULT_REPLICATION_VERSION.

Specified by:
getStateTransferVersion in interface TreeCacheMBean
Returns:
a short identifying JBossCache release; e.g. 124 for JBossCache 1.2.4

setStateTransferVersion

public void setStateTransferVersion(short version)
Description copied from interface: TreeCacheMBean
Sets the format version of the data transferred during an initial state transfer or a call to TreeCacheMBean.activateRegion(String). Different releases of JBossCache may format this data differently; this property identifies the format version being used by this cache instance. Setting this property to a value other than the default allows a cache instance from a later release to interoperate with a cache instance from an earlier release.

Specified by:
setStateTransferVersion in interface TreeCacheMBean
Parameters:
version - a short identifying JBossCache release; e.g. 124 for JBossCache 1.2.4

acquireLocksForStateTransfer

protected void acquireLocksForStateTransfer(DataNode root,
                                            java.lang.Object lockOwner,
                                            long timeout,
                                            boolean lockChildren,
                                            boolean force)
                                     throws java.lang.Exception
java.lang.Exception

releaseStateTransferLocks

protected void releaseStateTransferLocks(DataNode root,
                                         java.lang.Object lockOwner,
                                         boolean childrenLocked)

notifyCallForInactiveSubtree

public void notifyCallForInactiveSubtree(java.lang.String fqn)
Method provided to JGroups by TreeCacheMarshaller.objectFromByteBuffer(byte[]) when it receives a replication event for an Fqn that has been marked as inactive. Currently a no-op.

See Also:
#inactivate(Fqn)

fetchStateOnStartup

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

get

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

get

public Node get(Fqn fqn)
         throws CacheException
Specified by:
get in interface TreeCacheMBean
Parameters:
fqn - fqn instance to retrieve from cache
Returns:
Node corresponding to the fqn. Null if does not exist. No guarantees wrt replication, cache loading are given if the underlying node is modified
CacheException

_get

public Node _get(Fqn fqn)
          throws CacheException
CacheException

getKeys

public java.util.Set getKeys(java.lang.String fqn)
                      throws CacheException
Specified by:
getKeys in interface TreeCacheMBean
Parameters:
fqn -
Returns:
CacheException

getKeys

public java.util.Set getKeys(Fqn fqn)
                      throws CacheException
Specified by:
getKeys in interface TreeCacheMBean
Parameters:
fqn -
Returns:
A Set of keys. This is a copy of the key set, modifications will not be written to the original. Returns null if the node is not found, or the node has no attributes
CacheException

_getKeys

public java.util.Set _getKeys(Fqn fqn)
                       throws CacheException
CacheException

get

public java.lang.Object get(java.lang.String fqn,
                            java.lang.Object 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 tree or the key was not found in the hashmap.

Specified by:
get in interface TreeCacheMBean
Parameters:
fqn - The fully qualified name of the node.
key - The key.
CacheException

get

public java.lang.Object get(Fqn fqn,
                            java.lang.Object 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 tree or the key was not found in the hashmap.

Specified by:
get in interface TreeCacheMBean
Parameters:
fqn - The fully qualified name of the node.
key - The key.
CacheException

_get

public java.lang.Object _get(Fqn fqn,
                             java.lang.Object key,
                             boolean sendNodeEvent)
                      throws CacheException
CacheException

get

protected java.lang.Object get(Fqn fqn,
                               java.lang.Object key,
                               boolean sendNodeEvent)
                        throws CacheException
CacheException

peek

public java.lang.Object peek(Fqn fqn,
                             java.lang.Object key)
                      throws CacheException
Like get() method but without triggering a node visit event. This is used to prevent refresh of the cache data in the eviction policy.

Parameters:
fqn -
key -
Returns:
CacheException

peek

public DataNode peek(Fqn fqn)

exists

public boolean exists(java.lang.String fqn)
Checks whether a given node exists in the tree

Specified by:
exists in interface TreeCacheMBean
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 the tree. Does not acquire any locks in doing so (result may be dirty read)

Specified by:
exists in interface TreeCacheMBean
Parameters:
fqn - The fully qualified name of the node
Returns:
boolean Whether or not the node exists

exists

public boolean exists(java.lang.String fqn,
                      java.lang.Object key)
Specified by:
exists in interface TreeCacheMBean
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)

Specified by:
exists in interface TreeCacheMBean
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 tree 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.

Specified by:
put in interface TreeCacheMBean
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.
CacheException

put

public void put(Fqn fqn,
                java.util.Map data)
         throws CacheException
Adds a new node to the tree 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.

Specified by:
put in interface TreeCacheMBean
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.
CacheException

put

public java.lang.Object put(java.lang.String fqn,
                            java.lang.Object key,
                            java.lang.Object 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 TreeCacheMBean
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
CacheException

putFailFast

public java.lang.Object putFailFast(Fqn fqn,
                                    java.lang.Object key,
                                    java.lang.Object value,
                                    long timeout)
                             throws CacheException
Deprecated. This is a kludge created specifically form the Hibernate 3.0 release. This method should not be used by any application. The methodV will likely be removed in a future release

Put with the following properties:
  1. Fails fast (after timeout milliseconds)
  2. If replication is used: replicates asynchronously, overriding a potential synchronous mode
This method should be used without running in a transaction (suspend()/resume() before calling it)

Parameters:
fqn - The fully qualified name of the node
key -
value -
timeout - Number of milliseconds to wait until a lock has been acquired. A TimeoutException will be thrown if not successful. 0 means to wait forever
Returns:
Throws:
CacheException

putFailFast

public java.lang.Object putFailFast(java.lang.String fqn,
                                    java.lang.Object key,
                                    java.lang.Object value,
                                    long timeout)
                             throws CacheException
Deprecated.  

Parameters:
fqn -
key -
value -
timeout -
Returns:
Throws:
CacheException

put

public java.lang.Object put(Fqn fqn,
                            java.lang.Object key,
                            java.lang.Object 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 TreeCacheMBean
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
CacheException

remove

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

Specified by:
remove in interface TreeCacheMBean
Parameters:
fqn - The fully qualified name of the node.
CacheException

remove

public void remove(Fqn fqn)
            throws CacheException
Removes the node from the tree.

Specified by:
remove in interface TreeCacheMBean
Parameters:
fqn - The fully qualified name of the node.
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 is will cause the replcation nodes not synchronizing, but it is ok since user is supposed to add the node again when get is null. After that, the contents will be in sync.

Specified by:
evict in interface TreeCacheMBean
Parameters:
fqn - Will remove everythign assoicated with this fqn.
Throws:
CacheException

remove

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

Specified by:
remove in interface TreeCacheMBean
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
CacheException

remove

public java.lang.Object remove(Fqn fqn,
                               java.lang.Object key)
                        throws CacheException
Removes key from the node's hashmap

Specified by:
remove in interface TreeCacheMBean
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
CacheException

removeData

public void removeData(java.lang.String fqn)
                throws CacheException
Specified by:
removeData in interface TreeCacheMBean
Parameters:
fqn -
Throws:
CacheException

removeData

public void removeData(Fqn fqn)
                throws CacheException
Specified by:
removeData in interface TreeCacheMBean
Parameters:
fqn -
Throws:
CacheException

releaseAllLocks

public void releaseAllLocks(java.lang.String fqn)
Force-releases all locks in this node and the entire subtree

Specified by:
releaseAllLocks in interface TreeCacheMBean
Parameters:
fqn -

releaseAllLocks

public void releaseAllLocks(Fqn fqn)
Force-releases all locks in this node and the entire subtree

Specified by:
releaseAllLocks in interface TreeCacheMBean
Parameters:
fqn -

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.

Specified by:
print in interface TreeCacheMBean

print

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

Specified by:
print in interface TreeCacheMBean

getChildrenNames

public java.util.Set getChildrenNames(java.lang.String fqn)
                               throws CacheException
Returns all children of a given node

Specified by:
getChildrenNames in interface TreeCacheMBean
Parameters:
fqn - The fully qualified name of the node
Returns:
Set A list of child names (as Strings)
CacheException

getChildrenNames

public java.util.Set getChildrenNames(Fqn fqn)
                               throws CacheException
Returns all children of a given node

Specified by:
getChildrenNames in interface TreeCacheMBean
Parameters:
fqn - The fully qualified name of the node
Returns:
Set A list of child names (as Objects). Must not be modified because this would modify the underlying node directly (will throw an exception if modification is attempted). Returns null of the parent node was not found, or if there are no children
CacheException

_getChildrenNames

public java.util.Set _getChildrenNames(Fqn fqn)
                                throws CacheException
CacheException

hasChild

public boolean hasChild(Fqn fqn)

toString

public java.lang.String toString()
Specified by:
toString in interface TreeCacheMBean
Overrides:
toString in class java.lang.Object
Returns:

toString

public java.lang.String toString(boolean details)
Returns:

printDetails

public java.lang.String printDetails()
Specified by:
printDetails in interface TreeCacheMBean
Returns:

printLockInfo

public java.lang.String printLockInfo()
Specified by:
printLockInfo in interface TreeCacheMBean
Returns:

getNumberOfLocksHeld

public int getNumberOfLocksHeld()
Gets the number of read or write locks held across the entire tree

Specified by:
getNumberOfLocksHeld in interface TreeCacheMBean
Returns:

getNumberOfNodes

public int getNumberOfNodes()
Returns an approximation of the total number of nodes in the tree. 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 TreeCacheMBean
Returns:

getNumberOfAttributes

public int getNumberOfAttributes()
Returns an approximation of the total number of attributes in the tree. 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 TreeCacheMBean
Returns:

callRemoteMethods

public java.util.List callRemoteMethods(java.util.Vector mbrs,
                                        org.jgroups.blocks.MethodCall method_call,
                                        boolean synchronous,
                                        boolean exclude_self,
                                        long timeout)
                                 throws java.lang.Exception
java.lang.Exception

callRemoteMethods

public java.util.List callRemoteMethods(java.util.Vector members,
                                        java.lang.reflect.Method method,
                                        java.lang.Object[] args,
                                        boolean synchronous,
                                        boolean exclude_self,
                                        long timeout)
                                 throws java.lang.Exception
Specified by:
callRemoteMethods in interface TreeCacheMBean
Parameters:
members -
method -
args -
synchronous -
exclude_self -
timeout -
Returns:
Throws:
java.lang.Exception

callRemoteMethods

public java.util.List callRemoteMethods(java.util.Vector 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
Specified by:
callRemoteMethods in interface TreeCacheMBean
Parameters:
members -
method_name -
types -
args -
synchronous -
exclude_self -
timeout -
Returns:
Throws:
java.lang.Exception

_put

public void _put(GlobalTransaction tx,
                 java.lang.String fqn,
                 java.util.Map data,
                 boolean create_undo_ops)
          throws CacheException
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

Specified by:
_put in interface TreeCacheMBean
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()).
CacheException

_put

public void _put(GlobalTransaction tx,
                 Fqn fqn,
                 java.util.Map data,
                 boolean create_undo_ops)
          throws CacheException
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

Specified by:
_put in interface TreeCacheMBean
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()).
CacheException

_put

public void _put(GlobalTransaction tx,
                 Fqn fqn,
                 java.util.Map data,
                 boolean create_undo_ops,
                 boolean erase_contents)
          throws CacheException
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

Specified by:
_put in interface TreeCacheMBean
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()).
CacheException

_put

public java.lang.Object _put(GlobalTransaction tx,
                             java.lang.String fqn,
                             java.lang.Object key,
                             java.lang.Object value,
                             boolean create_undo_ops)
                      throws CacheException
Specified by:
_put in interface TreeCacheMBean
Parameters:
fqn -
key -
value -
Returns:
Previous value (if any)
CacheException

_put

public java.lang.Object _put(GlobalTransaction tx,
                             Fqn fqn,
                             java.lang.Object key,
                             java.lang.Object value,
                             boolean create_undo_ops)
                      throws CacheException
Specified by:
_put in interface TreeCacheMBean
Parameters:
fqn -
key -
value -
Returns:
Previous value (if any)
CacheException

_put

public java.lang.Object _put(GlobalTransaction tx,
                             Fqn fqn,
                             java.lang.Object key,
                             java.lang.Object value,
                             boolean create_undo_ops,
                             long timeout)
                      throws CacheException
CacheException

_remove

public void _remove(GlobalTransaction tx,
                    java.lang.String fqn,
                    boolean create_undo_ops)
             throws CacheException
Specified by:
_remove in interface TreeCacheMBean
Parameters:
fqn -
CacheException

_remove

public void _remove(GlobalTransaction tx,
                    Fqn fqn,
                    boolean create_undo_ops)
             throws CacheException
Specified by:
_remove in interface TreeCacheMBean
Parameters:
fqn -
CacheException

_remove

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

_remove

public void _remove(GlobalTransaction tx,
                    Fqn fqn,
                    boolean create_undo_ops,
                    boolean sendNodeEvent,
                    boolean eviction)
             throws CacheException
Remove a node

Parameters:
tx -
fqn -
create_undo_ops -
sendNodeEvent -
CacheException

_remove

public java.lang.Object _remove(GlobalTransaction tx,
                                java.lang.String fqn,
                                java.lang.Object key,
                                boolean create_undo_ops)
                         throws CacheException
Specified by:
_remove in interface TreeCacheMBean
Parameters:
fqn -
key -
Returns:
Object
CacheException

_remove

public java.lang.Object _remove(GlobalTransaction tx,
                                Fqn fqn,
                                java.lang.Object key,
                                boolean create_undo_ops)
                         throws CacheException
Specified by:
_remove in interface TreeCacheMBean
Parameters:
fqn -
key -
Returns:
Object
CacheException

_removeData

public void _removeData(GlobalTransaction tx,
                        java.lang.String fqn,
                        boolean create_undo_ops)
                 throws CacheException
Parameters:
fqn -
CacheException

_removeData

public void _removeData(GlobalTransaction tx,
                        Fqn fqn,
                        boolean create_undo_ops)
                 throws CacheException
Parameters:
fqn -
CacheException

_removeData

public void _removeData(GlobalTransaction tx,
                        Fqn fqn,
                        boolean create_undo_ops,
                        boolean sendNodeEvent)
                 throws CacheException
CacheException

_removeData

public void _removeData(GlobalTransaction tx,
                        Fqn fqn,
                        boolean create_undo_ops,
                        boolean sendNodeEvent,
                        boolean eviction)
                 throws CacheException
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 is will cause the replcation nodes not synchronizing, but it is ok since user is supposed to add the node again when get is null. After that, the contents will be in sync.

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

_addChild

public void _addChild(GlobalTransaction tx,
                      Fqn parent_fqn,
                      java.lang.Object child_name,
                      DataNode old_node)
               throws CacheException
Compensating method to _remove(GlobalTransaction,Fqn,boolean). This is package-private on purpose because it is only supposed to be called inside the same VM (by rollback(GlobalTransaction)).

Parameters:
parent_fqn -
child_name -
old_node -
CacheException

_replicate

public java.lang.Object _replicate(org.jgroups.blocks.MethodCall method_call)
                            throws java.lang.Throwable
Invoked by the ReplicationInterceptor of other nodes in the cluster, to replicate their changes across the cluster. Needs to be forwarded to the ReplicationInterceptor in this interceptor chain.
This method will later be moved entirely into the ReplicationInterceptor.

Parameters:
method_call -
Returns:
Throws:
java.lang.Throwable

_replicate

public void _replicate(java.util.List method_calls)
                throws java.lang.Throwable
java.lang.Throwable

_releaseAllLocks

public void _releaseAllLocks(Fqn fqn)

_print

public java.lang.String _print(Fqn fqn)

_lock

public void _lock(Fqn fqn,
                  int lock_type,
                  boolean recursive)
           throws TimeoutException,
                  LockingException
TimeoutException
LockingException

optimisticPrepare

public void optimisticPrepare(GlobalTransaction gtx,
                              java.util.List modifications,
                              java.util.Map data,
                              org.jgroups.Address address,
                              boolean bool)

prepare

public void prepare(GlobalTransaction global_tx,
                    java.util.List modifications,
                    org.jgroups.Address coord,
                    boolean commit)

commit

public void commit(GlobalTransaction tx)

rollback

public void rollback(GlobalTransaction tx)

addNode

public void addNode(GlobalTransaction gtx,
                    Fqn node)

viewAccepted

public void viewAccepted(org.jgroups.View new_view)
Specified by:
viewAccepted in interface org.jgroups.MembershipListener

suspect

public void suspect(org.jgroups.Address suspected_mbr)
Called when a member is suspected

Specified by:
suspect in interface org.jgroups.MembershipListener

block

public void block()
Block sending and receiving of messages until viewAccepted() is called

Specified by:
block in interface org.jgroups.MembershipListener

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()

Returns:

getCurrentTransaction

public GlobalTransaction getCurrentTransaction()
Get the transaction associated with the current thread and maps it onto a GlobalTransaction. The mapping is maintained in the tx_map table. 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 too.

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

getCurrentTransaction

public GlobalTransaction getCurrentTransaction(javax.transaction.Transaction tx)

invokeMethod

protected java.lang.Object invokeMethod(org.jgroups.blocks.MethodCall m)
                                 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).

Parameters:
m -
Returns:
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.


loadClass

protected java.lang.Class loadClass(java.lang.String classname)
                             throws java.lang.ClassNotFoundException
Loads the specified class using this class's classloader, or, if it is null (i.e. this class was loaded by the bootstrap classloader), the system classloader.

If loadtime instrumentation via GenerateInstrumentedClassLoader is used, this class may be loaded by the bootstrap classloader.

Throws:
java.lang.ClassNotFoundException

notifyNodeCreated

public void notifyNodeCreated(Fqn fqn)

notifyNodeLoaded

public void notifyNodeLoaded(Fqn fqn)

notifyNodeActivate

public void notifyNodeActivate(Fqn fqn,
                               boolean pre)

notifyNodePassivate

public void notifyNodePassivate(Fqn fqn,
                                boolean pre)

notifyNodeRemove

protected void notifyNodeRemove(Fqn fqn,
                                boolean pre)

notifyNodeRemoved

protected void notifyNodeRemoved(Fqn fqn)

notifyNodeEvict

protected void notifyNodeEvict(Fqn fqn,
                               boolean pre)

notifyNodeEvicted

protected void notifyNodeEvicted(Fqn fqn)

notifyNodeModify

protected void notifyNodeModify(Fqn fqn,
                                boolean pre)

notifyNodeModified

protected void notifyNodeModified(Fqn fqn)

notifyNodeVisited

protected void notifyNodeVisited(Fqn fqn)

notifyCacheStarted

protected void notifyCacheStarted()

notifyCacheStopped

protected void notifyCacheStopped()

notifyViewChange

protected void notifyViewChange(org.jgroups.View v)

notifyAllNodesCreated

protected void notifyAllNodesCreated(DataNode curr)
Generates NodeAdded notifications for all nodes of the tree. This is called whenever the tree is initially retrieved (state transfer)


getDefaultProperties

protected java.lang.String getDefaultProperties()

string2Mode

protected int string2Mode(java.lang.String mode)


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.