JBoss Cache SVN: r6641 - in core/trunk/src: test/java/org/jboss/cache/eviction and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-29 00:57:46 -0400 (Fri, 29 Aug 2008)
New Revision: 6641
Modified:
core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java
core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java
core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java
Log:
Better timing control between eviction events
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java 2008-08-29 04:23:28 UTC (rev 6640)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java 2008-08-29 04:57:46 UTC (rev 6641)
@@ -34,12 +34,14 @@
private static AtomicInteger tcount = new AtomicInteger();
private long wakeupInterval;
ScheduledExecutorService scheduledExecutor;
+ private Task task;
public EvictionTimerTask()
{
// synchronized set because we need to maintain thread safety
// for dynamic configuration purposes.
processedRegions = new ConcurrentHashSet<Region>();
+ task = new Task();
}
public void init(long wakeupInterval)
@@ -106,16 +108,7 @@
return new Thread(r, "EvictionTimer-" + tcount.getAndIncrement());
}
});
- scheduledExecutor.scheduleWithFixedDelay(new 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();
- }
- }, wakeupInterval, wakeupInterval, TimeUnit.MILLISECONDS);
+ scheduledExecutor.scheduleWithFixedDelay(task, wakeupInterval, wakeupInterval, TimeUnit.MILLISECONDS);
}
private void processRegions()
@@ -146,6 +139,17 @@
}
}
}
+
+ 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();
+ }
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java 2008-08-29 04:23:28 UTC (rev 6640)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/EvictionTestsBase.java 2008-08-29 04:57:46 UTC (rev 6641)
@@ -13,6 +13,7 @@
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.internals.EvictionController;
import org.jboss.cache.util.internals.EvictionWatcher;
import java.util.concurrent.TimeUnit;
@@ -48,6 +49,10 @@
*/
public boolean waitForEviction(Cache cache, long timeToWait, TimeUnit unit, Fqn... fqnsToEvict) throws InterruptedException
{
- return new EvictionWatcher(cache, fqnsToEvict).waitForEviction(timeToWait, unit);
+ EvictionController ec = new EvictionController(cache);
+ EvictionController.Signaller signaller = ec.getEvictionThreadSignaller();
+ boolean evicted = new EvictionWatcher(cache, fqnsToEvict).waitForEviction(timeToWait, unit);
+ signaller.waitForEvictionThreadCompletion(timeToWait, unit);
+ return evicted;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2008-08-29 04:23:28 UTC (rev 6640)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2008-08-29 04:57:46 UTC (rev 6641)
@@ -16,6 +16,7 @@
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.internals.EvictionController;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -68,45 +69,63 @@
public void testUpdateToFuture() throws Exception
{
- log.info("update 1 from future to past");
- cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
- TestingUtil.sleepThread(200);
- assertNotNull(cache.getNode(fqn1));
- cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future + 250);
- TestingUtil.sleepThread(500);
- assertNotNull(cache.getNode(fqn1));
- TestingUtil.sleepThread(100);
- assertNull(cache.getNode(fqn1));
- cache.removeNode(Fqn.ROOT);
+ try
+ {
+ log.info("update 1 from future to past");
+ cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
+ TestingUtil.sleepThread(200);
+ new EvictionController(cache).startEviction();
+ assertNotNull(cache.getNode(fqn1));
+ cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future + 250);
+ TestingUtil.sleepThread(500);
+ new EvictionController(cache).startEviction();
+ assertNotNull(cache.getNode(fqn1));
+ TestingUtil.sleepThread(100);
+ new EvictionController(cache).startEviction();
+ assertNull(cache.getNode(fqn1));
+ }
+ finally
+ {
+ cache.removeNode(Fqn.ROOT);
+ }
}
+ @Test(invocationCount = 10)
public void testEviction() throws Exception
{
cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
cache.put(fqn2, ExpirationAlgorithmConfig.EXPIRATION_KEY, past);
cache.put(fqn3, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
cache.put(fqn4, "foo", "bar");
- assert waitForEviction(cache, 30, TimeUnit.SECONDS, fqn2) : "Eviction event not received!";
+
+ waitForEviction(cache, 30, TimeUnit.SECONDS, fqn2);
assertNotNull(cache.getNode(fqn1));
assertNull(cache.getNode(fqn2));
assertNotNull(cache.getNode(fqn3));
assertNotNull(cache.getNode(fqn4));
log.info("should remove 1 and 3 now");
- assert waitForEviction(cache, 30, TimeUnit.SECONDS, fqn1, fqn3) : "Eviction event not received!";
+ waitForEviction(cache, 30, TimeUnit.SECONDS, fqn1, fqn3);
assertNull(cache.getNode(fqn1));
assertNull(cache.getNode(fqn3));
}
public void testUpdate() throws Exception
{
- log.info("update 1 from future to past");
- cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
- assertNotNull(cache.getNode(fqn1));
- cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, past);
- assert waitForEviction(cache, 1, TimeUnit.SECONDS, fqn1) : "Eviction event not received!";
- assertNull(cache.getNode(fqn1));
- cache.removeNode(Fqn.ROOT);
+ try
+ {
+ log.info("update 1 from future to past");
+ cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
+ new EvictionController(cache).startEviction();
+ assertNotNull(cache.getNode(fqn1));
+ cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, past);
+ new EvictionController(cache).startEviction();
+ assertNull(cache.getNode(fqn1));
+ }
+ finally
+ {
+ cache.removeNode(Fqn.ROOT);
+ }
}
public void testMaxNodes() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java 2008-08-29 04:23:28 UTC (rev 6640)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/EvictionController.java 2008-08-29 04:57:46 UTC (rev 6641)
@@ -8,10 +8,14 @@
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.EvictionTimerTask;
+import org.jboss.cache.eviction.EvictionTimerTask.Task;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.util.TestingUtil;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
/**
* when used on a cache will disable defaul eviction behavior and it will supply means of kicking off evction
@@ -115,4 +119,72 @@
}
}
}
+
+ public Signaller getEvictionThreadSignaller()
+ {
+ final Signaller s = new Signaller();
+ Task signallingTask = timerTask.new Task()
+ {
+ public void run()
+ {
+ s.getToken();
+ try
+ {
+ super.run();
+ }
+ finally
+ {
+ s.releaseToken();
+ }
+ }
+ };
+
+ try
+ {
+ Class ettClass = EvictionTimerTask.class;
+ Field f = ettClass.getDeclaredField("task");
+ f.setAccessible(true);
+ f.set(timerTask, signallingTask);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ timerTask.init(originalWakeupInterval);
+ return s;
+ }
+
+ public static class Signaller
+ {
+ Semaphore s = new Semaphore(1);
+
+ public boolean waitForEvictionThreadCompletion(long time, TimeUnit unit) throws InterruptedException
+ {
+ try
+ {
+ return s.tryAcquire(time, unit);
+ }
+ finally
+ {
+ s.release();
+ }
+ }
+
+ void getToken()
+ {
+ try
+ {
+ s.acquire();
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ void releaseToken()
+ {
+ s.release();
+ }
+ }
}
16 years, 4 months
JBoss Cache SVN: r6640 - core/trunk/src/test/java/org/jboss/cache/lock.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-29 00:23:28 -0400 (Fri, 29 Aug 2008)
New Revision: 6640
Modified:
core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java
core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java
Log:
Fixed broken tests
Modified: core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java 2008-08-29 03:57:03 UTC (rev 6639)
+++ core/trunk/src/test/java/org/jboss/cache/lock/PessimisticLockTest.java 2008-08-29 04:23:28 UTC (rev 6640)
@@ -46,7 +46,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- cache.stop();
+ TestingUtil.killCaches(cache);
}
private void assertNoStaleLocks()
Modified: core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java 2008-08-29 03:57:03 UTC (rev 6639)
+++ core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java 2008-08-29 04:23:28 UTC (rev 6640)
@@ -3,6 +3,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -24,6 +25,7 @@
{
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
// reduce LAT so the test runs faster
cache.getConfiguration().setLockAcquisitionTimeout(500);
16 years, 4 months
JBoss Cache SVN: r6639 - core/branches/2.2.X.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-28 23:57:03 -0400 (Thu, 28 Aug 2008)
New Revision: 6639
Modified:
core/branches/2.2.X/pom.xml
Log:
Updated commons-core
Modified: core/branches/2.2.X/pom.xml
===================================================================
--- core/branches/2.2.X/pom.xml 2008-08-29 03:32:18 UTC (rev 6638)
+++ core/branches/2.2.X/pom.xml 2008-08-29 03:57:03 UTC (rev 6639)
@@ -47,7 +47,7 @@
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
- <version>2.2.3.GA</version>
+ <version>2.2.8.GA</version>
<exclusions>
<exclusion>
<groupId>apache-slide</groupId>
@@ -430,7 +430,7 @@
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
- <version>2.2.7.GA</version>
+ <version>2.2.8.GA</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
16 years, 4 months
JBoss Cache SVN: r6638 - core/tags/2.2.0.GA.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-28 23:32:18 -0400 (Thu, 28 Aug 2008)
New Revision: 6638
Modified:
core/tags/2.2.0.GA/pom.xml
Log:
Modified: core/tags/2.2.0.GA/pom.xml
===================================================================
--- core/tags/2.2.0.GA/pom.xml 2008-08-29 03:24:27 UTC (rev 6637)
+++ core/tags/2.2.0.GA/pom.xml 2008-08-29 03:32:18 UTC (rev 6638)
@@ -47,7 +47,7 @@
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
- <version>2.2.3.GA</version>
+ <version>2.2.8.GA</version>
<exclusions>
<exclusion>
<groupId>apache-slide</groupId>
@@ -430,7 +430,7 @@
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
- <version>2.2.7.GA</version>
+ <version>2.2.8.GA</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
16 years, 4 months
JBoss Cache SVN: r6637 - core/trunk.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-28 23:24:27 -0400 (Thu, 28 Aug 2008)
New Revision: 6637
Modified:
core/trunk/pom.xml
Log:
Updated commons-core
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-08-28 16:45:10 UTC (rev 6636)
+++ core/trunk/pom.xml 2008-08-29 03:24:27 UTC (rev 6637)
@@ -47,7 +47,7 @@
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
- <version>2.2.7.GA</version>
+ <version>2.2.8.GA</version>
</dependency>
<!-- optional dependencies -->
@@ -415,7 +415,7 @@
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
- <version>2.2.7.GA</version>
+ <version>2.2.8.GA</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
16 years, 4 months
JBoss Cache SVN: r6636 - core/trunk/src/test/java/org/jboss/cache/jmx/deprecated.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-28 12:45:10 -0400 (Thu, 28 Aug 2008)
New Revision: 6636
Modified:
core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTestBase.java
Log:
fixed tests
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTestBase.java 2008-08-28 16:41:07 UTC (rev 6635)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTestBase.java 2008-08-28 16:45:10 UTC (rev 6636)
@@ -102,6 +102,7 @@
protected CacheJmxWrapper<String, String> createWrapper(Configuration config)
{
CacheJmxWrapper<String, String> wrapper = new CacheJmxWrapper<String, String>();
+ config.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
wrapper.setConfiguration(config);
return wrapper;
}
@@ -117,6 +118,7 @@
{
Configuration c = new Configuration();
c.setClusterName(CLUSTER_NAME);
+ c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
c.setExposeManagementStatistics(true);
c.setCacheMode(Configuration.CacheMode.LOCAL);
return c;
16 years, 4 months
JBoss Cache SVN: r6635 - core/trunk/src/test/resources.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-28 12:41:07 -0400 (Thu, 28 Aug 2008)
New Revision: 6635
Modified:
core/trunk/src/test/resources/log4j.xml
Log:
rolledback
Modified: core/trunk/src/test/resources/log4j.xml
===================================================================
--- core/trunk/src/test/resources/log4j.xml 2008-08-28 16:38:07 UTC (rev 6634)
+++ core/trunk/src/test/resources/log4j.xml 2008-08-28 16:41:07 UTC (rev 6635)
@@ -10,7 +10,7 @@
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="../jbosscache.log"/>
- <param name="Append" value="false"/>
+ <param name="Append" value="true"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
@@ -46,13 +46,9 @@
<!-- ================ -->
<category name="org.jboss.cache">
- <priority value="TRACE"/>
+ <priority value="WARN"/>
</category>
- <category name="org.jboss.cache.lock.BreakDeadMemberLocksTest">
- <priority value="TRACE"/>
- </category>
-
<category name="org.jboss.cache.factories">
<priority value="WARN"/>
</category>
@@ -70,7 +66,7 @@
<!-- ======================= -->
<root>
- <appender-ref ref="CONSOLE"/>
+ <!--<appender-ref ref="CONSOLE"/>-->
<appender-ref ref="FILE"/>
</root>
16 years, 4 months
JBoss Cache SVN: r6634 - core/trunk/src/test/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-28 12:38:07 -0400 (Thu, 28 Aug 2008)
New Revision: 6634
Modified:
core/trunk/src/test/java/org/jboss/cache/CallbackTest.java
Log:
this scenario is only acceptable in a pessimistic locking scheme
Modified: core/trunk/src/test/java/org/jboss/cache/CallbackTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2008-08-28 16:27:09 UTC (rev 6633)
+++ core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2008-08-28 16:38:07 UTC (rev 6634)
@@ -108,6 +108,7 @@
{
Configuration c = new Configuration();
c.setCacheMode(mode);
+ c.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
c.setIsolationLevel(level);
c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
return (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(c);
16 years, 4 months