org.jboss.cache
Class ConsoleListener

java.lang.Object
  extended by org.jboss.cache.AbstractTreeCacheListener
      extended by org.jboss.cache.ConsoleListener
All Implemented Interfaces:
ExtendedTreeCacheListener, TreeCacheListener

public class ConsoleListener
extends AbstractTreeCacheListener

This class provides a non-graphical view of JBossCache replication events for a replicated cache.

It can be utilized as a standalone application or as a component in other applications.

WARNING: take care when using this class in conjunction with transactionally replicated cache's as it can cause deadlock situations due to the reading of values for nodes in the cache.

Author:
Jimmy Wilson 12-2004

Constructor Summary
ConsoleListener(TreeCache cache)
          Constructor.
ConsoleListener(TreeCache cache, boolean startCache, boolean stopCache)
          Constructor.
 
Method Summary
 void cacheStarted(TreeCache cache)
          Called when the cache is started.
 void cacheStopped(TreeCache cache)
          Called when the cache is stopped.
 void listen()
          Instructs this class to listen for cache replication events.
 void listen(boolean wait)
          Instructs this class to listen for cache replication events.
static void main(java.lang.String[] args)
          The main method.
 void nodeActivate(Fqn fqn, boolean pre)
          Called when a node is to be or has been activated into memory via the CacheLoader that was evicted earlier.
 void nodeCreated(Fqn fqn)
          Called when a node is created
 void nodeEvict(Fqn fqn, boolean pre)
          Called when a node is about to be evicted or has been evicted from the in-memory cache.
 void nodeEvicted(Fqn fqn)
          Called when a node is evicted (not the same as remove()).
 void nodeLoaded(Fqn fqn)
          Called when a node is loaded into memory via the CacheLoader.
 void nodeModified(Fqn fqn)
          Called when a node is modified, e.g., one (key, value) pair in the internal map storage has been modified.
 void nodeModify(Fqn fqn, boolean pre, boolean isLocal)
          Called when a node is about to be modified or has been modified.
 void nodePassivate(Fqn fqn, boolean pre)
          Called when a node is to be or has been written to the backend store via the cache loader due to a node eviction by the eviction policy provider
 void nodeRemove(Fqn fqn, boolean pre, boolean isLocal)
          Called when a node is about to be removed or has been removed from the in-memory cache.
 void nodeRemoved(Fqn fqn)
          Called when a node is removed.
 void nodeVisited(Fqn fqn)
          Called when a node is visisted, i.e., get().
 void viewChange(org.jgroups.View new_view)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsoleListener

public ConsoleListener(TreeCache cache)
                throws java.lang.Exception
Constructor.

When using this constructor, this class with attempt to start and stop the specified cache.

Parameters:
cache - the cache to monitor for replication events.
Throws:
java.lang.Exception

ConsoleListener

public ConsoleListener(TreeCache cache,
                       boolean startCache,
                       boolean stopCache)
                throws java.lang.Exception
Constructor.

Parameters:
cache - the cache to monitor for replication events.
startCache - indicates whether or not the cache should be started by this class.
stopCache - indicates whether or not the cache should be stopped by this class.
Throws:
java.lang.Exception
Method Detail

listen

public void listen()
            throws java.lang.Exception
Instructs this class to listen for cache replication events.

This method waits indefinately. Use the notify method of this class (using traditional Java thread notification semantics) to cause this method to return.

Throws:
java.lang.Exception

listen

public void listen(boolean wait)
            throws java.lang.Exception
Instructs this class to listen for cache replication events.

Parameters:
wait - whether or not this method should wait indefinately.

If this parameter is set to true, using the notify method of this class (using traditional Java thread notification semantics) will cause this method to return.

Throws:
java.lang.Exception

cacheStarted

public void cacheStarted(TreeCache cache)
Description copied from interface: TreeCacheListener
Called when the cache is started.

Specified by:
cacheStarted in interface TreeCacheListener
Overrides:
cacheStarted in class AbstractTreeCacheListener

cacheStopped

public void cacheStopped(TreeCache cache)
Description copied from interface: TreeCacheListener
Called when the cache is stopped.

Specified by:
cacheStopped in interface TreeCacheListener
Overrides:
cacheStopped in class AbstractTreeCacheListener

nodeCreated

public void nodeCreated(Fqn fqn)
Description copied from interface: TreeCacheListener
Called when a node is created

Specified by:
nodeCreated in interface TreeCacheListener
Overrides:
nodeCreated in class AbstractTreeCacheListener

nodeEvicted

public void nodeEvicted(Fqn fqn)
Description copied from interface: TreeCacheListener
Called when a node is evicted (not the same as remove()).

Specified by:
nodeEvicted in interface TreeCacheListener
Overrides:
nodeEvicted in class AbstractTreeCacheListener

nodeLoaded

public void nodeLoaded(Fqn fqn)
Description copied from interface: TreeCacheListener
Called when a node is loaded into memory via the CacheLoader. This is not the same as TreeCacheListener.nodeCreated(Fqn).

Specified by:
nodeLoaded in interface TreeCacheListener
Overrides:
nodeLoaded in class AbstractTreeCacheListener

nodeModified

public void nodeModified(Fqn fqn)
Description copied from interface: TreeCacheListener
Called when a node is modified, e.g., one (key, value) pair in the internal map storage has been modified.

Specified by:
nodeModified in interface TreeCacheListener
Overrides:
nodeModified in class AbstractTreeCacheListener

nodeModify

public void nodeModify(Fqn fqn,
                       boolean pre,
                       boolean isLocal)
Description copied from interface: ExtendedTreeCacheListener
Called when a node is about to be modified or has been modified. Note: Currently TreeCacheListener has TreeCacheListener.nodeModified(Fqn) which will be merged with this method in release 1.3.

Specified by:
nodeModify in interface ExtendedTreeCacheListener
Overrides:
nodeModify in class AbstractTreeCacheListener
See Also:
TreeCacheListener.nodeModified(Fqn)

nodeRemoved

public void nodeRemoved(Fqn fqn)
Description copied from interface: TreeCacheListener
Called when a node is removed.

Specified by:
nodeRemoved in interface TreeCacheListener
Overrides:
nodeRemoved in class AbstractTreeCacheListener

nodeVisited

public void nodeVisited(Fqn fqn)
Description copied from interface: TreeCacheListener
Called when a node is visisted, i.e., get().

Specified by:
nodeVisited in interface TreeCacheListener
Overrides:
nodeVisited in class AbstractTreeCacheListener

viewChange

public void viewChange(org.jgroups.View new_view)
Specified by:
viewChange in interface TreeCacheListener
Overrides:
viewChange in class AbstractTreeCacheListener

nodeEvict

public void nodeEvict(Fqn fqn,
                      boolean pre)
Description copied from interface: ExtendedTreeCacheListener
Called when a node is about to be evicted or has been evicted from the in-memory cache. Note: Currently TreeCacheListener has TreeCacheListener.nodeEvicted(Fqn) which will be merged with method in release 1.3.

Specified by:
nodeEvict in interface ExtendedTreeCacheListener
Overrides:
nodeEvict in class AbstractTreeCacheListener
See Also:
TreeCacheListener.nodeEvicted(Fqn)

nodeRemove

public void nodeRemove(Fqn fqn,
                       boolean pre,
                       boolean isLocal)
Description copied from interface: ExtendedTreeCacheListener
Called when a node is about to be removed or has been removed from the in-memory cache. Note: Currently TreeCacheListener has TreeCacheListener.nodeRemoved(Fqn) which will be merged with this method in release 1.3.

Specified by:
nodeRemove in interface ExtendedTreeCacheListener
Overrides:
nodeRemove in class AbstractTreeCacheListener
See Also:
TreeCacheListener.nodeRemoved(Fqn)

nodeActivate

public void nodeActivate(Fqn fqn,
                         boolean pre)
Description copied from interface: ExtendedTreeCacheListener
Called when a node is to be or has been activated into memory via the CacheLoader that was evicted earlier.

Specified by:
nodeActivate in interface ExtendedTreeCacheListener
Overrides:
nodeActivate in class AbstractTreeCacheListener

nodePassivate

public void nodePassivate(Fqn fqn,
                          boolean pre)
Description copied from interface: ExtendedTreeCacheListener
Called when a node is to be or has been written to the backend store via the cache loader due to a node eviction by the eviction policy provider

Specified by:
nodePassivate in interface ExtendedTreeCacheListener
Overrides:
nodePassivate in class AbstractTreeCacheListener

main

public static void main(java.lang.String[] args)
The main method.

Parameters:
args - command line arguments dictated by convention.

The first command line argument is the name of the JBossCache configuration file to be utilized for configuration of the cache. Only the name of the configuration file is necessary as it is read off of the classpath.

If a configuration file is not specified on the command line, jboss-cache.xml will be the assumed file name.

All command line arguments after the first are ignored.



Copyright 1998-2005 JBoss Inc . All Rights Reserved.