[jboss-cvs] JBossCache/tests/stress/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Thu Jan 11 08:49:04 EST 2007
User: msurtani
Date: 07/01/11 08:49:04
Modified: tests/stress/org/jboss/cache EvictionLocalStressTest.java
LocalStressTest.java
Log:
Changed CacheImpl ctor to be protected, and changed cache factories accordingly
Revision Changes Path
1.9 +23 -10 JBossCache/tests/stress/org/jboss/cache/EvictionLocalStressTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: EvictionLocalStressTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/stress/org/jboss/cache/EvictionLocalStressTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- EvictionLocalStressTest.java 30 Dec 2006 17:50:04 -0000 1.8
+++ EvictionLocalStressTest.java 11 Jan 2007 13:49:04 -0000 1.9
@@ -14,7 +14,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockStrategyFactory;
import org.jboss.cache.transaction.DummyTransactionManager;
@@ -30,7 +29,7 @@
* Local mode stress test for CacheImpl.
*
* @author <a href="mailto:bwang at jboss.org">Ben Wang</a> May 20 2003
- * @version $Id: EvictionLocalStressTest.java,v 1.8 2006/12/30 17:50:04 msurtani Exp $
+ * @version $Id: EvictionLocalStressTest.java,v 1.9 2007/01/11 13:49:04 msurtani Exp $
*/
public class EvictionLocalStressTest extends TestCase
{
@@ -90,13 +89,11 @@
void initCaches(Configuration.CacheMode caching_mode) throws Exception
{
cachingMode_ = caching_mode;
- cache_ = new CacheImpl();
- cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-lru-eviction-service.xml")); // read in generic local xml
+ cache_ = (CacheImpl) DefaultCacheFactory.getInstance().createCache("META-INF/local-lru-eviction-service.xml", false);// read in generic local xml
cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
LockStrategyFactory.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
cache_.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
cache_.getConfiguration().setLockAcquisitionTimeout(10000);
- cache_.create();
cache_.start();
}
@@ -126,8 +123,10 @@
System.out.println("number of nodes/locks: " + cache_.getNumberOfNodes() + " / " + cache_.getNumberOfLocksHeld());
if (thread_ex != null)
+ {
throw thread_ex;
}
+ }
static class RunThread extends Thread
{
@@ -188,13 +187,17 @@
// tx=startTransaction();
//try {
if (log.isTraceEnabled())
+ {
log.trace("op1.get(" + node + ", " + key + ") thread=" + Thread.currentThread());
+ }
cache_.get(node, key);
- sleep_(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
+ sleep_(random_.nextInt(SLEEP_TIME));// sleep for max 200 millis
if (log.isTraceEnabled())
+ {
log.trace("op1.put(" + node + ", " + key + ", " + value + ") thread=" + Thread.currentThread());
+ }
cache_.put(node, key, value);
//}
//finally {
@@ -213,14 +216,18 @@
try
{
if (log.isTraceEnabled())
+ {
log.trace("op2.get(" + node + ", " + key + ") thread=" + Thread.currentThread());
+ }
cache_.get(node, key);
- sleep_(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
+ sleep_(random_.nextInt(SLEEP_TIME));// sleep for max 200 millis
if (log.isTraceEnabled())
+ {
log.trace("op2.get(" + node + ", " + key + ") thread=" + Thread.currentThread());
+ }
cache_.get(node, key);
- sleep_(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
+ sleep_(random_.nextInt(SLEEP_TIME));// sleep for max 200 millis
}
finally
{
@@ -240,13 +247,17 @@
try
{
if (log.isTraceEnabled())
+ {
log.trace("op3.put(" + node + ", " + key + ", " + value + ") thread=" + Thread.currentThread());
+ }
cache_.put(node, key, value);
- sleep_(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
+ sleep_(random_.nextInt(SLEEP_TIME));// sleep for max 200 millis
if (log.isTraceEnabled())
+ {
log.trace("op3.remove(" + node + ", " + key + ") thread=" + Thread.currentThread());
+ }
cache_.remove(node, key);
}
finally
@@ -293,7 +304,9 @@
String tmp = (String) oldList.get(i);
tmp += Integer.toString(j);
if (depth != 1)
+ {
tmp += "/";
+ }
newList.add(tmp);
}
}
@@ -314,7 +327,7 @@
private static void log(String str)
{
System.out.println(Thread.currentThread() + ": " + str);
-// System.out.println(str);
+ // System.out.println(str);
}
}
1.10 +11 -9 JBossCache/tests/stress/org/jboss/cache/LocalStressTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LocalStressTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/stress/org/jboss/cache/LocalStressTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- LocalStressTest.java 30 Dec 2006 17:50:04 -0000 1.9
+++ LocalStressTest.java 11 Jan 2007 13:49:04 -0000 1.10
@@ -12,7 +12,6 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockStrategyFactory;
import org.jboss.cache.misc.TestingUtil;
@@ -38,7 +37,7 @@
* Local mode stress test for CacheImpl.
*
* @author <a href="mailto:bwang at jboss.org">Ben Wang</a> May 20 2003
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public class LocalStressTest extends TestCase
{
@@ -101,8 +100,7 @@
void initCaches(Configuration.CacheMode caching_mode) throws Exception
{
cachingMode_ = caching_mode;
- cache_ = new CacheImpl();
- cache_.setConfiguration(new XmlConfigurationParser().parseFile("META-INF/local-lru-eviction-service.xml")); // read in generic local xml
+ cache_ = (CacheImpl) DefaultCacheFactory.getInstance().createCache("META-INF/local-lru-eviction-service.xml", false);// read in generic local xml
cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
cache_.create();
cache_.start();
@@ -156,12 +154,14 @@
t1.start();
t2.start();
- t1.join(60000); // wait for 20 secs
- t2.join(60000); // wait for 20 secs
+ t1.join(60000);// wait for 20 secs
+ t2.join(60000);// wait for 20 secs
if (thread_ex != null)
+ {
throw thread_ex;
}
+ }
static class RunThread extends Thread
{
@@ -219,9 +219,9 @@
// uncommenting these leads to a classic deadlock.
-// cache_.put(node, key, value);
-// sleep_(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
-// cache_.remove(node, key);
+ // cache_.put(node, key, value);
+ // sleep_(random_.nextInt(SLEEP_TIME)); // sleep for max 200 millis
+ // cache_.remove(node, key);
tx_.commit();
}
@@ -284,7 +284,9 @@
String tmp = anOldList;
tmp += Integer.toString(j);
if (depth != 1)
+ {
tmp += "/";
+ }
newList.add(tmp);
}
}
More information about the jboss-cvs-commits
mailing list