FileDocCategorySizeDatePackage
AbortableLRUAlgorithm.javaAPI DocJBoss 4.2.13346Fri Jul 13 20:53:48 BST 2007org.jboss.ejb3.cache.tree

AbortableLRUAlgorithm

public class AbortableLRUAlgorithm extends org.jboss.cache.eviction.LRUAlgorithm
LRUAlgorithm subclass that doesn't log an error if it catches ContextInUseException.
author
Brian Stansberry
version
$Revision: 1.1 $

Fields Summary
private static final Logger
log
Constructors Summary
public AbortableLRUAlgorithm()

   
    
   
      super();
   
Methods Summary
protected booleanevictCacheNode(org.jboss.cache.Fqn fqn)
Evict a node from cache.

param
fqn node corresponds to this fqn
return
True if successful

      if (log.isTraceEnabled())
      {
         log.trace("Attempting to evict cache node with fqn of " + fqn);
      }
      
      EvictionPolicy policy = region.getEvictionPolicy();
      try
      {
         policy.evict(fqn);
      }
      catch (ContextInUseException e)
      {
         // Don't log it at any alarming level
         if (log.isTraceEnabled())
            log.trace("Eviction of " + fqn + " aborted as bean is in use");
         return false;
      }
      catch (TimeoutException e)
      {
         log.warn("Eviction of " + fqn + " timed out, retrying later");
         log.debug(e, e);
         return false;
      }
      catch (RuntimeException e)
      {
         Throwable cause = e.getCause();
         if (cause instanceof ContextInUseException)
         {
            // Don't log it at any alarming level
            if (log.isTraceEnabled())
               log.trace("Eviction of " + fqn + " aborted as bean is in use");
            return false;            
         }
         log.error("Eviction of " + fqn + " failed", e);
         return false;
      }
      catch (Exception e)
      {
         log.error("Eviction of " + fqn + " failed", e);
         return false;
      }

      if (log.isTraceEnabled())
      {
         log.trace("Eviction of cache node with fqn of " + fqn + " successful");
      }

      return true;