Author: manik.surtani(a)jboss.com
Date: 2008-10-30 21:16:04 -0400 (Thu, 30 Oct 2008)
New Revision: 7038
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConfigBase.java
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.java
Log:
Eviction defaults to match 2.x
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-10-30
22:55:15 UTC (rev 7037)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-10-31
01:16:04 UTC (rev 7038)
@@ -509,7 +509,7 @@
{
// this is ok, but certainly log this as a warning
// this is hugely noisy!
- if (log.isDebugEnabled()) log.debug("Unrecognised attribute " +
propName + ". Please check your configuration. Ignoring!!");
+ if (log.isTraceEnabled()) log.trace("Unrecognised attribute " +
propName + ". Please check your configuration. Ignoring!!");
}
catch (Exception e)
{
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-10-30
22:55:15 UTC (rev 7037)
+++
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-10-31
01:16:04 UTC (rev 7038)
@@ -120,10 +120,17 @@
XmlConfigHelper.setValues(c, attributes.stringAttribs, false, false);
// Special handling for XML elements -- we hard code the parsing
setXmlValues(c, attributes.xmlAttribs);
-
+ if (c.getEvictionConfig() != null)
correctEvictionUnlimitedValues(c.getEvictionConfig());
return c;
}
+ private void correctEvictionUnlimitedValues(EvictionConfig ec)
+ {
+ EvictionRegionConfig def = ec.getDefaultEvictionRegionConfig();
+ EvictionAlgorithmConfig eac = def.getEvictionAlgorithmConfig();
+
+ }
+
/**
* Check for and remove any attributes that were supported in the
* 1.x releases and no longer are. Log a WARN or throw a
@@ -532,8 +539,22 @@
if (key.indexOf("Seconds") > 0)
{
key = key.substring(0, key.length() - "Seconds".length());
+
+
value = value.trim() + "000";
}
+ int intval = 1;
+ try
+ {
+ intval = Integer.parseInt(value);
+
+ }
+ catch (NumberFormatException e)
+ {
+
+ }
+ value = intval < 1 ? "-1" : value;
+
updatedElements.put(key, value);
}
attributes.stringAttribs.clear();
Modified:
core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmConfig.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmConfig.java 2008-10-30
22:55:15 UTC (rev 7037)
+++
core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeAlgorithmConfig.java 2008-10-31
01:16:04 UTC (rev 7038)
@@ -40,7 +40,7 @@
private static final long serialVersionUID = 2510593544656833758L;
@Dynamic
- private int maxElementsPerNode;
+ private int maxElementsPerNode = -1;
public ElementSizeAlgorithmConfig()
{
@@ -75,11 +75,7 @@
public void validate() throws ConfigurationException
{
super.validate();
- if (maxElementsPerNode < 0)
- {
- throw new ConfigurationException("maxElementsPerNode must be must be "
+
- "configured to a value greater than or equal to 0");
- }
+ if (maxElementsPerNode < -1) maxElementsPerNode = -1;
}
@Override
Modified:
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConfigBase.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConfigBase.java 2008-10-30
22:55:15 UTC (rev 7037)
+++
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionAlgorithmConfigBase.java 2008-10-31
01:16:04 UTC (rev 7038)
@@ -41,9 +41,9 @@
protected String evictionAlgorithmClassName;
@Dynamic
- protected int maxNodes = 0;
+ protected int maxNodes = -1;
@Dynamic
- protected long minTimeToLive;
+ protected long minTimeToLive = -1;
/**
* Can only be instantiated by a subclass.
@@ -131,8 +131,8 @@
public void reset()
{
- maxNodes = 0;
- minTimeToLive = 0;
+ maxNodes = -1;
+ minTimeToLive = -1;
}
public EvictionAlgorithmConfig clone() throws CloneNotSupportedException
Modified:
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmConfig.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmConfig.java 2008-10-30
22:55:15 UTC (rev 7037)
+++
core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationAlgorithmConfig.java 2008-10-31
01:16:04 UTC (rev 7038)
@@ -49,7 +49,7 @@
private boolean warnNoExpirationKey = true;
@Dynamic
- private long timeToLive = 0;
+ private long timeToLive = -1;
public ExpirationAlgorithmConfig()
{
@@ -156,6 +156,6 @@
super.reset();
evictionAlgorithmClassName = ExpirationAlgorithm.class.getName();
warnNoExpirationKey = true;
- timeToLive = 0;
+ timeToLive = -1;
}
}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.java 2008-10-30
22:55:15 UTC (rev 7037)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOAlgorithmConfig.java 2008-10-31
01:16:04 UTC (rev 7038)
@@ -60,11 +60,7 @@
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");
- }
+ if (maxNodes < -1) maxNodes = -1;
}
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.java 2008-10-30
22:55:15 UTC (rev 7037)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUAlgorithmConfig.java 2008-10-31
01:16:04 UTC (rev 7038)
@@ -37,7 +37,7 @@
private static final long serialVersionUID = 1865801530398969179L;
@Dynamic
- private int minNodes;
+ private int minNodes = -1;
public LFUAlgorithmConfig()
{
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java 2008-10-30
22:55:15 UTC (rev 7037)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithm.java 2008-10-31
01:16:04 UTC (rev 7038)
@@ -48,13 +48,24 @@
@Override
protected boolean shouldEvictNode(NodeEntry entry)
{
+ if (trace) log.trace("Deciding whether to evict node " + entry);
+ LRUAlgorithmConfig config = (LRUAlgorithmConfig) evictionAlgorithmConfig;
+ if (trace) log.trace("Config is " + config);
// 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;
+ if (isYoungerThanMinimumTimeToLive(entry))
+ {
+ log.trace("Do not evict - is younger than minimum TTL");
+ return false;
+ }
- LRUAlgorithmConfig config = (LRUAlgorithmConfig) evictionAlgorithmConfig;
+
// no idle or max time limit
- if (config.getTimeToLive() < 0 && config.getMaxAge() < 0) return
false;
+ if (config.getTimeToLive() < 0 && config.getMaxAge() < 0)
+ {
+ log.trace("No idle or max time limit!");
+ return false;
+ }
long currentTime = System.currentTimeMillis();
if (config.getTimeToLive() > -1)
@@ -103,10 +114,17 @@
@Override
protected void evict(NodeEntry ne)
{
+ if (trace)
+ {
+ if (ne == null) log.trace("Got a NULL node entry!");
+ else log.trace("About to evict " + ne.getFqn());
+ }
+
if (ne != null && !this.evictCacheNode(ne.getFqn()))
{
try
{
+ if (trace) log.trace("Could not evict " + ne.getFqn() + " so
adding to recycle queue");
recycleQueue.put(ne.getFqn());
}
catch (InterruptedException e)
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.java 2008-10-30
22:55:15 UTC (rev 7037)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUAlgorithmConfig.java 2008-10-31
01:16:04 UTC (rev 7038)
@@ -45,13 +45,13 @@
* value expressed in millis
*/
@Dynamic
- private long timeToLive;
+ private long timeToLive = -1;
/**
* value expressed in millis
*/
@Dynamic
- private long maxAge;
+ private long maxAge = -1;
public LRUAlgorithmConfig()
{
@@ -139,11 +139,7 @@
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());
- }
+ if (timeToLive < -1) timeToLive = -1;
}
public String toString()
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.java 2008-10-30
22:55:15 UTC (rev 7037)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUAlgorithmConfig.java 2008-10-31
01:16:04 UTC (rev 7038)
@@ -59,8 +59,7 @@
public void validate() throws ConfigurationException
{
super.validate();
- if (getMaxNodes() < 0)
- throw new ConfigurationException("maxNodes not configured");
+ if (getMaxNodes() < -1) maxNodes = -1;
}
@Override
Show replies by date