[jbosscache-commits] JBoss Cache SVN: r8450 - core/branches/1.4.X/src/org/jboss/cache/eviction.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Dec 28 23:34:06 EST 2010


Author: dereed
Date: 2010-12-28 23:34:06 -0500 (Tue, 28 Dec 2010)
New Revision: 8450

Modified:
   core/branches/1.4.X/src/org/jboss/cache/eviction/EvictionConfiguration.java
   core/branches/1.4.X/src/org/jboss/cache/eviction/Region.java
   core/branches/1.4.X/src/org/jboss/cache/eviction/RegionManager.java
Log:
[JBCACHE-1596] Make eviction event queue size configurable, to avoid 200,000 node limit in a region with initial state transfer.


Modified: core/branches/1.4.X/src/org/jboss/cache/eviction/EvictionConfiguration.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/eviction/EvictionConfiguration.java	2010-09-30 01:20:36 UTC (rev 8449)
+++ core/branches/1.4.X/src/org/jboss/cache/eviction/EvictionConfiguration.java	2010-12-29 04:34:06 UTC (rev 8450)
@@ -25,6 +25,7 @@
 
    public static final String ATTR = "attribute";
    public static final String NAME = "name";
+   public static final String EVENT_QUEUE_SIZE = "eventQueueSize";
 
    public static final String REGION = "region";
    public static final String WAKEUP_INTERVAL_SECONDS = "wakeUpIntervalSeconds";

Modified: core/branches/1.4.X/src/org/jboss/cache/eviction/Region.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/eviction/Region.java	2010-09-30 01:20:36 UTC (rev 8449)
+++ core/branches/1.4.X/src/org/jboss/cache/eviction/Region.java	2010-12-29 04:34:06 UTC (rev 8450)
@@ -38,24 +38,22 @@
    // Count of how many times between attempt to check capacity
    protected int checkCapacityCount = 0;
 
-   // Added capacity warning threshold constant with correct calculation. Plus 100 to be on the safe side.
-   private final static int CAPACITY_WARN_THRESHOLD = (98 * RegionManager.CAPACITY) / 100 - 100;
+   int eventQueueSize = RegionManager.CAPACITY;
 
+   // Added capacity warning threshold with correct calculation. Plus 100 to be on the safe side.
+   private int capacityWarnThreshold = (RegionManager.CAPACITY * eventQueueSize) / 100 - 100;
+
    /**
     * Default to package namespace on purpose so no one outside the package can instantiate it,
     */
    Region()
    {
-      if (CAPACITY_WARN_THRESHOLD <= 0)
-      {
-         throw new RuntimeException("Region.Region(): CAPACITY_WARN_THRESHOLD constant used in eviction is smaller than 1.");
-      }
       createQueue();
    }
 
    void createQueue()
    {
-      nodeEventQueue_ = new BoundedLinkedQueue(RegionManager.CAPACITY);
+      nodeEventQueue_ = new BoundedLinkedQueue(eventQueueSize);
    }
 
    Region(String fqn, EvictionPolicy policy, EvictionConfiguration config)
@@ -72,6 +70,30 @@
       createQueue();
    }
 
+   public int getEventQueueSize()
+   {
+      return eventQueueSize;
+   }
+
+   public void setEventQueueSize(int queueSize)
+   {
+      if (queueSize <= 0)
+      {
+         log_.warn ("Ignoring invalid queue capacity " +
+               queueSize + " -- using " + RegionManager.CAPACITY);
+         queueSize = RegionManager.CAPACITY;
+      }
+
+      capacityWarnThreshold = (98 * eventQueueSize) / 100 - 100;
+      if (capacityWarnThreshold <= 0 )
+      {
+         log_.warn("Capacity warn threshold used in eviction is smaller than 1. Defined Event queue size is:" + eventQueueSize);
+      }
+
+      this.eventQueueSize = queueSize;
+      nodeEventQueue_.setCapacity ( eventQueueSize );
+   }
+
    public EvictionConfiguration getEvictionConfiguration()
    {
       return this.configuration_;
@@ -132,7 +154,7 @@
          if (++checkCapacityCount > 100)
          {
             checkCapacityCount = 0;
-            if (nodeEventQueue_.size() > (CAPACITY_WARN_THRESHOLD))
+            if (nodeEventQueue_.size() > capacityWarnThreshold)
             {
                log_.warn("putNodeEvent(): eviction node event queue size is at 98% threshold value of capacity: "
                      + RegionManager.CAPACITY + " You will need to reduce the wakeUpIntervalSeconds parameter.");

Modified: core/branches/1.4.X/src/org/jboss/cache/eviction/RegionManager.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/eviction/RegionManager.java	2010-09-30 01:20:36 UTC (rev 8449)
+++ core/branches/1.4.X/src/org/jboss/cache/eviction/RegionManager.java	2010-12-29 04:34:06 UTC (rev 8450)
@@ -140,8 +140,15 @@
          throws RegionNameConflictException
    {
       EvictionPolicy policy = this.createEvictionPolicy(regionConfig);
+
       EvictionConfiguration config = this.configureEvictionPolicy(policy, regionConfig);
-      return this.createRegion(fqn, policy, config);
+
+      String temp = regionConfig.getAttribute(EvictionConfiguration.EVENT_QUEUE_SIZE);
+      int eventQueueSize = 0;
+      if ( ! "".equals ( temp ) )
+         eventQueueSize = Integer.parseInt ( temp );
+
+      return this.createRegion(fqn, policy, config, eventQueueSize);
    }
 
    public Region createRegion(String fqn, EvictionPolicy policy, EvictionConfiguration config) throws RegionNameConflictException
@@ -151,12 +158,19 @@
 
    public Region createRegion(Fqn fqn, EvictionPolicy policy, EvictionConfiguration config) throws RegionNameConflictException
    {
+      return createRegion(fqn, policy, config, 0);
+   }
+
+   public Region createRegion(Fqn fqn, EvictionPolicy policy, EvictionConfiguration config, int eventQueueSize) throws RegionNameConflictException
+   {
       if (log_.isDebugEnabled())
       {
          log_.debug("createRegion(): creating region for fqn- " + fqn);
       }
 
       Region region = new Region(fqn, policy, config);
+      if ( eventQueueSize > 0 )
+         region.setEventQueueSize ( eventQueueSize );
       addRegion(fqn, region);
       evictionTimerTask_.addRegionToProcess(region);
       return region;



More information about the jbosscache-commits mailing list