3 Replies Latest reply on Nov 29, 2006 9:27 AM by manik

    Monitoring puts and evictions

    kagey

      Hey all,

      I am trying to devise a way to montior puts and expires. When i put a new node on the tree, i use put(fqn, key, value) - each node contains only one key/value pair. I use the LRU eviction policy.

      What i would like to have a listener able to monitor the adds and evictions of the cache, with access to the data objects. I tried using TreeCacheListener but it seems the nodeCreated and nodeEvicted callbacks are signaled too early and too late, respectively. This means the key/value mapping either doesn't exist yet, or the entire node is gone.

      Does anyone have any ideas on how I can accomplish my goal? I was thinking about tacking on a custom interceptor to the chain - do you think this would work?

      Thanks
      kagey

        • 1. Re: Monitoring puts and evictions
          kagey

          just to help out anyone who has the same problem. I found additional listener methods in abstracttreecachelistener, that have the "pre" parameter. so i can listen for adds and evictions using the following listener methods:

          for new inserts:
          nodeModify(Fqn fqn, boolean pre, boolean isLocal)
          where pre is false

          for evictions:
          nodeEvict(Fqn fqn, boolean pre)
          where pre is true

          cheers

          • 2. Re: Monitoring puts and evictions
            brian.stansberry

            The methods with the "pre" parameter come from interface org.jboss.cache.ExtendedTreeCacheListener. So, you can implement that interface to get those callbacks. Subclassing AbstractTreeCacheListener is a simple way to do that, or you can write your own impl from scratch.

            • 3. Re: Monitoring puts and evictions
              manik

              Also, a much richer CacheListener interface in JBoss Cache 2.0.0 supercedes TreeCacheListener and ExtendedTreeCacheListener of 1.x.y.

              See the 2.0.0 CacheListener javadoc (currently available as ALPHA1) for more info.