JBoss Cache SVN: r7845 - core/branches/flat/src/main/java/org/horizon/remoting.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-04 08:22:46 -0500 (Wed, 04 Mar 2009)
New Revision: 7845
Modified:
core/branches/flat/src/main/java/org/horizon/remoting/RPCManagerImpl.java
Log:
Better retrieve state retry loop
Modified: core/branches/flat/src/main/java/org/horizon/remoting/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/remoting/RPCManagerImpl.java 2009-03-04 12:26:34 UTC (rev 7844)
+++ core/branches/flat/src/main/java/org/horizon/remoting/RPCManagerImpl.java 2009-03-04 13:22:46 UTC (rev 7845)
@@ -106,19 +106,20 @@
currentStateTransferSource = null;
}
}
+ }
- if (!success) {
- if (log.isWarnEnabled())
- log.warn("Could not find available peer for state, backing off and retrying");
+ if (!success) {
+ if (log.isWarnEnabled())
+ log.warn("Could not find available peer for state, backing off and retrying");
- try {
- Thread.sleep(wait *= waitTimeIncreaseFactor);
- }
- catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
+ try {
+ Thread.sleep(wait *= waitTimeIncreaseFactor);
}
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
}
+
}
} finally {
currentStateTransferSource = null;
15 years, 9 months
JBoss Cache SVN: r7844 - core/branches/flat/src/test/java/org/horizon/loader/jdbc.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-04 07:26:34 -0500 (Wed, 04 Mar 2009)
New Revision: 7844
Modified:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/PooledConnectionFactoryTest.java
Log:
Modified: core/branches/flat/src/test/java/org/horizon/loader/jdbc/PooledConnectionFactoryTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/jdbc/PooledConnectionFactoryTest.java 2009-03-04 11:43:46 UTC (rev 7843)
+++ core/branches/flat/src/test/java/org/horizon/loader/jdbc/PooledConnectionFactoryTest.java 2009-03-04 12:26:34 UTC (rev 7844)
@@ -15,7 +15,7 @@
*
* @author
*/
-@Test(groups = "functional", testName = "loader.jdbc.PooledConnectionFactoryTest")
+@Test(groups = "functional", testName = "loader.jdbc.PooledConnectionFactoryTest", enabled = false)
public class PooledConnectionFactoryTest {
private PooledConnectionFactory factory;
15 years, 9 months
JBoss Cache SVN: r7843 - core/branches/flat/src/test/java/org/horizon/loader/bdbje.
by jbosscache-commits@lists.jboss.org
Author: adriancole
Date: 2009-03-04 06:43:46 -0500 (Wed, 04 Mar 2009)
New Revision: 7843
Modified:
core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java
Log:
removed manik todos
Modified: core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java 2009-03-04 11:41:10 UTC (rev 7842)
+++ core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java 2009-03-04 11:43:46 UTC (rev 7843)
@@ -306,7 +306,7 @@
try {
runner.run(new ModificationsTransactionWorker(mods));
} catch (Exception e) {
- e.printStackTrace(); // TODO: Manik: Customise this generated block
+ e.printStackTrace();
}
} else {
PreparableTransactionRunner runner = new PreparableTransactionRunner(env);
@@ -316,7 +316,7 @@
txn = CurrentTransaction.getInstance(env).getTransaction();
txnMap.put(tx, txn);
} catch (Exception e) {
- e.printStackTrace(); // TODO: Manik: Customise this generated block
+ e.printStackTrace();
}
}
@@ -332,7 +332,7 @@
try {
currentTransaction.commitTransaction();
} catch (DatabaseException e) {
- e.printStackTrace(); // TODO: Manik: Customise this generated block
+ e.printStackTrace();
}
} else {
log.error("Transactions must be committed on the same thread");
@@ -348,7 +348,7 @@
try {
currentTransaction.abortTransaction();
} catch (DatabaseException e) {
- e.printStackTrace(); // TODO: Manik: Customise this generated block
+ e.printStackTrace();
}
} else {
log.error("Transactions must be committed on the same thread");
15 years, 9 months
JBoss Cache SVN: r7842 - core/branches/flat/src/test/java/org/horizon/api/tree.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-04 06:41:10 -0500 (Wed, 04 Mar 2009)
New Revision: 7842
Modified:
core/branches/flat/src/test/java/org/horizon/api/tree/NodeMoveAPITest.java
Log:
Reduced lock acquisition timeout
Modified: core/branches/flat/src/test/java/org/horizon/api/tree/NodeMoveAPITest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/tree/NodeMoveAPITest.java 2009-03-04 11:32:48 UTC (rev 7841)
+++ core/branches/flat/src/test/java/org/horizon/api/tree/NodeMoveAPITest.java 2009-03-04 11:41:10 UTC (rev 7842)
@@ -50,6 +50,7 @@
Configuration c = new Configuration();
c.setFetchInMemoryState(false);
c.setInvocationBatchingEnabled(true);
+ c.setLockAcquisitionTimeout(1000);
cm.defineCache("test", c);
cache = cm.getCache("test");
tm = TestingUtil.extractComponent(cache, TransactionManager.class);
15 years, 9 months
JBoss Cache SVN: r7841 - in core/branches/flat/src/test/java/org/horizon/loader: bdbje and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: adriancole
Date: 2009-03-04 06:32:48 -0500 (Wed, 04 Mar 2009)
New Revision: 7841
Modified:
core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java
Log:
cannot use testNG threads until http://jira.opensymphony.com/browse/TESTNG-286 is fixed
Modified: core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-03-04 11:14:01 UTC (rev 7840)
+++ core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-03-04 11:32:48 UTC (rev 7841)
@@ -23,6 +23,7 @@
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Set;
@@ -35,16 +36,11 @@
protected abstract CacheStore createCacheStore() throws Exception;
protected CacheStore cs;
- final Random r = new Random();
- protected StoredEntry[] entries;
- @BeforeMethod(firstTimeOnly = true)
+ @BeforeMethod
public void setUp() throws Exception {
try {
cs = createCacheStore();
- entries = new StoredEntry[10];
- for (int i = 0; i < entries.length; i++)
- entries[i] = new StoredEntry("k" + i, "v" + i);
} catch (Exception e) {
//in IDEs this won't be printed which makes debugging harder
e.printStackTrace();
@@ -52,7 +48,7 @@
}
}
- @AfterMethod(lastTimeOnly = true)
+ @AfterMethod
public void tearDown() throws CacheLoaderException {
if (cs != null) {
cs.clear();
@@ -65,7 +61,7 @@
public void assertNoLocksHeld() {
//doesn't really make sense to add a subclass for this check only
if (cs instanceof LockSupportCacheStore) {
- assert ((LockSupportCacheStore) cs).getTotalLockCount() == 0;
+ assert ((LockSupportCacheStore)cs).getTotalLockCount() == 0;
}
}
@@ -437,15 +433,69 @@
assert clc.getClassName().equals(cs.getClass().getName()) : "Cache loader doesn't provide a proper configuration type that is capable of creating the loader!";
}
- @Test(threadPoolSize = 3, invocationCount = 3, timeOut = 10000)
- public void testConcurrency() throws CacheLoaderException {
- for (int i = 0; i < 500; i++) {
- cs.store(entries[r.nextInt(entries.length)]);
- cs.remove(entries[r.nextInt(entries.length)]);
- int index = r.nextInt(entries.length);
- StoredEntry entry = cs.load(entries[index]);
- assert entry == null || entry.getValue().equals(entries[index].getValue());
- cs.loadAll();
+ public void testConcurrency() throws Exception {
+ int numThreads = 3;
+ final int loops = 500;
+ final String[] keys = new String[10];
+ final String[] values = new String[10];
+ for (int i = 0; i < 10; i++) keys[i] = "k" + i;
+ for (int i = 0; i < 10; i++) values[i] = "v" + i;
+
+
+ final Random r = new Random();
+ final List<Exception> exceptions = new LinkedList<Exception>();
+
+ final Runnable store = new Runnable() {
+ public void run() {
+ try {
+ int randomInt = r.nextInt(10);
+ cs.store(new StoredEntry(keys[randomInt], values[randomInt]));
+ } catch (Exception e) {
+ exceptions.add(e);
+ }
+ }
+ };
+
+ final Runnable remove = new Runnable() {
+ public void run() {
+ try {
+ cs.remove(keys[r.nextInt(10)]);
+ } catch (Exception e) {
+ exceptions.add(e);
+ }
+ }
+ };
+
+ final Runnable get = new Runnable() {
+ public void run() {
+ try {
+ int randomInt = r.nextInt(10);
+ StoredEntry se = cs.load(keys[randomInt]);
+ assert se == null || se.getValue().equals(values[randomInt]);
+ cs.loadAll();
+ } catch (Exception e) {
+ exceptions.add(e);
+ }
+ }
+ };
+
+ Thread[] threads = new Thread[numThreads];
+
+ for (int i = 0; i < numThreads; i++) {
+ threads[i] = new Thread(getClass().getSimpleName() + "-" + i) {
+ public void run() {
+ for (int i = 0; i < loops; i++) {
+ store.run();
+ remove.run();
+ get.run();
+ }
+ }
+ };
}
+
+ for (Thread t : threads) t.start();
+ for (Thread t : threads) t.join();
+
+ if (!exceptions.isEmpty()) throw exceptions.get(0);
}
}
Modified: core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java 2009-03-04 11:14:01 UTC (rev 7840)
+++ core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java 2009-03-04 11:32:48 UTC (rev 7841)
@@ -42,6 +42,7 @@
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.Random;
@@ -55,7 +56,7 @@
* @version $Id: $
* @since 1.0
*/
-@Test(groups = "learning", enabled = false, testName = "loader.bdbje.BdbjeLearningTest")
+@Test(groups = "unit", enabled = true, testName = "loader.bdbje.BdbjeLearningTest")
public class BdbjeLearningTest {
String dbHome = TestingUtil.TEST_FILES + "/Horizon-BdbjeLearningTest";
Environment env;
@@ -66,11 +67,9 @@
private static final String STORED_ENTRIES = "storedEntriesDb";
private Database storedEntriesDb;
private StoredMap<Object, StoredEntry> cacheMap;
- final Random r = new Random();
- protected StoredEntry[] entries;
- @BeforeMethod(firstTimeOnly = true)
+ @BeforeMethod
public void setUp() throws Exception {
new File(dbHome).mkdirs();
System.out.println("Opening environment in: " + dbHome);
@@ -98,10 +97,8 @@
cacheMap =
new StoredMap<Object, StoredEntry>(storedEntriesDb,
storedEntryKeyBinding, storedEntryValueBinding, true);
- entries = new StoredEntry[10];
- for (int i = 0; i < entries.length; i++)
- entries[i] = new StoredEntry("k" + i, "v" + i);
+
}
public void testTransactionWorker() throws Exception {
@@ -125,7 +122,7 @@
}
- @AfterMethod(lastTimeOnly = true)
+ @AfterMethod
public void tearDown() throws Exception {
storedEntriesDb.close();
javaCatalog.close();
@@ -665,16 +662,72 @@
assert expected.isEmpty();
}
- @Test(threadPoolSize = 3, invocationCount = 3, timeOut = 10000)
- public void testConcurrency() throws CacheLoaderException {
- for (int i = 0; i < 500; i++) {
- store(entries[r.nextInt(entries.length)]);
- cacheMap.remove(entries[r.nextInt(entries.length)]);
- int index = r.nextInt(entries.length);
- StoredEntry entry = load(entries[index]);
- assert entry == null || entry.getValue().equals(entries[index].getValue());
- loadAll();
+ public void testConcurrency() throws Throwable {
+ int numThreads = 3;
+ final int loops = 500;
+ final String[] keys = new String[10];
+ final String[] values = new String[10];
+ for (int i = 0; i < 10; i++) keys[i] = "k" + i;
+ for (int i = 0; i < 10; i++) values[i] = "v" + i;
+
+
+ final Random r = new Random();
+ final List<Throwable> throwables = new LinkedList<Throwable>();
+
+ final Runnable store = new Runnable() {
+ public void run() {
+ try {
+ int randomInt = r.nextInt(10);
+ store(new StoredEntry(keys[randomInt], values[randomInt]));
+ } catch (Throwable e) {
+ throwables.add(e);
+ }
+ }
+ };
+
+ final Runnable remove = new Runnable() {
+ public void run() {
+ try {
+ cacheMap.remove(keys[r.nextInt(10)]);
+ } catch (Throwable e) {
+ throwables.add(e);
+ }
+ }
+ };
+
+ final Runnable get = new Runnable() {
+ public void run() {
+ try {
+ int randomInt = r.nextInt(10);
+ StoredEntry se = load(keys[randomInt]);
+ assert se == null || se.getValue().equals(values[randomInt]);
+ loadAll();
+ } catch (Throwable e) {
+ throwables.add(e);
+ }
+ }
+ };
+
+ Thread[] threads = new Thread[numThreads];
+
+ for (int i = 0; i < numThreads; i++) {
+ threads[i] = new Thread(getClass().getSimpleName() + "-" + i) {
+ public void run() {
+ for (int i = 0; i < loops; i++) {
+ store.run();
+ remove.run();
+ get.run();
+ }
+ }
+ };
}
+
+ for (Thread t : threads) t.start();
+ for (Thread t : threads) t.join();
+
+ if (!throwables.isEmpty()) throw throwables.get(0);
}
+
+
}
15 years, 9 months
JBoss Cache SVN: r7840 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-04 06:14:01 -0500 (Wed, 04 Mar 2009)
New Revision: 7840
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
Log:
JBCACHE-1487
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2009-03-04 10:14:23 UTC (rev 7839)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2009-03-04 11:14:01 UTC (rev 7840)
@@ -409,10 +409,13 @@
{
return sb.toString();
}
- for (Object n : root.getChildrenDirect())
+ if (started && !usingMvcc)
{
- ((NodeSPI) n).print(sb, indent);
- sb.append("\n");
+ for (Object n : root.getChildrenDirect())
+ {
+ ((NodeSPI) n).print(sb, indent);
+ sb.append("\n");
+ }
}
}
return sb.toString();
@@ -420,11 +423,12 @@
public int getNumberOfLocksHeld()
{
- return numLocks(root);
+ return started ? numLocks(root) : -1;
}
private int numLocks(NodeSPI n)
{
+ if (!started) return 0;
int num = 0;
if (n != null)
{
@@ -451,7 +455,7 @@
}
else
{
- return 0;
+ return -1;
}
}
15 years, 9 months
JBoss Cache SVN: r7839 - core/branches/flat/src/test/java/org/horizon/loader/bdbje.
by jbosscache-commits@lists.jboss.org
Author: adriancole
Date: 2009-03-04 05:14:23 -0500 (Wed, 04 Mar 2009)
New Revision: 7839
Modified:
core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java
Log:
disabled by default
Modified: core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java 2009-03-04 10:10:36 UTC (rev 7838)
+++ core/branches/flat/src/test/java/org/horizon/loader/bdbje/BdbjeLearningTest.java 2009-03-04 10:14:23 UTC (rev 7839)
@@ -42,7 +42,6 @@
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.Random;
@@ -56,7 +55,7 @@
* @version $Id: $
* @since 1.0
*/
-@Test(groups = "unit", enabled = true, testName = "loader.bdbje.BdbjeLearningTest")
+@Test(groups = "learning", enabled = false, testName = "loader.bdbje.BdbjeLearningTest")
public class BdbjeLearningTest {
String dbHome = TestingUtil.TEST_FILES + "/Horizon-BdbjeLearningTest";
Environment env;
@@ -67,9 +66,11 @@
private static final String STORED_ENTRIES = "storedEntriesDb";
private Database storedEntriesDb;
private StoredMap<Object, StoredEntry> cacheMap;
+ final Random r = new Random();
+ protected StoredEntry[] entries;
- @BeforeMethod
+ @BeforeMethod(firstTimeOnly = true)
public void setUp() throws Exception {
new File(dbHome).mkdirs();
System.out.println("Opening environment in: " + dbHome);
@@ -97,8 +98,10 @@
cacheMap =
new StoredMap<Object, StoredEntry>(storedEntriesDb,
storedEntryKeyBinding, storedEntryValueBinding, true);
+ entries = new StoredEntry[10];
+ for (int i = 0; i < entries.length; i++)
+ entries[i] = new StoredEntry("k" + i, "v" + i);
-
}
public void testTransactionWorker() throws Exception {
@@ -122,7 +125,7 @@
}
- @AfterMethod
+ @AfterMethod(lastTimeOnly = true)
public void tearDown() throws Exception {
storedEntriesDb.close();
javaCatalog.close();
@@ -662,72 +665,16 @@
assert expected.isEmpty();
}
- public void testConcurrency() throws Throwable {
- int numThreads = 3;
- final int loops = 500;
- final String[] keys = new String[10];
- final String[] values = new String[10];
- for (int i = 0; i < 10; i++) keys[i] = "k" + i;
- for (int i = 0; i < 10; i++) values[i] = "v" + i;
-
-
- final Random r = new Random();
- final List<Throwable> throwables = new LinkedList<Throwable>();
-
- final Runnable store = new Runnable() {
- public void run() {
- try {
- int randomInt = r.nextInt(10);
- store(new StoredEntry(keys[randomInt], values[randomInt]));
- } catch (Throwable e) {
- throwables.add(e);
- }
- }
- };
-
- final Runnable remove = new Runnable() {
- public void run() {
- try {
- cacheMap.remove(keys[r.nextInt(10)]);
- } catch (Throwable e) {
- throwables.add(e);
- }
- }
- };
-
- final Runnable get = new Runnable() {
- public void run() {
- try {
- int randomInt = r.nextInt(10);
- StoredEntry se = load(keys[randomInt]);
- assert se == null || se.getValue().equals(values[randomInt]);
- loadAll();
- } catch (Throwable e) {
- throwables.add(e);
- }
- }
- };
-
- Thread[] threads = new Thread[numThreads];
-
- for (int i = 0; i < numThreads; i++) {
- threads[i] = new Thread(getClass().getSimpleName() + "-" + i) {
- public void run() {
- for (int i = 0; i < loops; i++) {
- store.run();
- remove.run();
- get.run();
- }
- }
- };
+ @Test(threadPoolSize = 3, invocationCount = 3, timeOut = 10000)
+ public void testConcurrency() throws CacheLoaderException {
+ for (int i = 0; i < 500; i++) {
+ store(entries[r.nextInt(entries.length)]);
+ cacheMap.remove(entries[r.nextInt(entries.length)]);
+ int index = r.nextInt(entries.length);
+ StoredEntry entry = load(entries[index]);
+ assert entry == null || entry.getValue().equals(entries[index].getValue());
+ loadAll();
}
-
- for (Thread t : threads) t.start();
- for (Thread t : threads) t.join();
-
- if (!throwables.isEmpty()) throw throwables.get(0);
}
-
-
}
15 years, 9 months
JBoss Cache SVN: r7838 - core/branches/flat/src/test/java/org/horizon/loader.
by jbosscache-commits@lists.jboss.org
Author: adriancole
Date: 2009-03-04 05:10:36 -0500 (Wed, 04 Mar 2009)
New Revision: 7838
Modified:
core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
Log:
updated testConcurrency to use testNG thread pool
Modified: core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-03-04 09:32:20 UTC (rev 7837)
+++ core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-03-04 10:10:36 UTC (rev 7838)
@@ -23,7 +23,6 @@
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Set;
@@ -36,11 +35,16 @@
protected abstract CacheStore createCacheStore() throws Exception;
protected CacheStore cs;
+ final Random r = new Random();
+ protected StoredEntry[] entries;
- @BeforeMethod
+ @BeforeMethod(firstTimeOnly = true)
public void setUp() throws Exception {
try {
cs = createCacheStore();
+ entries = new StoredEntry[10];
+ for (int i = 0; i < entries.length; i++)
+ entries[i] = new StoredEntry("k" + i, "v" + i);
} catch (Exception e) {
//in IDEs this won't be printed which makes debugging harder
e.printStackTrace();
@@ -48,7 +52,7 @@
}
}
- @AfterMethod
+ @AfterMethod(lastTimeOnly = true)
public void tearDown() throws CacheLoaderException {
if (cs != null) {
cs.clear();
@@ -61,7 +65,7 @@
public void assertNoLocksHeld() {
//doesn't really make sense to add a subclass for this check only
if (cs instanceof LockSupportCacheStore) {
- assert ((LockSupportCacheStore)cs).getTotalLockCount() == 0;
+ assert ((LockSupportCacheStore) cs).getTotalLockCount() == 0;
}
}
@@ -433,69 +437,15 @@
assert clc.getClassName().equals(cs.getClass().getName()) : "Cache loader doesn't provide a proper configuration type that is capable of creating the loader!";
}
- public void testConcurrency() throws Exception {
- int numThreads = 3;
- final int loops = 500;
- final String[] keys = new String[10];
- final String[] values = new String[10];
- for (int i = 0; i < 10; i++) keys[i] = "k" + i;
- for (int i = 0; i < 10; i++) values[i] = "v" + i;
-
-
- final Random r = new Random();
- final List<Exception> exceptions = new LinkedList<Exception>();
-
- final Runnable store = new Runnable() {
- public void run() {
- try {
- int randomInt = r.nextInt(10);
- cs.store(new StoredEntry(keys[randomInt], values[randomInt]));
- } catch (Exception e) {
- exceptions.add(e);
- }
- }
- };
-
- final Runnable remove = new Runnable() {
- public void run() {
- try {
- cs.remove(keys[r.nextInt(10)]);
- } catch (Exception e) {
- exceptions.add(e);
- }
- }
- };
-
- final Runnable get = new Runnable() {
- public void run() {
- try {
- int randomInt = r.nextInt(10);
- StoredEntry se = cs.load(keys[randomInt]);
- assert se == null || se.getValue().equals(values[randomInt]);
- cs.loadAll();
- } catch (Exception e) {
- exceptions.add(e);
- }
- }
- };
-
- Thread[] threads = new Thread[numThreads];
-
- for (int i = 0; i < numThreads; i++) {
- threads[i] = new Thread(getClass().getSimpleName() + "-" + i) {
- public void run() {
- for (int i = 0; i < loops; i++) {
- store.run();
- remove.run();
- get.run();
- }
- }
- };
+ @Test(threadPoolSize = 3, invocationCount = 3, timeOut = 10000)
+ public void testConcurrency() throws CacheLoaderException {
+ for (int i = 0; i < 500; i++) {
+ cs.store(entries[r.nextInt(entries.length)]);
+ cs.remove(entries[r.nextInt(entries.length)]);
+ int index = r.nextInt(entries.length);
+ StoredEntry entry = cs.load(entries[index]);
+ assert entry == null || entry.getValue().equals(entries[index].getValue());
+ cs.loadAll();
}
-
- for (Thread t : threads) t.start();
- for (Thread t : threads) t.join();
-
- if (!exceptions.isEmpty()) throw exceptions.get(0);
}
}
15 years, 9 months
JBoss Cache SVN: r7837 - core/branches/flat/src/test/java/org/horizon/statetransfer.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-03-04 04:32:20 -0500 (Wed, 04 Mar 2009)
New Revision: 7837
Modified:
core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferCacheLoaderFunctionalTest.java
Log:
Disabled NBST test
Modified: core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferCacheLoaderFunctionalTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferCacheLoaderFunctionalTest.java 2009-03-04 09:16:37 UTC (rev 7836)
+++ core/branches/flat/src/test/java/org/horizon/statetransfer/StateTransferCacheLoaderFunctionalTest.java 2009-03-04 09:32:20 UTC (rev 7837)
@@ -10,7 +10,7 @@
import org.horizon.test.TestingUtil;
import org.testng.annotations.Test;
-@Test(groups = "functional", testName = "statetransfer.StateTransferCacheLoaderFunctionalTest")
+@Test(groups = "functional", testName = "statetransfer.StateTransferCacheLoaderFunctionalTest", enabled = false)
public class StateTransferCacheLoaderFunctionalTest extends StateTransferFunctionalTest {
int id;
ThreadLocal<Boolean> sharedCacheLoader = new ThreadLocal<Boolean>() {
15 years, 9 months