[jbosscache-commits] JBoss Cache SVN: r7029 - in core/branches/flat/src: main/java/org/jboss/cache and 28 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Oct 29 15:06:27 EDT 2008


Author: mircea.markus
Date: 2008-10-29 15:06:26 -0400 (Wed, 29 Oct 2008)
New Revision: 7029

Added:
   core/branches/flat/src/main/java/org/jboss/starobrno/EvictionManager.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionCacheConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionAction.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAction.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManager.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManagerImpl.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionManagerImpl.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/KeyEntry.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/BaseEvictionAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/BaseSortedEvictionAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/ElementSizeAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/ExpirationAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/SortedEvictionQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/EvictionListEntry.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/EvictionQueueList.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/EvictionManagerFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/EvictionInterceptor.java
Removed:
   core/branches/flat/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseSortedEvictionAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionListEntry.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueueList.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NodeEntry.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/SortedEvictionQueue.java
Modified:
   core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml
   core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java
   core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
   core/branches/flat/src/main/java/org/jboss/cache/Region.java
   core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java
   core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java
   core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
   core/branches/flat/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
   core/branches/flat/src/main/java/org/jboss/cache/commands/Visitor.java
   core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
   core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java
   core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
   core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java
   core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
   core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
   core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
   core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
   core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
   core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
   core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
   core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueue.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionTimerTask.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithmConfig.java
   core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java
   core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ChannelMessageListener.java
   core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java
   core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/DefaultStateTransferManager.java
   core/branches/flat/src/main/resources/config-samples/cacheloader-enabled.xml
   core/branches/flat/src/main/resources/config-samples/eviction-enabled.xml
   core/branches/flat/src/test/resources/configs/clonable-config.xml
   core/branches/flat/src/test/resources/configs/local-lru-eviction.xml
   core/branches/flat/src/test/resources/configs/local-passivation.xml
   core/branches/flat/src/test/resources/configs/local-tx.xml
   core/branches/flat/src/test/resources/configs/mixedPolicy-eviction.xml
   core/branches/flat/src/test/resources/configs/parser-test-async.xml
   core/branches/flat/src/test/resources/configs/parser-test.xml
   core/branches/flat/src/test/resources/configs/policyPerRegion-eviction.xml
   core/branches/flat/src/test/resources/configs/string-property-replaced.xml
   core/branches/flat/src/test/resources/jbc2-registry-configs.xml
   core/branches/flat/src/test/resources/jbc3-registry-configs.xml
   core/branches/flat/src/test/resources/unit-test-cache-service.xml
Log:
ongoing eviction work

Modified: core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml
===================================================================
--- core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -259,7 +259,7 @@
                       org.jboss.cache.eviction.LRUPolicy
                    </property>
                   <property name="wakeupIntervalSeconds">5</property>
-                  <property name="evictionRegionConfigs">
+                  <property name="evictionCacheConfigs">
                      <list>
                         <bean name="ExampleDefaultEvictionRegionConfig"
                               class="org.jboss.cache.config.EvictionRegionConfig">

Modified: core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -24,6 +24,8 @@
 import org.jboss.cache.annotations.Compat;
 import org.jboss.cache.jmx.PlatformMBeanServerRegistration;
 import org.jboss.starobrno.CacheDelegate;
+import org.jboss.starobrno.CacheSPI;
+import org.jboss.starobrno.Cache;
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.ConfigurationException;
 import org.jboss.starobrno.config.parsing.XmlConfigurationParser;
@@ -107,7 +109,7 @@
    {
       try
       {
-         org.jboss.starobrno.CacheSPI<K, V> cache = createAndWire(configuration);
+         CacheSPI<K, V> cache = createAndWire(configuration);
          if (start) cache.start();
          return cache;
       }
@@ -127,7 +129,7 @@
 
    protected org.jboss.starobrno.CacheSPI<K, V> createAndWire(Configuration configuration) throws Exception
    {
-      org.jboss.starobrno.CacheSPI<K, V> spi = new CacheDelegate<K, V>();
+      CacheSPI<K, V> spi = new CacheDelegate<K, V>();
       bootstrap(spi, configuration);
       return spi;
    }
@@ -135,14 +137,14 @@
    /**
     * Bootstraps this factory with a Configuration and a ComponentRegistry.
     */
-   private void bootstrap(org.jboss.starobrno.CacheSPI spi, Configuration configuration)
+   private void bootstrap( CacheSPI spi, Configuration configuration)
    {
       // injection bootstrap stuff
       componentRegistry = new ComponentRegistry(configuration, spi);
       componentRegistry.registerDefaultClassLoader(defaultClassLoader);
       this.configuration = configuration;
 
-      componentRegistry.registerComponent(spi, org.jboss.starobrno.CacheSPI.class);
+      componentRegistry.registerComponent(spi, CacheSPI.class);
       componentRegistry.registerComponent(new PlatformMBeanServerRegistration(), PlatformMBeanServerRegistration.class);
    }
 
@@ -156,7 +158,7 @@
       this.defaultClassLoader = loader;
    }
 
-   public org.jboss.starobrno.Cache<K, V> createCache(InputStream is) throws ConfigurationException
+   public Cache<K, V> createCache(InputStream is) throws ConfigurationException
    {
       XmlConfigurationParser parser = new XmlConfigurationParser();
       Configuration c = null;
@@ -164,7 +166,7 @@
       return createCache(c);
    }
 
-   public org.jboss.starobrno.Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException
+   public  Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException
    {
       XmlConfigurationParser parser = new XmlConfigurationParser();
       Configuration c = parser.parseStream(is);

Modified: core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -370,7 +370,7 @@
       {
          boolean localTx = deadOwner.getAddress().equals(getLocalAddress());
          // TODO: Fix me!!!
-//         boolean broken = LockUtil.breakTransactionLock(node.getFqn(), lockManager, deadOwner, localTx, txTable, txManager);
+//         boolean broken = LockUtil.breakTransactionLock(node.getKey(), lockManager, deadOwner, localTx, txTable, txManager);
          boolean broken = true;
 
          if (broken && trace) log.trace("Broke lock for node " + node.getFqn() + " held by " + deadOwner);
@@ -399,7 +399,7 @@
       for (GlobalTransaction deadOwner : deadOwners)
       {
          boolean localTx = deadOwner.getAddress().equals(getLocalAddress());
-//         boolean broken = LockUtil.breakTransactionLock(node.getFqn(), lockManager, deadOwner, localTx, txTable, txManager);
+//         boolean broken = LockUtil.breakTransactionLock(node.getKey(), lockManager, deadOwner, localTx, txTable, txManager);
          boolean broken = true; // TODO fix me!!
 
          if (broken && trace) log.trace("Broke lock for node " + node.getFqn() + " held by " + deadOwner);

Modified: core/branches/flat/src/main/java/org/jboss/cache/Region.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Region.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/Region.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -23,7 +23,7 @@
 
 import org.jboss.cache.annotations.Compat;
 import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.config.EvictionRegionConfig;
+import org.jboss.starobrno.config.EvictionCacheConfig;
 import org.jboss.starobrno.eviction.EvictionEvent;
 
 /**
@@ -141,14 +141,14 @@
    /**
     * Configures this region for eviction.
     *
-    * @param evictionRegionConfig configuration to set
+    * @param evictionCacheConfig configuration to set
     */
-   void setEvictionRegionConfig(EvictionRegionConfig evictionRegionConfig);
+   void setEvictionRegionConfig(EvictionCacheConfig evictionCacheConfig);
 
    /**
     * @return the eviction region config, if any, set on the current region.
     */
-   EvictionRegionConfig getEvictionRegionConfig();
+   EvictionCacheConfig getEvictionRegionConfig();
 
    /**
     * Registers an eviction event on the region's eviction event queue for later processing by
@@ -174,7 +174,7 @@
    /**
     * Marks a {@link org.jboss.cache.Node} as currently in use, by adding an event to the eviction queue.
     * If there is an {@link org.jboss.cache.config.EvictionRegionConfig} associated with this region, and
-    * it respects this event (e.g., {@link org.jboss.starobrno.eviction.LRUAlgorithm} does), then the {@link org.jboss.cache.Node} will not
+    * it respects this event (e.g., {@link org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm} does), then the {@link org.jboss.cache.Node} will not
     * be evicted until {@link #unmarkNodeCurrentlyInUse(Fqn)} is invoked.
     * <p/>
     * This mechanism can be used to prevent eviction of data that the application

Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -26,9 +26,10 @@
 import org.jboss.starobrno.util.Util;
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.EvictionAlgorithmConfig;
-import org.jboss.starobrno.config.EvictionRegionConfig;
-import org.jboss.starobrno.eviction.EvictionActionPolicy;
+import org.jboss.starobrno.config.EvictionCacheConfig;
+import org.jboss.starobrno.eviction.EvictionAction;
 import org.jboss.starobrno.eviction.EvictionEvent;
+import org.jboss.starobrno.eviction.EvictionAlgorithm;
 
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -48,8 +49,8 @@
    private ClassLoader classLoader;
    private BlockingQueue<EvictionEvent> evictionEventQueue = null;
    private int capacityWarnThreshold = 0;
-   private EvictionRegionConfig evictionRegionConfig;
-   private org.jboss.starobrno.eviction.EvictionAlgorithm evictionAlgorithm;
+   private EvictionCacheConfig evictionCacheConfig;
+   private EvictionAlgorithm evictionAlgorithm;
 
 
    /**
@@ -65,10 +66,10 @@
    /**
     * Constructs an eviction region from a policy and configuration, defined by an fqn and region manager.
     */
-   public RegionImpl(EvictionRegionConfig config, Fqn fqn, RegionManager regionManager)
+   public RegionImpl(EvictionCacheConfig config, Fqn fqn, RegionManager regionManager)
    {
       this(fqn, regionManager);
-      this.evictionRegionConfig = config;
+      this.evictionCacheConfig = config;
       createQueue();
    }
 
@@ -168,7 +169,7 @@
             "; classloader=" + classLoader +
             "; status=" + status +
             "; eviction=" + (evictionAlgorithm != null) +
-            "; timerThreadRegistered=" + (evictionAlgorithm != null && regionManager.getEvictionTimerTask().isRegionRegisteredForProcessing(this)) +
+            "; timerThreadRegistered=" + (evictionAlgorithm != null /*&& regionManager.getEvictionTimerTask().isRegionRegisteredForProcessing(this)*/) +
             '}';
    }
 
@@ -201,18 +202,18 @@
       evictionEventQueue.clear();
    }
 
-   public void setEvictionRegionConfig(EvictionRegionConfig evictionRegionConfig)
+   public void setEvictionRegionConfig(EvictionCacheConfig evictionCacheConfig)
    {
-      this.evictionRegionConfig = evictionRegionConfig;
-      evictionAlgorithm = createEvictionAlgorithm(evictionRegionConfig.getEvictionAlgorithmConfig(), evictionRegionConfig.getEvictionActionPolicyClassName());
-      regionManager.getEvictionTimerTask().addRegionToProcess(this);
+      this.evictionCacheConfig = evictionCacheConfig;
+      evictionAlgorithm = createEvictionAlgorithm(evictionCacheConfig.getEvictionAlgorithmConfig(), evictionCacheConfig.getEvictionActionClassName());
+//      regionManager.getEvictionTimerTask().addRegionToProcess(this);
       if (evictionEventQueue == null) createQueue();
       evictionAlgorithm.initialize();
    }
 
-   public EvictionRegionConfig getEvictionRegionConfig()
+   public EvictionCacheConfig getEvictionRegionConfig()
    {
-      return evictionRegionConfig;
+      return evictionCacheConfig;
    }
 
    public EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventType)
@@ -237,7 +238,7 @@
          if (evictionEventQueue.size() > capacityWarnThreshold)
          {
             if (log.isWarnEnabled())
-               log.warn("putNodeEvent(): eviction node event queue size is at 98% threshold value of capacity: " + evictionRegionConfig.getEventQueueSize() +
+               log.warn("putNodeEvent(): eviction node event queue size is at 98% threshold value of capacity: " + evictionCacheConfig.getEventQueueSize() +
                      " Region: " + fqn +
                      " You will need to reduce the wakeUpIntervalSeconds parameter.");
          }
@@ -255,11 +256,11 @@
    {
       if (evictionEventQueue == null)
       {
-         if (evictionRegionConfig == null)
+         if (evictionCacheConfig == null)
          {
             throw new IllegalArgumentException("null eviction configuration");
          }
-         int size = evictionRegionConfig.getEventQueueSize();
+         int size = evictionCacheConfig.getEventQueueSize();
          capacityWarnThreshold = (98 * size) / 100 - 100;
          if (capacityWarnThreshold <= 0)
          {
@@ -280,13 +281,13 @@
       try
       {
          if (trace) log.trace("Instantiating " + evictionActionPolicyClass);
-         EvictionActionPolicy actionPolicy = (EvictionActionPolicy) Util.getInstance(evictionActionPolicyClass);
-         actionPolicy.setCache(regionManager.getCache());
+         EvictionAction evictionAction = (EvictionAction) Util.getInstance(evictionActionPolicyClass);
+//         evictionAction.setCache(regionManager.getCache());
 
          if (trace) log.trace("Instantiating " + algoConfig.getEvictionAlgorithmClassName());
          org.jboss.starobrno.eviction.EvictionAlgorithm algorithm = (org.jboss.starobrno.eviction.EvictionAlgorithm) Util.getInstance(algoConfig.getEvictionAlgorithmClassName());
-         algorithm.setEvictionActionPolicy(actionPolicy);
-         algorithm.assignToRegion(fqn, regionManager.getCache(), algoConfig, regionManager.getConfiguration());
+         algorithm.setEvictionAction(evictionAction);
+//         algorithm.assignToCache(fqn, regionManager.getCache(), algoConfig, regionManager.getConfiguration());
          return algorithm;
       }
       catch (Exception e)
@@ -299,13 +300,13 @@
    public Region copy(Fqn newRoot)
    {
       RegionImpl clone;
-      clone = new RegionImpl(evictionRegionConfig, Fqn.fromRelativeFqn(newRoot, fqn), regionManager);
+      clone = new RegionImpl(evictionCacheConfig, Fqn.fromRelativeFqn(newRoot, fqn), regionManager);
       clone.status = status;
       // we also need to copy all of the eviction event nodes to the clone's queue
       clone.createQueue();
       for (EvictionEvent een : this.evictionEventQueue)
       {
-         clone.registerEvictionEvent(een.getFqn(), een.getEventType(), een.getElementDifference());
+//         clone.registerEvictionEvent(een.getKey(), een.getEventType(), een.getElementDifference());
       }
       return clone;
    }

Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -32,9 +32,8 @@
 import org.jboss.starobrno.util.concurrent.locks.ReentrantLockContainer;
 import org.jboss.starobrno.CacheException;
 import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.config.ConfigurationException;
 import org.jboss.starobrno.config.EvictionConfig;
-import org.jboss.starobrno.config.EvictionRegionConfig;
+import org.jboss.starobrno.config.EvictionCacheConfig;
 import org.jboss.starobrno.factories.annotations.Destroy;
 import org.jboss.starobrno.factories.annotations.Inject;
 import org.jboss.starobrno.factories.annotations.Start;
@@ -69,7 +68,7 @@
    CacheSPI_Legacy<?, ?> cache;
    private boolean usingEvictions;
    private EvictionConfig evictionConfig;
-   private final org.jboss.starobrno.eviction.EvictionTimerTask evictionTimerTask = new org.jboss.starobrno.eviction.EvictionTimerTask();
+   private final org.jboss.starobrno.eviction.EvictionTimerTask evictionTimerTask = null;//new org.jboss.starobrno.eviction.EvictionTimerTask();
 
    private final LockContainer<Fqn> regionLocks = new ReentrantLockContainer<Fqn>(4);
    protected Configuration configuration;
@@ -117,11 +116,11 @@
       {
          this.evictionConfig = configuration.getEvictionConfig();
          // start with the default region
-         EvictionRegionConfig defaultRegion = configuration.getEvictionConfig().getDefaultEvictionRegionConfig();
-         if (defaultRegion.getEvictionAlgorithmConfig() != null) defaultRegion.getEvictionAlgorithmConfig().validate();
+         EvictionCacheConfig defaultCache = configuration.getEvictionConfig().getDefaultEvictionRegionConfig();
+         if (defaultCache.getEvictionAlgorithmConfig() != null) defaultCache.getEvictionAlgorithmConfig().validate();
 
          // validate individual region configs now
-         for (EvictionRegionConfig erc : configuration.getEvictionConfig().getEvictionRegionConfigs())
+         for (EvictionCacheConfig erc : configuration.getEvictionConfig().getEvictionCacheConfigs())
          {
             evictionConfig.applyDefaults(erc);
             erc.validate();
@@ -290,7 +289,7 @@
 
       if (isUsingEvictions() && r.getEvictionRegionConfig() != null)
       {
-         evictionTimerTask.removeRegionToProcess(r);
+//         evictionTimerTask.removeRegionToProcess(r);
       }
       return true;
    }
@@ -568,7 +567,7 @@
          case ANY:
             return true;
          case EVICTION:
-            return r.getEvictionRegionConfig() != null && evictionTimerTask.isRegionRegisteredForProcessing(r);
+            return r.getEvictionRegionConfig() != null /*&& evictionTimerTask.isRegionRegisteredForProcessing(r)*/;
          case MARSHALLING:
             return r.isActive() && r.getClassLoader() != null;
       }
@@ -639,9 +638,9 @@
          // we need to loop thru the regions and only select specific regions to rtn.
          for (Region r : regionsRegistry.values())
          {
-            if ((type == EVICTION && r.getEvictionRegionConfig() != null && evictionTimerTask.isRegionRegisteredForProcessing(r)) ||
-                  (type == MARSHALLING && r.isActive() && r.getClassLoader() != null))
-               regions.add(r);
+//            if ((type == EVICTION && r.getEvictionCacheConfig() != null /*&& evictionTimerTask.isRegionRegisteredForProcessing(r))*/ ||
+//                  (type == MARSHALLING && r.isActive() && r.getClassLoader() != null))
+//               regions.add(r);
          }
       }
       else
@@ -665,7 +664,7 @@
       // JBAS-1288
       // Try to establish a default region if there isn't one already
 //      boolean needDefault;
-      List<EvictionRegionConfig> ercs = evictionConfig.getEvictionRegionConfigs();
+      List<EvictionCacheConfig> ercs = evictionConfig.getEvictionCacheConfigs();
       // Only add a default region if there are no regions. This is
       // contrary to the idea that there *must* be a default region, but some
       // unit tests fail w/ APPROACH 1, so for now we go with this approach.
@@ -677,24 +676,24 @@
       // create regions for the regions defined in the evictionConfig.
       // scan to be sure the _default_ region isn't added twice
       boolean setDefault = false;
-      for (EvictionRegionConfig erc : ercs)
+      for (EvictionCacheConfig erc : ercs)
       {
-         Fqn fqn = erc.getRegionFqn();
-         if (trace) log.trace("Creating eviction region " + fqn);
-
-         if (fqn.equals(DEFAULT_REGION) || fqn.isRoot())
-         {
-            if (setDefault)
-            {
-               throw new ConfigurationException("A default region for evictions has already been set for this cache");
-            }
-            if (trace) log.trace("Applying settings for default region to Fqn.ROOT");
-            fqn = Fqn.ROOT;
-            setDefault = true;
-         }
-         Region r = getRegion(fqn, true);
-         evictionConfig.applyDefaults(erc);
-         r.setEvictionRegionConfig(erc);
+//         Fqn fqn = erc.getCacheName();
+//         if (trace) log.trace("Creating eviction region " + fqn);
+//
+//         if (fqn.equals(DEFAULT_REGION) || fqn.isRoot())
+//         {
+//            if (setDefault)
+//            {
+//               throw new ConfigurationException("A default region for evictions has already been set for this cache");
+//            }
+//            if (trace) log.trace("Applying settings for default region to Fqn.ROOT");
+//            fqn = Fqn.ROOT;
+//            setDefault = true;
+//         }
+//         Region r = getRegion(fqn, true);
+//         evictionConfig.applyDefaults(erc);
+//         r.setEvictionRegionConfig(erc);
       }
    }
 

Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -117,7 +117,7 @@
    }
 
    @Override
-   public Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+   public Object visitEvictKeyCommand(InvocationContext ctx, EvictCommand command) throws Throwable
    {
       Fqn fqn = getBackupFqn(command.getFqn());
       return factory.buildEvictFqnCommand(fqn);

Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/AbstractVisitor.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/AbstractVisitor.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -78,7 +78,7 @@
       return handleDefault(ctx, command);
    }
 
-   public Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+   public Object visitEvictKeyCommand(InvocationContext ctx, EvictCommand command) throws Throwable
    {
       return handleDefault(ctx, command);
    }

Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/Visitor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/Visitor.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/Visitor.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -111,7 +111,7 @@
     * @return response from the visit
     * @throws Throwable in the event of problems.
     */
-   Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable;
+   Object visitEvictKeyCommand(InvocationContext ctx, EvictCommand command) throws Throwable;
 
    /**
     * Visits a InvalidateCommand.

Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -82,7 +82,7 @@
    /**
     * Evicts a node.
     * <p/>
-    * See {@link org.jboss.cache.interceptors.EvictionInterceptor#visitEvictFqnCommand(org.jboss.cache.InvocationContext , EvictCommand)}
+    * See {@link org.jboss.starobrno.interceptors.EvictionInterceptor#visitEvictKeyCommand(org.jboss.cache.InvocationContext , EvictCommand)}
     * which is where the return value is used
     *
     * @return true if the node was removed from the tree or if it is resident.  Returns false if the node still exists; i.e. was only data removed because it still has children.
@@ -175,7 +175,7 @@
 
    public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
    {
-      return visitor.visitEvictFqnCommand(ctx, this);
+      return visitor.visitEvictKeyCommand(ctx, this);
    }
 
    public int getCommandId()

Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -25,6 +25,7 @@
 import org.jboss.cache.Region;
 import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
 import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.interceptors.EvictionInterceptor;
 
 /**
  * A subclass of EvictionInterceptor that is aware of and able to deal with buddy regions.
@@ -42,29 +43,29 @@
       this.buddyFqnTransformer = transformer;
    }
 
-   @Override
    protected Region getRegion(Fqn fqn)
    {
-      Region r = super.getRegion(fqn);
-      if (r != null)
-         return r;
-      else if (buddyFqnTransformer.isBackupFqn(fqn))
-      {
-         // try and grab a backup region, creating one if need be.
-         Fqn actualFqn = buddyFqnTransformer.getActualFqn(fqn);
-         Fqn backupRoot = buddyFqnTransformer.getBackupRootFromFqn(fqn);
-
-         // the actual region could be a few levels higher than actualFqn
-         Region actualRegion = regionManager.getRegion(actualFqn, Region.Type.EVICTION, false);
-
-         if (actualRegion == null) return null;
-
-         //create a new region for this backup
-         Region newRegion = regionManager.getRegion(Fqn.fromRelativeFqn(backupRoot, actualRegion.getFqn()), Region.Type.EVICTION, true);
-         newRegion.setEvictionRegionConfig(actualRegion.getEvictionRegionConfig());
-
-         return newRegion;
-      }
-      else return null;
+//      Region r = super.getRegion(fqn);
+//      if (r != null)
+//         return r;
+//      else if (buddyFqnTransformer.isBackupFqn(fqn))
+//      {
+//         // try and grab a backup region, creating one if need be.
+//         Fqn actualFqn = buddyFqnTransformer.getActualFqn(fqn);
+//         Fqn backupRoot = buddyFqnTransformer.getBackupRootFromFqn(fqn);
+//
+//         // the actual region could be a few levels higher than actualFqn
+//         Region actualRegion = evictionCacheManager.getRegion(actualFqn, Region.Type.EVICTION, false);
+//
+//         if (actualRegion == null) return null;
+//
+//         //create a new region for this backup
+//         Region newRegion = evictionCacheManager.getRegion(Fqn.fromRelativeFqn(backupRoot, actualRegion.getFqn()), Region.Type.EVICTION, true);
+//         newRegion.configure(actualRegion.getEvictionCacheConfig());
+//
+//         return newRegion;
+//      }
+//      else return null;
+      return null;
    }
 }

Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,257 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.interceptors;
-
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Region;
-import org.jboss.cache.RegionManager;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.interceptors.base.CommandInterceptor;
-import static org.jboss.starobrno.eviction.EvictionEvent.Type.*;
-import org.jboss.starobrno.factories.annotations.Inject;
-
-/**
- * Eviction Interceptor.
- * <p/>
- * This interceptor is used to handle eviction events.
- *
- * @author Daniel Huang
- * @author Mircea.Markus at jboss.com
- * @version $Revision$
- */
-public class EvictionInterceptor extends CommandInterceptor
-{
-   protected RegionManager regionManager;
-
-   private DataContainer dataContainer;
-
-   @Inject
-   public void initialize(DataContainer dataContainer)
-   {
-      this.dataContainer = dataContainer;
-   }
-
-   /**
-    * this method is for ease of unit testing. thus package access.
-    * <p/>
-    * Not to be attempted to be used anywhere else.
-    */
-   @Inject
-   void setRegionManager(RegionManager regionManager)
-   {
-      this.regionManager = regionManager;
-   }
-
-   @Override
-   public Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
-   {
-      Fqn fqn = command.getFqn();
-      Object retVal = invokeNextInterceptor(ctx, command);
-      // See if the node still exists; i.e. was only data removed
-      // because it still has children.
-      // If yes, put an ADD event in the queue so the node gets revisited
-      boolean complete = (retVal != null && (Boolean) retVal);
-      if (!complete)
-      {
-         Region r;
-         if (fqn != null && (r = getRegion(fqn)) != null)
-         {
-            registerEvictionEventToRegionManager(fqn, ADD_NODE_EVENT, 0, r);
-         }
-      }
-      return retVal;
-   }
-
-   @Override
-   public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
-   {
-      return visitPutKeyValueCommand(ctx, command);
-   }
-
-   @Override
-   public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
-   {
-      Object retVal = invokeNextInterceptor(ctx, command);
-      Region r;
-      if (command.getFqn() != null && command.getKey() != null && (r = getRegion(command.getFqn())) != null)
-      {
-         registerEvictionEventToRegionManager(command.getFqn(), ADD_ELEMENT_EVENT, 1, r);
-      }
-      return retVal;
-   }
-
-   @Override
-   public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
-   {
-      Object retVal = invokeNextInterceptor(ctx, command);
-      Fqn fqn = command.getFqn();
-      Region r;
-      if (fqn != null && (r = getRegion(fqn)) != null)
-      {
-         if (command.getData() == null)
-         {
-            if (trace)
-            {
-               log.trace("Putting null data under fqn " + fqn + ".");
-            }
-         }
-         else
-         {
-            int size;
-            synchronized (command.getData())
-            {
-               size = command.getData().size();
-            }
-            registerEvictionEventToRegionManager(fqn, ADD_NODE_EVENT, size, r);
-         }
-      }
-      return retVal;
-   }
-
-   @Override
-   public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
-   {
-      Object retVal = invokeNextInterceptor(ctx, command);
-      if (retVal == null)
-      {
-         if (trace)
-         {
-            log.trace("No event added. Element does not exist");
-         }
-
-      }
-      else
-      {
-         Fqn fqn = command.getFqn();
-         Region r;
-         if (fqn != null && command.getKey() != null && (r = getRegion(fqn)) != null)
-         {
-            registerEvictionEventToRegionManager(fqn, REMOVE_ELEMENT_EVENT, 1, r);
-         }
-      }
-      return retVal;
-   }
-
-   @Override
-   public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
-   {
-      Object retVal = invokeNextInterceptor(ctx, command);
-      return handleGetNodeOrDataCommands(ctx, retVal, command.getFqn());
-   }
-
-   private Object handleGetNodeOrDataCommands(InvocationContext ctx, Object retVal, Fqn fqn)
-   {
-      if (retVal == null)
-      {
-         if (trace)
-         {
-            log.trace("No event added. Node does not exist");
-         }
-      }
-      else
-      {
-         Region r;
-         if (fqn != null && (r = getRegion(fqn)) != null)
-         {
-            registerEvictionEventToRegionManager(fqn, VISIT_NODE_EVENT, 0, r);
-         }
-      }
-      return retVal;
-   }
-
-   @Override
-   public Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
-   {
-      Object retVal = invokeNextInterceptor(ctx, command);
-      return handleGetNodeOrDataCommands(ctx, retVal, command.getFqn());
-   }
-
-   @Override
-   public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
-   {
-      Object retVal = invokeNextInterceptor(ctx, command);
-      Fqn fqn = command.getFqn();
-      Region r;
-      if (retVal == null)
-      {
-         if (trace)
-         {
-            log.trace("No event added. Element does not exist");
-         }
-      }
-      else if (fqn != null && command.getKey() != null && (r = getRegion(fqn)) != null)
-      {
-         registerEvictionEventToRegionManager(fqn, VISIT_NODE_EVENT, 0, r);
-      }
-      return retVal;
-   }
-
-   @Override
-   public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
-   {
-      Object retVal = invokeNextInterceptor(ctx, command);
-      Region r;
-      if (command.getFqn() != null && (r = getRegion(command.getFqn())) != null)
-      {
-         registerEvictionEventToRegionManager(command.getFqn(), REMOVE_NODE_EVENT, 0, r);
-      }
-      return retVal;
-   }
-
-   @Override
-   public Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
-   {
-      Object retVal = invokeNextInterceptor(ctx, command);
-      Region r;
-      if (command.getFqn() != null && (r = getRegion(command.getFqn())) != null)
-      {
-         registerEvictionEventToRegionManager(command.getFqn(), REMOVE_NODE_EVENT, 0, r);
-      }
-      return retVal;
-   }
-
-   private void registerEvictionEventToRegionManager(Fqn fqn, org.jboss.starobrno.eviction.EvictionEvent.Type type, int elementDifference, Region region)
-   {
-      //we do not trigger eviction events for resident nodes
-      if (dataContainer.isResident(fqn)) return;
-
-      region.registerEvictionEvent(fqn, type, elementDifference);
-
-      if (trace) log.trace("Registering event " + type + " on node " + fqn);
-   }
-
-   protected Region getRegion(Fqn fqn)
-   {
-      return regionManager.getRegion(fqn, Region.Type.EVICTION, false);
-   }
-}

Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -65,7 +65,7 @@
     * store using the CacheLoader.
     */
    @Override
-   public Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+   public Object visitEvictKeyCommand(InvocationContext ctx, EvictCommand command) throws Throwable
    {
       if (command.isRecursive())
       {

Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -154,7 +154,7 @@
    }
 
    @Override
-   public final Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+   public final Object visitEvictKeyCommand(InvocationContext ctx, EvictCommand command) throws Throwable
    {
       try
       {

Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -135,7 +135,7 @@
    }
 
    @Override
-   public final Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+   public final Object visitEvictKeyCommand(InvocationContext ctx, EvictCommand command) throws Throwable
    {
       if (skipInterception(ctx, command))
       {

Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -159,11 +159,11 @@
          case GetKeyValueCommand.METHOD_ID:
          case GetKeysCommand.METHOD_ID:
          case ExistsCommand.METHOD_ID:
-            fqn = ((DataCommand) cmd).getFqn();
+            fqn = ((DataCommand) cmd).getKey();
             break;
 
          case DataGravitationCleanupCommand.METHOD_ID:
-            fqn = ((DataGravitationCleanupCommand) cmd).getFqn();
+            fqn = ((DataGravitationCleanupCommand) cmd).getKey();
             break;
 
          case AnnounceBuddyPoolNameCommand.METHOD_ID:
@@ -179,12 +179,12 @@
             fqn = extractFqn(((ReplicateCommand) cmd).getModifications().get(0));
             break;
          case ClusteredGetCommand.METHOD_ID:
-            fqn = ((ClusteredGetCommand) cmd).getDataCommand().getFqn();
+            fqn = ((ClusteredGetCommand) cmd).getDataCommand().getKey();
             break;
          default:
             if (cmd instanceof DataCommand)
             {
-               fqn = ((DataCommand) cmd).getFqn();
+               fqn = ((DataCommand) cmd).getKey();
             }
             else
             {

Modified: core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -329,7 +329,7 @@
       {
          log.debug("Setting received partial state for subroot " + state_id);
          Fqn subroot = Fqn.fromString(targetRoot);
-//            Region region = regionManager.getRegion(subroot, false);
+//            Region region = evictionCacheManager.getRegion(subroot, false);
 //            ClassLoader cl = null;
 //            if (region != null)
 //            {
@@ -378,7 +378,7 @@
          log.debug("Setting received partial state for subroot " + stateId);
          in = new MarshalledValueInputStream(istream);
          Fqn subroot = Fqn.fromString(targetRoot);
-//            Region region = regionManager.getRegion(subroot, false);
+//            Region region = evictionCacheManager.getRegion(subroot, false);
 //            ClassLoader cl = null;
 //            if (region != null)
 //            {

Modified: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -190,13 +190,13 @@
    {
       if (curr == null) return;
       ctx.setOriginLocal(false);
-//      cache.getNotifier().notifyNodeCreated(curr.getFqn(), true, ctx);
-//      cache.getNotifier().notifyNodeCreated(curr.getFqn(), false, ctx);
+//      cache.getNotifier().notifyNodeCreated(curr.getKey(), true, ctx);
+//      cache.getNotifier().notifyNodeCreated(curr.getKey(), false, ctx);
       // AND notify that they have been modified!!
       if (!curr.getKeys().isEmpty())
       {
-//         cache.getNotifier().notifyNodeModified(curr.getFqn(), true, NodeModifiedEvent.ModificationType.PUT_MAP, Collections.emptyMap(), ctx);
-//         cache.getNotifier().notifyNodeModified(curr.getFqn(), false, NodeModifiedEvent.ModificationType.PUT_MAP, curr.getData(), ctx);
+//         cache.getNotifier().notifyNodeModified(curr.getKey(), true, NodeModifiedEvent.ModificationType.PUT_MAP, Collections.emptyMap(), ctx);
+//         cache.getNotifier().notifyNodeModified(curr.getKey(), false, NodeModifiedEvent.ModificationType.PUT_MAP, curr.getData(), ctx);
       }
       ctx.setOriginLocal(true);
 

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -57,4 +57,6 @@
    public void endBatch(boolean successful);
 
    List<Address> getMembers();
+
+   String getName();
 }

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -44,11 +44,13 @@
 import org.jboss.starobrno.factories.annotations.Inject;
 import org.jboss.starobrno.factories.annotations.NonVolatile;
 import org.jboss.starobrno.interceptors.InterceptorChain;
+import org.jboss.starobrno.interceptors.EvictionInterceptor;
 import org.jboss.starobrno.interceptors.base.CommandInterceptor;
 import org.jboss.starobrno.invocation.InvocationContextContainer;
 import org.jboss.starobrno.notifications.Notifier;
 import org.jboss.starobrno.transaction.GlobalTransaction;
 import org.jboss.starobrno.transaction.TransactionTable;
+import org.jboss.starobrno.eviction.EvictionCacheManager;
 import org.jgroups.Address;
 
 import javax.transaction.Transaction;
@@ -73,9 +75,12 @@
    protected ComponentRegistry componentRegistry;
    protected TransactionManager transactionManager;
    protected RPCManager rpcManager;
+   private String name;
+   private EvictionManager evictionManager;
 
    @Inject
-   private void injectDependencies(InvocationContextContainer invocationContextContainer,
+   private void injectDependencies(EvictionManager evictionManager,
+                                   InvocationContextContainer invocationContextContainer,
                                    CommandsFactory commandsFactory,
                                    InterceptorChain interceptorChain,
                                    Configuration configuration,
@@ -94,6 +99,7 @@
       this.transactionManager = transactionManager;
       this.batchContainer = batchContainer;
       this.rpcManager = rpcManager;
+      this.evictionManager = evictionManager;
    }
 
    public V putIfAbsent(K key, V value)
@@ -237,6 +243,10 @@
    public void stop()
    {
       componentRegistry.stop();
+      if (config.isUsingEviction())
+      {
+         evictionManager.cacheStopped(getName());
+      }
    }
 
    private InvocationContext buildCtx()
@@ -294,6 +304,11 @@
       throw new IllegalStateException();//todo Implement me properly
    }
 
+   public EvictionManager getEvictionManager()
+   {
+      return evictionManager;
+   }
+
    public RPCManager getRPCManager()
    {
       return rpcManager;
@@ -357,4 +372,19 @@
    {
       return rpcManager.getMembers();      
    }
+
+   public Object getDirect(Object key)
+   {
+      throw new UnsupportedOperationException("Not implemented");//todo please implement!
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public void setName(String name)
+   {
+      this.name = name;
+   }
 }

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -164,6 +164,9 @@
     */
    TransactionTable getTransactionTable();
 
+
+   EvictionManager getEvictionManager();
+
    /**
     * Gets a handle of the RPC manager.
     * <p/>
@@ -239,4 +242,6 @@
     * @see org.jboss.cache.factories.ComponentRegistry
     */
    ComponentRegistry getComponentRegistry();
+
+   public Object getDirect(Object key);
 }

Added: core/branches/flat/src/main/java/org/jboss/starobrno/EvictionManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/EvictionManager.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/EvictionManager.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,38 @@
+package org.jboss.starobrno;
+
+import org.jboss.starobrno.eviction.EvictionCacheManager;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import net.jcip.annotations.ThreadSafe;
+
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at ThreadSafe
+ at NonVolatile
+public interface EvictionManager
+{
+   /**
+    * Whenever a new cache is created this method should be called.
+    * If this cache does not have eviction enabled then this is a no-op.
+    * If the cache has eviction enabled then it is reistered for receivinge eviction information.
+    * If this is the first cache that requires eviction, the eviction theread will be started.
+    *
+    * @param cacheName
+    * @param cacheManager newly create cache.
+    */
+   public void cacheCreated(String cacheName, EvictionCacheManager cacheManager);
+
+
+   /**
+    * Whenever a cache will be stoped this method should be called.
+    * If the given cache doesn't have eviction enabled this is an no-op.
+    * If this is the only cache that has eviction enabled, then the eviction thread will be stopped.
+    * After calling this method the given cache will be unregistered from eviction events.
+    * @param chacheName
+    */
+   public void cacheStopped(String cacheName);
+
+   public void runEviction();
+}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -93,7 +93,9 @@
 
    public EvictCommand buildEvictCommand(Object key)
    {
-      return new EvictCommand(key);
+      EvictCommand command = new EvictCommand(key);
+      command.initialize(notifier);
+      return command;
    }
 
    public PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List modifications, Address localAddress, boolean onePhaseCommit)

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/EvictCommand.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -25,6 +25,7 @@
 import org.jboss.starobrno.commands.read.AbstractDataCommand;
 import org.jboss.starobrno.container.MVCCEntry;
 import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.notifications.Notifier;
 
 /**
  * @author Mircea.Markus at jboss.com
@@ -33,11 +34,18 @@
 {
    public static final byte METHOD_ID = 120;
 
+   private Notifier notifier;
+
    public EvictCommand(Object key)
    {
       this.key = key;
    }
 
+   public void initialize(Notifier notifier)
+   {
+      this.notifier = notifier;
+   }
+
    public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
    {
       return visitor.visitEvictCommand(ctx, this);
@@ -45,14 +53,16 @@
 
    public Object perform(InvocationContext ctx) throws Throwable
    {
-      // TODO: notification?!??
+
       if (key == null) throw new NullPointerException("Key is null!!");
 
       MVCCEntry e = ctx.lookupEntry(key);
       if (e != null && !e.isNullEntry())
       {
+         notifier.notifyCacheEntryEvicted(key, true, ctx);
          e.setDeleted(true);
          e.setValid(false);
+         notifier.notifyCacheEntryEvicted(key, false, ctx);
       }
 
       return null;

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -31,9 +31,7 @@
 import org.w3c.dom.Element;
 
 import java.net.URL;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
+import java.util.*;
 
 /**
  * Encapsulates the configuration of a Cache.
@@ -50,6 +48,18 @@
    private transient JGroupsStackParser jGroupsStackParser = new JGroupsStackParser();
    private boolean invocationBatchingEnabled;
 
+   private Map<String, EvictionCacheConfig> evictionCacheConfigs = new HashMap<String, EvictionCacheConfig>(4); 
+
+   public EvictionCacheConfig getEvictionCacheConfig(String cacheName)
+   {
+      return evictionCacheConfigs.values().iterator().next();
+   }
+
+   public void addEvictionCacheConfig(String cacheName, EvictionCacheConfig ecc)
+   {
+      evictionCacheConfigs.put(cacheName, ecc);
+   }
+
    /**
     * Behavior of the JVM shutdown hook registered by the cache
     */
@@ -970,4 +980,8 @@
       return null;
    }
 
+   public boolean isUsingEviction()
+   {
+      return getEvictionConfig() != null;
+   }
 }

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionAlgorithmConfig.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -59,4 +59,6 @@
     * @return a clone of the EvictionAlgorithmConfig.
     */
    EvictionAlgorithmConfig clone() throws CloneNotSupportedException;
+
+   public long getMinTimeToLive();
 }

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionCacheConfig.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionCacheConfig.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionCacheConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.config;
+
+import org.apache.commons.logging.LogFactory;
+
+public class EvictionCacheConfig extends ConfigurationComponent
+{
+   /**
+    * The serialVersionUID
+    */
+   private static final long serialVersionUID = -5482474634995601400L;
+
+   public static final String NAME = "name";
+   public static final String REGION = "region";
+
+   @Dynamic
+   private Integer eventQueueSize;
+   private EvictionAlgorithmConfig evictionAlgorithmConfig;
+   private String evictionActionClassName;
+
+   public EvictionCacheConfig(EvictionAlgorithmConfig evictionAlgorithmConfig)
+   {
+      eventQueueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
+      evictionActionClassName = EvictionConfig.EVICTION_ACTION_CLASS_DEFAULT;
+      this.evictionAlgorithmConfig = evictionAlgorithmConfig;
+   }
+
+   public EvictionCacheConfig(Integer eventQueueSize, EvictionAlgorithmConfig evictionAlgorithmConfig, String evictionActionClassName)
+   {
+      this.eventQueueSize = eventQueueSize;
+      this.evictionAlgorithmConfig = evictionAlgorithmConfig;
+      this.evictionActionClassName = evictionActionClassName;
+   }
+
+   public void setEventQueueSize(int queueSize)
+   {
+      testImmutability("eventQueueSize");
+      if (queueSize <= 0)
+      {
+         LogFactory.getLog(EvictionCacheConfig.class).warn("Ignoring invalid queue capacity " +
+               queueSize + " -- using " +
+               EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
+         queueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
+      }
+      this.eventQueueSize = queueSize;
+   }
+
+   /**
+    * Ensure this is a valid eviction region configuration.
+    */
+   public void validate()
+   {
+      if (eventQueueSize < 1)
+         throw new ConfigurationException("Eviction event queue size cannot be less than 1!");
+
+      if (evictionAlgorithmConfig == null)
+         throw new MissingPolicyException("Eviction algorithm configuration cannot be null!");
+
+      evictionAlgorithmConfig.validate();
+   }
+
+
+   public Integer getEventQueueSize()
+   {
+      return eventQueueSize;
+   }
+
+   public EvictionAlgorithmConfig getEvictionAlgorithmConfig()
+   {
+      return evictionAlgorithmConfig;
+   }
+
+   public String getEvictionActionClassName()
+   {
+      return evictionActionClassName;
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (o == null || getClass() != o.getClass()) return false;
+
+      EvictionCacheConfig that = (EvictionCacheConfig) o;
+
+      if (eventQueueSize != null ? !eventQueueSize.equals(that.eventQueueSize) : that.eventQueueSize != null)
+         return false;
+      if (evictionActionClassName != null ? !evictionActionClassName.equals(that.evictionActionClassName) : that.evictionActionClassName != null)
+         return false;
+      if (evictionAlgorithmConfig != null ? !evictionAlgorithmConfig.equals(that.evictionAlgorithmConfig) : that.evictionAlgorithmConfig != null)
+         return false;
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result;
+      result = (eventQueueSize != null ? eventQueueSize.hashCode() : 0);
+      result = 31 * result + (evictionAlgorithmConfig != null ? evictionAlgorithmConfig.hashCode() : 0);
+      result = 31 * result + (evictionActionClassName != null ? evictionActionClassName.hashCode() : 0);
+      return result;
+   }
+   
+}
\ No newline at end of file

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -22,8 +22,7 @@
 package org.jboss.starobrno.config;
 
 import org.jboss.cache.Fqn;
-import org.jboss.cache.RegionManagerImpl;
-import org.jboss.starobrno.eviction.DefaultEvictionActionPolicy;
+import org.jboss.starobrno.eviction.DefaultEvictionAction;
 
 import java.util.LinkedList;
 import java.util.List;
@@ -38,7 +37,7 @@
 
    public static final int WAKEUP_DEFAULT = 5000;
    public static final int EVENT_QUEUE_SIZE_DEFAULT = 200000;
-   public static final String EVICTION_ACTION_POLICY_CLASS_DEFAULT = DefaultEvictionActionPolicy.class.getName();
+   public static final String EVICTION_ACTION_CLASS_DEFAULT = DefaultEvictionAction.class.getName();
 
    /**
     * value expressed in millis
@@ -50,56 +49,56 @@
 
    // Dynamic to support runtime adds/removes of regions
    @Dynamic
-   private List<EvictionRegionConfig> evictionRegionConfigs;
-   private EvictionRegionConfig defaultEvictionRegionConfig;
+   private List<EvictionCacheConfig> evictionCacheConfigs;
+   private EvictionCacheConfig defaultEvictionCacheConfig;
    @Deprecated
    private String defaultEvictionPolicyClass;
 
    public EvictionConfig()
    {
-      evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
-      defaultEvictionRegionConfig = new EvictionRegionConfig(Fqn.ROOT);
-      defaultEvictionRegionConfig.setEventQueueSize(EVENT_QUEUE_SIZE_DEFAULT);
-      defaultEvictionRegionConfig.setEvictionActionPolicyClassName(DefaultEvictionActionPolicy.class.getName());
+//      evictionCacheConfigs = new LinkedList<EvictionCacheConfig>();
+//      defaultEvictionCacheConfig = new EvictionCacheConfig(Fqn.ROOT);
+//      defaultEvictionCacheConfig.setEventQueueSize(EVENT_QUEUE_SIZE_DEFAULT);
+//      defaultEvictionCacheConfig.setEvictionActionClassName(DefaultEvictionAction.class.getName());
    }
 
-   public EvictionConfig(EvictionRegionConfig defaultEvictionRegionConfig)
+   public EvictionConfig(EvictionCacheConfig defaultEvictionCacheConfig)
    {
-      evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
-      try
-      {
-         this.defaultEvictionRegionConfig = defaultEvictionRegionConfig.clone();
-      }
-      catch (CloneNotSupportedException e)
-      {
-         throw new ConfigurationException(e);
-      }
-      this.defaultEvictionRegionConfig.setEventQueueSize(EVENT_QUEUE_SIZE_DEFAULT);
-      if (this.defaultEvictionRegionConfig.getEvictionActionPolicyClassName() == null)
-         this.defaultEvictionRegionConfig.setEvictionActionPolicyClassName(DefaultEvictionActionPolicy.class.getName());
+      evictionCacheConfigs = new LinkedList<EvictionCacheConfig>();
+//      try
+//      {
+//         this.defaultEvictionCacheConfig = defaultEvictionCacheConfig.clone();
+//      }
+//      catch (CloneNotSupportedException e)
+//      {
+//         throw new ConfigurationException(e);
+//      }
+      this.defaultEvictionCacheConfig.setEventQueueSize(EVENT_QUEUE_SIZE_DEFAULT);
+//      if (this.defaultEvictionCacheConfig.getEvictionActionClassName() == null)
+//         this.defaultEvictionCacheConfig.setEvictionActionClassName(DefaultEvictionAction.class.getName());
    }
 
-   public EvictionConfig(EvictionRegionConfig defaultEvictionRegionConfig, int wakeupInterval)
+   public EvictionConfig(EvictionCacheConfig defaultEvictionCacheConfig, int wakeupInterval)
    {
-      this(defaultEvictionRegionConfig);
+      this(defaultEvictionCacheConfig);
       this.wakeupInterval = wakeupInterval;
    }
 
    public boolean isValidConfig()
    {
-      return (defaultEvictionRegionConfig != null && defaultEvictionRegionConfig.getEvictionActionPolicyClassName() != null && defaultEvictionRegionConfig.getEvictionAlgorithmConfig() != null)
-            || (evictionRegionConfigs != null && evictionRegionConfigs.size() > 0);
+      return (defaultEvictionCacheConfig != null && defaultEvictionCacheConfig.getEvictionActionClassName() != null && defaultEvictionCacheConfig.getEvictionAlgorithmConfig() != null)
+            || (evictionCacheConfigs != null && evictionCacheConfigs.size() > 0);
    }
 
-   public EvictionRegionConfig getDefaultEvictionRegionConfig()
+   public EvictionCacheConfig getDefaultEvictionRegionConfig()
    {
-      return defaultEvictionRegionConfig;
+      return defaultEvictionCacheConfig;
    }
 
-   public void setDefaultEvictionRegionConfig(EvictionRegionConfig defaultEvictionRegionConfig)
+   public void setDefaultEvictionRegionConfig(EvictionCacheConfig defaultEvictionCacheConfig)
    {
-      this.defaultEvictionRegionConfig = defaultEvictionRegionConfig;
-      this.defaultEvictionRegionConfig.setEventQueueSizeIfUnset(EVENT_QUEUE_SIZE_DEFAULT);
+      this.defaultEvictionCacheConfig = defaultEvictionCacheConfig;
+//      this.defaultEvictionCacheConfig.setEventQueueSizeIfUnset(EVENT_QUEUE_SIZE_DEFAULT);
    }
 
    /**
@@ -128,54 +127,54 @@
     * @deprecated the default region is now created when this instance is constructed.  Use {@link #getDefaultEvictionRegionConfig()} instead.
     */
    @Deprecated
-   public EvictionRegionConfig createDefaultEvictionRegionConfig()
+   public EvictionCacheConfig createDefaultEvictionRegionConfig()
    {
       return getDefaultEvictionRegionConfig();
    }
 
-   public List<EvictionRegionConfig> getEvictionRegionConfigs()
+   public List<EvictionCacheConfig> getEvictionCacheConfigs()
    {
-      return evictionRegionConfigs;
+      return evictionCacheConfigs;
    }
 
-   public void setEvictionRegionConfigs(List<EvictionRegionConfig> evictionRegionConfigs)
+   public void setEvictionRegionConfigs(List<EvictionCacheConfig> evictionCacheConfigs)
    {
-      testImmutability("evictionRegionConfigs");
-      EvictionRegionConfig toRemove = null;
-      for (EvictionRegionConfig erc : evictionRegionConfigs)
+      testImmutability("evictionCacheConfigs");
+      EvictionCacheConfig toRemove = null;
+      for (EvictionCacheConfig erc : evictionCacheConfigs)
       {
-         if (erc.getRegionFqn().isRoot() || erc.getRegionFqn().equals(RegionManagerImpl.DEFAULT_REGION))
-         {
-            mergeWithDefault(erc);
-            toRemove = erc;
-            break;
-         }
+//         if (erc.getCacheName().isRoot() || erc.getCacheName().equals(RegionManagerImpl.DEFAULT_REGION))
+//         {
+//            mergeWithDefault(erc);
+//            toRemove = erc;
+//            break;
+//         }
       }
 
-      if (toRemove != null) evictionRegionConfigs.remove(toRemove);
+      if (toRemove != null) evictionCacheConfigs.remove(toRemove);
 
-      this.evictionRegionConfigs = evictionRegionConfigs;
+      this.evictionCacheConfigs = evictionCacheConfigs;
    }
 
-   private void mergeWithDefault(EvictionRegionConfig erc)
+   private void mergeWithDefault(EvictionCacheConfig erc)
    {
-      erc.setEventQueueSizeIfUnset(defaultEvictionRegionConfig.getEventQueueSize());
-      if (erc.getEvictionAlgorithmConfig() == null)
-         erc.setEvictionAlgorithmConfig(defaultEvictionRegionConfig.getEvictionAlgorithmConfig());
-      defaultEvictionRegionConfig = erc;
+//      erc.setEventQueueSizeIfUnset(defaultEvictionCacheConfig.getEventQueueSize());
+//      if (erc.getEvictionAlgorithmConfig() == null)
+//         erc.setEvictionAlgorithmConfig(defaultEvictionCacheConfig.getEvictionAlgorithmConfig());
+//      defaultEvictionCacheConfig = erc;
    }
 
-   public void addEvictionRegionConfig(EvictionRegionConfig evictionRegionConfig)
+   public void addEvictionRegionConfig(EvictionCacheConfig evictionCacheConfig)
    {
-      testImmutability("evictionRegionConfigs");
-      if (evictionRegionConfig.getRegionFqn().isRoot() || evictionRegionConfig.getRegionFqn().equals(RegionManagerImpl.DEFAULT_REGION))
-      {
-         mergeWithDefault(evictionRegionConfig);
-      }
-      else
-      {
-         evictionRegionConfigs.add(evictionRegionConfig);
-      }
+      testImmutability("evictionCacheConfigs");
+//      if (evictionCacheConfig.getCacheName().isRoot() || evictionCacheConfig.getCacheName().equals(RegionManagerImpl.DEFAULT_REGION))
+//      {
+//         mergeWithDefault(evictionCacheConfig);
+//      }
+//      else
+//      {
+//         evictionCacheConfigs.add(evictionCacheConfig);
+//      }
    }
 
    /**
@@ -236,9 +235,9 @@
 
       if (defaultEventQueueSize != that.defaultEventQueueSize) return false;
       if (wakeupInterval != that.wakeupInterval) return false;
-      if (defaultEvictionRegionConfig != null ? !defaultEvictionRegionConfig.equals(that.defaultEvictionRegionConfig) : that.defaultEvictionRegionConfig != null)
+      if (defaultEvictionCacheConfig != null ? !defaultEvictionCacheConfig.equals(that.defaultEvictionCacheConfig) : that.defaultEvictionCacheConfig != null)
          return false;
-      if (evictionRegionConfigs != null ? !evictionRegionConfigs.equals(that.evictionRegionConfigs) : that.evictionRegionConfigs != null)
+      if (evictionCacheConfigs != null ? !evictionCacheConfigs.equals(that.evictionCacheConfigs) : that.evictionCacheConfigs != null)
          return false;
 
       return true;
@@ -249,7 +248,7 @@
       int result;
       result = 31 + (int) (wakeupInterval ^ (wakeupInterval >>> 32));
       result = 31 * result + defaultEventQueueSize;
-      result = 31 * result + (evictionRegionConfigs != null ? evictionRegionConfigs.hashCode() : 0);
+      result = 31 * result + (evictionCacheConfigs != null ? evictionCacheConfigs.hashCode() : 0);
       return result;
    }
 
@@ -257,12 +256,12 @@
    public EvictionConfig clone() throws CloneNotSupportedException
    {
       EvictionConfig clone = (EvictionConfig) super.clone();
-      if (evictionRegionConfigs != null)
+      if (evictionCacheConfigs != null)
       {
          // needs to be a deep copy
-         clone.evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
-         for (EvictionRegionConfig erc : evictionRegionConfigs)
-            clone.addEvictionRegionConfig(erc.clone());
+         clone.evictionCacheConfigs = new LinkedList<EvictionCacheConfig>();
+//         for (EvictionCacheConfig erc : evictionCacheConfigs)
+//            clone.addEvictionRegionConfig(erc.clone());
       }
       return clone;
    }
@@ -272,16 +271,16 @@
     * Returns the <code>EvictionRegionConfig</code> coresponding to given region fqn, or <code>null</code> if no
     * match is found.
     */
-   public EvictionRegionConfig getEvictionRegionConfig(String region)
+   public EvictionCacheConfig getEvictionRegionConfig(String region)
    {
       Fqn fqn = Fqn.fromString(region);
-      for (EvictionRegionConfig evConfig : getEvictionRegionConfigs())
+      for (EvictionCacheConfig evConfig : getEvictionCacheConfigs())
       {
-         if (evConfig.getRegionFqn().equals(fqn))
-         {
-            return evConfig;
-         }
-      }
+//         if (evConfig.getCacheName().equals(fqn))
+//         {
+//            return evConfig;
+//         }
+}
       return null;
    }
 
@@ -290,10 +289,10 @@
     *
     * @param config config to apply defaults to
     */
-   public void applyDefaults(EvictionRegionConfig config)
+   public void applyDefaults(EvictionCacheConfig config)
    {
-      if (config == null) return; // no op
-      config.setDefaults(defaultEvictionRegionConfig);
+//      if (config == null) return; // no op
+//      config.setDefaults(defaultEvictionCacheConfig);
    }
 
    /**
@@ -302,6 +301,6 @@
    @Deprecated
    public void setDefaultEventQueueSize(int queueSize)
    {
-      defaultEvictionRegionConfig.setEventQueueSize(queueSize);
+      defaultEvictionCacheConfig.setEventQueueSize(queueSize);
    }
 }

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,218 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.config;
-
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.starobrno.util.Util;
-
-import java.lang.reflect.Method;
-
-public class EvictionRegionConfig extends ConfigurationComponent
-{
-   /**
-    * The serialVersionUID
-    */
-   private static final long serialVersionUID = -5482474634995601400L;
-
-   public static final String NAME = "name";
-   public static final String REGION = "region";
-
-   private Fqn regionFqn;
-   @Dynamic
-   private Integer eventQueueSize;
-   private EvictionAlgorithmConfig evictionAlgorithmConfig;
-   private String evictionActionPolicyClassName;
-
-   public EvictionRegionConfig()
-   {
-   }
-
-   public EvictionRegionConfig(Fqn regionFqn, EvictionAlgorithmConfig evictionAlgorithmConfig)
-   {
-      this.regionFqn = regionFqn;
-      this.evictionAlgorithmConfig = evictionAlgorithmConfig;
-   }
-
-   public EvictionRegionConfig(Fqn regionFqn, EvictionAlgorithmConfig evictionAlgorithmConfig, int queueSize)
-   {
-      this.regionFqn = regionFqn;
-      this.evictionAlgorithmConfig = evictionAlgorithmConfig;
-      this.eventQueueSize = queueSize;
-   }
-
-   public EvictionRegionConfig(Fqn fqn)
-   {
-      this.regionFqn = fqn;
-   }
-
-   public EvictionAlgorithmConfig getEvictionAlgorithmConfig()
-   {
-      return evictionAlgorithmConfig;
-   }
-
-   public void setEvictionAlgorithmConfig(EvictionAlgorithmConfig config)
-   {
-      testImmutability("evictionAlgorithmConfig");
-      this.evictionAlgorithmConfig = config;
-   }
-
-   public Fqn getRegionFqn()
-   {
-      return regionFqn;
-   }
-
-   public void setRegionFqn(Fqn regionFqn)
-   {
-      testImmutability("regionFqn");
-      this.regionFqn = regionFqn;
-   }
-
-   public String getRegionName()
-   {
-      return regionFqn == null ? null : regionFqn.toString();
-   }
-
-   public void setRegionName(String name)
-   {
-      setRegionFqn(name == null ? null : Fqn.fromString(name));
-   }
-
-   public int getEventQueueSize()
-   {
-      return eventQueueSize == null ? EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT : eventQueueSize;
-   }
-
-   public void setEventQueueSize(int queueSize)
-   {
-      testImmutability("eventQueueSize");
-      if (queueSize <= 0)
-      {
-         LogFactory.getLog(EvictionRegionConfig.class).warn("Ignoring invalid queue capacity " +
-               queueSize + " -- using " +
-               EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
-         queueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
-      }
-      this.eventQueueSize = queueSize;
-   }
-
-   public void setDefaults(EvictionRegionConfig defaults)
-   {
-      // go thru each element that is unset here and copy from "defaults"
-      if (eventQueueSize == null) eventQueueSize = defaults.getEventQueueSize();
-      if (evictionAlgorithmConfig == null) evictionAlgorithmConfig = defaults.getEvictionAlgorithmConfig();
-      if (evictionActionPolicyClassName == null)
-         evictionActionPolicyClassName = defaults.getEvictionActionPolicyClassName();
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      if (this == obj)
-         return true;
-
-      if (obj instanceof EvictionRegionConfig)
-      {
-         EvictionRegionConfig other = (EvictionRegionConfig) obj;
-         boolean equalRegions = Util.safeEquals(this.regionFqn, other.regionFqn);
-         boolean equalConfigurations = Util.safeEquals(this.evictionAlgorithmConfig, other.evictionAlgorithmConfig);
-         boolean equalEventQueuSizes = this.getEventQueueSize() == other.getEventQueueSize();
-         return equalRegions && equalConfigurations && equalConfigurations && equalEventQueuSizes;
-      }
-      return false;
-   }
-
-   @Override
-   public int hashCode()
-   {
-      int result = 17;
-      result = 31 * result + (regionFqn == null ? 0 : regionFqn.hashCode());
-
-      return result;
-   }
-
-   @Override
-   public EvictionRegionConfig clone() throws CloneNotSupportedException
-   {
-      EvictionRegionConfig clone = (EvictionRegionConfig) super.clone();
-      if (evictionAlgorithmConfig != null)
-      {
-         if (evictionAlgorithmConfig instanceof ConfigurationComponent)
-         {
-            clone.setEvictionAlgorithmConfig((EvictionAlgorithmConfig) ((ConfigurationComponent) evictionAlgorithmConfig).clone());
-         }
-         else
-         {
-            try
-            {
-               Method cloneMethod = this.evictionAlgorithmConfig.getClass().getDeclaredMethod("clone");
-               EvictionAlgorithmConfig evictionAlgorithmConfig = (EvictionAlgorithmConfig) cloneMethod.invoke(this.evictionAlgorithmConfig);
-               clone.setEvictionAlgorithmConfig(evictionAlgorithmConfig);
-            }
-            catch (Exception e)
-            {
-               CloneNotSupportedException cnse = new CloneNotSupportedException("Cannot invoke clone() on " + evictionAlgorithmConfig);
-               cnse.initCause(e);
-               throw cnse;
-            }
-         }
-      }
-
-      clone.evictionActionPolicyClassName = evictionActionPolicyClassName;
-
-      return clone;
-   }
-
-   public boolean isDefaultRegion()
-   {
-      return regionFqn.isRoot();
-   }
-
-   public String getEvictionActionPolicyClassName()
-   {
-      return evictionActionPolicyClassName == null ? EvictionConfig.EVICTION_ACTION_POLICY_CLASS_DEFAULT : evictionActionPolicyClassName;
-   }
-
-   public void setEvictionActionPolicyClassName(String evictionActionPolicyClassName)
-   {
-      this.evictionActionPolicyClassName = evictionActionPolicyClassName;
-   }
-
-   public void setEventQueueSizeIfUnset(int eventQueueSize)
-   {
-      if (this.eventQueueSize == null) this.eventQueueSize = eventQueueSize;
-   }
-
-   /**
-    * Ensure this is a valid eviction region configuration.
-    */
-   public void validate()
-   {
-      if (eventQueueSize < 1)
-         throw new ConfigurationException("Eviction event queue size cannot be less than 1!");
-
-      if (evictionAlgorithmConfig == null)
-         throw new MissingPolicyException("Eviction algorithm configuration cannot be null!");
-
-      evictionAlgorithmConfig.validate();
-   }
-}
\ No newline at end of file

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -22,11 +22,8 @@
 package org.jboss.starobrno.config.parsing.element;
 
 import org.jboss.starobrno.util.Util;
-import org.jboss.starobrno.config.ConfigurationException;
-import org.jboss.starobrno.config.EvictionAlgorithmConfig;
-import org.jboss.starobrno.config.EvictionConfig;
-import org.jboss.starobrno.config.EvictionRegionConfig;
-import org.jboss.starobrno.config.MissingPolicyException;
+import org.jboss.starobrno.config.EvictionCacheConfig;
+import org.jboss.starobrno.config.*;
 import org.jboss.starobrno.config.parsing.ParsedAttributes;
 import org.jboss.starobrno.config.parsing.XmlConfigHelper;
 import org.jboss.starobrno.config.parsing.XmlParserBase;
@@ -62,124 +59,125 @@
          throw new ConfigurationException("Missing mandatory attribute wakeUpInterval");
       }
 
-      List<EvictionRegionConfig> evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
+      List<EvictionCacheConfig> evictionCacheConfigs = new LinkedList<EvictionCacheConfig>();
       Element defaultRegion = getSingleElementInCoreNS("default", evictionElement);
 
       if (defaultRegion != null)
       {
-         EvictionRegionConfig defaultRegionConfig = getEvictionRegionConfig(defaultRegion, null, true);
-         if (defaultRegionConfig.getEvictionAlgorithmConfig() == null)
+         EvictionCacheConfig defaultCacheConfig = getEvictionRegionConfig(defaultRegion, null, true);
+         if (defaultCacheConfig.getEvictionAlgorithmConfig() == null)
             throw new MissingPolicyException("Default eviction region should have an evictionAlgorithmClass defined.");
-         evictionConfig.setDefaultEvictionRegionConfig(defaultRegionConfig);
+         evictionConfig.setDefaultEvictionRegionConfig(defaultCacheConfig);
       }
 
       NodeList regions = evictionElement.getElementsByTagName("region");
       for (int i = 0; i < regions.getLength(); i++)
       {
          Element regionConfig = (Element) regions.item(i);
-         EvictionRegionConfig erc = getEvictionRegionConfig(regionConfig, evictionConfig.getDefaultEvictionRegionConfig(), false);
+         EvictionCacheConfig erc = getEvictionRegionConfig(regionConfig, evictionConfig.getDefaultEvictionRegionConfig(), false);
          evictionConfig.applyDefaults(erc);
-         evictionRegionConfigs.add(erc);
+         evictionCacheConfigs.add(erc);
       }
-      evictionConfig.setEvictionRegionConfigs(evictionRegionConfigs);
+      evictionConfig.setEvictionRegionConfigs(evictionCacheConfigs);
       return evictionConfig;
    }
 
    @SuppressWarnings("unchecked")
-   private EvictionRegionConfig getEvictionRegionConfig(Element element, EvictionRegionConfig defaultRegion, boolean isDefault)
+   private EvictionCacheConfig getEvictionRegionConfig(Element element, EvictionCacheConfig defaultCache, boolean isDefault)
    {
-      EvictionRegionConfig erc = new EvictionRegionConfig();
-      erc.setRegionName(getAttributeValue(element, "name"));
-      String queueSize = getAttributeValue(element, "eventQueueSize");
-      if (existsAttribute(queueSize))
-      {
-         erc.setEventQueueSize(getInt(queueSize));
-      }
-      else if (defaultRegion == null)
-      {
-         erc.setEventQueueSize(EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
-      }
-
-      String algorithmClassName = getAttributeValue(element, "algorithmClass");
-      EvictionAlgorithmConfig algorithmConfig = null; // every eviction region config needs an algorithm config.
-
-      if (existsAttribute(algorithmClassName))
-      {
-         EvictionAlgorithm algorithm;
-         Class<? extends EvictionAlgorithm> algorithmClass;
-         // try using a 'getInstance()' factory.
-
-         try
-         {
-            algorithmClass = Util.loadClass(algorithmClassName);
-         }
-         catch (Exception e)
-         {
-            throw new RuntimeException("Unable to load eviction algorithm class [" + algorithmClassName + "]", e);
-         }
-
-
-         try
-         {
-            algorithm = Util.getInstance(algorithmClass);
-         }
-         catch (Exception e)
-         {
-            throw new ConfigurationException("Unable to construct eviction algorithm class [" + algorithmClassName + "]", e);
-         }
-
-         try
-         {
-            algorithmConfig = Util.getInstance(algorithm.getConfigurationClass());
-         }
-         catch (Exception e)
-         {
-            throw new RuntimeException("Failed to instantiate eviction algorithm configuration class [" +
-                  algorithm.getConfigurationClass() + "]", e);
-         }
-      }
-      else
-      {
-         if (!isDefault)
-         {
-            if (defaultRegion == null || defaultRegion.getEvictionAlgorithmConfig() == null)
-            {
-               throw new MissingPolicyException("There is no Eviction Algorithm Class specified on the region or for the entire cache!");
-            }
-            else
-            {
-               try
-               {
-                  algorithmConfig = defaultRegion.getEvictionAlgorithmConfig().clone();
-               }
-               catch (CloneNotSupportedException e)
-               {
-                  throw new ConfigurationException("Unable to clone eviction algorithm configuration from default", e);
-               }
-            }
-         }
-      }
-
-      if (algorithmConfig != null)
-      {
-         parseEvictionPolicyConfig(element, algorithmConfig);
-
-         erc.setEvictionAlgorithmConfig(algorithmConfig);
-      }
-
-      String actionPolicyClass = getAttributeValue(element, "actionPolicyClass");
-      if (existsAttribute(actionPolicyClass))
-      {
-         erc.setEvictionActionPolicyClassName(actionPolicyClass);
-      }
-      else if (defaultRegion == null)
-      {
-         // this is the default region. Make sure we set the default EvictionActionPolicyClass.
-         erc.setEvictionActionPolicyClassName(EvictionConfig.EVICTION_ACTION_POLICY_CLASS_DEFAULT);
-      }
-
-
-      return erc;
+//      EvictionCacheConfig erc = new EvictionCacheConfig();
+//      erc.setRegionName(getAttributeValue(element, "name"));
+//      String queueSize = getAttributeValue(element, "eventQueueSize");
+//      if (existsAttribute(queueSize))
+//      {
+//         erc.setEventQueueSize(getInt(queueSize));
+//      }
+//      else if (defaultCache == null)
+//      {
+//         erc.setEventQueueSize(EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
+//      }
+//
+//      String algorithmClassName = getAttributeValue(element, "algorithmClass");
+//      EvictionAlgorithmConfig algorithmConfig = null; // every eviction region config needs an algorithm config.
+//
+//      if (existsAttribute(algorithmClassName))
+//      {
+//         EvictionAlgorithm algorithm;
+//         Class<? extends EvictionAlgorithm> algorithmClass;
+//         // try using a 'getInstance()' factory.
+//
+//         try
+//         {
+//            algorithmClass = Util.loadClass(algorithmClassName);
+//         }
+//         catch (Exception e)
+//         {
+//            throw new RuntimeException("Unable to load eviction algorithm class [" + algorithmClassName + "]", e);
+//         }
+//
+//
+//         try
+//         {
+//            algorithm = Util.getInstance(algorithmClass);
+//         }
+//         catch (Exception e)
+//         {
+//            throw new ConfigurationException("Unable to construct eviction algorithm class [" + algorithmClassName + "]", e);
+//         }
+//
+//         try
+//         {
+//            algorithmConfig = (EvictionAlgorithmConfig) Util.getInstance(algorithm.getConfigurationClass());
+//         }
+//         catch (Exception e)
+//         {
+//            throw new RuntimeException("Failed to instantiate eviction algorithm configuration class [" +
+//                  algorithm.getConfigurationClass() + "]", e);
+//         }
+//      }
+//      else
+//      {
+//         if (!isDefault)
+//         {
+//            if (defaultCache == null || defaultCache.getEvictionAlgorithmConfig() == null)
+//            {
+//               throw new MissingPolicyException("There is no Eviction Algorithm Class specified on the region or for the entire cache!");
+//            }
+//            else
+//            {
+//               try
+//               {
+//                  algorithmConfig = defaultCache.getEvictionAlgorithmConfig().clone();
+//               }
+//               catch (CloneNotSupportedException e)
+//               {
+//                  throw new ConfigurationException("Unable to clone eviction algorithm configuration from default", e);
+//               }
+//            }
+//         }
+//      }
+//
+//      if (algorithmConfig != null)
+//      {
+//         parseEvictionPolicyConfig(element, algorithmConfig);
+//
+//         erc.setEvictionAlgorithmConfig(algorithmConfig);
+//      }
+//
+//      String actionPolicyClass = getAttributeValue(element, "actionPolicyClass");
+//      if (existsAttribute(actionPolicyClass))
+//      {
+//         erc.setEvictionActionClassName(actionPolicyClass);
+//      }
+//      else if (defaultCache == null)
+//      {
+//         // this is the default region. Make sure we set the default EvictionActionPolicyClass.
+//         erc.setEvictionActionClassName(EvictionConfig.EVICTION_ACTION_CLASS_DEFAULT);
+//      }
+//
+//
+//      return erc;
+      return null;
    }
 
    public static void parseEvictionPolicyConfig(Element element, EvictionAlgorithmConfig target)

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,614 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
-import org.jboss.starobrno.lock.TimeoutException;
-import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.config.EvictionAlgorithmConfig;
-import org.jboss.starobrno.eviction.EvictionEvent.Type;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Abstract Event Processing Eviction Algorithm.
- * This class is used to implement basic event processing for Eviction Algorithms.
- * To extend this abstract class to make an Eviction Algorithm, implement the
- * abstract methods and a policy.
- *
- * @author Daniel Huang - dhuang at jboss.org 10/2005
- * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
- * @version $Revision: 6776 $
- */
-public abstract class BaseEvictionAlgorithm implements EvictionAlgorithm
-{
-   private static final Log log = LogFactory.getLog(BaseEvictionAlgorithm.class);
-   private static final boolean trace = log.isTraceEnabled();
-   protected org.jboss.starobrno.eviction.EvictionActionPolicy evictionActionPolicy;
-   protected EvictionAlgorithmConfig evictionAlgorithmConfig;
-   /**
-    * Contains Fqn instances.
-    */
-   protected BlockingQueue<Fqn> recycleQueue;
-   /**
-    * Contains NodeEntry instances.
-    */
-   protected org.jboss.starobrno.eviction.EvictionQueue evictionQueue;
-   protected boolean allowTombstones = false;
-   protected Configuration configuration;
-   protected Fqn regionFqn;
-   protected CacheSPI_Legacy<?, ?> cache;
-
-   /**
-    * This method will create an EvictionQueue implementation and prepare it for use.
-    *
-    * @return The created EvictionQueue to be used as the eviction queue for this algorithm.
-    * @throws org.jboss.starobrno.eviction.EvictionException
-    *          if there are problems
-    * @see org.jboss.starobrno.eviction.EvictionQueue
-    */
-   protected abstract org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException;
-
-   /**
-    * This method will check whether the given node should be evicted or not.
-    *
-    * @param ne NodeEntry to test eviction for.
-    * @return True if the given node should be evicted. False if the given node should not be evicted.
-    */
-   protected abstract boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne);
-
-   protected BaseEvictionAlgorithm()
-   {
-      recycleQueue = new LinkedBlockingQueue<Fqn>(500000);
-   }
-
-   public synchronized void initialize()
-   {
-      if (evictionQueue == null)
-      {
-         evictionQueue = setupEvictionQueue();
-         allowTombstones = false;
-      }
-   }
-
-   public org.jboss.starobrno.eviction.EvictionActionPolicy getEvictionActionPolicy()
-   {
-      return evictionActionPolicy;
-   }
-
-   public void setEvictionActionPolicy(org.jboss.starobrno.eviction.EvictionActionPolicy evictionActionPolicy)
-   {
-      this.evictionActionPolicy = evictionActionPolicy;
-   }
-
-   public EvictionAlgorithmConfig getEvictionAlgorithmConfig()
-   {
-      return evictionAlgorithmConfig;
-   }
-
-   public void assignToRegion(Fqn fqn, CacheSPI_Legacy<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration)
-   {
-      this.regionFqn = fqn;
-      this.cache = cache;
-      this.evictionAlgorithmConfig = evictionAlgorithmConfig;
-      this.configuration = configuration;
-   }
-
-   public boolean canIgnoreEvent(Type eventType)
-   {
-      return false; // don't ignore anything!
-   }
-
-   /**
-    * Process the given eviction event queue.  Eviction Processing encompasses the following:
-    * <p/>
-    * - Add/Remove/Visit Nodes
-    * - Prune according to Eviction Algorithm
-    * - Empty/Retry the recycle queue of previously evicted but locked (during actual cache eviction) nodes.
-    *
-    * @param eventQueue queue containing eviction events
-    * @throws org.jboss.starobrno.eviction.EvictionException
-    *
-    */
-   public void process(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> eventQueue) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      if (trace) log.trace("process(): region: " + regionFqn);
-      initialize();
-      this.processQueues(eventQueue);
-      this.emptyRecycleQueue();
-      this.prune();
-   }
-
-   public void resetEvictionQueue()
-   {
-      // a no-op
-   }
-
-   /**
-    * Get the underlying EvictionQueue implementation.
-    *
-    * @return the EvictionQueue used by this algorithm
-    * @see org.jboss.starobrno.eviction.EvictionQueue
-    */
-   public org.jboss.starobrno.eviction.EvictionQueue getEvictionQueue()
-   {
-      return this.evictionQueue;
-   }
-
-   protected org.jboss.starobrno.eviction.EvictionEvent getNextInQueue(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> queue)
-   {
-      try
-      {
-         return queue.poll(0, TimeUnit.SECONDS);
-      }
-      catch (InterruptedException e)
-      {
-         Thread.currentThread().interrupt();
-      }
-      return null;
-   }
-
-   /**
-    * Event processing for Evict/Add/Visiting of nodes.
-    * <p/>
-    * - On AddEvents a new element is added into the eviction queue
-    * - On RemoveEvents, the removed element is removed from the eviction queue.
-    * - On VisitEvents, the visited node has its eviction statistics updated (idleTime, numberOfNodeVisists, etc..)
-    *
-    * @param queue queue to inspect
-    * @throws org.jboss.starobrno.eviction.EvictionException
-    *          in the event of problems
-    */
-   protected void processQueues(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> queue) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      org.jboss.starobrno.eviction.EvictionEvent node;
-      int count = 0;
-      while ((node = getNextInQueue(queue)) != null)
-      {
-         count++;
-         switch (node.getEventType())
-         {
-            case ADD_NODE_EVENT:
-               this.processAddedNodes(node);
-               break;
-            case REMOVE_NODE_EVENT:
-               this.processRemovedNodes(node);
-               break;
-            case VISIT_NODE_EVENT:
-               this.processVisitedNodes(node);
-               break;
-            case ADD_ELEMENT_EVENT:
-               this.processAddedElement(node);
-               break;
-            case REMOVE_ELEMENT_EVENT:
-               this.processRemovedElement(node);
-               break;
-            case MARK_IN_USE_EVENT:
-               this.processMarkInUseNodes(node.getFqn(), node.getInUseTimeout());
-               break;
-            case UNMARK_USE_EVENT:
-               this.processUnmarkInUseNodes(node.getFqn());
-               break;
-            default:
-               throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
-         }
-      }
-
-      if (trace) log.trace("processed " + count + " node events");
-   }
-
-   protected void evict(org.jboss.starobrno.eviction.NodeEntry ne)
-   {
-//      NodeEntry ne = evictionQueue.getNodeEntry(fqn);
-      if (ne != null)
-      {
-         evictionQueue.removeNodeEntry(ne);
-         if (!this.evictCacheNode(ne.getFqn()))
-         {
-            try
-            {
-               boolean result = recycleQueue.offer(ne.getFqn(), 5, TimeUnit.SECONDS);
-               if (!result)
-               {
-                  log.warn("Unable to add Fqn[" + ne.getFqn() + "] to recycle " +
-                        "queue because it's full. This is often sign that " +
-                        "evictions are not occurring and nodes that should be " +
-                        "evicted are piling up waiting to be evicted.");
-               }
-            }
-            catch (InterruptedException e)
-            {
-               log.debug("InterruptedException", e);
-            }
-         }
-      }
-   }
-
-   /**
-    * Evict a node from cache.
-    *
-    * @param fqn node corresponds to this fqn
-    * @return True if successful
-    */
-   protected boolean evictCacheNode(Fqn fqn)
-   {
-      if (trace) log.trace("Attempting to evict cache node with fqn of " + fqn);
-
-      try
-      {
-         evictionActionPolicy.evict(fqn);
-      }
-      catch (TimeoutException e)
-      {
-         log.warn("Eviction of " + fqn + " timed out, retrying later");
-         log.debug(e, e);
-         return false;
-      }
-      catch (Exception e)
-      {
-         log.error("Eviction of " + fqn + " failed", e);
-         return false;
-      }
-
-      if (trace)
-      {
-         log.trace("Eviction of cache node with fqn of " + fqn + " successful");
-      }
-
-      return true;
-   }
-
-   protected void processMarkInUseNodes(Fqn fqn, long inUseTimeout) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      if (trace)
-      {
-         log.trace("Marking node " + fqn + " as in use with a usage timeout of " + inUseTimeout);
-      }
-
-      org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
-      if (ne != null)
-      {
-         ne.setCurrentlyInUse(true, inUseTimeout);
-      }
-   }
-
-   protected void processUnmarkInUseNodes(Fqn fqn) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      if (trace)
-      {
-         log.trace("Unmarking node " + fqn + " as in use");
-      }
-
-      org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
-      if (ne != null)
-      {
-         ne.setCurrentlyInUse(false, 0);
-      }
-   }
-
-   /**
-    * Convenience method, which calls {@link #processAddedNodes(org.jboss.starobrno.eviction.EvictionEvent , int)}  using values in the
-    * evictedEventNode for number of added elements and the resetElementCount flag.
-    *
-    * @param evictedEventNode an evictedEventNode to process
-    * @throws org.jboss.starobrno.eviction.EvictionException
-    *          on problems
-    */
-   protected void processAddedNodes(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      processAddedNodes(evictedEventNode, evictedEventNode.getElementDifference());
-   }
-
-   protected void processAddedNodes(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode, int numAddedElements) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      Fqn fqn = evictedEventNode.getFqn();
-
-      if (trace)
-      {
-         log.trace("Adding node " + fqn + " with " + numAddedElements + " elements to eviction queue");
-      }
-
-      org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
-      if (ne != null)
-      {
-         ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
-         ne.setNumberOfNodeVisits(ne.getNumberOfNodeVisits() + 1);
-         ne.setNumberOfElements(ne.getNumberOfElements() + numAddedElements);
-         if (trace)
-         {
-            log.trace("Queue already contains " + ne.getFqn() + " processing it as visited");
-         }
-         processVisitedNodes(evictedEventNode);
-         return;
-      }
-
-      ne = new org.jboss.starobrno.eviction.NodeEntry(fqn);
-      ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
-      ne.setNumberOfNodeVisits(1);
-      ne.setNumberOfElements(numAddedElements);
-
-      evictionQueue.addNodeEntry(ne);
-
-      if (trace)
-      {
-         log.trace(ne.getFqn() + " added successfully to eviction queue");
-      }
-   }
-
-   /**
-    * Remove a node from cache.
-    * <p/>
-    * This method will remove the node from the eviction queue as well as
-    * evict the node from cache.
-    * <p/>
-    * If a node cannot be removed from cache, this method will remove it from the eviction queue
-    * and place the element into the recycleQueue. Each node in the recycle queue will get retried until
-    * proper cache eviction has taken place.
-    * <p/>
-    * Because EvictionQueues are collections, when iterating them from an iterator, use iterator.remove()
-    * to avoid ConcurrentModificationExceptions. Use the boolean parameter to indicate the calling context.
-    *
-    * @throws org.jboss.starobrno.eviction.EvictionException
-    *
-    */
-   protected void processRemovedNodes(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      Fqn fqn = evictedEventNode.getFqn();
-
-      if (trace)
-      {
-         log.trace("Removing node " + fqn + " from eviction queue and attempting eviction");
-      }
-
-      org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
-      if (ne != null)
-      {
-         if (allowTombstones)
-         {
-            // don't remove from the queue - deleting a node results in a tombstone which means the nodes
-            // still need to be considered for eviction!
-            return;
-         }
-         else
-         {
-            // a removeNode operation will simply remove the node.  Nothing to worry about.
-            evictionQueue.removeNodeEntry(ne);
-         }
-      }
-      else
-      {
-         if (trace)
-         {
-            log.trace("processRemoveNodes(): Can't find node associated with fqn: " + fqn
-                  + "Could have been evicted earlier. Will just continue.");
-         }
-         return;
-      }
-
-      if (trace)
-      {
-         log.trace(fqn + " removed from eviction queue");
-      }
-   }
-
-   /**
-    * Visit a node in cache.
-    * <p/>
-    * This method will update the numVisits and modifiedTimestamp properties of the Node.
-    * These properties are used as statistics to determine eviction (LRU, LFU, MRU, etc..)
-    * <p/>
-    * *Note* that this method updates Node Entries by reference and does not put them back
-    * into the queue. For some sorted collections, a remove, and a re-add is required to
-    * maintain the sorted order of the elements.
-    *
-    * @throws org.jboss.starobrno.eviction.EvictionException
-    *
-    */
-   protected void processVisitedNodes(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      Fqn fqn = evictedEventNode.getFqn();
-      org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
-      if (ne == null)
-      {
-         if (log.isDebugEnabled())
-         {
-            log.debug("Visiting node that was not added to eviction queues. Assuming that it has 1 element.");
-         }
-         this.processAddedNodes(evictedEventNode, 1);
-         return;
-      }
-      // note this method will visit and modify the node statistics by reference!
-      // if a collection is only guaranteed sort order by adding to the collection,
-      // this implementation will not guarantee sort order.
-      ne.setNumberOfNodeVisits(ne.getNumberOfNodeVisits() + 1);
-      ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
-   }
-
-   protected void processRemovedElement(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      Fqn fqn = evictedEventNode.getFqn();
-      org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
-
-      if (ne == null)
-      {
-         if (log.isDebugEnabled())
-         {
-            log.debug("Removing element from " + fqn + " but eviction queue does not contain this node. " +
-                  "Ignoring removeElement event.");
-         }
-         return;
-      }
-
-      ne.setNumberOfElements(ne.getNumberOfElements() - 1);
-      // also treat it as a node visit.
-      ne.setNumberOfNodeVisits(ne.getNumberOfNodeVisits() + 1);
-      ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
-   }
-
-   protected void processAddedElement(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      Fqn fqn = evictedEventNode.getFqn();
-      org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
-      if (ne == null)
-      {
-         if (trace)
-         {
-            log.trace("Adding element " + fqn + " for a node that doesn't exist yet. Process as an add.");
-         }
-         this.processAddedNodes(evictedEventNode, 1);
-         return;
-      }
-
-      ne.setNumberOfElements(ne.getNumberOfElements() + 1);
-
-      // also treat it as a node visit.
-      ne.setNumberOfNodeVisits(ne.getNumberOfNodeVisits() + 1);
-      ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
-//      log.error ("*** Processing nodeAdded for fqn " + fqn + " NodeEntry's hashcode is " + ne.hashCode());
-   }
-
-
-   /**
-    * Empty the Recycle Queue.
-    * <p/>
-    * This method will go through the recycle queue and retry to evict the nodes from cache.
-    *
-    * @throws org.jboss.starobrno.eviction.EvictionException
-    *
-    */
-   protected void emptyRecycleQueue() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      while (true)
-      {
-         Fqn fqn;
-
-         try
-         {
-            //fqn = (Fqn) recycleQueue.take();
-            fqn = recycleQueue.poll(0, TimeUnit.SECONDS);
-         }
-         catch (InterruptedException e)
-         {
-            log.debug(e, e);
-            break;
-         }
-
-         if (fqn == null)
-         {
-            if (trace)
-            {
-               log.trace("Recycle queue is empty");
-            }
-            break;
-         }
-
-         if (trace)
-         {
-            log.trace("emptying recycle bin. Evict node " + fqn);
-         }
-
-         // Still doesn't work
-         if (!evictCacheNode(fqn))
-         {
-            try
-            {
-               recycleQueue.put(fqn);
-            }
-            catch (InterruptedException e)
-            {
-               log.debug(e, e);
-            }
-            break;
-         }
-      }
-   }
-
-   protected boolean isNodeInUseAndNotTimedOut(org.jboss.starobrno.eviction.NodeEntry ne)
-   {
-      if (ne.isCurrentlyInUse())
-      {
-         if (ne.getInUseTimeoutTimestamp() == 0)
-         {
-            return true;
-         }
-
-         if (System.currentTimeMillis() < ne.getInUseTimeoutTimestamp())
-         {
-            return true;
-         }
-      }
-      return false;
-   }
-
-   protected void prune() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      org.jboss.starobrno.eviction.NodeEntry entry;
-      while ((entry = evictionQueue.getFirstNodeEntry()) != null)
-      {
-         if (this.shouldEvictNode(entry))
-         {
-            this.evict(entry);
-         }
-         else
-         {
-            break;
-         }
-      }
-   }
-
-   /**
-    * Returns debug information.
-    */
-   @Override
-   public String toString()
-   {
-      return super.toString() +
-            " recycle=" + recycleQueue.size() +
-            " evict=" + evictionQueue.getNumberOfNodes();
-   }
-
-   /**
-    * Tests whether a node entry is younger than the minimum time to live - if one is configured.
-    *
-    * @param entry the node entry being examined
-    * @return true if the node is younger than - or exactly equal to - the minimum time to live, if one is configured for the given region.  False otherwise.
-    */
-   protected boolean isYoungerThanMinimumTimeToLive(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      if (evictionAlgorithmConfig instanceof org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase)
-      {
-         org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase cfg = (org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase) evictionAlgorithmConfig;
-         long minTTL = cfg.getMinTimeToLive();
-         return minTTL >= 1 && (entry.getModifiedTimeStamp() + minTTL > System.currentTimeMillis());
-      }
-      else
-      {
-         log.trace("Eviction policy implementation does not support minimum TTL!");
-         return false;
-      }
-   }
-}

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseSortedEvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseSortedEvictionAlgorithm.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseSortedEvictionAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,126 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.concurrent.BlockingQueue;
-
-
-/**
- * An abstract SortedEvictionAlgorithm.
- * <p/>
- * This class supports early termination of the eviction queue processing. Because the eviction
- * queue is sorted by first to evict to last to evict, when iterating the eviction queue, the first time
- * a node is encountered that does not require eviction will terminate the loop early. This way we don't incur
- * the full breadth of the O(n) = n operation everytime we need to check for eviction (defined by eviction poll time
- * interval).
- *
- * @author Daniel Huang - dhuang at jboss.org - 10/2005
- */
-public abstract class BaseSortedEvictionAlgorithm extends BaseEvictionAlgorithm
-{
-   private static final Log log = LogFactory.getLog(BaseSortedEvictionAlgorithm.class);
-   private static final boolean trace = log.isTraceEnabled();
-
-   @Override
-   protected void processQueues(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> queue) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      boolean evictionNodesModified = false;
-
-      org.jboss.starobrno.eviction.EvictionEvent node;
-      int count = 0;
-      while ((node = getNextInQueue(queue)) != null)
-      {
-         count++;
-         switch (node.getEventType())
-         {
-            case ADD_NODE_EVENT:
-               this.processAddedNodes(node);
-               evictionNodesModified = true;
-               break;
-            case REMOVE_NODE_EVENT:
-               this.processRemovedNodes(node);
-               break;
-            case VISIT_NODE_EVENT:
-               this.processVisitedNodes(node);
-               evictionNodesModified = true;
-               break;
-            case ADD_ELEMENT_EVENT:
-               this.processAddedElement(node);
-               evictionNodesModified = true;
-               break;
-            case REMOVE_ELEMENT_EVENT:
-               this.processRemovedElement(node);
-               evictionNodesModified = true;
-               break;
-            default:
-               throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
-         }
-      }
-
-      if (trace)
-      {
-         log.trace("Eviction nodes visited or added requires resort of queue " + evictionNodesModified);
-      }
-
-      this.resortEvictionQueue(evictionNodesModified);
-
-
-      if (trace)
-      {
-         log.trace("processed " + count + " node events");
-      }
-
-   }
-
-   /**
-    * This method is called to resort the queue after add or visit events have occurred.
-    * <p/>
-    * If the parameter is true, the queue needs to be resorted. If it is false, the queue does not
-    * need resorting.
-    *
-    * @param evictionQueueModified True if the queue was added to or visisted during event processing.
-    */
-   protected void resortEvictionQueue(boolean evictionQueueModified)
-   {
-      if (!evictionQueueModified)
-      {
-         if (log.isDebugEnabled())
-         {
-            log.debug("Eviction queue not modified. Resort unnecessary.");
-         }
-         return;
-      }
-      long begin = System.currentTimeMillis();
-      ((org.jboss.starobrno.eviction.SortedEvictionQueue) evictionQueue).resortEvictionQueue();
-      long end = System.currentTimeMillis();
-
-      if (trace)
-      {
-         long diff = end - begin;
-         log.trace("Took " + diff + "ms to sort queue with " + getEvictionQueue().getNumberOfNodes() + " elements");
-      }
-   }
-
-}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionAction.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionAction.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionAction.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.Cache;
+
+/**
+ * Default eviction action policy that calls {@link org.jboss.cache.Cache_Legacy#evict(org.jboss.cache.Fqn)} to evict a node.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 3.0
+ */
+public class DefaultEvictionAction<K> implements EvictionAction<K>
+{
+   private static final Log log = LogFactory.getLog(DefaultEvictionAction.class);
+   private static boolean trace = log.isTraceEnabled();
+   private Cache<K, ?> cache;
+
+   public void setCache(Cache<K, ?> cache)
+   {
+      this.cache = cache;
+   }
+
+   public boolean evict(K key)
+   {
+      if (trace) log.trace("Attempting to evict cache node with key of " + key);
+
+      try
+      {
+         cache.evict(key);
+         log.trace("Eviction of cache node with key of " + key + " successful");
+         return true;
+      }
+      catch (Exception e)
+      {
+         if (log.isDebugEnabled()) log.debug("Unable to evict " + key, e);
+         return false;
+      }
+   }
+}

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache_Legacy;
-import org.jboss.cache.Fqn;
-
-/**
- * Default eviction action policy that calls {@link org.jboss.cache.Cache_Legacy#evict(org.jboss.cache.Fqn)} to evict a node.
- *
- * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
- * @since 3.0
- */
-public class DefaultEvictionActionPolicy implements EvictionActionPolicy
-{
-   Cache_Legacy<?, ?> cache;
-   private static final Log log = LogFactory.getLog(DefaultEvictionActionPolicy.class);
-
-   public void setCache(Cache_Legacy<?, ?> cache)
-   {
-      this.cache = cache;
-   }
-
-   public boolean evict(Fqn fqn)
-   {
-      try
-      {
-         if (log.isTraceEnabled()) log.trace("Evicting Fqn " + fqn);
-         cache.evict(fqn);
-         return true;
-      }
-      catch (Exception e)
-      {
-         if (log.isDebugEnabled()) log.debug("Unable to evict " + fqn, e);
-         return false;
-      }
-   }
-}

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithm.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.starobrno.config.EvictionAlgorithmConfig;
-
-/**
- * @author Daniel Huang
- * @version $Revision: 6776 $
- */
-public class ElementSizeAlgorithm extends BaseSortedEvictionAlgorithm
-{
-   @Override
-   protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      return new org.jboss.starobrno.eviction.ElementSizeQueue();
-   }
-
-   @Override
-   protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne)
-   {
-      // check the minimum time to live and see if we should not evict the node.  This check will
-      // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
-      if (isYoungerThanMinimumTimeToLive(ne)) return false;
-      int size = this.getEvictionQueue().getNumberOfNodes();
-      org.jboss.starobrno.eviction.ElementSizeAlgorithmConfig config = (org.jboss.starobrno.eviction.ElementSizeAlgorithmConfig) evictionAlgorithmConfig;
-      return config.getMaxNodes() > -1 && size > config.getMaxNodes() || ne.getNumberOfElements() > config.getMaxElementsPerNode();
-   }
-
-   @Override
-   protected void prune() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      super.prune();
-
-      // clean up the Queue's eviction removals
-      ((org.jboss.starobrno.eviction.ElementSizeQueue) this.evictionQueue).prune();
-   }
-
-   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
-   {
-      return ElementSizeAlgorithmConfig.class;
-   }
-}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithmConfig.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -23,9 +23,10 @@
 
 import org.jboss.starobrno.config.ConfigurationException;
 import org.jboss.starobrno.config.Dynamic;
+import org.jboss.starobrno.eviction.algorithms.ElementSizeAlgorithm;
 
 /**
- * Configuration for {@link org.jboss.starobrno.eviction.ElementSizeAlgorithm}.
+ * Configuration for {@link org.jboss.starobrno.eviction.algorithms.ElementSizeAlgorithm}.
  * <p/>
  * Requires a positive "maxElementsPerNode" value otherwise a ConfigurationException is thrown.
  *
@@ -44,7 +45,7 @@
 
    public ElementSizeAlgorithmConfig()
    {
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.ElementSizeAlgorithm.class.getName();
+      evictionAlgorithmClassName = ElementSizeAlgorithm.class.getName();
       // Force configuration of maxElementsPerNode
       setMaxElementsPerNode(-1);
    }
@@ -116,7 +117,7 @@
    {
       super.reset();
       setMaxElementsPerNode(-1);
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.ElementSizeAlgorithm.class.getName();
+      evictionAlgorithmClassName = ElementSizeAlgorithm.class.getName();
    }
 
    @Override

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeQueue.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -21,38 +21,28 @@
  */
 package org.jboss.starobrno.eviction;
 
-import org.jboss.cache.Fqn;
+import org.jboss.starobrno.eviction.algorithms.SortedEvictionQueue;
 
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
+import java.util.*;
 
 /**
  * @author Daniel Huang
- * @version $Revision: 6776 $
  */
-public class ElementSizeQueue implements SortedEvictionQueue
+public class ElementSizeQueue<K> implements SortedEvictionQueue<K>
 {
-   private Map<Fqn, org.jboss.starobrno.eviction.NodeEntry> nodeMap;
-   private LinkedList<org.jboss.starobrno.eviction.NodeEntry> evictionList;
-   private Comparator<org.jboss.starobrno.eviction.NodeEntry> comparator;
+   private Map<K, KeyEntry<K>> nodeMap;
+   private LinkedList<KeyEntry<K>> evictionList;
+   private Comparator<KeyEntry> comparator;
 
-   private Set<org.jboss.starobrno.eviction.NodeEntry> removalQueue;
+   private Set<KeyEntry> removalQueue;
    private int numElements = 0;
 
-   protected ElementSizeQueue()
+   public ElementSizeQueue()
    {
-      nodeMap = new HashMap<Fqn, org.jboss.starobrno.eviction.NodeEntry>();
-      evictionList = new LinkedList<org.jboss.starobrno.eviction.NodeEntry>();
+      nodeMap = new HashMap<K, KeyEntry<K>>();
+      evictionList = new LinkedList<KeyEntry<K>>();
       comparator = new MaxElementComparator();
-      removalQueue = new HashSet<org.jboss.starobrno.eviction.NodeEntry>();
+      removalQueue = new HashSet<KeyEntry>();
    }
 
    public void resortEvictionQueue()
@@ -60,19 +50,18 @@
       Collections.sort(evictionList, comparator);
    }
 
-   public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
+   public KeyEntry<K> getFirstNodeEntry()
    {
       try
       {
-         org.jboss.starobrno.eviction.NodeEntry ne;
+         KeyEntry<K> ne;
          while ((ne = evictionList.getFirst()) != null)
          {
             if (removalQueue.contains(ne))
             {
                evictionList.removeFirst();
                removalQueue.remove(ne);
-            }
-            else
+            } else
             {
                break;
             }
@@ -83,29 +72,23 @@
       {
          //
       }
-
       return null;
    }
 
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
+   public KeyEntry<K> getNodeEntry(K key)
    {
-      return nodeMap.get(fqn);
+      return nodeMap.get(key);
    }
 
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
+   public boolean containsNodeEntry(KeyEntry<K> entry)
    {
-      return this.getNodeEntry(Fqn.fromString(fqn));
+      K key = entry.getKey();
+      return this.getNodeEntry(key) != null;
    }
 
-   public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+   public void removeNodeEntry(KeyEntry<K> entry)
    {
-      Fqn fqn = entry.getFqn();
-      return this.getNodeEntry(fqn) != null;
-   }
-
-   public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      org.jboss.starobrno.eviction.NodeEntry ne = nodeMap.remove(entry.getFqn());
+      KeyEntry ne = nodeMap.remove(entry.getKey());
       if (ne != null)
       {
          // don't remove directly from the LinkedList otherwise we will incur a O(n) = n
@@ -121,13 +104,12 @@
       }
    }
 
-   public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+   public void addNodeEntry(KeyEntry<K> entry)
    {
       if (!this.containsNodeEntry(entry))
       {
-         Fqn fqn = entry.getFqn();
-         entry.queue = this;
-         nodeMap.put(fqn, entry);
+         K key = entry.getKey();
+         nodeMap.put(key, entry);
          evictionList.add(entry);
          this.numElements += entry.getNumberOfElements();
       }
@@ -155,20 +137,20 @@
       removalQueue.clear();
       this.numElements = 0;
    }
-
-   protected final List<org.jboss.starobrno.eviction.NodeEntry> getEvictionList()
+   
+   protected final List<KeyEntry<K>> getEvictionList()
    {
       return evictionList;
    }
 
-   protected final Set<org.jboss.starobrno.eviction.NodeEntry> getRemovalQueue()
+   protected final Set<KeyEntry> getRemovalQueue()
    {
       return removalQueue;
    }
 
-   protected final void prune()
+   public final void prune()
    {
-      Iterator<org.jboss.starobrno.eviction.NodeEntry> it = evictionList.iterator();
+      Iterator<KeyEntry<K>> it = evictionList.iterator();
       while (it.hasNext() && removalQueue.size() > 0)
       {
          if (removalQueue.remove(it.next()))
@@ -178,7 +160,7 @@
       }
    }
 
-   public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
+   public Iterator<KeyEntry<K>> iterator()
    {
       return evictionList.iterator();
    }
@@ -194,37 +176,31 @@
     * Note: this class has a natural ordering that is inconsistent with equals as defined by the java.lang.Comparator
     * contract.
     */
-   protected static class MaxElementComparator implements Comparator<org.jboss.starobrno.eviction.NodeEntry>
+   protected static class MaxElementComparator implements Comparator<KeyEntry>
    {
 
-      public int compare(org.jboss.starobrno.eviction.NodeEntry ne1, org.jboss.starobrno.eviction.NodeEntry ne2)
+      public int compare(KeyEntry ne1, KeyEntry ne2)
       {
          if (ne1.equals(ne2))
          {
             return 0;
          }
-
          int neNumElements = ne1.getNumberOfElements();
          int neNumElements2 = ne2.getNumberOfElements();
 
          if (neNumElements > neNumElements2)
          {
             return -1;
-         }
-         else if (neNumElements < neNumElements2)
+         } else if (neNumElements < neNumElements2)
          {
             return 1;
-         }
-         else if (neNumElements == neNumElements2)
+         } else if (neNumElements == neNumElements2)
          {
             return 0;
          }
-
          throw new RuntimeException("Should never reach this condition");
       }
-
    }
-
 }
 
 

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAction.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAction.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAction.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction;
+
+import org.jboss.starobrno.Cache;
+
+/**
+ * Performs an eviction on a given Fqn.
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 3.0
+ */
+public interface EvictionAction<K>
+{
+   /**
+    * Sets a reference to the cache.
+    *
+    * @param cache cache
+    */
+   void setCache(Cache<K, ?> cache);
+
+   /**
+    * Performs an eviction on a given node.
+    *
+    * @return true if the eviction was successful, false if not.
+    */
+   boolean evict(K key);
+}

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.cache.Cache_Legacy;
-import org.jboss.cache.Fqn;
-
-/**
- * Performs an eviction on a given Fqn.
- *
- * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
- * @since 3.0
- */
-public interface EvictionActionPolicy
-{
-   /**
-    * Sets a reference to the cache.
-    *
-    * @param cache cache
-    */
-   void setCache(Cache_Legacy<?, ?> cache);
-
-   /**
-    * Performs an eviction on a given node.
-    *
-    * @param fqn fqn to evict
-    * @return true if the eviction was successful, false if not.
-    */
-   boolean evict(Fqn fqn);
-}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -21,8 +21,7 @@
  */
 package org.jboss.starobrno.eviction;
 
-import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
+import org.jboss.starobrno.CacheSPI;
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.EvictionAlgorithmConfig;
 import org.jboss.starobrno.eviction.EvictionEvent.Type;
@@ -37,17 +36,14 @@
  *
  * @author Ben Wang 2-2004
  * @author Daniel Huang - dhuang at jboss.org - 10/2005
- * @version $Revision: 6776 $
  */
-public interface EvictionAlgorithm
+public interface EvictionAlgorithm<K>
 {
    /**
     * Entry point for eviction algorithm.  Invoking this will cause the algorithm to process the queue of {@link EvictionEvent}
     * passed in.
-    *
-    * @param queue to process
     */
-   void process(BlockingQueue<EvictionEvent> queue) throws org.jboss.starobrno.eviction.EvictionException;
+   void process(BlockingQueue<EvictionEvent<K>> queue) throws EvictionException;
 
    /**
     * Reset the whole eviction queue. The queue may need to be reset due to corrupted state, for example.
@@ -56,27 +52,18 @@
 
    /**
     * Get the EvictionQueue implementation used by this algorithm.
-    *
-    * @return the EvictionQueue implementation.
     */
-   org.jboss.starobrno.eviction.EvictionQueue getEvictionQueue();
+   EvictionQueue getEvictionQueue();
 
    /**
     * Sets the eviction action policy, so the algorithm knows what to do when a node is to be evicted.
-    *
-    * @param evictionActionPolicy to set
     */
-   void setEvictionActionPolicy(org.jboss.starobrno.eviction.EvictionActionPolicy evictionActionPolicy);
+   void setEvictionAction(EvictionAction<K> evictionAction);
 
    /**
-    * Assigns the algorithm instance to a specific region.
-    *
-    * @param fqn                     of the region to be assigned to
-    * @param cache                   cache reference
-    * @param evictionAlgorithmConfig configuration for the current algorithm instance.
-    * @param configuration           for the entire cache.
+    * Assigns the algorithm instance to a given Cache.
     */
-   void assignToRegion(Fqn fqn, CacheSPI_Legacy<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration);
+   void assignToCache(CacheSPI<K, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig);
 
    /**
     * Tests whether the algorithm would ignore certain event types on certain Fqns.
@@ -91,11 +78,5 @@
     */
    void initialize();
 
-   /**
-    * This is a helper so that the XML parser will be able to select and use the correct {@link org.jboss.cache.config.EvictionAlgorithmConfig} implementation
-    * class corresponding to this EvictionAlgorithm.  E.g., the {@link FIFOAlgorithm} would return {@link FIFOAlgorithmConfig}.class.
-    *
-    * @return a class that is used to configure this EvictionAlgorithm.
-    */
    Class<? extends EvictionAlgorithmConfig> getConfigurationClass();
 }

Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManager.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManager.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,63 @@
+package org.jboss.starobrno.eviction;
+
+import org.jboss.starobrno.config.EvictionCacheConfig;
+import org.jboss.cache.Fqn;
+
+/**
+ * There is one eviction manager per cache.
+ * @author Mircea.Markus at jboss.com
+ */
+public interface EvictionCacheManager<K>
+{
+   /**
+    * Processes the eviction queues (primary and recycle queues) associated with this cache.
+    */
+   void processEvictionQueues();
+
+   /**
+    * Clears the node event queue used for processing eviction.
+    */
+   void resetEvictionQueues();
+
+   /**
+    * Configures this EvictionCacheManager for eviction.
+    *
+    * @param evictionCacheConfig configuration to set
+    */
+   void configure(EvictionCacheConfig evictionCacheConfig);
+
+   /**
+    * Registers an eviction event on the cache's eviction event queue for later processing by
+    * {@link #processEvictionQueues()}.
+    */
+   EvictionEvent registerEvictionEvent(K key, EvictionEvent.Type eventType, int elementDifference);
+
+   /**
+    * An overloaded version of {@link #registerEvictionEvent(String, org.jboss.starobrno.eviction.EvictionEvent.Type, int)} which
+    * uses a default elementDifference value.
+    *
+    * @param eventType passed in to the constructor of {@link org.jboss.starobrno.eviction.EvictionEvent}
+    * @return an EvictedEventNode that has been created for this queue
+    */
+   EvictionEvent registerEvictionEvent(K key, EvictionEvent.Type eventType);
+
+   /**
+    * Marks a {@link org.jboss.cache.Node} as currently in use, by adding an event to the eviction queue.
+    * If there is an {@link org.jboss.cache.config.EvictionRegionConfig} associated with this cahe, and
+    * it respects this event (e.g., {@link org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm} does), then the {@link org.jboss.cache.Node} will not
+    * be evicted until {@link #unmarkNodeCurrentlyInUse(Fqn)} is invoked.
+    * <p/>
+    * This mechanism can be used to prevent eviction of data that the application
+    * is currently using, in the absence of any locks on the {@link org.jboss.cache.Node} where the
+    * data is stored.
+    */
+   void markNodeCurrentlyInUse(K key, long timeout);
+
+   /**
+    * Adds an event to the eviction queue indicating that a node is no longer in use.
+    *
+    * @param key Fqn of the node.
+    */
+   void unmarkNodeCurrentlyInUse(K key);
+}
+

Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManagerImpl.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionCacheManagerImpl.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,143 @@
+package org.jboss.starobrno.eviction;
+
+import org.jboss.starobrno.config.EvictionCacheConfig;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.util.Util;
+import org.jboss.starobrno.CacheSPI;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class EvictionCacheManagerImpl<K> implements EvictionCacheManager<K>
+{
+   private static Log log = LogFactory.getLog(EvictionCacheManagerImpl.class);
+   private static boolean trace = log.isTraceEnabled();
+
+   private BlockingQueue<EvictionEvent<K>> evictionEventQueue = null;
+   private int capacityWarnThreshold = 0;
+   private EvictionCacheConfig evictionCacheConfig;
+   private EvictionAlgorithm<K> evictionAlgorithm;
+   private CacheSPI<K,?> cache;
+
+   public EvictionCacheManagerImpl(CacheSPI<K, ?> cache)
+   {
+      this.cache = cache;
+   }
+
+   public void processEvictionQueues()
+   {
+      evictionAlgorithm.process(evictionEventQueue);
+   }
+
+   public void resetEvictionQueues()
+   {
+      evictionEventQueue.clear();
+   }
+
+   public EvictionEvent registerEvictionEvent(K key, EvictionEvent.Type eventType, int elementDifference)
+   {
+      if (evictionAlgorithm.canIgnoreEvent(eventType)) return null;
+      EvictionEvent<K> event = new EvictionEvent<K>(key, eventType, elementDifference);
+      registerEvictionEvent(event);
+      return event;
+   }
+
+   public EvictionEvent registerEvictionEvent(K key, EvictionEvent.Type eventType)
+   {
+      return registerEvictionEvent(key, eventType, 0);
+   }
+
+   public void markNodeCurrentlyInUse(K key, long timeout)
+   {
+      registerEvictionEvent(key, EvictionEvent.Type.MARK_IN_USE_EVENT, 0).setInUseTimeout(timeout);
+   }
+
+   public void unmarkNodeCurrentlyInUse(K key)
+   {
+      registerEvictionEvent(key, EvictionEvent.Type.UNMARK_USE_EVENT, 0);
+   }
+
+   public void configure(EvictionCacheConfig evictionCacheConfig)
+   {
+      this.evictionCacheConfig = evictionCacheConfig;
+      evictionAlgorithm = createEvictionAlgorithm(evictionCacheConfig.getEvictionAlgorithmConfig(), evictionCacheConfig.getEvictionActionClassName());
+      if (evictionEventQueue == null) createQueue();
+      evictionAlgorithm.initialize();
+   }
+
+   private void registerEvictionEvent(EvictionEvent<K> ee)
+   {
+      try
+      {
+         createQueue();// in case the queue does not exist yet.
+         if (evictionEventQueue.size() > capacityWarnThreshold)
+         {
+            if (log.isWarnEnabled())
+               log.warn("putNodeEvent(): eviction node event queue size is at 98% threshold value of capacity: " + evictionCacheConfig.getEventQueueSize() +
+                     " Cache name: " + cache.getName() + " You will need to reduce the wakeUpIntervalSeconds parameter.");
+         }
+         evictionEventQueue.put(ee);
+      }
+      catch (InterruptedException e)
+      {
+         if (log.isDebugEnabled()) log.debug("Interrupted on adding event", e);
+         // reinstate interrupt flag
+         Thread.currentThread().interrupt();
+      }
+   }
+
+   private void createQueue()
+   {
+      if (evictionEventQueue == null)
+      {
+         if (evictionCacheConfig == null)
+         {
+            throw new IllegalArgumentException("null eviction configuration");
+         }
+         int size = evictionCacheConfig.getEventQueueSize();
+         capacityWarnThreshold = (98 * size) / 100 - 100;
+         if (capacityWarnThreshold <= 0)
+         {
+            if (log.isWarnEnabled()) log.warn("Capacity warn threshold used in eviction is smaller than 1.");
+         }
+         evictionEventQueue = new LinkedBlockingQueue<EvictionEvent<K>>(size);
+      }
+   }
+
+   private EvictionAlgorithm<K> createEvictionAlgorithm(EvictionAlgorithmConfig algoConfig, String evictionActionClass)
+   {
+      if (algoConfig == null)
+         throw new IllegalArgumentException("Eviction algorithm class must not be null!");
+
+      if (evictionActionClass == null)
+         throw new IllegalArgumentException("Eviction action policy class must not be null!");
+
+      try
+      {
+         if (trace) log.trace("Instantiating " + evictionActionClass);
+         EvictionAction<K> evictionAction = (EvictionAction<K>) Util.getInstance(evictionActionClass);
+         evictionAction.setCache(cache);
+
+         if (trace) log.trace("Instantiating " + algoConfig.getEvictionAlgorithmClassName());
+         EvictionAlgorithm<K> algorithm = (EvictionAlgorithm) Util.getInstance(algoConfig.getEvictionAlgorithmClassName());
+         algorithm.setEvictionAction(evictionAction);
+         algorithm.assignToCache(cache, algoConfig);
+         return algorithm;
+      }
+      catch (Exception e)
+      {
+         log.fatal("Unable to instantiate eviction algorithm " + algoConfig.getEvictionAlgorithmClassName(), e);
+         throw new IllegalStateException(e);
+      }
+   }
+
+   public String getCacheName()
+   {
+      return cache.getName();
+   }
+}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -30,9 +30,9 @@
  *
  * @see org.jboss.cache.Region
  */
-public class EvictionEvent
+public class EvictionEvent<K>
 {
-   private Fqn fqn;
+   private K key;
    private Type type;
    private int elementDifference;
 
@@ -54,9 +54,9 @@
       UNMARK_USE_EVENT
    }
 
-   public EvictionEvent(Fqn fqn, Type type, int elementDifference)
+   public EvictionEvent(K key, Type type, int elementDifference)
    {
-      this.fqn = fqn;
+      this.key = key;
       this.type = type;
       this.elementDifference = elementDifference;
       this.creationTimestamp = System.currentTimeMillis();
@@ -87,14 +87,14 @@
       this.elementDifference = elementDifference;
    }
 
-   public Fqn getFqn()
+   public K getKey()
    {
-      return fqn;
+      return key;
    }
 
-   public void setFqn(Fqn fqn)
+   public void setKey(K key)
    {
-      this.fqn = fqn;
+      this.key = key;
    }
 
    public void setEventType(Type event)
@@ -110,18 +110,18 @@
    @Override
    public String toString()
    {
-      return "EvictedEventNode[fqn=" + fqn + " event=" + type + " diff=" + elementDifference + "]";
+      return "EvictedEventNode[key=" + key + " event=" + type + " diff=" + elementDifference + "]";
    }
 
    /**
     * Copies this evicted event node to create a new one with the same values, except with a new Fqn root.
     *
-    * @param newRoot new Fqn root to use
+    * @param key new Fqn root to use
     * @return a new EvictedEventNode instance
     * @see org.jboss.cache.Region#copy(org.jboss.cache.Fqn)
     */
-   public EvictionEvent copy(Fqn newRoot)
+   public EvictionEvent copy(K key)
    {
-      return new EvictionEvent(Fqn.fromRelativeFqn(newRoot, fqn), type, elementDifference);
+      return new EvictionEvent<K>(key, type, elementDifference);
    }
 }

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionListEntry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionListEntry.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionListEntry.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-/**
- * // TODO: MANIK: Document this
- *
- * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
- * @since 3.0
- */
-class EvictionListEntry
-{
-   EvictionListEntry next;
-   EvictionListEntry previous;
-
-   NodeEntry node;
-
-   EvictionListEntry()
-   {
-   }
-
-   EvictionListEntry(NodeEntry node)
-   {
-      this.node = node;
-   }
-
-   @Override
-   public boolean equals(Object o)
-   {
-      if (!(o instanceof EvictionListEntry))
-         return false;
-      EvictionListEntry entry = (EvictionListEntry) o;
-      return this.node.getFqn().equals(entry.node.getFqn());
-   }
-
-   @Override
-   public int hashCode()
-   {
-      return this.node.getFqn().hashCode();
-   }
-
-   @Override
-   public String toString()
-   {
-      return "EntryLE=" + node;
-   }
-
-}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionManagerImpl.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionManagerImpl.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,79 @@
+package org.jboss.starobrno.eviction;
+
+import net.jcip.annotations.ThreadSafe;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.EvictionManager;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at ThreadSafe
+public class EvictionManagerImpl implements EvictionManager
+{
+   private static Log log = LogFactory.getLog(EvictionManagerImpl.class);
+   private boolean externalEvictionThread;
+   private EvictionTimerTask evictionTimerTask;
+   private final Map<String, EvictionCacheManager> evictionCacheManagers = new HashMap<String, EvictionCacheManager>(4);
+   private ThreadFactory threadFactory;
+   private long wakeUpInterval;
+
+   public synchronized void configureEvictionThread(long wakeUpInterval, ThreadFactory threadFactory)
+   {
+      if (wakeUpInterval <= 0)
+      {
+         log.info("wakeUpInterval is <= 0, not starting eviction thread");
+         externalEvictionThread = true;
+         return;
+      }
+      this.wakeUpInterval = wakeUpInterval;
+      this.threadFactory = threadFactory;
+      evictionTimerTask = new EvictionTimerTask(this);
+   }
+
+   public synchronized void cacheCreated(String cacheName, EvictionCacheManager cacheManager)
+   {
+      if (!externalEvictionThread && evictionCacheManagers.isEmpty())//this is the first cache to be added, also start ev thread here
+      {
+         evictionTimerTask.init(wakeUpInterval, threadFactory);
+      }
+      evictionCacheManagers.put(cacheName, cacheManager);
+   }
+
+   public synchronized void cacheStopped(String cacheName)
+   {
+      if (evictionCacheManagers.remove(cacheName) == null)
+      {
+         throw new IllegalStateException("Attempting to stop an unregistred cache: " + cacheName);
+      }
+      if (!externalEvictionThread && evictionCacheManagers.isEmpty())
+      {
+         evictionTimerTask.stop();
+      }
+   }
+
+   public void runEviction()
+   {
+      synchronized (evictionCacheManagers)
+      {
+         for (EvictionCacheManager evictionCacheManager : evictionCacheManagers.values())
+         {
+            try
+            {
+               evictionCacheManager.processEvictionQueues();
+            }
+            catch (EvictionException e)
+            {
+               //we cannot die in peace here, as this is not the main thread and the user won't get informed...
+               log.error("run(): error processing eviction with exception: " + e.toString()
+                     + " will reset the eviction queue list.", e);
+               evictionCacheManager.resetEvictionQueues();
+            }
+         }
+      }
+   }
+}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueue.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -21,9 +21,6 @@
  */
 package org.jboss.starobrno.eviction;
 
-import org.jboss.cache.Fqn;
-
-
 /**
  * Eviction Queue interface defines a contract for the Eviction Queue implementations used by EvictionPolicies.
  * <p/>
@@ -33,7 +30,7 @@
  * @author Daniel Huang (dhuang at jboss.org)
  * @version $Revision: 6776 $
  */
-public interface EvictionQueue extends Iterable<org.jboss.starobrno.eviction.NodeEntry>
+public interface EvictionQueue<K> extends Iterable<KeyEntry<K>>
 {
    /**
     * Get the first entry in the queue.
@@ -44,19 +41,17 @@
     *
     * @return first NodeEntry in queue.
     */
-   org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry();
+   KeyEntry<K> getFirstNodeEntry();
 
    /**
     * Retrieve a node entry by Fqn.
     * <p/>
     * This will return null if the entry is not found.
     *
-    * @param fqn Fqn of the node entry to retrieve.
     * @return Node Entry object associated with given Fqn param.
     */
-   org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn);
+   KeyEntry<K> getNodeEntry(K key);
 
-   org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn);
 
    /**
     * Check if queue contains the given NodeEntry.
@@ -64,7 +59,7 @@
     * @param entry NodeEntry to check for existence in queue.
     * @return true/false if NodeEntry exists in queue.
     */
-   boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry);
+   boolean containsNodeEntry(KeyEntry<K> entry);
 
    /**
     * Remove a NodeEntry from queue.
@@ -73,14 +68,14 @@
     *
     * @param entry The NodeEntry to remove from queue.
     */
-   void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry);
+   void removeNodeEntry(KeyEntry<K> entry);
 
    /**
     * Add a NodeEntry to the queue.
     *
     * @param entry The NodeEntry to add to queue.
     */
-   void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry);
+   void addNodeEntry(KeyEntry<K> entry);
 
    /**
     * Get the number of nodes in the queue.
@@ -102,5 +97,4 @@
     * Clear the queue.
     */
    void clear();
-
 }

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueueList.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueueList.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueueList.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,349 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-/**
- * @author Daniel Huang (dhuang at jboss.org)
- * @version $Revision: 6776 $
- */
-public class EvictionQueueList
-{
-   EvictionListEntry head;
-   EvictionListEntry tail;
-   int modCount;
-   private int size;
-
-   EvictionQueueList()
-   {
-      head = null;
-      tail = null;
-      size = 0;
-      modCount = 0;
-   }
-
-   void addToTop(EvictionListEntry entry)
-   {
-      EvictionListEntry formerHead = head;
-      head = entry;
-      // if there was no previous head then this list was empty.
-      if (formerHead != null)
-      {
-         formerHead.previous = head;
-         head.next = formerHead;
-         head.previous = null;
-      }
-      else
-      {
-         tail = entry;
-      }
-      size++;
-      modCount++;
-   }
-
-   void addToBottom(EvictionListEntry entry)
-   {
-      EvictionListEntry formerTail = tail;
-      tail = entry;
-      // if there was no previous head then this list was empty.
-      if (formerTail != null)
-      {
-         tail.previous = formerTail;
-         formerTail.next = tail;
-         tail.next = null;
-      }
-      else
-      {
-         head = entry;
-      }
-      size++;
-      modCount++;
-   }
-
-   void remove(EvictionListEntry entry)
-   {
-      if (this.isEmpty())
-      {
-         return;
-      }
-
-      if (isSingleNode(entry))
-      {
-         head = null;
-         tail = null;
-      }
-      else if (isTail(entry))
-      {
-         tail = entry.previous;
-         // unlink the last node.
-         entry.previous.next = null;
-      }
-      else if (isHead(entry))
-      {
-         head = entry.next;
-         head.previous = null;
-      }
-      else
-      {
-         // node is in between two other nodes.
-         entry.next.previous = entry.previous;
-         entry.previous.next = entry.next;
-      }
-      size--;
-      modCount++;
-   }
-
-   int size()
-   {
-      return this.size;
-   }
-
-   void clear()
-   {
-      head = null;
-      tail = null;
-      size = 0;
-      modCount++;
-   }
-
-   EvictionListEntry getFirst()
-   {
-      if (head == null)
-      {
-         throw new NoSuchElementException("List is empty");
-      }
-      return head;
-   }
-
-   EvictionListEntry getLast()
-   {
-      if (tail == null)
-      {
-         throw new NoSuchElementException("List is empty");
-      }
-      return tail;
-   }
-
-   Iterator<NodeEntry> iterator()
-   {
-      return new EvictionListIterator();
-   }
-
-   NodeEntry[] toNodeEntryArray()
-   {
-      if (isEmpty())
-      {
-         return null;
-      }
-      NodeEntry[] ret = new NodeEntry[size];
-      int i = 0;
-      EvictionListEntry temp = head;
-
-      do
-      {
-         ret[i] = temp.node;
-         temp = temp.next;
-         i++;
-      }
-      while (temp != null);
-
-      return ret;
-   }
-
-   EvictionListEntry[] toArray()
-   {
-      if (isEmpty())
-      {
-         return null;
-      }
-      EvictionListEntry[] ret = new EvictionListEntry[size];
-      int i = 0;
-      EvictionListEntry temp = head;
-
-      do
-      {
-         ret[i] = temp;
-         temp = temp.next;
-         i++;
-      }
-      while (temp != null);
-
-      return ret;
-   }
-
-   void fromArray(EvictionListEntry[] evictionListEntries)
-   {
-
-      for (EvictionListEntry evictionListEntry : evictionListEntries)
-      {
-         this.addToBottom(evictionListEntry);
-      }
-   }
-
-   private boolean isEmpty()
-   {
-      return head == null && tail == null;
-   }
-
-   private boolean isSingleNode(EvictionListEntry entry)
-   {
-      return isTail(entry) && isHead(entry);
-   }
-
-   private boolean isTail(EvictionListEntry entry)
-   {
-      return entry.next == null;
-   }
-
-   private boolean isHead(EvictionListEntry entry)
-   {
-      return entry.previous == null;
-   }
-
-   @Override
-   public String toString()
-   {
-      return Arrays.asList(toArray()).toString();
-   }
-
-   static class EvictionListComparator implements Comparator<EvictionListEntry>
-   {
-      Comparator<NodeEntry> nodeEntryComparator;
-
-      EvictionListComparator(Comparator<NodeEntry> nodeEntryComparator)
-      {
-         this.nodeEntryComparator = nodeEntryComparator;
-      }
-
-      public int compare(EvictionListEntry e1, EvictionListEntry e2)
-      {
-         return nodeEntryComparator.compare(e1.node, e2.node);
-      }
-   }
-
-   class EvictionListIterator implements ListIterator<NodeEntry>
-   {
-      EvictionListEntry next = head;
-      EvictionListEntry previous;
-      EvictionListEntry cursor;
-
-      int initialModCount = EvictionQueueList.this.modCount;
-
-      public boolean hasNext()
-      {
-         this.doConcurrentModCheck();
-         return next != null;
-      }
-
-      public NodeEntry next()
-      {
-         this.doConcurrentModCheck();
-         this.forwardCursor();
-         return cursor.node;
-      }
-
-      public boolean hasPrevious()
-      {
-         this.doConcurrentModCheck();
-         return previous != null;
-      }
-
-      public NodeEntry previous()
-      {
-         this.doConcurrentModCheck();
-         this.rewindCursor();
-         return cursor.node;
-      }
-
-      public int nextIndex()
-      {
-         throw new UnsupportedOperationException();
-      }
-
-      public int previousIndex()
-      {
-         throw new UnsupportedOperationException();
-      }
-
-      public void remove()
-      {
-         this.doConcurrentModCheck();
-         if (cursor == null)
-         {
-            throw new IllegalStateException("Cannot remove from iterator when there is nothing at the current iteration point");
-         }
-         EvictionQueueList.this.remove(cursor);
-         cursor = null;
-         initialModCount++;
-      }
-
-      public void set(NodeEntry o)
-      {
-         this.doConcurrentModCheck();
-         cursor.node = (NodeEntry) o;
-      }
-
-      public void add(NodeEntry o)
-      {
-         this.doConcurrentModCheck();
-         initialModCount++;
-      }
-
-      private void doConcurrentModCheck()
-      {
-         if (EvictionQueueList.this.modCount != initialModCount)
-         {
-            throw new ConcurrentModificationException();
-         }
-      }
-
-      private void forwardCursor()
-      {
-         if (next == null)
-         {
-            throw new NoSuchElementException("No more objects to iterate.");
-         }
-         previous = cursor;
-         cursor = next;
-         next = cursor.next;
-      }
-
-      private void rewindCursor()
-      {
-         if (previous == null)
-         {
-            throw new NoSuchElementException();
-         }
-         next = cursor;
-         cursor = previous;
-         previous = cursor.previous;
-      }
-   }
-
-}
-

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionTimerTask.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionTimerTask.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionTimerTask.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -23,10 +23,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Region;
-import org.jboss.cache.util.concurrent.ConcurrentHashSet;
+import org.jboss.starobrno.EvictionManager;
 
-import java.util.Set;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ThreadFactory;
@@ -38,68 +36,36 @@
  *
  * @author Ben Wang 2-2004
  * @author Daniel Huang (dhuang at jboss.org)
- * @version $Revision: 6840 $
  */
 public class EvictionTimerTask
 {
    private Log log = LogFactory.getLog(EvictionTimerTask.class);
 
-   private final Set<Region> processedRegions;
    private static AtomicInteger tcount = new AtomicInteger();
    private long wakeupInterval;
-   ScheduledExecutorService scheduledExecutor;
+   private ScheduledExecutorService scheduledExecutor;
    private Task task;
+   private EvictionManager evictionManager;
 
-   public EvictionTimerTask()
+
+   public EvictionTimerTask(EvictionManager evManager)
    {
-      // synchronized set because we need to maintain thread safety
-      // for dynamic configuration purposes.
-      processedRegions = new ConcurrentHashSet<Region>();
+      this.evictionManager = evManager;
       task = new Task();
    }
 
    public void init(long wakeupInterval, ThreadFactory evictionThreadFactory)
    {
       if (log.isTraceEnabled())
-         log.trace("Creating a new eviction listener with wakeupInterval millis set at " + wakeupInterval);
+         log.trace("Creating a new eviction timer task with wakeupInterval millis set at " + wakeupInterval);
       this.wakeupInterval = wakeupInterval;
       start(evictionThreadFactory);
    }
 
-   /**
-    * Add a MarshRegion to process by the Eviction Thread.
-    *
-    * @param region MarshRegion to process.
-    */
-   public void addRegionToProcess(Region region)
-   {
-      processedRegions.add(region);
-   }
 
-   /**
-    * Remove a MarshRegion to process from the Eviction thread.
-    *
-    * @param region
-    */
-   public void removeRegionToProcess(Region region)
-   {
-      processedRegions.remove(region);
-   }
-
-   public boolean isRegionRegisteredForProcessing(Region region)
-   {
-      return processedRegions.contains(region);
-   }
-
-   public Set<Region> getProcessedRegions()
-   {
-      return processedRegions;
-   }
-
    public void stop()
    {
       if (log.isDebugEnabled()) log.debug("Stopping eviction timer");
-
       if (scheduledExecutor != null)
       {
          scheduledExecutor.shutdownNow();
@@ -109,13 +75,6 @@
 
    private void start(ThreadFactory tf)
    {
-      if (wakeupInterval < 1)
-      {
-         if (log.isInfoEnabled())
-            log.info("Wakeup Interval set to " + wakeupInterval + ".  Not starting an eviction thread!");
-         return;
-      }
-
       if (tf == null) tf = new ThreadFactory()
       {
          public Thread newThread(Runnable r)
@@ -125,48 +84,15 @@
             return t;
          }
       };
-
       scheduledExecutor = Executors.newSingleThreadScheduledExecutor(tf);
       scheduledExecutor.scheduleWithFixedDelay(task, wakeupInterval, wakeupInterval, TimeUnit.MILLISECONDS);
    }
 
-   private void processRegions()
-   {
-      synchronized (processedRegions)
-      {
-         for (Region region : processedRegions)
-         {
-            handleRegion(region);
-         }
-      }
-   }
-
-   private void handleRegion(Region region)
-   {
-      synchronized (region)
-      {
-         try
-         {
-            region.processEvictionQueues();
-         }
-         catch (EvictionException e)
-         {
-            log.error("run(): error processing eviction with exception: " + e.toString()
-                  + " will reset the eviction queue list.");
-            region.resetEvictionQueues();
-            log.debug("trace", e);
-         }
-      }
-   }
-
    public class Task implements Runnable
    {
       public void run()
       {
-         // Run the eviction thread.
-         // This thread will synchronize the set of regions and iterate through every MarshRegion registered w/ the
-         // Eviction thread. It also synchronizes on each individual region as it is being processed.
-         processRegions();
+         evictionManager.runEviction();
       }
    }
 }

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithm.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,377 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeSPI;
-import org.jboss.starobrno.config.EvictionAlgorithmConfig;
-import org.jboss.starobrno.eviction.EvictionEvent.Type;
-
-import java.util.Iterator;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.concurrent.BlockingQueue;
-
-/**
- * Eviction algorithm that uses a key in the Node data that indicates the time
- * the node should be evicted.  The key must be a java.lang.Long object, with
- * the time to expire as milliseconds past midnight January 1st, 1970 UTC (the
- * same relative time as provided by {@link
- * java.lang.System#currentTimeMillis()}).
- * <p/>
- * This algorithm also obeys the configuration key {@link
- * org.jboss.starobrno.eviction.ExpirationAlgorithmConfig#getMaxNodes()}, and will evict the soonest to
- * expire entires first to reduce the region size.  If there are not enough
- * nodes with expiration keys set, a warning is logged.
- * <p/>
- * If a node in the eviction region does not have an expiration value, then
- * {@link org.jboss.starobrno.eviction.ExpirationAlgorithmConfig#getTimeToLive()} (if set) will be used.
- * The expiration is updated when a node is added or updated.
- * <p/>
- * If there is no time-to-live set, and a node in the eviction region does not
- * have an expiration value, then that node will never be evicted.  As
- * forgetting to indicate an expiration value is likely a mistake, a warning
- * message is logged by this class. This warning, however, can be disabled
- * through {@link org.jboss.starobrno.eviction.ExpirationAlgorithmConfig#setWarnNoExpirationKey(boolean)}.
- * <p/>
- * A node's expiration time can be changed by setting a new value in the node.
- * <p/>
- * Example usage:
- * <pre>
- * Cache cache;
- * Fqn fqn1 = Fqn.fromString("/node/1");
- * Long future = new Long(System.currentTimeMillis() + 2000);
- * cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future);
- * cache.put(fqn1, "foo");
- * assertTrue(cache.get(fqn1) != null);
- * <p/>
- * Thread.sleep(5000); // 5 seconds
- * assertTrue(cache.get(fqn1) == null);
- * <p/>
- * </pre>
- */
-public class ExpirationAlgorithm extends BaseEvictionAlgorithm
-{
-
-   private static final Log log = LogFactory.getLog(ExpirationAlgorithm.class);
-   private static final boolean trace = log.isTraceEnabled();
-
-   private org.jboss.starobrno.eviction.ExpirationAlgorithmConfig config;
-
-   private SortedSet<ExpirationEntry> set;
-
-   /**
-    * Constructs a new algorithm with a policy.
-    */
-   public ExpirationAlgorithm()
-   {
-      this.set = new TreeSet<ExpirationEntry>();
-   }
-
-   private void addEvictionEntry(org.jboss.starobrno.eviction.EvictionEvent node)
-   {
-      Fqn fqn = node.getFqn();
-      addEvictionEntry(fqn);
-   }
-
-   private void addEvictionEntry(Fqn fqn)
-   {
-      Long l = getExpiration(fqn);
-      if (l == null)
-      {
-         if (config.isWarnNoExpirationKey() && log.isWarnEnabled())
-            log.warn("No expiration key '" + config.getExpirationKeyName() + "' for Node: " + fqn);
-         else if (log.isDebugEnabled())
-            log.debug("No expiration key for Node: " + fqn);
-      }
-      else
-      {
-         setExpiration(fqn, l);
-      }
-   }
-
-   private void setExpiration(Fqn fqn, Long l)
-   {
-      ExpirationEntry ee = new ExpirationEntry(fqn, l);
-      if (trace)
-         log.trace("adding eviction entry: " + ee);
-      set.add(ee);
-   }
-
-   @SuppressWarnings("unchecked")
-   private Long getExpiration(Fqn fqn)
-   {
-      NodeSPI n = cache.peek(fqn, false);
-      if (n == null)
-         return null;
-      return (Long) n.getDirect(config.getExpirationKeyName());
-   }
-
-   @Override
-   protected void processQueues(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> queue) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      org.jboss.starobrno.eviction.EvictionEvent node;
-      int count = 0;
-      while ((node = getNextInQueue(queue)) != null)
-      {
-         count++;
-         switch (node.getEventType())
-         {
-            case ADD_NODE_EVENT:
-            case ADD_ELEMENT_EVENT:
-               addEvictionEntry(node);
-               break;
-            case REMOVE_ELEMENT_EVENT:
-            case REMOVE_NODE_EVENT:
-            case UNMARK_USE_EVENT:
-               // Removals will be noticed when double-checking expiry time
-               // removeEvictionEntry(node);
-               break;
-            case VISIT_NODE_EVENT:
-               // unused
-               break;
-            case MARK_IN_USE_EVENT:
-               markInUse(node);
-               break;
-            default:
-               throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
-         }
-      }
-
-      if (trace) log.trace("processed " + count + " node events in region: " + regionFqn);
-   }
-
-   private void markInUse(org.jboss.starobrno.eviction.EvictionEvent node)
-   {
-      long expiration = node.getInUseTimeout() + System.currentTimeMillis();
-      setExpiration(node.getFqn(), expiration);
-   }
-
-   @Override
-   protected void prune() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      if (set.isEmpty())
-         return;
-      long now = System.currentTimeMillis();
-      int max = config.getMaxNodes();
-      for (Iterator<ExpirationEntry> i = set.iterator(); i.hasNext();)
-      {
-         ExpirationEntry ee = i.next();
-         Long ce = getExpiration(ee.getFqn());
-         if (ce == null || ce > ee.getExpiration())
-         {
-            // Expiration now older
-            i.remove();
-            continue;
-         }
-         if (ee.getExpiration() < now || (max != 0 && set.size() > max))
-         {
-            i.remove();
-            evictCacheNode(ee.getFqn());
-         }
-         else
-         {
-            break;
-         }
-      }
-      if (max != 0 && max > set.size())
-         log.warn("Unable to remove nodes to reduce region size below " +
-               config.getMaxNodes() + ".  " +
-               "Set expiration for nodes in this region");
-   }
-
-   @Override
-   public void resetEvictionQueue()
-   {
-      for (ExpirationEntry ee : set)
-      {
-         addEvictionEntry(ee.getFqn());
-      }
-   }
-
-   @Override
-   protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      this.config = (org.jboss.starobrno.eviction.ExpirationAlgorithmConfig) evictionAlgorithmConfig;
-      return new DummyEvictionQueue();
-   }
-
-   @Override
-   protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne)
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   @Override
-   public boolean canIgnoreEvent(Type eventType)
-   {
-      return (eventType == org.jboss.starobrno.eviction.EvictionEvent.Type.VISIT_NODE_EVENT);
-   }
-
-   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
-   {
-      return org.jboss.starobrno.eviction.ExpirationAlgorithmConfig.class;
-   }
-
-   /**
-    * Ordered list of FQN, with the expiration taken from the Map at the time
-    * of processing.
-    */
-   static class ExpirationEntry implements Comparable<ExpirationEntry>
-   {
-
-      private long expiration;
-
-      private Fqn fqn;
-
-      public ExpirationEntry(Fqn fqn)
-      {
-         this.fqn = fqn;
-      }
-
-      public ExpirationEntry(Fqn fqn, long expiration)
-      {
-         this.fqn = fqn;
-         this.expiration = expiration;
-      }
-
-      /**
-       * Compares expiration, then FQN order.
-       */
-      public int compareTo(ExpirationEntry ee)
-      {
-         long n = expiration - ee.expiration;
-         if (n < 0)
-            return -1;
-         if (n > 0)
-            return 1;
-         return fqn.compareTo(ee.fqn);
-      }
-
-      /**
-       * @return the expiration
-       */
-      public long getExpiration()
-      {
-         return expiration;
-      }
-
-      /**
-       * @return the fqn
-       */
-      public Fqn getFqn()
-      {
-         return fqn;
-      }
-
-      @Override
-      public boolean equals(Object o)
-      {
-         if (!(o instanceof ExpirationEntry))
-            return false;
-         ExpirationEntry ee = (ExpirationEntry) o;
-         return expiration == ee.expiration && fqn.equals(ee.fqn);
-      }
-
-      @Override
-      public int hashCode()
-      {
-         return (int) expiration ^ fqn.hashCode();
-      }
-
-      @Override
-      public String toString()
-      {
-         long now = System.currentTimeMillis();
-         long ttl = expiration - now;
-         String sttl;
-         if (ttl > 1000 * 60)
-            sttl = (ttl / (1000 * 60)) + "min";
-         else if (ttl > 1000)
-            sttl = (ttl / 1000) + "s";
-         else
-            sttl = ttl + "ms";
-         return "EE fqn=" + fqn + " ttl=" + sttl;
-      }
-   }
-
-   class DummyEvictionQueue implements org.jboss.starobrno.eviction.EvictionQueue
-   {
-
-      public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-      {
-         throw new UnsupportedOperationException();
-      }
-
-      public void clear()
-      {
-         set.clear();
-      }
-
-      public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-      {
-         return false;
-      }
-
-      public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
-      {
-         return null;
-      }
-
-      public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
-      {
-         return null;
-      }
-
-      public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
-      {
-         return null;
-      }
-
-      public int getNumberOfElements()
-      {
-         return set.size();
-      }
-
-      public int getNumberOfNodes()
-      {
-         return set.size();
-      }
-
-      public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
-      {
-         return null;
-      }
-
-      public void modifyElementCount(int difference)
-      {
-      }
-
-      public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-      {
-         throw new UnsupportedOperationException();
-      }
-   }
-
-}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithmConfig.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -23,6 +23,7 @@
 
 import org.jboss.cache.annotations.Compat;
 import org.jboss.starobrno.config.Dynamic;
+import org.jboss.starobrno.eviction.algorithms.ExpirationAlgorithm;
 
 import java.util.concurrent.TimeUnit;
 
@@ -53,7 +54,7 @@
 
    public ExpirationAlgorithmConfig()
    {
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.ExpirationAlgorithm.class.getName();
+      evictionAlgorithmClassName = ExpirationAlgorithm.class.getName();
    }
 
    /**
@@ -154,7 +155,7 @@
    public void reset()
    {
       super.reset();
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.ExpirationAlgorithm.class.getName();
+      evictionAlgorithmClassName = ExpirationAlgorithm.class.getName();
       warnNoExpirationKey = true;
       timeToLive = 0;
    }

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithm.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.starobrno.config.EvictionAlgorithmConfig;
-
-/**
- * First-in-first-out algorithm used to evict nodes.
- *
- * @author Daniel Huang - dhuang at jboss.org
- * @author Morten Kvistgaard
- * @version $Revision: 6776 $
- */
-public class FIFOAlgorithm extends BaseEvictionAlgorithm
-{
-   private static final Log log = LogFactory.getLog(FIFOAlgorithm.class);
-   private static final boolean trace = log.isTraceEnabled();
-
-
-   @Override
-   protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      return new org.jboss.starobrno.eviction.FIFOQueue();
-   }
-
-   /**
-    * For FIFO, a node should be evicted if the queue size is >= to the configured maxNodes size.
-    */
-   @Override
-   protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne)
-   {
-      // check the minimum time to live and see if we should not evict the node.  This check will
-      // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
-      if (isYoungerThanMinimumTimeToLive(ne)) return false;
-
-      org.jboss.starobrno.eviction.FIFOAlgorithmConfig config = (org.jboss.starobrno.eviction.FIFOAlgorithmConfig) evictionAlgorithmConfig;
-      if (trace)
-      {
-         log.trace("Deciding whether node in queue " + ne.getFqn() + " requires eviction.");
-      }
-
-      int size = this.getEvictionQueue().getNumberOfNodes();
-      return config.getMaxNodes() != 0 && size > config.getMaxNodes();
-   }
-
-   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
-   {
-      return org.jboss.starobrno.eviction.FIFOAlgorithmConfig.class;
-   }
-}
-

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithmConfig.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.starobrno.config.ConfigurationException;
-
-/**
- * Configuration for {@link org.jboss.starobrno.eviction.FIFOAlgorithm}.
- * <p/>
- * Requires a "maxNodes" attribute otherwise a ConfigurationException is thrown.
- *
- * @author Manik Surtani
- * @since 3.0
- */
-public class FIFOAlgorithmConfig extends EvictionAlgorithmConfigBase
-{
-   /**
-    * The serialVersionUID
-    */
-   private static final long serialVersionUID = -7229715009546277313L;
-
-   public FIFOAlgorithmConfig()
-   {
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.FIFOAlgorithm.class.getName();
-      // We require that maxNodes is set
-      setMaxNodes(-1);
-   }
-
-   public FIFOAlgorithmConfig(int maxNodes)
-   {
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.FIFOAlgorithm.class.getName();
-      // We require that maxNodes is set
-      setMaxNodes(maxNodes);
-   }
-
-   /**
-    * Requires a positive maxNodes value or ConfigurationException
-    * is thrown.
-    */
-   @Override
-   public void validate() throws ConfigurationException
-   {
-      super.validate();
-      if (getMaxNodes() < 0)
-      {
-         throw new ConfigurationException("maxNodes must be must be " +
-               "configured to a value greater than or equal to 0");
-      }
-   }
-
-   @Override
-   public String toString()
-   {
-      StringBuilder ret = new StringBuilder();
-      ret.append("FIFOAlgorithmConfig: maxNodes = ").append(getMaxNodes());
-      return ret.toString();
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      return (obj instanceof FIFOAlgorithmConfig && super.equals(obj));
-   }
-
-   @Override
-   public void reset()
-   {
-      super.reset();
-      setMaxNodes(-1);
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.FIFOAlgorithm.class.getName();
-   }
-
-   @Override
-   public FIFOAlgorithmConfig clone() throws CloneNotSupportedException
-   {
-      return (FIFOAlgorithmConfig) super.clone();
-   }
-}
\ No newline at end of file

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOQueue.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,123 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.cache.Fqn;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * FIFO Eviction Queue implementation for FIFO Policy.
- *
- * @author Daniel Huang (dhuang at jboss.org)
- * @version $Revision: 6776 $
- */
-public class FIFOQueue implements EvictionQueue
-{
-   private Map<Fqn, org.jboss.starobrno.eviction.NodeEntry> nodeMap;
-   private int numElements = 0;
-
-   protected FIFOQueue()
-   {
-      nodeMap = new LinkedHashMap<Fqn, org.jboss.starobrno.eviction.NodeEntry>();
-      // We use a LinkedHashMap here because we want to maintain FIFO ordering and still get the benefits of
-      // O(n) = 1 for add/remove/search.
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
-   {
-/*      Iterator it = nodeMap.keySet().iterator();
-      if(it.hasNext()) {
-         return (NodeEntry) nodeMap.get(it.next());
-      }
-
-      return null; */
-
-      // this code path is *slightly* faster when profiling. 20ms faster iterating over 200000 entries in queue.
-      if (nodeMap.size() > 0)
-      {
-         return nodeMap.values().iterator().next();
-      }
-
-      return null;
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
-   {
-      return nodeMap.get(fqn);
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
-   {
-      return this.getNodeEntry(Fqn.fromString(fqn));
-   }
-
-   public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      Fqn fqn = entry.getFqn();
-      return this.getNodeEntry(fqn) != null;
-   }
-
-   public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      org.jboss.starobrno.eviction.NodeEntry e = nodeMap.remove(entry.getFqn());
-      this.numElements -= e.getNumberOfElements();
-   }
-
-   public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      if (!this.containsNodeEntry(entry))
-      {
-         entry.queue = this;
-         nodeMap.put(entry.getFqn(), entry);
-         this.numElements += entry.getNumberOfElements();
-      }
-   }
-
-   public int getNumberOfNodes()
-   {
-      return nodeMap.size();
-   }
-
-   public int getNumberOfElements()
-   {
-      return this.numElements;
-   }
-
-   public void modifyElementCount(int difference)
-   {
-      this.numElements += difference;
-   }
-
-   public void clear()
-   {
-      nodeMap.clear();
-      this.numElements = 0;
-   }
-
-   public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
-   {
-      return nodeMap.values().iterator();
-   }
-}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/KeyEntry.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NodeEntry.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/KeyEntry.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/KeyEntry.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,230 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction;
+
+/**
+ * Value object used in queue
+ *
+ * @author Ben Wang 2-2004
+ * @author Daniel Huang - dhuang at jboss.org
+ */
+public class KeyEntry<K>
+{
+   private long modifiedTimeStamp;
+   private long creationTimeStamp;
+   private int numberOfNodeVisits;
+   private int numberOfElements;
+   private K key;
+
+   private long inUseTimeoutTimestamp;
+   private boolean currentlyInUse = false;
+
+   private EvictionQueue queue;
+
+   /**
+    * Private constructor that automatically sets the creation time stamp of the node entry.
+    */
+   private KeyEntry()
+   {
+      this.creationTimeStamp = System.currentTimeMillis();
+   }
+
+   public KeyEntry(K key)
+   {
+      this();
+      setKey(key);
+   }
+
+   public KeyEntry(int numberOfNodeVisits, long modifiedTimeStamp, int numberOfElements, K key)
+   {
+      this(key);
+      this.numberOfNodeVisits = numberOfNodeVisits;
+      this.modifiedTimeStamp = modifiedTimeStamp;
+      this.numberOfElements = numberOfElements;
+   }
+
+   /**
+    * Is the node currently in use.
+    *
+    * @return True/false if the node is currently marked as in use.
+    */
+   public boolean isCurrentlyInUse()
+   {
+      return currentlyInUse;
+   }
+
+   public void setCurrentlyInUse(boolean currentlyInUse, long inUseTimeout)
+   {
+      this.currentlyInUse = currentlyInUse;
+      if (inUseTimeout > 0)
+      {
+         this.inUseTimeoutTimestamp = System.currentTimeMillis() + inUseTimeout;
+      }
+   }
+
+   public long getInUseTimeoutTimestamp()
+   {
+      return this.inUseTimeoutTimestamp;
+   }
+
+   /**
+    * Get modified time stamp. This stamp is created during the node is
+    * processed so it has some fuzy tolerance in there.
+    *
+    * @return The last modified time stamp
+    */
+   public long getModifiedTimeStamp()
+   {
+      return modifiedTimeStamp;
+   }
+
+   public void setModifiedTimeStamp(long modifiedTimeStamp)
+   {
+//      log.error("Being modified to " + modifiedTimeStamp, new Throwable());
+      this.modifiedTimeStamp = modifiedTimeStamp;
+   }
+
+   /**
+    * Get the time stamp for when the node entry was created.
+    *
+    * @return The node entry creation time stamp
+    */
+   public long getCreationTimeStamp()
+   {
+      return creationTimeStamp;
+   }
+
+   public void setCreationTimeStamp(long creationTimeStamp)
+   {
+      this.creationTimeStamp = creationTimeStamp;
+   }
+
+   public int getNumberOfNodeVisits()
+   {
+      return numberOfNodeVisits;
+   }
+
+   public void setNumberOfNodeVisits(int numberOfNodeVisits)
+   {
+      this.numberOfNodeVisits = numberOfNodeVisits;
+   }
+
+   public void incerementNumberOfNodeVisits()
+   {
+      this.numberOfNodeVisits ++;
+   }
+
+   public int getNumberOfElements()
+   {
+      return numberOfElements;
+   }
+
+   public void setNumberOfElements(int numberOfElements)
+   {
+      if (queue != null)
+      {
+         int difference = numberOfElements - this.numberOfElements;
+         queue.modifyElementCount(difference);
+      }
+      this.numberOfElements = numberOfElements;
+   }
+
+   public K getKey()
+   {
+      return key;
+   }
+
+   void setKey(K key)
+   {
+      this.key = key;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return key.hashCode();
+   }
+
+   public boolean isNodeInUseAndNotTimedOut()
+   {
+      if (isCurrentlyInUse())
+      {
+         if (getInUseTimeoutTimestamp() == 0)
+         {
+            return true;
+         }
+
+         if (System.currentTimeMillis() < getInUseTimeoutTimestamp())
+         {
+            return true;
+         }
+      }
+      return false;
+   }
+
+   /**
+    * Tests whether a node entry is younger than the minimum time to live - if one is configured.
+    *
+    * @return true if the node is younger than - or exactly equal to - the minimum time to live, if one is configured for the given region.  False otherwise.
+    */
+   public boolean isYoungerThanMinimumTimeToLive(long minTTL)
+   {
+      return minTTL >= 1 && (getModifiedTimeStamp() + minTTL > System.currentTimeMillis());
+   }
+
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (!(o instanceof KeyEntry))
+         return false;
+      KeyEntry ne = (KeyEntry) o;
+      return key.equals(ne.getKey());
+   }
+
+   @Override
+   public String toString()
+   {
+      StringBuilder output = new StringBuilder();
+      output.append("Fqn: ");
+      if (key != null)
+      {
+         output.append(key);
+      }
+      else
+      {
+         output.append(" null");
+      }
+
+      output.append(" CreateTime: ").append(this.getCreationTimeStamp());
+      output.append(" NodeVisits: ").append(this.getNumberOfNodeVisits());
+      output.append(" ModifiedTime: ").append(this.getModifiedTimeStamp());
+      output.append(" NumberOfElements: ").append(this.getNumberOfElements());
+      output.append(" CurrentlyInUse: ").append(this.isCurrentlyInUse());
+      return output.toString();
+   }
+
+   public void setQueue(EvictionQueue queue)
+   {
+      this.queue = queue;
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/KeyEntry.java
___________________________________________________________________
Name: svn:executable
   + *

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithm.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,107 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.starobrno.config.EvictionAlgorithmConfig;
-
-/**
- * Least Frequently Used algorithm for cache eviction.
- * Note that this algorithm is not thread-safe.
- * <p/>
- * This algorithm relies on maxNodes and minNodes to operate correctly.
- * Eviction takes place using Least Frequently Used algorithm. A node A
- * that is used less than a node B is evicted sooner.
- * <p/>
- * The minNodes property defines a threshold for eviction. If minNodes = 100,
- * the LFUAlgorithm will not evict the cache to anything less than 100 elements
- * still left in cache. The maxNodes property defines the maximum number of nodes
- * the cache will accept before eviction. maxNodes = 0 means that this region is
- * unbounded. minNodes = 0 means that the eviction queue will attempt to bring
- * the cache of this region to 0 elements (evict all elements) whenever it is run.
- * <p/>
- * This algorithm uses a sorted eviction queue. The eviction queue is sorted in
- * ascending order based on the number of times a node is visited. The more frequently
- * a node is visited, the less likely it will be evicted.
- *
- * @author Daniel Huang - dhuang at jboss.org 10/2005
- * @version $Revision: 6776 $
- */
-public class LFUAlgorithm extends BaseSortedEvictionAlgorithm
-{
-   private static final Log log = LogFactory.getLog(LFUAlgorithm.class);
-   private static final boolean trace = log.isTraceEnabled();
-
-   @Override
-   protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne)
-   {
-      if (trace)
-      {
-         log.trace("Deciding whether node in queue " + ne.getFqn() + " requires eviction.");
-      }
-
-      // check the minimum time to live and see if we should not evict the node.  This check will
-      // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
-      if (isYoungerThanMinimumTimeToLive(ne)) return false;
-
-      org.jboss.starobrno.eviction.LFUAlgorithmConfig config = (org.jboss.starobrno.eviction.LFUAlgorithmConfig) evictionAlgorithmConfig;
-      int size = this.getEvictionQueue().getNumberOfNodes();
-      if (config.getMaxNodes() > -1 && size > config.getMaxNodes())
-      {
-         return true;
-      }
-      else if (size > config.getMinNodes())
-      {
-         return true;
-      }
-
-      return false;
-   }
-
-   /**
-    * Will create a LFUQueue to be used as the underlying eviction queue.
-    *
-    * @return The created LFUQueue.
-    * @throws org.jboss.starobrno.eviction.EvictionException
-    *
-    */
-   @Override
-   protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      return new org.jboss.starobrno.eviction.LFUQueue();
-   }
-
-   @Override
-   protected void prune() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      super.prune();
-
-      // clean up the Queue's eviction removals
-      ((org.jboss.starobrno.eviction.LFUQueue) this.evictionQueue).prune();
-   }
-
-   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
-   {
-      return org.jboss.starobrno.eviction.LFUAlgorithmConfig.class;
-   }
-}

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithmConfig.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.starobrno.config.Dynamic;
-
-/**
- * Configuration implementation for {@link org.jboss.starobrno.eviction.LFUAlgorithm}.
- *
- * @author Manik Surtani
- * @since 3.0
- */
-public class LFUAlgorithmConfig extends EvictionAlgorithmConfigBase
-{
-   /**
-    * The serialVersionUID
-    */
-   private static final long serialVersionUID = 1865801530398969179L;
-
-   @Dynamic
-   private int minNodes;
-
-   public LFUAlgorithmConfig()
-   {
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.LFUAlgorithm.class.getName();
-   }
-
-   public LFUAlgorithmConfig(int maxNodes, int minNodes)
-   {
-      this();
-      setMaxNodes(maxNodes);
-      setMinNodes(minNodes);
-   }
-
-   public int getMinNodes()
-   {
-      return minNodes;
-   }
-
-   public void setMinNodes(int minNodes)
-   {
-      testImmutability("minNodes");
-      this.minNodes = minNodes;
-   }
-
-   @Override
-   public String toString()
-   {
-      StringBuilder ret = new StringBuilder();
-      ret.append("LFUAlgorithmConfig: maxNodes = ").append(getMaxNodes()).append(" minNodes = ").append(getMinNodes());
-      return ret.toString();
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      if (obj instanceof LFUAlgorithmConfig && super.equals(obj))
-      {
-         return (this.minNodes == ((LFUAlgorithmConfig) obj).minNodes);
-      }
-      return false;
-   }
-
-   @Override
-   public int hashCode()
-   {
-      int result = super.hashCode();
-      result = 31 * result + minNodes;
-      return result;
-   }
-
-   @Override
-   public LFUAlgorithmConfig clone() throws CloneNotSupportedException
-   {
-      return (LFUAlgorithmConfig) super.clone();
-   }
-
-   @Override
-   public void reset()
-   {
-      super.reset();
-      minNodes = -1;
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.LFUAlgorithm.class.getName();
-   }
-}
\ No newline at end of file

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUQueue.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,237 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.cache.Fqn;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * LFUQueue EvictionQueue implementation for LFU Policy.
- * <p/>
- * The queue is sorted in least frequently used order.
- *
- * @author Daniel Huang (dhuang at jboss.org)
- * @version $Revision: 6776 $
- */
-public class LFUQueue implements SortedEvictionQueue
-{
-   private Map<Fqn, org.jboss.starobrno.eviction.NodeEntry> nodeMap;
-   private LinkedList<org.jboss.starobrno.eviction.NodeEntry> evictionList;
-   private Comparator<org.jboss.starobrno.eviction.NodeEntry> comparator;
-
-   private Set<org.jboss.starobrno.eviction.NodeEntry> removalQueue;
-   private int numElements = 0;
-
-   protected LFUQueue()
-   {
-      nodeMap = new HashMap<Fqn, org.jboss.starobrno.eviction.NodeEntry>();
-      comparator = new LFUComparator();
-      evictionList = new LinkedList<org.jboss.starobrno.eviction.NodeEntry>();
-      removalQueue = new HashSet<org.jboss.starobrno.eviction.NodeEntry>();
-   }
-
-   /**
-    * Return the first node to evict.
-    * <p/>
-    * This method will return the least frequently used entry in the queue.
-    */
-   public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
-   {
-      try
-      {
-         org.jboss.starobrno.eviction.NodeEntry ne;
-         while ((ne = evictionList.getFirst()) != null)
-         {
-            if (removalQueue.contains(ne))
-            {
-               evictionList.removeFirst();
-               removalQueue.remove(ne);
-            }
-            else
-            {
-               break;
-            }
-         }
-         return ne;
-      }
-      catch (NoSuchElementException e)
-      {
-         //
-      }
-
-      return null;
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
-   {
-      return nodeMap.get(fqn);
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
-   {
-      return this.getNodeEntry(Fqn.fromString(fqn));
-   }
-
-   public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      Fqn fqn = entry.getFqn();
-      return this.getNodeEntry(fqn) != null;
-   }
-
-   public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      org.jboss.starobrno.eviction.NodeEntry ne = nodeMap.remove(entry.getFqn());
-      if (ne != null)
-      {
-         // don't remove directly from the LinkedList otherwise we will incur a O(n) = n
-         // performance penalty for every removal! In the prune method for LFU, we will iterate the LinkedList through ONCE
-         // doing a single O(n) = n operation and removal. This is much preferred over running O(n) = n every single time
-         // remove is called. There is also special logic in the getFirstNodeEntry that will know to check
-         // the removalQueue before returning.
-         this.removalQueue.add(ne);
-/*         if(!evictionList.remove(ne)) {
-            throw new RuntimeException("");
-         } */
-         this.numElements -= ne.getNumberOfElements();
-      }
-   }
-
-   public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      if (!this.containsNodeEntry(entry))
-      {
-         Fqn fqn = entry.getFqn();
-         entry.queue = this;
-         nodeMap.put(fqn, entry);
-         evictionList.add(entry);
-         this.numElements += entry.getNumberOfElements();
-      }
-   }
-
-   public int getNumberOfNodes()
-   {
-      return nodeMap.size();
-   }
-
-   public int getNumberOfElements()
-   {
-      return this.numElements;
-   }
-
-   public void clear()
-   {
-      nodeMap.clear();
-      evictionList.clear();
-      removalQueue.clear();
-      this.numElements = 0;
-   }
-
-   public void resortEvictionQueue()
-   {
-      Collections.sort(evictionList, comparator);
-   }
-
-   public void modifyElementCount(int difference)
-   {
-      this.numElements += difference;
-   }
-
-   protected void prune()
-   {
-      Iterator<org.jboss.starobrno.eviction.NodeEntry> it = this.iterator();
-      while (it.hasNext() && removalQueue.size() > 0)
-      {
-         if (removalQueue.remove(it.next()))
-         {
-            it.remove();
-         }
-      }
-   }
-
-   protected final List<org.jboss.starobrno.eviction.NodeEntry> getEvictionList()
-   {
-      return this.evictionList;
-   }
-
-   protected final Set<org.jboss.starobrno.eviction.NodeEntry> getRemovalQueue()
-   {
-      return this.removalQueue;
-   }
-
-   public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
-   {
-      return evictionList.iterator();
-   }
-
-   /**
-    * Comparator class for LFU.
-    * <p/>
-    * This class will sort the eviction queue in the correct eviction order.
-    * The top of the list should evict before the bottom of the list.
-    * <p/>
-    * The sort is based on ascending order of nodeVisits.
-    * <p/>
-    * Note: this class has a natural ordering that is inconsistent with equals as defined by the java.lang.Comparator
-    * contract.
-    */
-   protected static class LFUComparator implements Comparator<org.jboss.starobrno.eviction.NodeEntry>
-   {
-
-      public int compare(org.jboss.starobrno.eviction.NodeEntry ne1, org.jboss.starobrno.eviction.NodeEntry ne2)
-      {
-         if (ne1.equals(ne2))
-         {
-            return 0;
-         }
-
-         int neNodeHits = ne1.getNumberOfNodeVisits();
-         int ne2NodeHits = ne2.getNumberOfNodeVisits();
-
-         if (neNodeHits > ne2NodeHits)
-         {
-            return 1;
-         }
-         else if (neNodeHits < ne2NodeHits)
-         {
-            return -1;
-         }
-         else if (neNodeHits == ne2NodeHits)
-         {
-            return 0;
-         }
-
-         throw new RuntimeException("Should never reach this condition");
-      }
-   }
-
-}
-

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithm.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,198 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.starobrno.config.EvictionAlgorithmConfig;
-
-import java.util.Iterator;
-
-/**
- * Least recently Used algorithm to purge old data.
- * Note that this algorithm is not thread-safe.
- *
- * @author Ben Wang 02-2004
- * @author Daniel Huang - dhuang at jboss.org
- */
-public class LRUAlgorithm extends BaseEvictionAlgorithm
-{
-   private static final Log log = LogFactory.getLog(LRUAlgorithm.class);
-   private static final boolean trace = log.isTraceEnabled();
-
-   @Override
-   protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      return new org.jboss.starobrno.eviction.LRUQueue();
-   }
-
-   @Override
-   protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      // check the minimum time to live and see if we should not evict the node.  This check will
-      // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
-      if (isYoungerThanMinimumTimeToLive(entry)) return false;
-
-      org.jboss.starobrno.eviction.LRUAlgorithmConfig config = (org.jboss.starobrno.eviction.LRUAlgorithmConfig) evictionAlgorithmConfig;
-      // no idle or max time limit
-      if (config.getTimeToLive() < 0 && config.getMaxAge() < 0) return false;
-
-      long currentTime = System.currentTimeMillis();
-      if (config.getTimeToLive() > -1)
-      {
-         long idleTime = currentTime - entry.getModifiedTimeStamp();
-         if (trace)
-         {
-            log.trace("Node " + entry.getFqn() + " has been idle for " + idleTime + "ms");
-         }
-         if ((idleTime >= (config.getTimeToLive())))
-         {
-            if (trace)
-            {
-               log.trace("Node " + entry.getFqn() + " should be evicted because of idle time");
-               log.trace("Time to live in millies is: " + (config.getTimeToLive()));
-               log.trace("Config instance is: " + System.identityHashCode(config));
-            }
-            return true;
-         }
-      }
-
-      if (config.getMaxAge() > -1)
-      {
-         long objectLifeTime = currentTime - entry.getCreationTimeStamp();
-         if (trace)
-         {
-            log.trace("Node " + entry.getFqn() + " has been alive for " + objectLifeTime + "ms");
-         }
-         if ((objectLifeTime >= config.getMaxAge()))
-         {
-            if (trace)
-            {
-               log.trace("Node " + entry.getFqn() + " should be evicted because of max age");
-            }
-            return true;
-         }
-      }
-
-      if (trace)
-      {
-         log.trace("Node " + entry.getFqn() + " should not be evicted");
-      }
-      return false;
-   }
-
-   @Override
-   protected void evict(org.jboss.starobrno.eviction.NodeEntry ne)
-   {
-      if (ne != null)
-      {
-         if (!this.evictCacheNode(ne.getFqn()))
-         {
-            try
-            {
-               recycleQueue.put(ne.getFqn());
-            }
-            catch (InterruptedException e)
-            {
-               log.debug("InterruptedException", e);
-            }
-         }
-      }
-   }
-
-   @Override
-   protected void prune() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      org.jboss.starobrno.eviction.LRUQueue lruQueue = (org.jboss.starobrno.eviction.LRUQueue) evictionQueue;
-      org.jboss.starobrno.eviction.NodeEntry ne;
-      Iterator it = lruQueue.iterateLRUQueue();
-      while (it.hasNext())
-      {
-         ne = (org.jboss.starobrno.eviction.NodeEntry) it.next();
-         if (isNodeInUseAndNotTimedOut(ne))
-         {
-            continue;
-         }
-
-         if (this.shouldEvictNode(ne))
-         {
-            it.remove();
-            lruQueue.removeNodeEntryFromMaxAge(ne);
-            this.evict(ne);
-         }
-         else
-         {
-            break;
-         }
-      }
-
-      it = lruQueue.iterateMaxAgeQueue();
-      while (it.hasNext())
-      {
-         ne = (org.jboss.starobrno.eviction.NodeEntry) it.next();
-         if (isNodeInUseAndNotTimedOut(ne))
-         {
-            continue;
-         }
-
-         if (this.shouldEvictNode(ne))
-         {
-            it.remove();
-            lruQueue.removeNodeEntryFromLRU(ne);
-            this.evict(ne);
-         }
-         else
-         {
-            break;
-         }
-      }
-
-      int maxNodes = ((org.jboss.starobrno.eviction.LRUAlgorithmConfig) evictionAlgorithmConfig).getMaxNodes();
-      if (maxNodes <= 0)
-      {
-         return;
-      }
-
-      it = lruQueue.iterateLRUQueue();
-      while (evictionQueue.getNumberOfNodes() > maxNodes)
-      {
-         ne = (org.jboss.starobrno.eviction.NodeEntry) it.next();
-         if (trace)
-         {
-            log.trace("Node " + ne.getFqn() + " will be evicted because of exceeding the maxNode limit." +
-                  " maxNode: " + maxNodes + " but current queue size is: " + evictionQueue.getNumberOfNodes());
-         }
-
-         if (!this.isNodeInUseAndNotTimedOut(ne))
-         {
-            it.remove();
-            lruQueue.removeNodeEntryFromMaxAge(ne);
-            this.evict(ne);
-         }
-      }
-   }
-
-   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
-   {
-      return org.jboss.starobrno.eviction.LRUAlgorithmConfig.class;
-   }
-}

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithmConfig.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,194 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.cache.annotations.Compat;
-import org.jboss.starobrno.config.ConfigurationException;
-import org.jboss.starobrno.config.Dynamic;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Configuration implementation for {@link org.jboss.starobrno.eviction.LRUAlgorithm}.
- * <p/>
- *
- * @author Manik Surtani
- * @since 3.0
- */
-public class LRUAlgorithmConfig extends EvictionAlgorithmConfigBase
-{
-   /**
-    * The serialVersionUID
-    */
-   private static final long serialVersionUID = -3426716488271559729L;
-
-   /**
-    * value expressed in millis
-    */
-   @Dynamic
-   private long timeToLive;
-
-   /**
-    * value expressed in millis
-    */
-   @Dynamic
-   private long maxAge;
-
-   public LRUAlgorithmConfig()
-   {
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.LRUAlgorithm.class.getName();
-      // Force config of ttls
-      setTimeToLive(-1);
-      setMaxAge(-1);
-   }
-
-   public LRUAlgorithmConfig(long timeToLive, long maxAge)
-   {
-      this();
-      this.timeToLive = timeToLive;
-      this.maxAge = maxAge;
-   }
-
-   public LRUAlgorithmConfig(long timeToLive, int maxAge, int maxNodes)
-   {
-      this(timeToLive, maxAge);
-      this.maxNodes = maxNodes;
-   }
-
-   /**
-    * @return the time to live, in milliseconds
-    */
-   public long getTimeToLive()
-   {
-      return timeToLive;
-   }
-
-   /**
-    * Sets the time to live
-    *
-    * @param timeToLive the time to live, in milliseconds
-    */
-   public void setTimeToLive(long timeToLive)
-   {
-      testImmutability("timeToLive");
-      this.timeToLive = timeToLive;
-   }
-
-   public void setTimeToLive(long timeToLive, TimeUnit timeUnit)
-   {
-      testImmutability("timeToLive");
-      this.timeToLive = timeUnit.toMillis(timeToLive);
-   }
-
-   @Deprecated
-   @Compat
-   public void setTimeToLiveSeconds(long time)
-   {
-      setTimeToLive(time, TimeUnit.SECONDS);
-   }
-
-   /**
-    * @return the max age per element, in milliseconds
-    */
-   public long getMaxAge()
-   {
-      return maxAge;
-   }
-
-   /**
-    * Sets the max age per element
-    *
-    * @param maxAge value in milliseconds
-    */
-   public void setMaxAge(long maxAge)
-   {
-      testImmutability("maxAge");
-      this.maxAge = maxAge;
-   }
-
-   public void setMaxAge(long maxAge, TimeUnit timeUnit)
-   {
-      testImmutability("maxAge");
-      this.maxAge = timeUnit.toMillis(maxAge);
-   }
-
-   /**
-    * Requires a positive timeToLive value or ConfigurationException
-    * is thrown.
-    */
-   @Override
-   public void validate() throws ConfigurationException
-   {
-      super.validate();
-      if (timeToLive < -1)
-      {
-         throw new ConfigurationException("timeToLive must be " +
-               "configured to a value greater than or equal to 0 (or -1 for unlimited time to live) for " + getEvictionAlgorithmClassName());
-      }
-   }
-
-   public String toString()
-   {
-      return "LRUAlgorithmConfig {" +
-            "algorithmClassName=" + evictionAlgorithmClassName +
-            ", timeToLive=" + timeToLive +
-            ", maxAge=" + maxAge +
-            '}';
-   }
-
-   public boolean equals(Object o)
-   {
-      if (this == o) return true;
-      if (!(o instanceof LRUAlgorithmConfig)) return false;
-      if (!super.equals(o)) return false;
-
-      LRUAlgorithmConfig that = (LRUAlgorithmConfig) o;
-
-      if (maxAge != that.maxAge) return false;
-      if (timeToLive != that.timeToLive) return false;
-
-      return true;
-   }
-
-   public int hashCode()
-   {
-      int result = super.hashCode();
-      result = 31 * result + (int) (timeToLive ^ (timeToLive >>> 32));
-      result = 31 * result + (int) (maxAge ^ (maxAge >>> 32));
-      return result;
-   }
-
-   @Override
-   public void reset()
-   {
-      super.reset();
-      setTimeToLive(-1);
-      setMaxAge(-1);
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.LRUAlgorithm.class.getName();
-   }
-
-   @Override
-   public LRUAlgorithmConfig clone() throws CloneNotSupportedException
-   {
-      return (LRUAlgorithmConfig) super.clone();
-   }
-}
\ No newline at end of file

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUQueue.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,203 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.cache.Fqn;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * LRU Eviction Queue implementation.
- * <p/>
- * This eviction queue will iterate properly through two sorted lists.
- * One sorted by maxAge and the other sorted by idleTime.
- *
- * @author Daniel Huang (dhuang at jboss.org)
- * @version $Revision: 6776 $
- */
-public class LRUQueue implements EvictionQueue
-{
-   private Map<Fqn, org.jboss.starobrno.eviction.NodeEntry> maxAgeQueue;
-   private Map<Fqn, org.jboss.starobrno.eviction.NodeEntry> lruQueue;
-   private long alternatingCount = 0;
-   private int numElements = 0;
-
-   protected LRUQueue()
-   {
-      maxAgeQueue = new LinkedHashMap<Fqn, org.jboss.starobrno.eviction.NodeEntry>();
-      lruQueue = new LinkedHashMap<Fqn, org.jboss.starobrno.eviction.NodeEntry>(16, 0.75f, true);
-   }
-
-   protected void reorderByLRU(Fqn fqn)
-   {
-      // leave the max age queue alone - it is like a fifo.
-
-      // the lru queue is access ordered. meaning the most recently read item is moved to the bottom of the queue.
-      // simply calling get against it visits it and will cause LinkedHashMap to move it to the bottom of the queue.
-      lruQueue.get(fqn);
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
-   {
-      // because the underlying queue is in two differently sorted queues, we alternate between them when calling
-      // a generic getFirstNodeEntry.
-      // we must alternate to keep things balanced when evicting nodes based on the maxNodes attribute. We don't
-      // want to just prune from one queue but rather we want to be able to prune from both.
-      org.jboss.starobrno.eviction.NodeEntry ne;
-      if (alternatingCount % 2 == 0)
-      {
-         ne = this.getFirstLRUNodeEntry();
-         if (ne == null)
-         {
-            ne = this.getFirstMaxAgeNodeEntry();
-         }
-      }
-      else
-      {
-         ne = this.getFirstMaxAgeNodeEntry();
-         if (ne == null)
-         {
-            ne = this.getFirstLRUNodeEntry();
-         }
-      }
-      alternatingCount++;
-      return ne;
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getFirstLRUNodeEntry()
-   {
-      if (lruQueue.size() > 0)
-      {
-         return lruQueue.values().iterator().next();
-      }
-
-      return null;
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getFirstMaxAgeNodeEntry()
-   {
-      if (maxAgeQueue.size() > 0)
-      {
-         return maxAgeQueue.values().iterator().next();
-      }
-
-      return null;
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
-   {
-      return lruQueue.get(fqn);
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
-   {
-      return this.getNodeEntry(Fqn.fromString(fqn));
-   }
-
-   public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      return this.maxAgeQueue.containsKey(entry.getFqn());
-   }
-
-   protected void removeNodeEntryFromLRU(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      Fqn fqn = entry.getFqn();
-      lruQueue.remove(fqn);
-   }
-
-   protected void removeNodeEntryFromMaxAge(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      Fqn fqn = entry.getFqn();
-      maxAgeQueue.remove(fqn);
-   }
-
-   public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      if (!this.containsNodeEntry(entry))
-      {
-         return;
-      }
-      Fqn fqn = entry.getFqn();
-      org.jboss.starobrno.eviction.NodeEntry ne1 = lruQueue.remove(fqn);
-      org.jboss.starobrno.eviction.NodeEntry ne2 = maxAgeQueue.remove(fqn);
-
-      if (ne1 == null || ne2 == null)
-      {
-         throw new RuntimeException("The queues are out of sync.");
-      }
-
-      this.numElements -= ne1.getNumberOfElements();
-
-   }
-
-   public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      if (!this.containsNodeEntry(entry))
-      {
-         Fqn fqn = entry.getFqn();
-         entry.queue = this;
-         maxAgeQueue.put(fqn, entry);
-         lruQueue.put(fqn, entry);
-         this.numElements += entry.getNumberOfElements();
-      }
-   }
-
-   public int getNumberOfNodes()
-   {
-      return maxAgeQueue.size();
-   }
-
-   public int getNumberOfElements()
-   {
-      return this.numElements;
-   }
-
-   public void clear()
-   {
-      maxAgeQueue.clear();
-      lruQueue.clear();
-      this.numElements = 0;
-   }
-
-   public void modifyElementCount(int difference)
-   {
-      this.numElements += difference;
-   }
-
-   public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
-   {
-      return lruQueue.values().iterator();
-   }
-
-   protected final Iterator<org.jboss.starobrno.eviction.NodeEntry> iterateMaxAgeQueue()
-   {
-      return maxAgeQueue.values().iterator();
-   }
-
-   protected final Iterator<org.jboss.starobrno.eviction.NodeEntry> iterateLRUQueue()
-   {
-      return lruQueue.values().iterator();
-   }
-
-}

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithm.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.starobrno.config.EvictionAlgorithmConfig;
-
-/**
- * Most Recently Used Algorithm.
- * <p/>
- * This algorithm will evict the most recently used cache entries from cache.
- * <p/>
- * Note: None of the Eviction classes are thread safe. It is assumed that an individual instance of an EvictionPolicy/
- * EvictionAlgorithm/EvictionQueue/EvictionConfiguration are only operated on by one thread at any given time.
- *
- * @author Daniel Huang (dhuang at jboss.org)
- * @version $Revision: 6776 $
- */
-public class MRUAlgorithm extends BaseEvictionAlgorithm
-{
-   @Override
-   protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
-   {
-      return new org.jboss.starobrno.eviction.MRUQueue();
-   }
-
-   @Override
-   protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne)
-   {
-      // check the minimum time to live and see if we should not evict the node.  This check will
-      // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
-      if (isYoungerThanMinimumTimeToLive(ne)) return false;
-
-      org.jboss.starobrno.eviction.MRUAlgorithmConfig config = (org.jboss.starobrno.eviction.MRUAlgorithmConfig) evictionAlgorithmConfig;
-      return evictionQueue.getNumberOfNodes() > config.getMaxNodes();
-   }
-
-   @Override
-   protected void processVisitedNodes(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      super.processVisitedNodes(evictedEventNode);
-      ((org.jboss.starobrno.eviction.MRUQueue) evictionQueue).moveToTopOfStack(evictedEventNode.getFqn());
-   }
-
-   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
-   {
-      return org.jboss.starobrno.eviction.MRUAlgorithmConfig.class;
-   }
-}

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithmConfig.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,95 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.starobrno.config.ConfigurationException;
-
-/**
- * Configuration for {@link org.jboss.starobrno.eviction.MRUAlgorithm}.
- * <p/>
- * Requires a "maxNodes" attribute otherwise a ConfigurationException is thrown.
- *
- * @author Manik Surtani
- * @since 3.0
- */
-public class MRUAlgorithmConfig extends EvictionAlgorithmConfigBase
-{
-   /**
-    * The serialVersionUID
-    */
-   private static final long serialVersionUID = -8734577898966155218L;
-
-   public MRUAlgorithmConfig()
-   {
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.MRUAlgorithm.class.getName();
-      // We require that maxNodes is set
-      setMaxNodes(-1);
-   }
-
-   public MRUAlgorithmConfig(int maxNodes)
-   {
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.MRUAlgorithm.class.getName();
-      setMaxNodes(maxNodes);
-   }
-
-   /**
-    * Requires a positive maxNodes value or ConfigurationException
-    * is thrown.
-    */
-   @Override
-   public void validate() throws ConfigurationException
-   {
-      super.validate();
-      if (getMaxNodes() < 0)
-         throw new ConfigurationException("maxNodes not configured");
-   }
-
-   @Override
-   public String toString()
-   {
-      StringBuilder str = new StringBuilder();
-      str.append("MRUAlgorithmConfig: ").
-            append(" maxNodes =").append(getMaxNodes());
-      return str.toString();
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      return (obj instanceof MRUAlgorithmConfig && super.equals(obj));
-   }
-
-   @Override
-   public void reset()
-   {
-      super.reset();
-      setMaxNodes(-1);
-      evictionAlgorithmClassName = org.jboss.starobrno.eviction.MRUAlgorithm.class.getName();
-   }
-
-   @Override
-   public MRUAlgorithmConfig clone() throws CloneNotSupportedException
-   {
-      return (MRUAlgorithmConfig) super.clone();
-   }
-
-}
\ No newline at end of file

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUQueue.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,169 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.cache.Fqn;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-/**
- * MRU Eviction Queue implementation.
- * <p/>
- * This nodeMap is sorted by MRU. The first entry in the nodeMap
- * will also be the most recently used entry. The sort is implicit
- * based on a Stack that we can implicitly sort to the top by moving
- * a node that is used to the top of the eviction stack.
- *
- * @author Daniel Huang (dhuang at jboss.org)
- * @version $Revision: 6776 $
- */
-public class MRUQueue implements EvictionQueue
-{
-   // we use our own Stack/Linked List implementation here because it guarantees O(n) = 1 for add, remove, get and
-   // we can sort it in order of MRU implicitly while still getting O(n) = 1 access time
-   // throughout.
-   Map<Fqn, EvictionListEntry> nodeMap;
-   org.jboss.starobrno.eviction.EvictionQueueList list;
-   private int numElements = 0;
-
-   protected MRUQueue()
-   {
-      nodeMap = new HashMap<Fqn, EvictionListEntry>();
-      list = new org.jboss.starobrno.eviction.EvictionQueueList();
-   }
-
-   /**
-    * This call moves a NodeEntry to the top of the stack.
-    * <p/>
-    * When a node is visited this method should be called to guarantee MRU ordering.
-    *
-    * @param fqn Fqn of the nodeEntry to move to the top of the stack.
-    */
-   protected void moveToTopOfStack(Fqn fqn)
-   {
-      EvictionListEntry le = nodeMap.remove(fqn);
-      if (le != null)
-      {
-         list.remove(le);
-         list.addToTop(le);
-         nodeMap.put(le.node.getFqn(), le);
-      }
-   }
-
-   /**
-    * Will return the first entry in the nodeMap.
-    * <p/>
-    * The first entry in this nodeMap will also be the most recently used entry.
-    *
-    * @return The first node entry in nodeMap.
-    */
-   public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
-   {
-      try
-      {
-         return list.getFirst().node;
-      }
-      catch (NoSuchElementException e)
-      {
-         //
-      }
-
-      return null;
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
-   {
-      EvictionListEntry le = nodeMap.get(fqn);
-      if (le != null)
-         return le.node;
-
-      return null;
-   }
-
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
-   {
-      return this.getNodeEntry(Fqn.fromString(fqn));
-   }
-
-   public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      return nodeMap.containsKey(entry.getFqn());
-   }
-
-   public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      EvictionListEntry le = nodeMap.remove(entry.getFqn());
-      if (le != null)
-      {
-         list.remove(le);
-         this.numElements -= le.node.getNumberOfElements();
-      }
-   }
-
-   public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      if (!this.containsNodeEntry(entry))
-      {
-         entry.queue = this;
-         EvictionListEntry le = new EvictionListEntry(entry);
-         list.addToBottom(le);
-         nodeMap.put(entry.getFqn(), le);
-         this.numElements += entry.getNumberOfElements();
-      }
-   }
-
-   public int getNumberOfNodes()
-   {
-      return list.size();
-   }
-
-   public int getNumberOfElements()
-   {
-      return this.numElements;
-   }
-
-   public void modifyElementCount(int difference)
-   {
-      this.numElements += difference;
-   }
-
-   public void clear()
-   {
-      nodeMap.clear();
-      list.clear();
-      this.numElements = 0;
-   }
-
-   public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
-   {
-      return list.iterator();
-   }
-
-   @Override
-   public String toString()
-   {
-      return list.toString();
-   }
-}

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NodeEntry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NodeEntry.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NodeEntry.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,193 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.cache.Fqn;
-
-/**
- * Value object used in queue
- *
- * @author Ben Wang 2-2004
- * @author Daniel Huang - dhuang at jboss.org
- */
-public class NodeEntry
-{
-   private long modifiedTimeStamp;
-   private long creationTimeStamp;
-   private int numberOfNodeVisits;
-   private int numberOfElements;
-   private Fqn fqn;
-
-   private long inUseTimeoutTimestamp;
-   private boolean currentlyInUse = false;
-
-   EvictionQueue queue;
-
-   /**
-    * Private constructor that automatically sets the creation time stamp of the node entry.
-    */
-   private NodeEntry()
-   {
-      this.creationTimeStamp = System.currentTimeMillis();
-   }
-
-   public NodeEntry(Fqn fqn)
-   {
-      this();
-      setFqn(fqn);
-   }
-
-   public NodeEntry(String fqn)
-   {
-      this();
-      setFqn(Fqn.fromString(fqn));
-   }
-
-   /**
-    * Is the node currently in use.
-    *
-    * @return True/false if the node is currently marked as in use.
-    */
-   public boolean isCurrentlyInUse()
-   {
-      return currentlyInUse;
-   }
-
-   public void setCurrentlyInUse(boolean currentlyInUse, long inUseTimeout)
-   {
-      this.currentlyInUse = currentlyInUse;
-      if (inUseTimeout > 0)
-      {
-         this.inUseTimeoutTimestamp = System.currentTimeMillis() + inUseTimeout;
-      }
-   }
-
-   public long getInUseTimeoutTimestamp()
-   {
-      return this.inUseTimeoutTimestamp;
-   }
-
-   /**
-    * Get modified time stamp. This stamp is created during the node is
-    * processed so it has some fuzy tolerance in there.
-    *
-    * @return The last modified time stamp
-    */
-   public long getModifiedTimeStamp()
-   {
-      return modifiedTimeStamp;
-   }
-
-   public void setModifiedTimeStamp(long modifiedTimeStamp)
-   {
-//      log.error("Being modified to " + modifiedTimeStamp, new Throwable());
-      this.modifiedTimeStamp = modifiedTimeStamp;
-   }
-
-   /**
-    * Get the time stamp for when the node entry was created.
-    *
-    * @return The node entry creation time stamp
-    */
-   public long getCreationTimeStamp()
-   {
-      return creationTimeStamp;
-   }
-
-   public void setCreationTimeStamp(long creationTimeStamp)
-   {
-      this.creationTimeStamp = creationTimeStamp;
-   }
-
-   public int getNumberOfNodeVisits()
-   {
-      return numberOfNodeVisits;
-   }
-
-   public void setNumberOfNodeVisits(int numberOfNodeVisits)
-   {
-      this.numberOfNodeVisits = numberOfNodeVisits;
-   }
-
-   public int getNumberOfElements()
-   {
-      return numberOfElements;
-   }
-
-   public void setNumberOfElements(int numberOfElements)
-   {
-      if (queue != null)
-      {
-         int difference = numberOfElements - this.numberOfElements;
-         queue.modifyElementCount(difference);
-      }
-      this.numberOfElements = numberOfElements;
-   }
-
-   public Fqn getFqn()
-   {
-      return fqn;
-   }
-
-   void setFqn(Fqn fqn)
-   {
-      this.fqn = fqn;
-   }
-
-   @Override
-   public int hashCode()
-   {
-      return fqn.hashCode();
-   }
-
-   @Override
-   public boolean equals(Object o)
-   {
-      if (!(o instanceof NodeEntry))
-         return false;
-      NodeEntry ne = (NodeEntry) o;
-      return fqn.equals(ne.getFqn());
-   }
-
-   @Override
-   public String toString()
-   {
-      StringBuilder output = new StringBuilder();
-      output.append("Fqn: ");
-      if (fqn != null)
-      {
-         output.append(fqn);
-      }
-      else
-      {
-         output.append(" null");
-      }
-
-      output.append(" CreateTime: ").append(this.getCreationTimeStamp());
-      output.append(" NodeVisits: ").append(this.getNumberOfNodeVisits());
-      output.append(" ModifiedTime: ").append(this.getModifiedTimeStamp());
-      output.append(" NumberOfElements: ").append(this.getNumberOfElements());
-      output.append(" CurrentlyInUse: ").append(this.isCurrentlyInUse());
-      return output.toString();
-   }
-
-}

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.cache.CacheSPI_Legacy;
-import org.jboss.cache.Fqn;
-import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.config.EvictionAlgorithmConfig;
-import org.jboss.starobrno.eviction.EvictionEvent.Type;
-
-import java.util.concurrent.BlockingQueue;
-
-/**
- * An eviction algorithm that does nothing - a no-op for everything.
- *
- * @author Brian Stansberry
- */
-public class NullEvictionAlgorithm implements EvictionAlgorithm
-{
-   /**
-    * Singleton instance of this class.
-    */
-   private static final NullEvictionAlgorithm INSTANCE = new NullEvictionAlgorithm();
-
-   /**
-    * Constructs a new NullEvictionAlgorithm.
-    */
-   private NullEvictionAlgorithm()
-   {
-   }
-
-   public static NullEvictionAlgorithm getInstance()
-   {
-      return INSTANCE;
-   }
-
-   /**
-    * Returns {@link org.jboss.starobrno.eviction.NullEvictionQueue#INSTANCE}.
-    */
-   public org.jboss.starobrno.eviction.EvictionQueue getEvictionQueue()
-   {
-      return org.jboss.starobrno.eviction.NullEvictionQueue.INSTANCE;
-   }
-
-   public void setEvictionActionPolicy(org.jboss.starobrno.eviction.EvictionActionPolicy evictionActionPolicy)
-   {
-      // no-op
-   }
-
-   public void assignToRegion(Fqn fqn, CacheSPI_Legacy<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration)
-   {
-      // no-op
-   }
-
-   public void process(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> queue) throws org.jboss.starobrno.eviction.EvictionException
-   {
-      // no-op
-   }
-
-   public void resetEvictionQueue()
-   {
-      // no-op
-   }
-
-   public boolean canIgnoreEvent(Type eventType)
-   {
-      return true; // always ignore everything!
-   }
-
-   public void initialize()
-   {
-      // no-op
-   }
-
-   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
-   {
-      return org.jboss.starobrno.eviction.NullEvictionAlgorithmConfig.class;
-   }
-}

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithmConfig.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.starobrno.config.ConfigurationComponent;
-import org.jboss.starobrno.config.ConfigurationException;
-import org.jboss.starobrno.config.EvictionAlgorithmConfig;
-
-/**
- * Configuration class for {@link NullEvictionAlgorithm}.
- *
- * @author Manik Surtani
- * @since 3.0
- */
-public class NullEvictionAlgorithmConfig extends ConfigurationComponent implements EvictionAlgorithmConfig
-{
-   private static final long serialVersionUID = -6591180473728241737L;
-
-   /**
-    * No-op
-    */
-   public void reset()
-   {
-      // no-op
-   }
-
-   public String getEvictionAlgorithmClassName()
-   {
-      return NullEvictionAlgorithm.class.getName();
-   }
-
-   /**
-    * No-op
-    */
-   public void validate() throws ConfigurationException
-   {
-      // no-op
-   }
-
-   public NullEvictionAlgorithmConfig clone() throws CloneNotSupportedException
-   {
-      return (NullEvictionAlgorithmConfig) super.clone();
-   }
-}
\ No newline at end of file

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionQueue.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,161 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-import org.jboss.cache.Fqn;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * A queue that does nothing.
- *
- * @author Brian Stansberry
- */
-public class NullEvictionQueue implements EvictionQueue
-{
-   /**
-    * Singleton instance of this class.
-    */
-   public static final NullEvictionQueue INSTANCE = new NullEvictionQueue();
-
-   /**
-    * Constructs a new NullEvictionQueue.
-    */
-   private NullEvictionQueue()
-   {
-   }
-
-   /**
-    * No-op
-    */
-   public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      // no-op
-   }
-
-   /**
-    * No-op
-    */
-   public void clear()
-   {
-      // no-op
-   }
-
-   /**
-    * Returns <code>false</code>
-    */
-   public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      return false;
-   }
-
-   /**
-    * Returns <code>null</code>
-    */
-   public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
-   {
-      return null;
-   }
-
-   /**
-    * Returns <code>null</code>
-    */
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
-   {
-      return null;
-   }
-
-   /**
-    * Returns <code>null</code>
-    */
-   public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
-   {
-      return null;
-   }
-
-   /**
-    * Returns <code>0</code>
-    */
-   public int getNumberOfElements()
-   {
-      return 0;
-   }
-
-   /**
-    * Returns <code>0</code>
-    */
-   public int getNumberOfNodes()
-   {
-      return 0;
-   }
-
-   /**
-    * Returns an <code>Iterator</code> whose
-    * <code>hasNext()</code> returns <code>false</code>.
-    */
-   public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
-   {
-      return NullQueueIterator.INSTANCE;
-   }
-
-   /**
-    * No-op
-    */
-   public void modifyElementCount(int difference)
-   {
-      // no-op
-   }
-
-   /**
-    * No-op
-    */
-   public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
-   {
-      // no-op
-   }
-
-   static class NullQueueIterator implements Iterator<org.jboss.starobrno.eviction.NodeEntry>
-   {
-      private static final NullQueueIterator INSTANCE = new NullQueueIterator();
-
-      private NullQueueIterator()
-      {
-      }
-
-      public boolean hasNext()
-      {
-         return false;
-      }
-
-      public org.jboss.starobrno.eviction.NodeEntry next()
-      {
-         throw new NoSuchElementException("No more elements");
-      }
-
-      public void remove()
-      {
-         throw new IllegalStateException("Must call next() before remove()");
-      }
-   }
-
-}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -25,6 +25,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.Cache_Legacy;
 import org.jboss.cache.Fqn;
+import org.jboss.starobrno.Cache;
 
 /**
  * An eviction action policy that calls {@link org.jboss.cache.Cache_Legacy#removeNode(org.jboss.cache.Fqn)} to evict a node.
@@ -32,25 +33,26 @@
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
  * @since 3.0
  */
-public class RemoveOnEvictActionPolicy implements EvictionActionPolicy
+public class RemoveOnEvictActionPolicy<K> implements EvictionAction<K>
 {
-   Cache_Legacy<?, ?> cache;
-   private static final Log log = LogFactory.getLog(org.jboss.starobrno.eviction.DefaultEvictionActionPolicy.class);
+   private Cache<K, ?> cache;
+   private static final Log log = LogFactory.getLog(DefaultEvictionAction.class);
 
-   public void setCache(Cache_Legacy<?, ?> cache)
+   public void setCache(Cache<K, ?> cache)
    {
       this.cache = cache;
    }
 
-   public boolean evict(Fqn fqn)
+   public boolean evict(K key)
    {
       try
       {
-         return cache.removeNode(fqn);
+         cache.remove(key);
+         return true;
       }
       catch (Exception e)
       {
-         if (log.isDebugEnabled()) log.debug("Unable to evict " + fqn, e);
+         if (log.isDebugEnabled()) log.debug("Unable to evict " + key, e);
          return false;
       }
    }

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/SortedEvictionQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/SortedEvictionQueue.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/SortedEvictionQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.eviction;
-
-/**
- * Sorted Eviction Queue implementation.
- *
- * @author Daniel Huang (dhuang at jboss.org)
- * @version $Revision: 6776 $
- */
-public interface SortedEvictionQueue extends EvictionQueue
-{
-   /**
-    * Provide contract to resort a sorted queue.
-    */
-   void resortEvictionQueue();
-}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/BaseEvictionAlgorithm.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/BaseEvictionAlgorithm.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/BaseEvictionAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,467 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.CacheSPI;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.*;
+import org.jboss.starobrno.eviction.EvictionEvent.Type;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Abstract Event Processing Eviction Algorithm.
+ * This class is used to implement basic event processing for Eviction Algorithms.
+ * To extend this abstract class to make an Eviction Algorithm, implement the
+ * abstract methods and a policy.
+ *
+ * @author Daniel Huang - dhuang at jboss.org 10/2005
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ */
+public abstract class BaseEvictionAlgorithm<K> implements EvictionAlgorithm<K>
+{
+   private static final Log log = LogFactory.getLog(BaseEvictionAlgorithm.class);
+   private static final boolean trace = log.isTraceEnabled();
+   protected EvictionAction<K> evictionAction;
+   protected EvictionAlgorithmConfig evictionAlgorithmConfig;
+   protected BlockingQueue<K> recycleQueue;
+   protected EvictionQueue<K> evictionQueue;
+   protected CacheSPI<K, ?> cache;
+
+   /**
+    * This method will create an EvictionQueue implementation and prepare it for use.
+    *
+    * @return The created EvictionQueue to be used as the eviction queue for this algorithm.
+    * @see org.jboss.starobrno.eviction.EvictionQueue
+    */
+   protected abstract EvictionQueue<K> setupEvictionQueue() throws EvictionException;
+
+   /**
+    * This method will check whether the given node should be evicted or not.
+    *
+    * @param ne NodeEntry to test eviction for.
+    * @return True if the given node should be evicted. False if the given node should not be evicted.
+    */
+   protected abstract boolean shouldEvictNode(KeyEntry<K> ne);
+
+   protected BaseEvictionAlgorithm()
+   {
+      recycleQueue = new LinkedBlockingQueue<K>(500000);
+   }
+
+   public synchronized void initialize()
+   {
+      if (evictionQueue == null)
+      {
+         evictionQueue = setupEvictionQueue();
+      }
+   }
+
+   public EvictionAction getEvictionActionPolicy()
+   {
+      return evictionAction;
+   }
+
+   public void setEvictionAction(EvictionAction<K> evictionAction)
+   {
+      this.evictionAction = evictionAction;
+   }
+
+   public EvictionAlgorithmConfig getEvictionAlgorithmConfig()
+   {
+      return evictionAlgorithmConfig;
+   }
+
+   public void assignToCache(CacheSPI<K, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig)
+   {
+      this.cache = cache;
+      this.evictionAlgorithmConfig = evictionAlgorithmConfig;
+   }
+
+   public boolean canIgnoreEvent(Type eventType)
+   {
+      return false; // don't ignore anything!
+   }
+
+   /**
+    * Process the given eviction event queue.  Eviction Processing encompasses the following:
+    * <p/>
+    * - Add/Remove/Visit Nodes
+    * - Prune according to Eviction Algorithm
+    * - Empty/Retry the recycle queue of previously evicted but locked (during actual cache eviction) nodes.
+    *
+    * @param eventQueue queue containing eviction events
+    * @throws org.jboss.starobrno.eviction.EvictionException
+    *
+    */
+   public void process(BlockingQueue<EvictionEvent<K>> eventQueue) throws org.jboss.starobrno.eviction.EvictionException
+   {
+      if (trace) log.trace("process(): cache: " + cache);
+      initialize();
+      this.processQueues(eventQueue);
+      this.emptyRecycleQueue();
+      this.prune();
+   }
+
+   public void resetEvictionQueue()
+   {
+      // a no-op
+   }
+
+   /**
+    * Get the underlying EvictionQueue implementation.
+    *
+    * @return the EvictionQueue used by this algorithm
+    * @see org.jboss.starobrno.eviction.EvictionQueue
+    */
+   public EvictionQueue getEvictionQueue()
+   {
+      return this.evictionQueue;
+   }
+
+   protected EvictionEvent<K> getNextInQueue(BlockingQueue<EvictionEvent<K>> queue)
+   {
+      try
+      {
+         return queue.poll(0, TimeUnit.SECONDS);
+      }
+      catch (InterruptedException e)
+      {
+         Thread.currentThread().interrupt();
+      }
+      return null;
+   }
+
+   /**
+    * Event processing for Evict/Add/Visiting of nodes.
+    * <p/>
+    * - On AddEvents a new element is added into the eviction queue
+    * - On RemoveEvents, the removed element is removed from the eviction queue.
+    * - On VisitEvents, the visited node has its eviction statistics updated (idleTime, numberOfNodeVisists, etc..)
+    *
+    * @param queue queue to inspect
+    * @throws org.jboss.starobrno.eviction.EvictionException
+    *          in the event of problems
+    */
+   protected void processQueues(BlockingQueue<EvictionEvent<K>> queue) throws org.jboss.starobrno.eviction.EvictionException
+   {
+      EvictionEvent<K> node;
+      int count = 0;
+      while ((node = getNextInQueue(queue)) != null)
+      {
+         count++;
+         switch (node.getEventType())
+         {
+            case ADD_NODE_EVENT:
+               this.processAddedNodes(node);
+               break;
+            case REMOVE_NODE_EVENT:
+               this.processRemovedNodes(node);
+               break;
+            case VISIT_NODE_EVENT:
+               this.processVisitedNodes(node);
+               break;
+            case ADD_ELEMENT_EVENT:
+               this.processAddedElement(node);
+               break;
+            case REMOVE_ELEMENT_EVENT:
+               this.processRemovedElement(node);
+               break;
+            case MARK_IN_USE_EVENT:
+               this.processMarkInUseNodes(node.getKey(), node.getInUseTimeout());
+               break;
+            case UNMARK_USE_EVENT:
+               this.processUnmarkInUseNodes(node.getKey());
+               break;
+            default:
+               throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
+         }
+      }
+      if (trace) log.trace("processed " + count + " node events");
+   }
+
+   protected void evict(KeyEntry<K> ne)
+   {
+      if (ne != null)
+      {
+         evictionQueue.removeNodeEntry(ne);
+         if (!evictionAction.evict(ne.getKey()))
+         {
+            try
+            {
+               boolean result = recycleQueue.offer(ne.getKey(), 5, TimeUnit.SECONDS);
+               if (!result)
+               {
+                  log.warn("Unable to add Fqn[" + ne.getKey() + "] to recycle " +
+                        "queue because it's full. This is often sign that " +
+                        "evictions are not occurring and nodes that should be " +
+                        "evicted are piling up waiting to be evicted.");
+               }
+            }
+            catch (InterruptedException e)
+            {
+               log.debug("InterruptedException", e);
+            }
+         }
+      }
+   }
+
+   protected void processMarkInUseNodes(K key, long inUseTimeout) throws EvictionException
+   {
+      if (trace)
+      {
+         log.trace("Marking  " + key + " as in use with a usage timeout of " + inUseTimeout);
+      }
+
+      KeyEntry ne = evictionQueue.getNodeEntry(key);
+      if (ne != null)
+      {
+         ne.setCurrentlyInUse(true, inUseTimeout);
+      }
+   }
+
+   protected void processUnmarkInUseNodes(K key) throws EvictionException
+   {
+      if (trace)
+      {
+         log.trace("Unmarking node " + key + " as in use");
+      }
+
+      KeyEntry ne = evictionQueue.getNodeEntry(key);
+      if (ne != null)
+      {
+         ne.setCurrentlyInUse(false, 0);
+      }
+   }
+
+   /**
+    * Convenience method, which calls {@link #processAddedNodes(EvictionEvent , int)}  using values in the
+    * evictedEventNode for number of added elements and the resetElementCount flag.
+    *
+    * @param evictedEventNode an evictedEventNode to process
+    * @throws EvictionException on problems
+    */
+   protected void processAddedNodes(EvictionEvent<K> evictedEventNode) throws EvictionException
+   {
+      processAddedNodes(evictedEventNode, evictedEventNode.getElementDifference());
+   }
+
+   protected void processAddedNodes(EvictionEvent<K> evictedEventNode, int numAddedElements) throws EvictionException
+   {
+      K key = evictedEventNode.getKey();
+      if (trace) log.trace("Adding node " + key + " with " + numAddedElements + " elements to eviction queue");
+      KeyEntry<K> ne = evictionQueue.getNodeEntry(key);
+      if (ne != null)
+      {
+         ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
+         ne.incerementNumberOfNodeVisits();
+         ne.setNumberOfElements(ne.getNumberOfElements() + numAddedElements);
+         if (trace) log.trace("Queue already contains " + ne.getKey() + " processing it as visited");
+         processVisitedNodes(evictedEventNode);
+         return;
+      }
+      ne = new KeyEntry<K>(1, evictedEventNode.getCreationTimestamp(), numAddedElements, key);
+      evictionQueue.addNodeEntry(ne);
+      ne.setQueue(evictionQueue);
+      if (trace) log.trace(ne.getKey() + " added successfully to eviction queue");
+   }
+
+   /**
+    * Remove a node from cache.
+    * <p/>
+    * This method will remove the node from the eviction queue as well as
+    * evict the node from cache.
+    * <p/>
+    * If a node cannot be removed from cache, this method will remove it from the eviction queue
+    * and place the element into the recycleQueue. Each node in the recycle queue will get retried until
+    * proper cache eviction has taken place.
+    * <p/>
+    * Because EvictionQueues are collections, when iterating them from an iterator, use iterator.remove()
+    * to avoid ConcurrentModificationExceptions. Use the boolean parameter to indicate the calling context.
+    *
+    * @throws EvictionException
+    */
+   protected void processRemovedNodes(EvictionEvent<K> evictedEventNode) throws EvictionException
+   {
+      K key = evictedEventNode.getKey();
+
+      if (trace)
+      {
+         log.trace("Removing key " + key + " from eviction queue and attempting eviction");
+      }
+
+      KeyEntry<K> ne = evictionQueue.getNodeEntry(key);
+      if (ne != null)
+      {
+         evictionQueue.removeNodeEntry(ne);
+      } else
+      {
+         if (trace)
+            log.trace("processRemoveNodes(): Can't find node associated with key: " + key
+                  + "Could have been evicted earlier. Will just continue.");
+         return;
+      }
+
+      if (trace)
+      {
+         log.trace(key + " removed from eviction queue");
+      }
+   }
+
+   /**
+    * Visit a node in cache.
+    * <p/>
+    * This method will update the numVisits and modifiedTimestamp properties of the Node.
+    * These properties are used as statistics to determine eviction (LRU, LFU, MRU, etc..)
+    * <p/>
+    * *Note* that this method updates Node Entries by reference and does not put them back
+    * into the queue. For some sorted collections, a remove, and a re-add is required to
+    * maintain the sorted order of the elements.
+    *
+    * @throws EvictionException
+    */
+   protected void processVisitedNodes(EvictionEvent<K> evictedEventNode) throws EvictionException
+   {
+      K key = evictedEventNode.getKey();
+      KeyEntry<K> ne = evictionQueue.getNodeEntry(key);
+      if (ne == null)
+      {
+         if (trace) log.trace("Visiting node that was not added to eviction queues. Assuming that it has 1 element.");
+         this.processAddedNodes(evictedEventNode, 1);
+         return;
+      }
+      // note this method will visit and modify the node statistics by reference!
+      // if a collection is only guaranteed sort order by adding to the collection,
+      // this implementation will not guarantee sort order.
+      ne.incerementNumberOfNodeVisits();
+      ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
+   }
+
+   protected void processRemovedElement(EvictionEvent<K> evictedEventNode) throws EvictionException
+   {
+      K key = evictedEventNode.getKey();
+      KeyEntry<K> ne = evictionQueue.getNodeEntry(key);
+
+      if (ne == null)
+      {
+         if (trace)
+            log.trace("Removing element from " + key + " but eviction queue does not contain this node. " +
+                  "Ignoring removeElement event.");
+         return;
+      }
+
+      ne.setNumberOfElements(ne.getNumberOfElements() - 1);
+      // also treat it as a node visit.
+      ne.incerementNumberOfNodeVisits();
+      ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
+   }
+
+   protected void processAddedElement(EvictionEvent<K> evictedEventNode) throws EvictionException
+   {
+      K key = evictedEventNode.getKey();
+      KeyEntry<K> ne = evictionQueue.getNodeEntry(key);
+      if (ne == null)
+      {
+         if (trace) log.trace("Adding element " + key + " for a node that doesn't exist yet. Process as an add.");
+         this.processAddedNodes(evictedEventNode, 1);
+         return;
+      }
+      ne.setNumberOfElements(ne.getNumberOfElements() + 1);
+      ne.incerementNumberOfNodeVisits();// also treat it as a node visit.
+      ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
+   }
+
+
+   /**
+    * Empty the Recycle Queue.
+    * <p/>
+    * This method will go through the recycle queue and retry to evict the nodes from cache.
+    *
+    * @throws EvictionException
+    */
+   protected void emptyRecycleQueue() throws EvictionException
+   {
+      while (true)
+      {
+         K key;
+         try
+         {
+            key = recycleQueue.poll(0, TimeUnit.SECONDS);
+         }
+         catch (InterruptedException e)
+         {
+            log.debug(e, e);
+            break;
+         }
+
+         if (key == null)
+         {
+            if (trace) log.trace("Recycle queue is empty");
+            break;
+         }
+
+         if (trace) log.trace("emptying recycle bin. Evict key " + key);
+
+         // Still doesn't work
+         if (!evictionAction.evict(key))
+         {
+            try
+            {
+               recycleQueue.put(key);
+            }
+            catch (InterruptedException e)
+            {
+               if (trace) log.trace(e, e);
+            }
+            break;
+         }
+      }
+   }
+
+   protected void prune() throws EvictionException
+   {
+      KeyEntry<K> entry;
+      while ((entry = evictionQueue.getFirstNodeEntry()) != null)
+      {
+         if (this.shouldEvictNode(entry))
+         {
+            this.evict(entry);
+         } else
+         {
+            break;
+         }
+      }
+   }
+
+   /**
+    * Returns debug information.
+    */
+   @Override
+   public String toString()
+   {
+      return super.toString() + " recycle=" + recycleQueue.size() + " evict=" + evictionQueue.getNumberOfNodes();
+   }
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/BaseSortedEvictionAlgorithm.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseSortedEvictionAlgorithm.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/BaseSortedEvictionAlgorithm.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/BaseSortedEvictionAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.eviction.EvictionEvent;
+import org.jboss.starobrno.eviction.EvictionException;
+import org.jboss.starobrno.eviction.algorithms.SortedEvictionQueue;
+
+import java.util.concurrent.BlockingQueue;
+
+
+/**
+ * An abstract SortedEvictionAlgorithm.
+ * <p/>
+ * This class supports early termination of the eviction queue processing. Because the eviction
+ * queue is sorted by first to evict to last to evict, when iterating the eviction queue, the first time
+ * a node is encountered that does not require eviction will terminate the loop early. This way we don't incur
+ * the full breadth of the O(n) = n operation everytime we need to check for eviction (defined by eviction poll time
+ * interval).
+ *
+ * @author Daniel Huang - dhuang at jboss.org - 10/2005
+ */
+public abstract class BaseSortedEvictionAlgorithm<K> extends BaseEvictionAlgorithm<K>
+{
+   private static final Log log = LogFactory.getLog(BaseSortedEvictionAlgorithm.class);
+   private static final boolean trace = log.isTraceEnabled();
+
+   @Override
+   protected void processQueues(BlockingQueue<EvictionEvent<K>> queue) throws EvictionException
+   {
+      boolean evictionNodesModified = false;
+
+      EvictionEvent<K> node;
+      int count = 0;
+      while ((node = getNextInQueue(queue)) != null)
+      {
+         count++;
+         switch (node.getEventType())
+         {
+            case ADD_NODE_EVENT:
+               this.processAddedNodes(node);
+               evictionNodesModified = true;
+               break;
+            case REMOVE_NODE_EVENT:
+               this.processRemovedNodes(node);
+               break;
+            case VISIT_NODE_EVENT:
+               this.processVisitedNodes(node);
+               evictionNodesModified = true;
+               break;
+            case ADD_ELEMENT_EVENT:
+               this.processAddedElement(node);
+               evictionNodesModified = true;
+               break;
+            case REMOVE_ELEMENT_EVENT:
+               this.processRemovedElement(node);
+               evictionNodesModified = true;
+               break;
+            default:
+               throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
+         }
+      }
+
+      if (trace) log.trace("Eviction nodes visited or added requires resort of queue " + evictionNodesModified);
+      this.resortEvictionQueue(evictionNodesModified);
+      if (trace) log.trace("processed " + count + " node events");
+   }
+
+   /**
+    * This method is called to resort the queue after add or visit events have occurred.
+    * <p/>
+    * If the parameter is true, the queue needs to be resorted. If it is false, the queue does not
+    * need resorting.
+    *
+    * @param evictionQueueModified True if the queue was added to or visisted during event processing.
+    */
+   protected void resortEvictionQueue(boolean evictionQueueModified)
+   {
+      if (!evictionQueueModified)
+      {
+         if (trace) log.debug("Eviction queue not modified. Resort unnecessary.");
+         return;
+      }
+      long begin = System.currentTimeMillis();
+      ((SortedEvictionQueue) evictionQueue).resortEvictionQueue();
+
+      if (trace)
+      {
+         long end = System.currentTimeMillis();
+         long diff = end - begin;
+         log.trace("Took " + diff + "ms to sort queue with " + getEvictionQueue().getNumberOfNodes() + " elements");
+      }
+   }
+
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/ElementSizeAlgorithm.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithm.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/ElementSizeAlgorithm.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/ElementSizeAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms;
+
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.*;
+
+/**
+ * @author Daniel Huang
+ * @version $Revision: 6776 $
+ */
+public class ElementSizeAlgorithm<K> extends BaseSortedEvictionAlgorithm<K>
+{
+   @Override
+   protected EvictionQueue<K> setupEvictionQueue() throws EvictionException
+   {
+      return new ElementSizeQueue<K>();
+   }
+
+   @Override
+   protected boolean shouldEvictNode(KeyEntry<K> ne)
+   {
+      // check the minimum time to live and see if we should not evict the node.  This check will
+      // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
+      if (ne.isYoungerThanMinimumTimeToLive(evictionAlgorithmConfig.getMinTimeToLive())) return false;
+      int size = this.getEvictionQueue().getNumberOfNodes();
+      ElementSizeAlgorithmConfig config = (ElementSizeAlgorithmConfig) evictionAlgorithmConfig;
+      return config.getMaxNodes() > -1 && size > config.getMaxNodes() || ne.getNumberOfElements() > config.getMaxElementsPerNode();
+   }
+
+   @Override
+   protected void prune() throws EvictionException
+   {
+      super.prune();
+
+      // clean up the Queue's eviction removals
+      ((ElementSizeQueue) this.evictionQueue).prune();
+   }
+
+   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+   {
+      return ElementSizeAlgorithmConfig.class;
+   }
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/ExpirationAlgorithm.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithm.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/ExpirationAlgorithm.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/ExpirationAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,364 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.*;
+import org.jboss.starobrno.eviction.EvictionEvent.Type;
+
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.BlockingQueue;
+
+/**
+ * Eviction algorithm that uses a key in the Node data that indicates the time
+ * the node should be evicted.  The key must be a java.lang.Long object, with
+ * the time to expire as milliseconds past midnight January 1st, 1970 UTC (the
+ * same relative time as provided by {@link
+ * java.lang.System#currentTimeMillis()}).
+ * <p/>
+ * This algorithm also obeys the configuration key {@link
+ * org.jboss.starobrno.eviction.ExpirationAlgorithmConfig#getMaxNodes()}, and will evict the soonest to
+ * expire entires first to reduce the region size.  If there are not enough
+ * nodes with expiration keys set, a warning is logged.
+ * <p/>
+ * If a node in the eviction region does not have an expiration value, then
+ * {@link org.jboss.starobrno.eviction.ExpirationAlgorithmConfig#getTimeToLive()} (if set) will be used.
+ * The expiration is updated when a node is added or updated.
+ * <p/>
+ * If there is no time-to-live set, and a node in the eviction region does not
+ * have an expiration value, then that node will never be evicted.  As
+ * forgetting to indicate an expiration value is likely a mistake, a warning
+ * message is logged by this class. This warning, however, can be disabled
+ * through {@link org.jboss.starobrno.eviction.ExpirationAlgorithmConfig#setWarnNoExpirationKey(boolean)}.
+ * <p/>
+ * A node's expiration time can be changed by setting a new value in the node.
+ * <p/>
+ * Example usage:
+ * <pre>
+ * Cache cache;
+ * Fqn fqn1 = Fqn.fromString("/node/1");
+ * Long future = new Long(System.currentTimeMillis() + 2000);
+ * cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future);
+ * cache.put(fqn1, "foo");
+ * assertTrue(cache.get(fqn1) != null);
+ * <p/>
+ * Thread.sleep(5000); // 5 seconds
+ * assertTrue(cache.get(fqn1) == null);
+ * <p/>
+ * </pre>
+ */
+public class ExpirationAlgorithm<K> extends BaseEvictionAlgorithm<K>
+{
+
+   private static final Log log = LogFactory.getLog(ExpirationAlgorithm.class);
+   private static final boolean trace = log.isTraceEnabled();
+
+   private ExpirationAlgorithmConfig config;
+
+   private SortedSet<ExpirationEntry<K>> set;
+
+   /**
+    * Constructs a new algorithm with a policy.
+    */
+   public ExpirationAlgorithm()
+   {
+      this.set = new TreeSet<ExpirationEntry<K>>();
+   }
+
+   private void addEvictionEntry(EvictionEvent<K> node)
+   {
+      K key = node.getKey();
+      addEvictionEntry(key);
+   }
+
+   private void addEvictionEntry(K key)
+   {
+      Long l = getExpiration();
+      if (l == null)
+      {
+         if (config.isWarnNoExpirationKey() && log.isWarnEnabled())
+            log.warn("No expiration key '" + config.getExpirationKeyName() + "' for Node: " + key);
+         else if (log.isDebugEnabled())
+            log.debug("No expiration key for Node: " + key);
+      } else
+      {
+         setExpiration(key, l);
+      }
+   }
+
+   private void setExpiration(K key, Long l)
+   {
+      ExpirationEntry<K> ee = new ExpirationEntry<K>(key, l);
+      if (trace) log.trace("adding eviction entry: " + ee);
+      set.add(ee);
+   }
+
+   private Long getExpiration()
+   {
+      return (Long) cache.getDirect(config.getExpirationKeyName());
+   }
+
+   @Override
+   protected void processQueues(BlockingQueue<EvictionEvent<K>> queue) throws EvictionException
+   {
+      EvictionEvent<K> node;
+      int count = 0;
+      while ((node = getNextInQueue(queue)) != null)
+      {
+         count++;
+         switch (node.getEventType())
+         {
+            case ADD_NODE_EVENT:
+            case ADD_ELEMENT_EVENT:
+               addEvictionEntry(node);
+               break;
+            case REMOVE_ELEMENT_EVENT:
+            case REMOVE_NODE_EVENT:
+            case UNMARK_USE_EVENT:
+               // Removals will be noticed when double-checking expiry time
+               // removeEvictionEntry(node);
+               break;
+            case VISIT_NODE_EVENT:
+               // unused
+               break;
+            case MARK_IN_USE_EVENT:
+               markInUse(node);
+               break;
+            default:
+               throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
+         }
+      }
+
+      if (trace) log.trace("processed " + count + " node events in cache: " + cache.getName());
+   }
+
+   private void markInUse(EvictionEvent<K> node)
+   {
+      long expiration = node.getInUseTimeout() + System.currentTimeMillis();
+      setExpiration(node.getKey(), expiration);
+   }
+
+   @Override
+   protected void prune() throws EvictionException
+   {
+      if (set.isEmpty())
+         return;
+      long now = System.currentTimeMillis();
+      int max = config.getMaxNodes();
+      for (Iterator<ExpirationEntry<K>> i = set.iterator(); i.hasNext();)
+      {
+         ExpirationEntry<K> ee = i.next();
+         Long ce = getExpiration();
+         if (ce == null || ce > ee.getExpiration())
+         {
+            // Expiration now older
+            i.remove();
+            continue;
+         }
+         if (ee.getExpiration() < now || (max != 0 && set.size() > max))
+         {
+            i.remove();
+            evictionAction.evict(ee.getKey());
+         } else
+         {
+            break;
+         }
+      }
+      if (max != 0 && max > set.size())
+         log.warn("Unable to remove nodes to reduce region size below " +
+               config.getMaxNodes() + ".  " +
+               "Set expiration for nodes in this region");
+   }
+
+   @Override
+   public void resetEvictionQueue()
+   {
+      for (ExpirationEntry<K> ee : set)
+      {
+         addEvictionEntry(ee.getKey());
+      }
+   }
+
+   @Override
+   @SuppressWarnings(value = "unchecked")
+   protected EvictionQueue<K> setupEvictionQueue() throws EvictionException
+   {
+      this.config = (ExpirationAlgorithmConfig) evictionAlgorithmConfig;
+      return new DummyEvictionQueue<K>();
+   }
+
+   @Override
+   protected boolean shouldEvictNode(KeyEntry<K> ne)
+   {
+      throw new UnsupportedOperationException();
+   }
+
+   @Override
+   public boolean canIgnoreEvent(Type eventType)
+   {
+      return (eventType == EvictionEvent.Type.VISIT_NODE_EVENT);
+   }
+
+   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+   {
+      return ExpirationAlgorithmConfig.class;
+   }
+
+   /**
+    * Ordered list of FQN, with the expiration taken from the Map at the time
+    * of processing.
+    */
+   static class ExpirationEntry<K> implements Comparable<ExpirationEntry>
+   {
+      private long expiration;
+
+      private K key;
+
+      public ExpirationEntry(K key)
+      {
+         this.key = key;
+      }
+
+      public ExpirationEntry(K key, long expiration)
+      {
+         this.key = key;
+         this.expiration = expiration;
+      }
+
+      /**
+       * Compares expiration, then FQN order.
+       */
+      public int compareTo(ExpirationEntry ee)
+      {
+         long n = expiration - ee.expiration;
+         if (n < 0)
+            return -1;
+         if (n > 0)
+            return 1;
+         return 0;
+      }
+
+      /**
+       * @return the expiration
+       */
+      public long getExpiration()
+      {
+         return expiration;
+      }
+
+      /**
+       * @return the fqn
+       */
+      public K getKey()
+      {
+         return key;
+      }
+
+      @Override
+      public boolean equals(Object o)
+      {
+         if (!(o instanceof ExpirationEntry))
+            return false;
+         ExpirationEntry ee = (ExpirationEntry) o;
+         return expiration == ee.expiration && key.equals(ee.key);
+      }
+
+      @Override
+      public int hashCode()
+      {
+         return (int) expiration ^ key.hashCode();
+      }
+
+      @Override
+      public String toString()
+      {
+         long now = System.currentTimeMillis();
+         long ttl = expiration - now;
+         String sttl;
+         if (ttl > 1000 * 60)
+            sttl = (ttl / (1000 * 60)) + "min";
+         else if (ttl > 1000)
+            sttl = (ttl / 1000) + "s";
+         else
+            sttl = ttl + "ms";
+         return "EE key=" + key + " ttl=" + sttl;
+      }
+   }
+
+   class DummyEvictionQueue<K> implements EvictionQueue<K>
+   {
+
+      public void addNodeEntry(KeyEntry entry)
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public void clear()
+      {
+         set.clear();
+      }
+
+      public boolean containsNodeEntry(KeyEntry entry)
+      {
+         return false;
+      }
+
+      public KeyEntry<K> getFirstNodeEntry()
+      {
+         return null;
+      }
+
+      public KeyEntry<K> getNodeEntry(K k)
+      {
+         return null;
+      }
+
+      public int getNumberOfElements()
+      {
+         return set.size();
+      }
+
+      public int getNumberOfNodes()
+      {
+         return set.size();
+      }
+
+      public Iterator<KeyEntry<K>> iterator()
+      {
+         return null;
+      }
+
+      public void modifyElementCount(int difference)
+      {
+      }
+
+      public void removeNodeEntry(KeyEntry entry)
+      {
+         throw new UnsupportedOperationException();
+      }
+   }
+
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/ExpirationAlgorithm.java
___________________________________________________________________
Name: svn:executable
   + *

Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionAlgorithm.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.NULL;
+
+import org.jboss.starobrno.CacheSPI;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.EvictionAction;
+import org.jboss.starobrno.eviction.EvictionAlgorithm;
+import org.jboss.starobrno.eviction.EvictionEvent.Type;
+import org.jboss.starobrno.eviction.EvictionException;
+import org.jboss.starobrno.eviction.EvictionQueue;
+
+import java.util.concurrent.BlockingQueue;
+
+/**
+ * An eviction algorithm that does nothing - a no-op for everything.
+ *
+ * @author Brian Stansberry
+ */
+public class NullEvictionAlgorithm implements EvictionAlgorithm
+{
+   /**
+    * Singleton instance of this class.
+    */
+   private static final NullEvictionAlgorithm INSTANCE = new NullEvictionAlgorithm();
+
+   /**
+    * Constructs a new NullEvictionAlgorithm.
+    */
+   private NullEvictionAlgorithm()
+   {
+   }
+
+   public static NullEvictionAlgorithm getInstance()
+   {
+      return INSTANCE;
+   }
+
+   /**
+    * Returns {@link NullEvictionQueue#INSTANCE}.
+    */
+   public EvictionQueue getEvictionQueue()
+   {
+      return NullEvictionQueue.INSTANCE;
+   }
+
+   public void setEvictionAction(EvictionAction evictionAction)
+   {
+      // no-op
+   }
+
+   public void assignToCache(CacheSPI cache, EvictionAlgorithmConfig evictionAlgorithmConfig)
+   {
+      // no-op
+   }
+
+   public void process(BlockingQueue queue) throws EvictionException
+   {
+      // no-op
+   }
+
+   public void resetEvictionQueue()
+   {
+      // no-op
+   }
+
+   public boolean canIgnoreEvent(Type eventType)
+   {
+      return true; // always ignore everything!
+   }
+
+   public void initialize()
+   {
+      // no-op
+   }
+
+   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+   {
+      return NullEvictionAlgorithmConfig.class;
+   }
+}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionAlgorithmConfig.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.NULL;
+
+import org.jboss.starobrno.config.ConfigurationComponent;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+
+/**
+ * Configuration class for {@link NullEvictionAlgorithm}.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class NullEvictionAlgorithmConfig extends ConfigurationComponent implements EvictionAlgorithmConfig
+{
+   private static final long serialVersionUID = -6591180473728241737L;
+
+   /**
+    * No-op
+    */
+   public void reset()
+   {
+      // no-op
+   }
+
+   public String getEvictionAlgorithmClassName()
+   {
+      return NullEvictionAlgorithm.class.getName();
+   }
+
+   /**
+    * No-op
+    */
+   public void validate() throws ConfigurationException
+   {
+      // no-op
+   }
+
+   public NullEvictionAlgorithmConfig clone() throws CloneNotSupportedException
+   {
+      return (NullEvictionAlgorithmConfig) super.clone();
+   }
+
+   public long getMinTimeToLive()
+   {
+      throw new UnsupportedOperationException("Not implemented");//todo please implement!
+   }
+}
\ No newline at end of file

Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionQueue.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/NULL/NullEvictionQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,163 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.NULL;
+
+import org.jboss.starobrno.eviction.EvictionQueue;
+import org.jboss.starobrno.eviction.KeyEntry;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * A queue that does nothing.
+ *
+ * @author Brian Stansberry
+ */
+public class NullEvictionQueue implements EvictionQueue
+{
+   /**
+    * Singleton instance of this class.
+    */
+   public static final NullEvictionQueue INSTANCE = new NullEvictionQueue();
+
+   /**
+    * Constructs a new NullEvictionQueue.
+    */
+   private NullEvictionQueue()
+   {
+   }
+
+   /**
+    * No-op
+    */
+   public void addNodeEntry(KeyEntry entry)
+   {
+      // no-op
+   }
+
+   /**
+    * No-op
+    */
+   public void clear()
+   {
+      // no-op
+   }
+
+   /**
+    * Returns <code>false</code>
+    */
+   public boolean containsNodeEntry(KeyEntry entry)
+   {
+      return false;
+   }
+
+   /**
+    * Returns <code>null</code>
+    */
+   public KeyEntry getFirstNodeEntry()
+   {
+      return null;
+   }
+
+   /**
+    * Returns <code>null</code>
+    */
+   public KeyEntry getNodeEntry(Object fqn)
+   {
+      return null;
+   }
+
+   /**
+    * Returns <code>null</code>
+    */
+   public KeyEntry getNodeEntry(String fqn)
+   {
+      return null;
+   }
+
+   /**
+    * Returns <code>0</code>
+    */
+   public int getNumberOfElements()
+   {
+      return 0;
+   }
+
+   /**
+    * Returns <code>0</code>
+    */
+   public int getNumberOfNodes()
+   {
+      return 0;
+   }
+
+   /**
+    * Returns an <code>Iterator</code> whose
+    * <code>hasNext()</code> returns <code>false</code>.
+    */
+   public Iterator iterator()
+   {
+      return NullQueueIterator.INSTANCE;
+   }
+
+
+   /**
+    * No-op
+    */
+   public void modifyElementCount(int difference)
+   {
+      // no-op
+   }
+
+   /**
+    * No-op
+    */
+   public void removeNodeEntry(KeyEntry entry)
+   {
+      // no-op
+   }
+
+   static class NullQueueIterator implements Iterator<KeyEntry>
+   {
+      private static final NullQueueIterator INSTANCE = new NullQueueIterator();
+
+      private NullQueueIterator()
+      {
+      }
+
+      public boolean hasNext()
+      {
+         return false;
+      }
+
+      public KeyEntry next()
+      {
+         throw new NoSuchElementException("No more elements");
+      }
+
+      public void remove()
+      {
+         throw new IllegalStateException("Must call next() before remove()");
+      }
+   }
+
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/SortedEvictionQueue.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/SortedEvictionQueue.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/SortedEvictionQueue.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/SortedEvictionQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms;
+
+import org.jboss.starobrno.eviction.EvictionQueue;
+
+/**
+ * Sorted Eviction Queue implementation.
+ *
+ * @author Daniel Huang (dhuang at jboss.org)
+ * @version $Revision: 6776 $
+ */
+public interface SortedEvictionQueue<K> extends EvictionQueue<K>
+{
+   /**
+    * Provide contract to resort a sorted queue.
+    */
+   void resortEvictionQueue();
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOAlgorithm.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithm.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOAlgorithm.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.fifo;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.algorithms.BaseEvictionAlgorithm;
+import org.jboss.starobrno.eviction.EvictionQueue;
+import org.jboss.starobrno.eviction.EvictionException;
+import org.jboss.starobrno.eviction.KeyEntry;
+
+/**
+ * First-in-first-out algorithm used to evict nodes.
+ *
+ * @author Daniel Huang - dhuang at jboss.org
+ * @author Morten Kvistgaard
+ * @version $Revision: 6776 $
+ */
+public class FIFOAlgorithm<K> extends BaseEvictionAlgorithm<K>
+{
+   private static final Log log = LogFactory.getLog(FIFOAlgorithm.class);
+   private static final boolean trace = log.isTraceEnabled();
+   
+   @Override
+   protected EvictionQueue<K> setupEvictionQueue() throws EvictionException
+   {
+      return new FIFOQueue<K>();
+   }
+
+   /**
+    * For FIFO, a node should be evicted if the queue size is >= to the configured maxNodes size.
+    */
+   @Override
+   protected boolean shouldEvictNode(KeyEntry ne)
+   {
+      // check the minimum time to live and see if we should not evict the node.  This check will
+      // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
+      if (ne.isYoungerThanMinimumTimeToLive(evictionAlgorithmConfig.getMinTimeToLive())) return false;
+
+      FIFOAlgorithmConfig config = (FIFOAlgorithmConfig) evictionAlgorithmConfig;
+      if (trace) log.trace("Deciding whether node in queue " + ne.getKey() + " requires eviction.");
+
+      int size = this.getEvictionQueue().getNumberOfNodes();
+      return config.getMaxNodes() != 0 && size > config.getMaxNodes();
+   }
+
+   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+   {
+      return FIFOAlgorithmConfig.class;
+   }
+}
+


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOAlgorithm.java
___________________________________________________________________
Name: svn:executable
   + *

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOAlgorithmConfig.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithmConfig.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOAlgorithmConfig.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.fifo;
+
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase;
+
+/**
+ * Configuration for {@link FIFOAlgorithm}.
+ * <p/>
+ * Requires a "maxNodes" attribute otherwise a ConfigurationException is thrown.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class FIFOAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+   /**
+    * The serialVersionUID
+    */
+   private static final long serialVersionUID = -7229715009546277313L;
+
+   public FIFOAlgorithmConfig()
+   {
+      evictionAlgorithmClassName = FIFOAlgorithm.class.getName();
+      // We require that maxNodes is set
+      setMaxNodes(-1);
+   }
+
+   public FIFOAlgorithmConfig(int maxNodes)
+   {
+      evictionAlgorithmClassName = FIFOAlgorithm.class.getName();
+      // We require that maxNodes is set
+      setMaxNodes(maxNodes);
+   }
+
+   /**
+    * Requires a positive maxNodes value or ConfigurationException
+    * is thrown.
+    */
+   @Override
+   public void validate() throws ConfigurationException
+   {
+      super.validate();
+      if (getMaxNodes() < 0)
+      {
+         throw new ConfigurationException("maxNodes must be must be " +
+               "configured to a value greater than or equal to 0");
+      }
+   }
+
+   @Override
+   public String toString()
+   {
+      StringBuilder ret = new StringBuilder();
+      ret.append("FIFOAlgorithmConfig: maxNodes = ").append(getMaxNodes());
+      return ret.toString();
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      return (obj instanceof FIFOAlgorithmConfig && super.equals(obj));
+   }
+
+   @Override
+   public void reset()
+   {
+      super.reset();
+      setMaxNodes(-1);
+      evictionAlgorithmClassName = FIFOAlgorithm.class.getName();
+   }
+
+   @Override
+   public FIFOAlgorithmConfig clone() throws CloneNotSupportedException
+   {
+      return (FIFOAlgorithmConfig) super.clone();
+   }
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOQueue.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOQueue.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOQueue.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/fifo/FIFOQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.fifo;
+
+import org.jboss.starobrno.eviction.EvictionQueue;
+import org.jboss.starobrno.eviction.KeyEntry;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * FIFO Eviction Queue implementation for FIFO Policy.
+ *
+ * @author Daniel Huang (dhuang at jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class FIFOQueue<K> implements EvictionQueue<K>
+{
+   private Map<K, KeyEntry<K>> keyMap;
+   private int numElements = 0;
+
+   protected FIFOQueue()
+   {
+      keyMap = new LinkedHashMap<K, KeyEntry<K>>();
+      // We use a LinkedHashMap here because we want to maintain FIFO ordering and still get the benefits of
+      // O(n) = 1 for add/remove/search.
+   }
+
+   public KeyEntry<K> getFirstNodeEntry()
+   {
+      if (keyMap.size() > 0)
+      {
+         return keyMap.values().iterator().next();
+      }
+      return null;
+   }
+
+   public KeyEntry<K> getNodeEntry(K key)
+   {
+      return keyMap.get(key);
+   }
+
+   public boolean containsNodeEntry(KeyEntry<K> entry)
+   {
+      K key = entry.getKey();
+      return this.getNodeEntry(key) != null;
+   }
+
+   public void removeNodeEntry(KeyEntry<K> entry)
+   {
+      KeyEntry<K> e = keyMap.remove(entry.getKey());
+      this.numElements -= e.getNumberOfElements();
+   }
+
+   public void addNodeEntry(KeyEntry<K> entry)
+   {
+      if (!this.containsNodeEntry(entry))
+      {
+         keyMap.put(entry.getKey(), entry);
+         this.numElements += entry.getNumberOfElements();
+      }
+   }
+
+   public int getNumberOfNodes()
+   {
+      return keyMap.size();
+   }
+
+   public int getNumberOfElements()
+   {
+      return this.numElements;
+   }
+
+   public void modifyElementCount(int difference)
+   {
+      this.numElements += difference;
+   }
+
+   public void clear()
+   {
+      keyMap.clear();
+      this.numElements = 0;
+   }
+
+   public Iterator<KeyEntry<K>> iterator()
+   {
+      return keyMap.values().iterator();
+   }
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUAlgorithm.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithm.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUAlgorithm.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.lfu;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.algorithms.BaseSortedEvictionAlgorithm;
+import org.jboss.starobrno.eviction.EvictionQueue;
+import org.jboss.starobrno.eviction.KeyEntry;
+import org.jboss.starobrno.eviction.EvictionException;
+
+/**
+ * Least Frequently Used algorithm for cache eviction.
+ * Note that this algorithm is not thread-safe.
+ * <p/>
+ * This algorithm relies on maxNodes and minNodes to operate correctly.
+ * Eviction takes place using Least Frequently Used algorithm. A node A
+ * that is used less than a node B is evicted sooner.
+ * <p/>
+ * The minNodes property defines a threshold for eviction. If minNodes = 100,
+ * the LFUAlgorithm will not evict the cache to anything less than 100 elements
+ * still left in cache. The maxNodes property defines the maximum number of nodes
+ * the cache will accept before eviction. maxNodes = 0 means that this region is
+ * unbounded. minNodes = 0 means that the eviction queue will attempt to bring
+ * the cache of this region to 0 elements (evict all elements) whenever it is run.
+ * <p/>
+ * This algorithm uses a sorted eviction queue. The eviction queue is sorted in
+ * ascending order based on the number of times a node is visited. The more frequently
+ * a node is visited, the less likely it will be evicted.
+ *
+ * @author Daniel Huang - dhuang at jboss.org 10/2005
+ * @version $Revision: 6776 $
+ */
+public class LFUAlgorithm extends BaseSortedEvictionAlgorithm
+{
+   private static final Log log = LogFactory.getLog(LFUAlgorithm.class);
+   private static final boolean trace = log.isTraceEnabled();
+
+   @Override
+   protected boolean shouldEvictNode( KeyEntry ne)
+   {
+      if (trace)
+      {
+         log.trace("Deciding whether node in queue " + ne.getKey() + " requires eviction.");
+      }
+
+      // check the minimum time to live and see if we should not evict the node.  This check will
+      // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
+      if (ne.isYoungerThanMinimumTimeToLive(evictionAlgorithmConfig.getMinTimeToLive())) return false;
+
+      LFUAlgorithmConfig config = (LFUAlgorithmConfig) evictionAlgorithmConfig;
+      int size = this.getEvictionQueue().getNumberOfNodes();
+      if (config.getMaxNodes() > -1 && size > config.getMaxNodes())
+      {
+         return true;
+      }
+      else if (size > config.getMinNodes())
+      {
+         return true;
+      }
+
+      return false;
+   }
+
+   /**
+    * Will create a LFUQueue to be used as the underlying eviction queue.
+    *
+    * @return The created LFUQueue.
+    * @throws org.jboss.starobrno.eviction.EvictionException
+    *
+    */
+   @Override
+   protected EvictionQueue setupEvictionQueue() throws EvictionException
+   {
+      return new LFUQueue();
+   }
+
+   @Override
+   protected void prune() throws  EvictionException
+   {
+      super.prune();
+
+      // clean up the Queue's eviction removals
+      ((LFUQueue) this.evictionQueue).prune();
+   }
+
+   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+   {
+      return LFUAlgorithmConfig.class;
+   }
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUAlgorithmConfig.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithmConfig.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUAlgorithmConfig.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.lfu;
+
+import org.jboss.starobrno.config.Dynamic;
+import org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase;
+
+/**
+ * Configuration implementation for {@link LFUAlgorithm}.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class LFUAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+   /**
+    * The serialVersionUID
+    */
+   private static final long serialVersionUID = 1865801530398969179L;
+
+   @Dynamic
+   private int minNodes;
+
+   public LFUAlgorithmConfig()
+   {
+      evictionAlgorithmClassName = LFUAlgorithm.class.getName();
+   }
+
+   public LFUAlgorithmConfig(int maxNodes, int minNodes)
+   {
+      this();
+      setMaxNodes(maxNodes);
+      setMinNodes(minNodes);
+   }
+
+   public int getMinNodes()
+   {
+      return minNodes;
+   }
+
+   public void setMinNodes(int minNodes)
+   {
+      testImmutability("minNodes");
+      this.minNodes = minNodes;
+   }
+
+   @Override
+   public String toString()
+   {
+      StringBuilder ret = new StringBuilder();
+      ret.append("LFUAlgorithmConfig: maxNodes = ").append(getMaxNodes()).append(" minNodes = ").append(getMinNodes());
+      return ret.toString();
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj instanceof LFUAlgorithmConfig && super.equals(obj))
+      {
+         return (this.minNodes == ((LFUAlgorithmConfig) obj).minNodes);
+      }
+      return false;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = super.hashCode();
+      result = 31 * result + minNodes;
+      return result;
+   }
+
+   @Override
+   public LFUAlgorithmConfig clone() throws CloneNotSupportedException
+   {
+      return (LFUAlgorithmConfig) super.clone();
+   }
+
+   @Override
+   public void reset()
+   {
+      super.reset();
+      minNodes = -1;
+      evictionAlgorithmClassName = LFUAlgorithm.class.getName();
+   }
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUQueue.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUQueue.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUQueue.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lfu/LFUQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,215 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.lfu;
+
+import org.jboss.starobrno.eviction.KeyEntry;
+import org.jboss.starobrno.eviction.algorithms.SortedEvictionQueue;
+
+import java.util.*;
+
+/**
+ * LFUQueue EvictionQueue implementation for LFU Policy.
+ * <p/>
+ * The queue is sorted in least frequently used order.
+ *
+ * @author Daniel Huang (dhuang at jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class LFUQueue<K> implements SortedEvictionQueue<K>
+{
+   private Map<K, KeyEntry<K>> keyMap;
+   private LinkedList<KeyEntry<K>> evictionList;
+   private Set<KeyEntry<K>> removalQueue;
+   private Comparator<KeyEntry<K>> comparator;
+   
+   private int numElements = 0;
+
+   protected LFUQueue()
+   {
+      keyMap = new HashMap<K, KeyEntry<K>>();
+      comparator = new LFUComparator<K>();
+      evictionList = new LinkedList<KeyEntry<K>>();
+      removalQueue = new HashSet<KeyEntry<K>>();
+   }
+
+   /**
+    * Return the first node to evict.
+    * <p/>
+    * This method will return the least frequently used entry in the queue.
+    */
+   public KeyEntry<K> getFirstNodeEntry()
+   {
+      try
+      {
+         KeyEntry<K> ne;
+         while ((ne = evictionList.getFirst()) != null)
+         {
+            if (removalQueue.contains(ne))
+            {
+               evictionList.removeFirst();
+               removalQueue.remove(ne);
+            } else
+            {
+               break;
+            }
+         }
+         return ne;
+      }
+      catch (NoSuchElementException e)
+      {
+         //
+      }
+      return null;
+   }
+
+   public KeyEntry<K> getNodeEntry(K key)
+   {
+      return keyMap.get(key);
+   }
+
+   public boolean containsNodeEntry(KeyEntry<K> entry)
+   {
+      K key = entry.getKey();
+      return this.getNodeEntry(key) != null;
+   }
+
+   public void removeNodeEntry(KeyEntry<K> entry)
+   {
+      KeyEntry<K> ne = keyMap.remove(entry.getKey());
+      if (ne != null)
+      {
+         // don't remove directly from the LinkedList otherwise we will incur a O(n) = n
+         // performance penalty for every removal! In the prune method for LFU, we will iterate the LinkedList through ONCE
+         // doing a single O(n) = n operation and removal. This is much preferred over running O(n) = n every single time
+         // remove is called. There is also special logic in the getFirstNodeEntry that will know to check
+         // the removalQueue before returning.
+         this.removalQueue.add(ne);
+         this.numElements -= ne.getNumberOfElements();
+      }
+   }
+
+   public void addNodeEntry(KeyEntry<K> entry)
+   {
+      if (!this.containsNodeEntry(entry))
+      {
+         K key = entry.getKey();
+         keyMap.put(key, entry);
+         evictionList.add(entry);
+         this.numElements += entry.getNumberOfElements();
+      }
+   }
+
+   public int getNumberOfNodes()
+   {
+      return keyMap.size();
+   }
+
+   public int getNumberOfElements()
+   {
+      return this.numElements;
+   }
+
+   public void clear()
+   {
+      keyMap.clear();
+      evictionList.clear();
+      removalQueue.clear();
+      this.numElements = 0;
+   }
+
+   public void resortEvictionQueue()
+   {
+      Collections.sort(evictionList, comparator);
+   }
+
+   public void modifyElementCount(int difference)
+   {
+      this.numElements += difference;
+   }
+
+   protected void prune()
+   {
+      Iterator<KeyEntry<K>> it = this.iterator();
+      while (it.hasNext() && removalQueue.size() > 0)
+      {
+         if (removalQueue.remove(it.next()))
+         {
+            it.remove();
+         }
+      }
+   }
+
+   protected final List<KeyEntry<K>> getEvictionList()
+   {
+      return this.evictionList;
+   }
+
+   protected final Set<KeyEntry<K>> getRemovalQueue()
+   {
+      return this.removalQueue;
+   }
+
+   public Iterator<KeyEntry<K>> iterator()
+   {
+      return evictionList.iterator();
+   }
+
+   /**
+    * Comparator class for LFU.
+    * <p/>
+    * This class will sort the eviction queue in the correct eviction order.
+    * The top of the list should evict before the bottom of the list.
+    * <p/>
+    * The sort is based on ascending order of nodeVisits.
+    * <p/>
+    * Note: this class has a natural ordering that is inconsistent with equals as defined by the java.lang.Comparator
+    * contract.
+    */
+   protected static class LFUComparator<K> implements Comparator<KeyEntry<K>>
+   {
+
+      public int compare(KeyEntry<K> ne1, KeyEntry<K> ne2)
+      {
+         if (ne1.equals(ne2))
+         {
+            return 0;
+         }
+
+         int neNodeHits = ne1.getNumberOfNodeVisits();
+         int ne2NodeHits = ne2.getNumberOfNodeVisits();
+
+         if (neNodeHits > ne2NodeHits)
+         {
+            return 1;
+         } else if (neNodeHits < ne2NodeHits)
+         {
+            return -1;
+         } else if (neNodeHits == ne2NodeHits)
+         {
+            return 0;
+         }
+         throw new RuntimeException("Should never reach this condition");
+      }
+   }
+
+}
+

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUAlgorithm.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithm.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUAlgorithm.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.lru;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.algorithms.BaseEvictionAlgorithm;
+import org.jboss.starobrno.eviction.KeyEntry;
+import org.jboss.starobrno.eviction.EvictionQueue;
+import org.jboss.starobrno.eviction.EvictionException;
+
+import java.util.Iterator;
+
+/**
+ * Least recently Used algorithm to purge old data.
+ * Note that this algorithm is not thread-safe.
+ *
+ * @author Ben Wang 02-2004
+ * @author Daniel Huang - dhuang at jboss.org
+ */
+public class LRUAlgorithm<K> extends BaseEvictionAlgorithm<K>
+{
+   private static final Log log = LogFactory.getLog(LRUAlgorithm.class);
+   private static final boolean trace = log.isTraceEnabled();
+
+   @Override
+   protected EvictionQueue<K> setupEvictionQueue() throws EvictionException
+   {
+      return new LRUQueue<K>();
+   }
+
+   @Override
+   protected boolean shouldEvictNode(KeyEntry<K> entry)
+   {
+      // check the minimum time to live and see if we should not evict the node.  This check will
+      // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
+      if (entry.isYoungerThanMinimumTimeToLive(evictionAlgorithmConfig.getMinTimeToLive())) return false;
+
+      LRUAlgorithmConfig config = (LRUAlgorithmConfig) evictionAlgorithmConfig;
+      // no idle or max time limit
+      if (config.getTimeToLive() < 0 && config.getMaxAge() < 0) return false;
+
+      long currentTime = System.currentTimeMillis();
+      if (config.getTimeToLive() > -1)
+      {
+         long idleTime = currentTime - entry.getModifiedTimeStamp();
+         if (trace)
+         {
+            log.trace("Node " + entry.getKey() + " has been idle for " + idleTime + "ms");
+         }
+         if ((idleTime >= (config.getTimeToLive())))
+         {
+            if (trace)
+            {
+               log.trace("Node " + entry.getKey() + " should be evicted because of idle time");
+               log.trace("Time to live in millies is: " + (config.getTimeToLive()));
+               log.trace("Config instance is: " + System.identityHashCode(config));
+            }
+            return true;
+         }
+      }
+
+      if (config.getMaxAge() > -1)
+      {
+         long objectLifeTime = currentTime - entry.getCreationTimeStamp();
+         if (trace)
+         {
+            log.trace("Node " + entry.getKey() + " has been alive for " + objectLifeTime + "ms");
+         }
+         if ((objectLifeTime >= config.getMaxAge()))
+         {
+            if (trace)
+            {
+               log.trace("Node " + entry.getKey() + " should be evicted because of max age");
+            }
+            return true;
+         }
+      }
+
+      if (trace)
+      {
+         log.trace("Node " + entry.getKey() + " should not be evicted");
+      }
+      return false;
+   }
+
+   @Override
+   protected void evict(KeyEntry<K> ne)
+   {
+      if (ne != null)
+      {
+         if (!evictionAction.evict(ne.getKey()))
+         {
+            try
+            {
+               recycleQueue.put(ne.getKey());
+            }
+            catch (InterruptedException e)
+            {
+               log.debug("InterruptedException", e);
+            }
+         }
+      }
+   }
+
+   @Override
+   protected void prune() throws EvictionException
+   {
+      LRUQueue<K> lruQueue = (LRUQueue<K>) evictionQueue;
+      KeyEntry<K> ne;
+      Iterator<KeyEntry<K>> it = lruQueue.iterateLRUQueue();
+      while (it.hasNext())
+      {
+         ne = it.next();
+         if (ne.isNodeInUseAndNotTimedOut()) continue;
+         if (this.shouldEvictNode(ne))
+         {
+            it.remove();
+            lruQueue.removeNodeEntryFromMaxAge(ne);
+            this.evict(ne);
+         } else
+         {
+            break;
+         }
+      }
+
+      it = lruQueue.iterateMaxAgeQueue();
+      while (it.hasNext())
+      {
+         ne = it.next();
+         if (ne.isNodeInUseAndNotTimedOut()) continue;
+         if (this.shouldEvictNode(ne))
+         {
+            it.remove();
+            lruQueue.removeNodeEntryFromLRU(ne);
+            this.evict(ne);
+         } else
+         {
+            break;
+         }
+      }
+
+      int maxNodes = ((LRUAlgorithmConfig) evictionAlgorithmConfig).getMaxNodes();
+      if (maxNodes <= 0)
+      {
+         return;
+      }
+
+      it = lruQueue.iterateLRUQueue();
+      while (evictionQueue.getNumberOfNodes() > maxNodes)
+      {
+         ne = it.next();
+         if (trace)
+         {
+            log.trace("Node " + ne.getKey() + " will be evicted because of exceeding the maxNode limit." +
+                  " maxNode: " + maxNodes + " but current queue size is: " + evictionQueue.getNumberOfNodes());
+         }
+
+         if (!ne.isNodeInUseAndNotTimedOut())
+         {
+            it.remove();
+            lruQueue.removeNodeEntryFromMaxAge(ne);
+            this.evict(ne);
+         }
+      }
+   }
+
+   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+   {
+      return LRUAlgorithmConfig.class;
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUAlgorithm.java
___________________________________________________________________
Name: svn:executable
   + *

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUAlgorithmConfig.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithmConfig.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUAlgorithmConfig.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,195 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.lru;
+
+import org.jboss.cache.annotations.Compat;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.Dynamic;
+import org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Configuration implementation for {@link LRUAlgorithm}.
+ * <p/>
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class LRUAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+   /**
+    * The serialVersionUID
+    */
+   private static final long serialVersionUID = -3426716488271559729L;
+
+   /**
+    * value expressed in millis
+    */
+   @Dynamic
+   private long timeToLive;
+
+   /**
+    * value expressed in millis
+    */
+   @Dynamic
+   private long maxAge;
+
+   public LRUAlgorithmConfig()
+   {
+      evictionAlgorithmClassName = LRUAlgorithm.class.getName();
+      // Force config of ttls
+      setTimeToLive(-1);
+      setMaxAge(-1);
+   }
+
+   public LRUAlgorithmConfig(long timeToLive, long maxAge)
+   {
+      this();
+      this.timeToLive = timeToLive;
+      this.maxAge = maxAge;
+   }
+
+   public LRUAlgorithmConfig(long timeToLive, int maxAge, int maxNodes)
+   {
+      this(timeToLive, maxAge);
+      this.maxNodes = maxNodes;
+   }
+
+   /**
+    * @return the time to live, in milliseconds
+    */
+   public long getTimeToLive()
+   {
+      return timeToLive;
+   }
+
+   /**
+    * Sets the time to live
+    *
+    * @param timeToLive the time to live, in milliseconds
+    */
+   public void setTimeToLive(long timeToLive)
+   {
+      testImmutability("timeToLive");
+      this.timeToLive = timeToLive;
+   }
+
+   public void setTimeToLive(long timeToLive, TimeUnit timeUnit)
+   {
+      testImmutability("timeToLive");
+      this.timeToLive = timeUnit.toMillis(timeToLive);
+   }
+
+   @Deprecated
+   @Compat
+   public void setTimeToLiveSeconds(long time)
+   {
+      setTimeToLive(time, TimeUnit.SECONDS);
+   }
+
+   /**
+    * @return the max age per element, in milliseconds
+    */
+   public long getMaxAge()
+   {
+      return maxAge;
+   }
+
+   /**
+    * Sets the max age per element
+    *
+    * @param maxAge value in milliseconds
+    */
+   public void setMaxAge(long maxAge)
+   {
+      testImmutability("maxAge");
+      this.maxAge = maxAge;
+   }
+
+   public void setMaxAge(long maxAge, TimeUnit timeUnit)
+   {
+      testImmutability("maxAge");
+      this.maxAge = timeUnit.toMillis(maxAge);
+   }
+
+   /**
+    * Requires a positive timeToLive value or ConfigurationException
+    * is thrown.
+    */
+   @Override
+   public void validate() throws ConfigurationException
+   {
+      super.validate();
+      if (timeToLive < -1)
+      {
+         throw new ConfigurationException("timeToLive must be " +
+               "configured to a value greater than or equal to 0 (or -1 for unlimited time to live) for " + getEvictionAlgorithmClassName());
+      }
+   }
+
+   public String toString()
+   {
+      return "LRUAlgorithmConfig {" +
+            "algorithmClassName=" + evictionAlgorithmClassName +
+            ", timeToLive=" + timeToLive +
+            ", maxAge=" + maxAge +
+            '}';
+   }
+
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (!(o instanceof LRUAlgorithmConfig)) return false;
+      if (!super.equals(o)) return false;
+
+      LRUAlgorithmConfig that = (LRUAlgorithmConfig) o;
+
+      if (maxAge != that.maxAge) return false;
+      if (timeToLive != that.timeToLive) return false;
+
+      return true;
+   }
+
+   public int hashCode()
+   {
+      int result = super.hashCode();
+      result = 31 * result + (int) (timeToLive ^ (timeToLive >>> 32));
+      result = 31 * result + (int) (maxAge ^ (maxAge >>> 32));
+      return result;
+   }
+
+   @Override
+   public void reset()
+   {
+      super.reset();
+      setTimeToLive(-1);
+      setMaxAge(-1);
+      evictionAlgorithmClassName = LRUAlgorithm.class.getName();
+   }
+
+   @Override
+   public LRUAlgorithmConfig clone() throws CloneNotSupportedException
+   {
+      return (LRUAlgorithmConfig) super.clone();
+   }
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUQueue.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUQueue.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUQueue.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/lru/LRUQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,185 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.lru;
+
+import org.jboss.starobrno.eviction.EvictionQueue;
+import org.jboss.starobrno.eviction.KeyEntry;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * LRU Eviction Queue implementation.
+ * <p/>
+ * This eviction queue will iterate properly through two sorted lists.
+ * One sorted by maxAge and the other sorted by idleTime.
+ *
+ * @author Daniel Huang (dhuang at jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class LRUQueue<K> implements EvictionQueue<K>
+{
+   private Map<K, KeyEntry<K>> maxAgeQueue;
+   private Map<K, KeyEntry<K>> lruQueue;
+   private long alternatingCount = 0;
+   private int numElements = 0;
+
+   protected LRUQueue()
+   {
+      maxAgeQueue = new LinkedHashMap<K, KeyEntry<K>>();
+      lruQueue = new LinkedHashMap<K, KeyEntry<K>>(16, 0.75f, true);
+   }
+
+   /**
+    * because the underlying queue is in two differently sorted queues, we alternate between them when calling
+    * a generic getFirstNodeEntry.
+    * we must alternate to keep things balanced when evicting nodes based on the maxNodes attribute. We don't
+    * want to just prune from one queue but rather we want to be able to prune from both.
+    */
+   public KeyEntry<K> getFirstNodeEntry()
+   {
+      KeyEntry<K> ne;
+      if (alternatingCount % 2 == 0)
+      {
+         ne = this.getFirstLRUNodeEntry();
+         if (ne == null)
+         {
+            ne = this.getFirstMaxAgeNodeEntry();
+         }
+      } else
+      {
+         ne = this.getFirstMaxAgeNodeEntry();
+         if (ne == null)
+         {
+            ne = this.getFirstLRUNodeEntry();
+         }
+      }
+      alternatingCount++;
+      return ne;
+   }
+
+   public KeyEntry<K> getFirstLRUNodeEntry()
+   {
+      if (lruQueue.size() > 0)
+      {
+         return lruQueue.values().iterator().next();
+      }
+      return null;
+   }
+
+   public KeyEntry<K> getFirstMaxAgeNodeEntry()
+   {
+      if (maxAgeQueue.size() > 0)
+      {
+         return maxAgeQueue.values().iterator().next();
+      }
+      return null;
+   }
+
+   public KeyEntry<K> getNodeEntry(K key)
+   {
+      return lruQueue.get(key);
+   }
+
+   public boolean containsNodeEntry(KeyEntry<K> entry)
+   {
+      return this.maxAgeQueue.containsKey(entry.getKey());
+   }
+
+   protected void removeNodeEntryFromLRU(KeyEntry<K> entry)
+   {
+      K key = entry.getKey();
+      lruQueue.remove(key);
+   }
+
+   protected void removeNodeEntryFromMaxAge(KeyEntry<K> entry)
+   {
+      K key = entry.getKey();
+      maxAgeQueue.remove(key);
+   }
+
+   public void removeNodeEntry(KeyEntry<K> entry)
+   {
+      if (!this.containsNodeEntry(entry))
+      {
+         return;
+      }
+      K key = entry.getKey();
+      KeyEntry ne1 = lruQueue.remove(key);
+      KeyEntry ne2 = maxAgeQueue.remove(key);
+      if (ne1 == null || ne2 == null)
+      {
+         throw new RuntimeException("The queues are out of sync.");
+      }
+      this.numElements -= ne1.getNumberOfElements();
+   }
+
+   public void addNodeEntry(KeyEntry<K> entry)
+   {
+      if (!this.containsNodeEntry(entry))
+      {
+         K key = entry.getKey();
+         maxAgeQueue.put(key, entry);
+         lruQueue.put(key, entry);
+         this.numElements += entry.getNumberOfElements();
+      }
+   }
+
+   public int getNumberOfNodes()
+   {
+      return maxAgeQueue.size();
+   }
+
+   public int getNumberOfElements()
+   {
+      return this.numElements;
+   }
+
+   public void clear()
+   {
+      maxAgeQueue.clear();
+      lruQueue.clear();
+      this.numElements = 0;
+   }
+
+   public void modifyElementCount(int difference)
+   {
+      this.numElements += difference;
+   }
+
+   public Iterator<KeyEntry<K>> iterator()
+   {
+      return lruQueue.values().iterator();
+   }
+
+   protected final Iterator<KeyEntry<K>> iterateMaxAgeQueue()
+   {
+      return maxAgeQueue.values().iterator();
+   }
+
+   protected final Iterator<KeyEntry<K>> iterateLRUQueue()
+   {
+      return lruQueue.values().iterator();
+   }
+
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/EvictionListEntry.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionListEntry.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/EvictionListEntry.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/EvictionListEntry.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.mru;
+
+import org.jboss.starobrno.eviction.KeyEntry;
+
+/**
+ * // TODO: MANIK: Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
+ * @since 3.0
+ */
+public class EvictionListEntry<K>
+{
+   EvictionListEntry<K> next;
+   KeyEntry<K> keyEntry;
+   EvictionListEntry<K> previous;
+
+   EvictionListEntry()
+   {
+   }
+
+   EvictionListEntry(KeyEntry<K> keyEntry)
+   {
+      this.keyEntry = keyEntry;
+   }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (!(o instanceof EvictionListEntry))
+         return false;
+      EvictionListEntry entry = (EvictionListEntry) o;
+      return this.keyEntry.getKey().equals(entry.keyEntry.getKey());
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return this.keyEntry.getKey().hashCode();
+   }
+
+   @Override
+   public String toString()
+   {
+      return "EvictionListEntry=" + keyEntry;
+   }
+
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/EvictionQueueList.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueueList.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/EvictionQueueList.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/EvictionQueueList.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,348 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.mru;
+
+import org.jboss.starobrno.eviction.KeyEntry;
+
+import java.util.*;
+
+/**
+ * @author Daniel Huang (dhuang at jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class EvictionQueueList<K>
+{
+   private EvictionListEntry<K> head;
+   private EvictionListEntry<K> tail;
+   private int modCount;
+   private int size;
+
+   EvictionQueueList()
+   {
+      head = null;
+      tail = null;
+      size = 0;
+      modCount = 0;
+   }
+
+   void addToTop(EvictionListEntry<K> entry)
+   {
+      EvictionListEntry<K> formerHead = head;
+      head = entry;
+      // if there was no previous head then this list was empty.
+      if (formerHead != null)
+      {
+         formerHead.previous = head;
+         head.next = formerHead;
+         head.previous = null;
+      }
+      else
+      {
+         tail = entry;
+      }
+      size++;
+      modCount++;
+   }
+
+   void addToBottom(EvictionListEntry<K> entry)
+   {
+      EvictionListEntry<K> formerTail = tail;
+      tail = entry;
+      // if there was no previous head then this list was empty.
+      if (formerTail != null)
+      {
+         tail.previous = formerTail;
+         formerTail.next = tail;
+         tail.next = null;
+      }
+      else
+      {
+         head = entry;
+      }
+      size++;
+      modCount++;
+   }
+
+   void remove(EvictionListEntry<K> entry)
+   {
+      if (this.isEmpty())
+      {
+         return;
+      }
+
+      if (isSingleNode(entry))
+      {
+         head = null;
+         tail = null;
+      }
+      else if (isTail(entry))
+      {
+         tail = entry.previous;
+         // unlink the last node.
+         entry.previous.next = null;
+      }
+      else if (isHead(entry))
+      {
+         head = entry.next;
+         head.previous = null;
+      }
+      else
+      {
+         // node is in between two other nodes.
+         entry.next.previous = entry.previous;
+         entry.previous.next = entry.next;
+      }
+      size--;
+      modCount++;
+   }
+
+   int size()
+   {
+      return this.size;
+   }
+
+   void clear()
+   {
+      head = null;
+      tail = null;
+      size = 0;
+      modCount++;
+   }
+
+   EvictionListEntry<K> getFirst()
+   {
+      if (head == null)
+      {
+         throw new NoSuchElementException("List is empty");
+      }
+      return head;
+   }
+
+   EvictionListEntry getLast()
+   {
+      if (tail == null)
+      {
+         throw new NoSuchElementException("List is empty");
+      }
+      return tail;
+   }
+
+   @SuppressWarnings(value = "unchecked")
+   Iterator<KeyEntry<K>> iterator()
+   {
+      return new EvictionListIterator();
+   }
+
+   KeyEntry[] toNodeEntryArray()
+   {
+      if (isEmpty())
+      {
+         return null;
+      }
+      KeyEntry[] ret = new KeyEntry[size];
+      int i = 0;
+      EvictionListEntry temp = head;
+
+      do
+      {
+         ret[i] = temp.keyEntry;
+         temp = temp.next;
+         i++;
+      }
+      while (temp != null);
+
+      return ret;
+   }
+
+   EvictionListEntry[] toArray()
+   {
+      if (isEmpty())
+      {
+         return null;
+      }
+      EvictionListEntry[] ret = new EvictionListEntry[size];
+      int i = 0;
+      EvictionListEntry temp = head;
+
+      do
+      {
+         ret[i] = temp;
+         temp = temp.next;
+         i++;
+      }
+      while (temp != null);
+
+      return ret;
+   }
+
+   void fromArray(EvictionListEntry<K>[] evictionListEntries)
+   {
+
+      for (EvictionListEntry<K> evictionListEntry : evictionListEntries)
+      {
+         this.addToBottom(evictionListEntry);
+      }
+   }
+
+   private boolean isEmpty()
+   {
+      return head == null && tail == null;
+   }
+
+   private boolean isSingleNode(EvictionListEntry entry)
+   {
+      return isTail(entry) && isHead(entry);
+   }
+
+   private boolean isTail(EvictionListEntry entry)
+   {
+      return entry.next == null;
+   }
+
+   private boolean isHead(EvictionListEntry entry)
+   {
+      return entry.previous == null;
+   }
+
+   @Override
+   public String toString()
+   {
+      return Arrays.asList(toArray()).toString();
+   }
+
+   static class EvictionListComparator implements Comparator<EvictionListEntry>
+   {
+      Comparator<KeyEntry> nodeEntryComparator;
+
+      EvictionListComparator(Comparator<KeyEntry> nodeEntryComparator)
+      {
+         this.nodeEntryComparator = nodeEntryComparator;
+      }
+
+      public int compare(EvictionListEntry e1, EvictionListEntry e2)
+      {
+         return nodeEntryComparator.compare(e1.keyEntry, e2.keyEntry);
+      }
+   }
+
+   class EvictionListIterator implements ListIterator
+   {
+      EvictionListEntry<K> next = head;
+      EvictionListEntry<K> previous;
+      EvictionListEntry<K> cursor;
+
+      int initialModCount = EvictionQueueList.this.modCount;
+
+      public boolean hasNext()
+      {
+         this.doConcurrentModCheck();
+         return next != null;
+      }
+
+      public KeyEntry<K> next()
+      {
+         this.doConcurrentModCheck();
+         this.forwardCursor();
+         return cursor.keyEntry;
+      }
+
+      public boolean hasPrevious()
+      {
+         this.doConcurrentModCheck();
+         return previous != null;
+      }
+
+      public KeyEntry<K> previous()
+      {
+         this.doConcurrentModCheck();
+         this.rewindCursor();
+         return cursor.keyEntry;
+      }
+
+      public int nextIndex()
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public int previousIndex()
+      {
+         throw new UnsupportedOperationException();
+      }
+
+      public void remove()
+      {
+         this.doConcurrentModCheck();
+         if (cursor == null)
+         {
+            throw new IllegalStateException("Cannot remove from iterator when there is nothing at the current iteration point");
+         }
+         EvictionQueueList.this.remove(cursor);
+         cursor = null;
+         initialModCount++;
+      }
+
+      @SuppressWarnings(value = "unchecked")
+      public void set(Object o)
+      {
+         this.doConcurrentModCheck();
+         cursor.keyEntry = (KeyEntry<K>) o;
+      }
+
+      public void add(Object o)
+      {
+         this.doConcurrentModCheck();
+         initialModCount++;
+      }
+
+      private void doConcurrentModCheck()
+      {
+         if (EvictionQueueList.this.modCount != initialModCount)
+         {
+            throw new ConcurrentModificationException();
+         }
+      }
+
+      private void forwardCursor()
+      {
+         if (next == null)
+         {
+            throw new NoSuchElementException("No more objects to iterate.");
+         }
+         previous = cursor;
+         cursor = next;
+         next = cursor.next;
+      }
+
+      private void rewindCursor()
+      {
+         if (previous == null)
+         {
+            throw new NoSuchElementException();
+         }
+         next = cursor;
+         cursor = previous;
+         previous = cursor.previous;
+      }
+   }
+
+}
+

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUAlgorithm.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithm.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUAlgorithm.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUAlgorithm.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.mru;
+
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.algorithms.BaseEvictionAlgorithm;
+import org.jboss.starobrno.eviction.KeyEntry;
+import org.jboss.starobrno.eviction.EvictionException;
+import org.jboss.starobrno.eviction.EvictionEvent;
+import org.jboss.starobrno.eviction.EvictionQueue;
+
+/**
+ * Most Recently Used Algorithm.
+ * <p/>
+ * This algorithm will evict the most recently used cache entries from cache.
+ * <p/>
+ * Note: None of the Eviction classes are thread safe. It is assumed that an individual instance of an EvictionPolicy/
+ * EvictionAlgorithm/EvictionQueue/EvictionConfiguration are only operated on by one thread at any given time.
+ *
+ * @author Daniel Huang (dhuang at jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class MRUAlgorithm<K> extends BaseEvictionAlgorithm<K>
+{
+   @Override
+   protected EvictionQueue<K> setupEvictionQueue() throws EvictionException
+   {
+      return new MRUQueue<K>();
+   }
+
+   @Override
+   protected boolean shouldEvictNode(KeyEntry ne)
+   {
+      // check the minimum time to live and see if we should not evict the node.  This check will
+      // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
+      if (ne.isYoungerThanMinimumTimeToLive(evictionAlgorithmConfig.getMinTimeToLive())) return false;
+
+      MRUAlgorithmConfig config = (MRUAlgorithmConfig) evictionAlgorithmConfig;
+      return evictionQueue.getNumberOfNodes() > config.getMaxNodes();
+   }
+
+   @Override
+   protected void processVisitedNodes(EvictionEvent<K> evictedEventNode) throws  EvictionException
+   {
+      super.processVisitedNodes(evictedEventNode);
+      ((MRUQueue<K>) evictionQueue).moveToTopOfStack(evictedEventNode.getKey());
+   }
+
+   public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+   {
+      return MRUAlgorithmConfig.class;
+   }
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUAlgorithmConfig.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithmConfig.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUAlgorithmConfig.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUAlgorithmConfig.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.mru;
+
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase;
+
+/**
+ * Configuration for {@link MRUAlgorithm}.
+ * <p/>
+ * Requires a "maxNodes" attribute otherwise a ConfigurationException is thrown.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class MRUAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+   /**
+    * The serialVersionUID
+    */
+   private static final long serialVersionUID = -8734577898966155218L;
+
+   public MRUAlgorithmConfig()
+   {
+      evictionAlgorithmClassName = MRUAlgorithm.class.getName();
+      // We require that maxNodes is set
+      setMaxNodes(-1);
+   }
+
+   public MRUAlgorithmConfig(int maxNodes)
+   {
+      evictionAlgorithmClassName = MRUAlgorithm.class.getName();
+      setMaxNodes(maxNodes);
+   }
+
+   /**
+    * Requires a positive maxNodes value or ConfigurationException
+    * is thrown.
+    */
+   @Override
+   public void validate() throws ConfigurationException
+   {
+      super.validate();
+      if (getMaxNodes() < 0)
+         throw new ConfigurationException("maxNodes not configured");
+   }
+
+   @Override
+   public String toString()
+   {
+      StringBuilder str = new StringBuilder();
+      str.append("MRUAlgorithmConfig: ").
+            append(" maxNodes =").append(getMaxNodes());
+      return str.toString();
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      return (obj instanceof MRUAlgorithmConfig && super.equals(obj));
+   }
+
+   @Override
+   public void reset()
+   {
+      super.reset();
+      setMaxNodes(-1);
+      evictionAlgorithmClassName = MRUAlgorithm.class.getName();
+   }
+
+   @Override
+   public MRUAlgorithmConfig clone() throws CloneNotSupportedException
+   {
+      return (MRUAlgorithmConfig) super.clone();
+   }
+
+}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUQueue.java (from rev 7011, core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUQueue.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUQueue.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/algorithms/mru/MRUQueue.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.eviction.algorithms.mru;
+
+import org.jboss.starobrno.eviction.EvictionQueue;
+import org.jboss.starobrno.eviction.KeyEntry;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+/**
+ * MRU Eviction Queue implementation.
+ * <p/>
+ * This nodeMap is sorted by MRU. The first entry in the nodeMap
+ * will also be the most recently used entry. The sort is implicit
+ * based on a Stack that we can implicitly sort to the top by moving
+ * a node that is used to the top of the eviction stack.
+ *
+ * @author Daniel Huang (dhuang at jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class MRUQueue<K> implements EvictionQueue<K>
+{
+   // we use our own Stack/Linked List implementation here because it guarantees O(n) = 1 for add, remove, get and
+   // we can sort it in order of MRU implicitly while still getting O(n) = 1 access time
+   // throughout.
+   Map<K, EvictionListEntry<K>> keyMap;
+   private EvictionQueueList<K> list;
+   private int numElements = 0;
+
+   protected MRUQueue()
+   {
+      keyMap = new HashMap<K, EvictionListEntry<K>>();
+      list = new EvictionQueueList<K>();
+   }
+
+   /**
+    * This call moves a NodeEntry to the top of the stack.
+    * <p/>
+    * When a node is visited this method should be called to guarantee MRU ordering.
+    *
+    * @param key Fqn of the nodeEntry to move to the top of the stack.
+    */
+   protected void moveToTopOfStack(K key)
+   {
+      EvictionListEntry<K> le = keyMap.remove(key);
+      if (le != null)
+      {
+         list.remove(le);
+         list.addToTop(le);
+         keyMap.put(le.keyEntry.getKey(), le);
+      }
+   }
+
+   /**
+    * Will return the first entry in the nodeMap.
+    * <p/>
+    * The first entry in this nodeMap will also be the most recently used entry.
+    *
+    * @return The first node entry in nodeMap.
+    */
+   public KeyEntry<K> getFirstNodeEntry()
+   {
+      try
+      {
+         return list.getFirst().keyEntry;
+      }
+      catch (NoSuchElementException e)
+      {
+         //
+      }
+      return null;
+   }
+
+   public KeyEntry<K> getNodeEntry(K key)
+   {
+      EvictionListEntry<K> le = keyMap.get(key);
+      if (le != null)
+         return le.keyEntry;
+      return null;
+   }
+
+   public boolean containsNodeEntry(KeyEntry<K> entry)
+   {
+      return keyMap.containsKey(entry.getKey());
+   }
+
+   public void removeNodeEntry(KeyEntry<K> entry)
+   {
+      EvictionListEntry<K> le = keyMap.remove(entry.getKey());
+      if (le != null)
+      {
+         list.remove(le);
+         this.numElements -= le.keyEntry.getNumberOfElements();
+      }
+   }
+
+   public void addNodeEntry(KeyEntry<K> entry)
+   {
+      if (!this.containsNodeEntry(entry))
+      {
+         EvictionListEntry<K> le = new EvictionListEntry<K>(entry);
+         list.addToBottom(le);
+         keyMap.put(entry.getKey(), le);
+         this.numElements += entry.getNumberOfElements();
+      }
+   }
+
+   public int getNumberOfNodes()
+   {
+      return list.size();
+   }
+
+   public int getNumberOfElements()
+   {
+      return this.numElements;
+   }
+
+   public void modifyElementCount(int difference)
+   {
+      this.numElements += difference;
+   }
+
+   public void clear()
+   {
+      keyMap.clear();
+      list.clear();
+      this.numElements = 0;
+   }
+
+   public Iterator<KeyEntry<K>> iterator()
+   {
+      return list.iterator();
+   }
+
+   @Override
+   public String toString()
+   {
+      return list.toString();
+   }
+}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -199,6 +199,7 @@
       s.add(NullComponentFactory.class);
       s.add(LockManagerFactory.class);
       s.add(DataContainerFactory.class);
+      s.add(EvictionManagerFactory.class);
       return s;
    }
 
@@ -244,7 +245,7 @@
          if (trace) log.trace("Registering component " + c + " under name " + name);
          componentLookup.put(name, c);
       }
-      c.nonVolatile = component.getClass().isAnnotationPresent(NonVolatile.class);
+      c.nonVolatile = component.getClass().isAnnotationPresent(NonVolatile.class) || type.isAnnotationPresent(NonVolatile.class);
       addComponentDependencies(c);
       // inject dependencies for this component
       c.injectDependencies();

Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/EvictionManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/EvictionManagerFactory.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/EvictionManagerFactory.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,24 @@
+package org.jboss.starobrno.factories;
+
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.EvictionManager;
+import org.jboss.starobrno.eviction.EvictionManagerImpl;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at DefaultFactoryFor (classes = {EvictionManager.class})
+public class EvictionManagerFactory extends ComponentFactory
+{
+   protected <T> T construct(Class<T> componentType)
+   {
+      if ( componentType != EvictionManager.class)
+      {
+         throw new IllegalStateException();
+      }
+      EvictionManagerImpl evManager = new EvictionManagerImpl();
+      long wakeupInterval = configuration.getEvictionConfig().getWakeupInterval();
+      evManager.configureEvictionThread(wakeupInterval, configuration.getRuntimeConfig().getEvictionTimerThreadFactory());
+      return (T) evManager;
+   }
+}

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -25,9 +25,14 @@
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.ConfigurationException;
 import org.jboss.starobrno.config.CustomInterceptorConfig;
+import org.jboss.starobrno.config.EvictionCacheConfig;
 import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
 import org.jboss.starobrno.interceptors.*;
 import org.jboss.starobrno.interceptors.base.CommandInterceptor;
+import org.jboss.starobrno.eviction.EvictionCacheManager;
+import org.jboss.starobrno.eviction.EvictionCacheManagerImpl;
+import org.jboss.starobrno.EvictionManager;
+import org.jboss.starobrno.CacheSPI;
 
 import java.util.List;
 
@@ -156,10 +161,17 @@
 //
 //      }
 
-      // TODO: Uncomment once the EvictionInterceptor has been moved to Starobrno
-      // eviction interceptor to come before the optimistic node interceptor
-//      if (configuration.getEvictionConfig() != null && configuration.getEvictionConfig().isValidConfig())
-//         interceptorChain.appendIntereceptor(createInterceptor(configuration.isUsingBuddyReplication() ? BuddyRegionAwareEvictionInterceptor.class : EvictionInterceptor.class));
+      if (configuration.isUsingEviction())
+      {
+         EvictionInterceptor evictionInterceptor = (EvictionInterceptor) createInterceptor(EvictionInterceptor.class);
+         interceptorChain.appendIntereceptor(evictionInterceptor);
+         EvictionCacheConfig ecc = configuration.getEvictionCacheConfig("bla");
+         EvictionCacheManager evCacheManager = new EvictionCacheManagerImpl(componentRegistry.getComponent(CacheSPI.class));
+         evCacheManager.configure(ecc);
+         evictionInterceptor.setEvictionCacheManager(evCacheManager);
+         EvictionManager evManager = componentRegistry.getComponent(EvictionManager.class);
+         evManager.cacheCreated("bla", evCacheManager);
+      }
 
       CommandInterceptor callInterceptor = createInterceptor(CallInterceptor.class);
       interceptorChain.appendIntereceptor(callInterceptor);

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -28,7 +28,7 @@
 
 /**
  * This annotation is used for components that will be registered in the {@link org.jboss.cache.factories.ComponentRegistry},
- * that are resilient to changes in configuration.  Examples are the {@link org.jboss.cache.CacheSPI_Legacy} implementation used, which does
+ * that are resilient to changes in configuration.  Examples are the {@link org.jboss.cache.CacheSPI} implementation used, which does
  * not change regardless of the configuration.  Components such as the {@link org.jboss.cache.lock.LockManager}, though, should
  * <b>never</b> be marked as <tt>@NonVolatile</tt> since based on the configuration, different lock manager implementations
  * may be selected.  LockManager is, hence, <b>not</b> resilient to changes in the configuration.

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/EvictionInterceptor.java (from rev 7016, core/branches/flat/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/EvictionInterceptor.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/EvictionInterceptor.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.interceptors;
+
+import org.jboss.starobrno.commands.read.GetKeyValueCommand;
+import org.jboss.starobrno.commands.write.*;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.eviction.EvictionCacheManager;
+import org.jboss.starobrno.eviction.EvictionEvent;
+import static org.jboss.starobrno.eviction.EvictionEvent.Type.*;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.interceptors.base.CommandInterceptor;
+
+/**
+ * Eviction Interceptor.
+ * <p/>
+ * This interceptor is used to handle eviction events.
+ *
+ * @author Mircea.Markus at jboss.com
+ */
+public class EvictionInterceptor extends CommandInterceptor
+{
+   protected EvictionCacheManager evictionCacheManager;
+
+   /**
+    * this method is for ease of unit testing. thus package access.
+    * <p/>
+    * Not to be attempted to be used anywhere else.
+    */
+   public void setEvictionCacheManager(EvictionCacheManager evictionCacheManager)
+   {
+      this.evictionCacheManager = evictionCacheManager;
+   }
+
+
+   @Override
+   public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+   {
+      Object retVal = invokeNextInterceptor(ctx, command);
+      if (command.getKey() != null)
+      {
+         registerEvictionEvent(command.getKey(), ADD_ELEMENT_EVENT, 1);
+      }
+      return retVal;
+   }
+
+   @Override
+   public Object visitPutMapCommand(InvocationContext ctx, PutMapCommand command) throws Throwable
+   {
+      Object retVal = invokeNextInterceptor(ctx, command);
+      if (command.getMap() == null)
+      {
+         if (trace) log.trace("Putting null data.");
+      } else
+      {
+         int size;
+         synchronized (command.getMap())
+         {
+            size = command.getMap().size();
+         }
+         registerEvictionEvent(null, ADD_NODE_EVENT, size);
+      }
+      return retVal;
+   }
+
+   @Override
+   public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) throws Throwable
+   {
+      Object retVal = invokeNextInterceptor(ctx, command);
+      if (retVal == null)
+      {
+         if (trace) log.trace("No event added. Element does not exist");
+      } else
+      {
+         if (command.getKey() != null)
+         {
+            registerEvictionEvent(command.getKey(), REMOVE_ELEMENT_EVENT, 1);
+         }
+      }
+      return retVal;
+   }
+
+   @Override
+   public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+   {
+      Object retVal = invokeNextInterceptor(ctx, command);
+      if (retVal == null)
+      {
+         if (trace) log.trace("No event added. Element does not exist");
+      } else if (command.getKey() != null)
+      {
+         registerEvictionEvent(command.getKey(), VISIT_NODE_EVENT, 0);
+      }
+      return retVal;
+   }
+
+   public Object visitReplaceCommand(InvocationContext ctx, ReplaceCommand command) throws Throwable
+   {
+      Boolean replaced = (Boolean) invokeNextInterceptor(ctx, command);
+      if (replaced) registerEvictionEvent(command.getKey(), ADD_NODE_EVENT, 1);
+         else registerEvictionEvent(command.getKey(), VISIT_NODE_EVENT, 0);
+      return replaced;
+   }
+
+   @Override
+   public Object visitClearCommand(InvocationContext ctx, ClearCommand command) throws Throwable
+   {
+      Object retVal = invokeNextInterceptor(ctx, command);
+      registerEvictionEvent(null, REMOVE_NODE_EVENT, 0);
+      return retVal;
+   }
+
+   @SuppressWarnings(value = "unchecked")
+   private void registerEvictionEvent(Object key, EvictionEvent.Type type, int elementDifference)
+   {
+      evictionCacheManager.registerEvictionEvent(key, type, elementDifference);
+      if (trace) log.trace("Registering event " + type + " on node " + key);
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/EvictionInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ChannelMessageListener.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ChannelMessageListener.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ChannelMessageListener.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -329,7 +329,7 @@
       {
          log.debug("Setting received partial state for subroot " + state_id);
          Fqn subroot = Fqn.fromString(targetRoot);
-//            Region region = regionManager.getRegion(subroot, false);
+//            Region region = evictionCacheManager.getRegion(subroot, false);
 //            ClassLoader cl = null;
 //            if (region != null)
 //            {
@@ -378,7 +378,7 @@
          log.debug("Setting received partial state for subroot " + stateId);
          in = new MarshalledValueInputStream(istream);
          Fqn subroot = Fqn.fromString(targetRoot);
-//            Region region = regionManager.getRegion(subroot, false);
+//            Region region = evictionCacheManager.getRegion(subroot, false);
 //            ClassLoader cl = null;
 //            if (region != null)
 //            {

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -306,10 +306,10 @@
 //      {
 //         boolean localTx = deadOwner.getAddress().equals(getLocalAddress());
 //          TODO: Fix me!!!
-//         boolean broken = LockUtil.breakTransactionLock(node.getFqn(), lockManager, deadOwner, localTx, txTable, txManager);
+//         boolean broken = LockUtil.breakTransactionLock(node.getKey(), lockManager, deadOwner, localTx, txTable, txManager);
 //         boolean broken = true;
 //
-//         if (broken && trace) log.trace("Broke lock for node " + node.getFqn() + " held by " + deadOwner);
+//         if (broken && trace) log.trace("Broke lock for node " + node.getKey() + " held by " + deadOwner);
 //      }
 //
 //       Recursively unlock children
@@ -328,7 +328,7 @@
    private void removeLocksForDeadMembers(InternalNode<?, ?> node, List deadMembers)
    {
       Set<GlobalTransaction> deadOwners = new HashSet<GlobalTransaction>();
-      Object owner = lockManager.getWriteOwner(node.getFqn());
+      Object owner = lockManager.getWriteOwner(node.getKey());
 
       if (isLockOwnerDead(owner, deadMembers)) deadOwners.add((GlobalTransaction) owner);
 
@@ -337,10 +337,10 @@
       for (GlobalTransaction deadOwner : deadOwners)
       {
          boolean localTx = deadOwner.getAddress().equals(getLocalAddress());
-//         boolean broken = LockUtil.breakTransactionLock(node.getFqn(), lockManager, deadOwner, localTx, txTable, txManager);
+//         boolean broken = LockUtil.breakTransactionLock(node.getKey(), lockManager, deadOwner, localTx, txTable, txManager);
          boolean broken = true; // TODO fix me!!
 
-         if (broken && trace) log.trace("Broke lock for node " + node.getFqn() + " held by " + deadOwner);
+         if (broken && trace) log.trace("Broke lock for node " + node.getKey() + " held by " + deadOwner);
       }
 
       // Recursively unlock children

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/DefaultStateTransferManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/DefaultStateTransferManager.java	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/statetransfer/DefaultStateTransferManager.java	2008-10-29 19:06:26 UTC (rev 7029)
@@ -91,7 +91,7 @@
       /*
 
       // can't give state for regions currently being activated/inactivated
-      boolean canProvideState = (!regionManager.isInactive(fqn) && cache.peek(fqn, false) != null);
+      boolean canProvideState = (!evictionCacheManager.isInactive(fqn) && cache.peek(fqn, false) != null);
       if (trace) log.trace("Can provide state? " + canProvideState);
       if (canProvideState && (fetchPersistentState || fetchTransientState))
       {
@@ -116,7 +116,7 @@
          {
             String exceptionMessage = "Cache instance at " + cache.getLocalAddress() + " cannot provide state for fqn " + fqn + ".";
 
-            if (regionManager.isInactive(fqn))
+            if (evictionCacheManager.isInactive(fqn))
             {
                exceptionMessage += " Region for fqn " + fqn + " is inactive.";
                e = new InactiveRegionException(exceptionMessage);

Modified: core/branches/flat/src/main/resources/config-samples/cacheloader-enabled.xml
===================================================================
--- core/branches/flat/src/main/resources/config-samples/cacheloader-enabled.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/resources/config-samples/cacheloader-enabled.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -21,7 +21,7 @@
    <!-- Specific eviction policy configurations -->
    <eviction wakeUpInterval="5000">
       <!-- Cache wide default -->
-      <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
+      <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm" eventQueueSize="200000">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="timeToLive">3000</attribute>
       </default>

Modified: core/branches/flat/src/main/resources/config-samples/eviction-enabled.xml
===================================================================
--- core/branches/flat/src/main/resources/config-samples/eviction-enabled.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/main/resources/config-samples/eviction-enabled.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -25,7 +25,7 @@
    -->
    <eviction wakeUpInterval="5000">
       <!-- Cache wide default -->
-      <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
+      <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm" eventQueueSize="200000">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="timeToLive">1000000</attribute>
       </default>

Modified: core/branches/flat/src/test/resources/configs/clonable-config.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/clonable-config.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/test/resources/configs/clonable-config.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -45,18 +45,18 @@
       </buddy>
    </replication>
    <eviction wakeUpInterval="45000">
-      <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="4">
+      <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm" eventQueueSize="4">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="timeToLive">1000000</attribute>
          <attribute name="maxAge">15000</attribute>
       </default>
-      <region name="/fifo" algorithmClass="org.jboss.starobrno.eviction.FIFOAlgorithm">
+      <region name="/fifo" algorithmClass="org.jboss.starobrno.eviction.algorithms.fifo.FIFOAlgorithm">
          <attribute name="maxNodes">5000</attribute>
       </region>
-      <region name="/mru" algorithmClass="org.jboss.starobrno.eviction.MRUAlgorithm">
+      <region name="/mru" algorithmClass="org.jboss.starobrno.eviction.algorithms.mru.MRUAlgorithm">
          <attribute name="maxNodes">10000</attribute>
       </region>
-      <region name="/lfu" algorithmClass="org.jboss.starobrno.eviction.LFUAlgorithm">
+      <region name="/lfu" algorithmClass="org.jboss.starobrno.eviction.algorithms.lfu.LFUAlgorithm">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="minNodes">4000</attribute>
       </region>

Modified: core/branches/flat/src/test/resources/configs/local-lru-eviction.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/local-lru-eviction.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/test/resources/configs/local-lru-eviction.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -7,7 +7,7 @@
    <stateRetrieval timeout="20000"/>
    <transport clusterName="JBossCache-Cluster"/>
    <eviction wakeUpInterval="5000">
-      <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
+      <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm" eventQueueSize="200000">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="timeToLive">1000000</attribute>
       </default>

Modified: core/branches/flat/src/test/resources/configs/local-passivation.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/local-passivation.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/test/resources/configs/local-passivation.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -7,7 +7,7 @@
    <stateRetrieval timeout="20000"/>
    <transport clusterName="JBossCache-Cluster"/>
    <eviction wakeUpInterval="1000">
-      <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
+      <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm" eventQueueSize="200000">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="timeToLive">1000</attribute>
       </default>

Modified: core/branches/flat/src/test/resources/configs/local-tx.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/local-tx.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/test/resources/configs/local-tx.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -8,7 +8,7 @@
    <stateRetrieval timeout="20000"/>
    <transport clusterName="JBossCache-Cluster"/>
    <eviction wakeUpInterval="5000">
-      <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
+      <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm" eventQueueSize="200000">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="timeToLive">1000000</attribute>
       </default>

Modified: core/branches/flat/src/test/resources/configs/mixedPolicy-eviction.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/mixedPolicy-eviction.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/test/resources/configs/mixedPolicy-eviction.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -35,14 +35,14 @@
       </jgroupsConfig>
    </transport>
    <eviction wakeUpInterval="5000">
-      <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
+      <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm" eventQueueSize="200000">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="timeToLive">1000000</attribute>
       </default>
-      <region name="/org/jboss/data" algorithmClass="org.jboss.starobrno.eviction.FIFOAlgorithm">
+      <region name="/org/jboss/data" algorithmClass="org.jboss.starobrno.eviction.algorithms.fifo.FIFOAlgorithm">
          <attribute name="maxNodes">5000</attribute>
       </region>
-      <region name="/test/" algorithmClass="org.jboss.starobrno.eviction.MRUAlgorithm">
+      <region name="/test/" algorithmClass="org.jboss.starobrno.eviction.algorithms.mru.MRUAlgorithm">
          <attribute name="maxNodes">10000</attribute>
       </region>
       <region name="/maxAgeTest/">

Modified: core/branches/flat/src/test/resources/configs/parser-test-async.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/parser-test-async.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/test/resources/configs/parser-test-async.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -59,14 +59,14 @@
    <jmxStatistics enabled="false"/>
 
    <eviction wakeUpInterval="5">
-      <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
+      <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm" eventQueueSize="200000">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="timeToLive">1000</attribute>
       </default>
       <region name="/org/jboss/data">
          <attribute name="timeToLive">1002</attribute>
       </region>
-      <region name="/org/jboss/xyz" algorithmClass="org.jboss.starobrno.eviction.MRUAlgorithm" eventQueueSize="21">
+      <region name="/org/jboss/xyz" algorithmClass="org.jboss.starobrno.eviction.algorithms.mru.MRUAlgorithm" eventQueueSize="21">
          <attribute name="maxNodes">2103</attribute>
          <attribute name="minTimeToLive">22</attribute>
       </region>

Modified: core/branches/flat/src/test/resources/configs/parser-test.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/parser-test.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/test/resources/configs/parser-test.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -59,14 +59,14 @@
    <jmxStatistics enabled="false"/>
 
    <eviction wakeUpInterval="5">
-      <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
+      <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm" eventQueueSize="200000">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="timeToLive">1000</attribute>
       </default>
       <region name="/org/jboss/data">
          <attribute name="timeToLive">1002</attribute>
       </region>
-      <region name="/org/jboss/xyz" algorithmClass="org.jboss.starobrno.eviction.MRUAlgorithm" eventQueueSize="21">
+      <region name="/org/jboss/xyz" algorithmClass="org.jboss.starobrno.eviction.algorithms.mru.MRUAlgorithm" eventQueueSize="21">
          <attribute name="maxNodes">2103</attribute>
          <attribute name="minTimeToLive">22</attribute>
       </region>

Modified: core/branches/flat/src/test/resources/configs/policyPerRegion-eviction.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/policyPerRegion-eviction.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/test/resources/configs/policyPerRegion-eviction.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -35,21 +35,21 @@
    </transport>
 
    <eviction wakeUpInterval="5000">
-      <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+      <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="timeToLive">1000000</attribute>
       </default>
-      <region name="/org/jboss/data" algorithmClass="org.jboss.starobrno.eviction.LFUAlgorithm">
+      <region name="/org/jboss/data" algorithmClass="org.jboss.starobrno.eviction.algorithms.lfu.LFUAlgorithm">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="minNodes">1000</attribute>
       </region>
-      <region name="/org/jboss/test/data" algorithmClass="org.jboss.starobrno.eviction.FIFOAlgorithm">
+      <region name="/org/jboss/test/data" algorithmClass="org.jboss.starobrno.eviction.algorithms.fifo.FIFOAlgorithm">
          <attribute name="maxNodes">5</attribute>
       </region>
-      <region name="/test/" algorithmClass="org.jboss.starobrno.eviction.MRUAlgorithm">
+      <region name="/test/" algorithmClass="org.jboss.starobrno.eviction.algorithms.mru.MRUAlgorithm">
          <attribute name="maxNodes">10000</attribute>
       </region>
-      <region name="/maxAgeTest/" algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+      <region name="/maxAgeTest/" algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm">
          <attribute name="maxNodes">10000</attribute>
          <attribute name="timeToLive">8000</attribute>
          <attribute name="maxAge">10000</attribute>

Modified: core/branches/flat/src/test/resources/configs/string-property-replaced.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/string-property-replaced.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/test/resources/configs/string-property-replaced.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -25,7 +25,7 @@
    </replication>
    <eviction wakeUpInterval="5000">
       <default
-            algorithmClass="${test.property.EvictionPolicyConfig.policyClass:org.jboss.starobrno.eviction.LRUAlgorithm}">
+            algorithmClass="${test.property.EvictionPolicyConfig.policyClass:org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm}">
          <attribute name="maxNodes">${test.property.EvictionPolicyConfig.maxNodes:5000}</attribute>
          <attribute name="timeToLive">1000000</attribute>
       </default>

Modified: core/branches/flat/src/test/resources/jbc2-registry-configs.xml
===================================================================
(Binary files differ)

Modified: core/branches/flat/src/test/resources/jbc3-registry-configs.xml
===================================================================
--- core/branches/flat/src/test/resources/jbc3-registry-configs.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/test/resources/jbc3-registry-configs.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -24,7 +24,7 @@
          <sync replTimeout="20000"/>
       </invalidation>
       <eviction wakeUpInterval="5000">
-         <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+         <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm">
             <attribute name="maxNodes">5000</attribute>
             <attribute name="timeToLive">1000</attribute>
          </default>
@@ -47,7 +47,7 @@
          <sync replTimeout="20000"/>
       </invalidation>
       <eviction wakeUpInterval="5000">
-         <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+         <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm">
             <attribute name="maxNodes">5000</attribute>
             <attribute name="timeToLive">1000</attribute>
          </default>
@@ -65,7 +65,7 @@
       <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
       <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
       <eviction wakeUpInterval="5000">
-         <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+         <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm">
             <attribute name="maxNodes">5000</attribute>
             <attribute name="timeToLive">1000</attribute>
          </default>
@@ -90,7 +90,7 @@
          <async/>
       </replication>
       <eviction wakeUpInterval="5000">
-         <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+         <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm">
             <attribute name="maxNodes">5000</attribute>
             <attribute name="timeToLive">1000</attribute>
          </default>
@@ -115,7 +115,7 @@
          <async/>
       </replication>
       <eviction wakeUpInterval="5000">
-         <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+         <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm">
             <attribute name="maxNodes">5000</attribute>
             <attribute name="timeToLive">1000</attribute>
          </default>
@@ -143,7 +143,7 @@
          <sync replTimeout="20000"/>
       </replication>
       <eviction wakeUpInterval="5000">
-         <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+         <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm">
             <attribute name="maxNodes">5000</attribute>
             <attribute name="timeToLive">1000</attribute>
          </default>
@@ -172,7 +172,7 @@
          <sync replTimeout="20000"/>
       </replication>
       <eviction wakeUpInterval="5000">
-         <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+         <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm">
             <attribute name="maxNodes">5000</attribute>
             <attribute name="timeToLive">1000</attribute>
          </default>

Modified: core/branches/flat/src/test/resources/unit-test-cache-service.xml
===================================================================
--- core/branches/flat/src/test/resources/unit-test-cache-service.xml	2008-10-29 14:11:57 UTC (rev 7028)
+++ core/branches/flat/src/test/resources/unit-test-cache-service.xml	2008-10-29 19:06:26 UTC (rev 7029)
@@ -10,7 +10,7 @@
       <sync replTimeout="15000"/>
    </replication>
    <eviction wakeUpInterval="2000">
-      <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+      <default algorithmClass="org.jboss.starobrno.eviction.algorithms.lru.LRUAlgorithm">
          <attribute name="maxNodes">5000</attribute>
          <attribute name="timeToLive">1000</attribute>
       </default>




More information about the jbosscache-commits mailing list