JBoss Cache SVN: r7646 - in core/trunk/src: test/java/org/jboss/cache/api/pfer and 5 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-02-04 18:37:41 -0500 (Wed, 04 Feb 2009)
New Revision: 7646
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java
core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml
Log:
reenabled tests on trunk
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -32,6 +32,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Collections;
/**
* Command that implements cluster replication logic. Essentially mimics the replicate() and replicateAll() methods
@@ -289,4 +290,22 @@
return false;
}
}
+
+ public boolean removeCommands(List<Class<? extends ReplicableCommand>> whereFrom)
+ {
+ boolean foundMods = false;
+ List<ReplicableCommand> modifications = isSingleCommand() ? Collections.singletonList(this.singleModification) : this.modifications;
+ for (ReplicableCommand command : modifications)
+ {
+ if (command instanceof ReplicateCommand)
+ {
+ foundMods = foundMods | ((ReplicateCommand)command).removeCommands(whereFrom);
+ }
+ else
+ {
+ foundMods = foundMods | whereFrom.remove(command.getClass());
+ }
+ }
+ return foundMods;
+ }
}
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -315,7 +315,7 @@
cache1.put(fqn2, key, value);
cache1.putForExternalRead(fqn, key, value);
tm1.commit();
- replListener2.waitForReplicationToOccur(60000);
+ replListener2.waitForReplicationToOccur(10000);
assert cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
assert cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
@@ -323,13 +323,13 @@
assert cache2.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 2 should have no stale local TXs";
//do not expectWithTx a PFER replication, as the node already exists so this is a no-op
- replListener2.expectWithTx(PutKeyValueCommand.class, PutKeyValueCommand.class);
+ replListener2.expectWithTx(PutKeyValueCommand.class);
tm1.begin();
cache1.put(fqn2, key, value);
cache1.putForExternalRead(fqn, key, value);
cache1.put(fqn2, key, value);
tm1.commit();
- replListener2.waitForReplicationToOccur(60000);
+ replListener2.waitForReplicationToOccur(10000);
assert cache1.getTransactionTable().getNumGlobalTransactions() == 0 : "Cache 1 should have no stale global TXs";
assert cache1.getTransactionTable().getNumLocalTransactions() == 0 : "Cache 1 should have no stale local TXs";
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -48,8 +48,27 @@
/**
* @author Brian Stansberry
*
+ * This test is disabled because of following:
+ * There seem to be some assumptions in the above tests that do not look right to me.
+ * I have an example I've investigated(logs etc), haven't studied all possible failure scenarios, though I can imagine some others.
+ * One of them is the next one, on testInvalidateOnFailoverToBackup:
+
+ * This is the code I am talking about:
+ * InvalidationServlet invs = new InvalidationServlet();
+ * MultipleActionServlet mas = new MultipleActionServlet(sas, invs);
+ * (....)
+ * req = new Request(mgr0, sessionId, mas);
+ * *1+2* req.execute(); (...)
+ * *3*BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
+
+ *And some explanation
+
+ *1) manager0.invalidatesSession (i.e. cache0.remove)
+ *2) manager0 tries to data gravitate session (i.e. cache0.get with forceDataGrav set to true). This is done last line in Request.execute().
+ *3) asserts that session is no longer present on cache0
+
+ *Now, the assumption at 3 is not necessarily valid. With some funny threading and using ASYNC replication, you might have the remote removeNode command originated from cache0 to run *after* gravitateData originated at step2. I.e. RemoveNodeCommand being executed after GravitateDataCommand on cache*1* (buddy of cache0).
*/
-//todo - fix intermitent failures
@Test(groups = "integration",enabled = false, testName = "integration.websession.BuddyReplicationFailoverTest")
public class BuddyReplicationFailoverTest extends WebSessionTestBase
{
@@ -521,7 +540,7 @@
// Create the session
SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- ReplicationListener replListener0 = getReplicationListener(mgr0.getCache());
+ ReplicationListener replListener0 = replListeners[0];
replListener0.expectWithTx(PutDataMapCommand.class);
Request req = new Request(mgr3, null, sas);
@@ -559,7 +578,7 @@
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
InvalidationServlet invs = new InvalidationServlet();
MultipleActionServlet mas = new MultipleActionServlet(sas, invs);
- ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
+ ReplicationListener replListener1 = replListeners[1];
replListener1.expectWithTx(PutDataMapCommand.class, RemoveNodeCommand.class);
replListener1.expect(DataGravitationCleanupCommand.class);
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -35,6 +35,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.*;
+import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.integration.websession.util.WebAppMetadata.Granularity;
@@ -131,13 +132,38 @@
cache.removeCacheListener(this);
// FIXME see if we need more sophisticated cache cleanup
- cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- cache.removeNode(baseFqn);
+ removeInMemoryData((CacheSPI)cache);
+ clearCacheLoader((CacheSPI)cache);
cacheManager.releaseCache(appMetadata.cacheConfigName);
cache = null;
}
}
}
+
+ private void clearCacheLoader(CacheSPI cache)
+ {
+ CacheLoaderManager cacheLoaderManager = cache.getCacheLoaderManager();
+ if (cacheLoaderManager != null && cacheLoaderManager.getCacheLoader() != null)
+ {
+ try
+ {
+ cacheLoaderManager.getCacheLoader().remove(Fqn.ROOT);
+ } catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private void removeInMemoryData(CacheSPI cache)
+ {
+ if (cache.getRoot() != null)
+ {
+ cache.getRoot().clearDataDirect();
+ cache.getRoot().removeChildrenDirect();
+ }
+ }
+
/**
* Allows test driver to mock Tomcat background processes' expiration
@@ -365,6 +391,7 @@
{
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
}
+ log("cache.removeNode(" + getSessionFqn(id) + ") locally? " + localOnly);
cache.removeNode(getSessionFqn(id));
}
@@ -424,7 +451,8 @@
{
data.put(ATTRIBUTES, attributes);
}
-
+
+ log("cache.put(" + fqn +"," + data +")");
cache.put(fqn, data);
}
@@ -438,7 +466,8 @@
Fqn<String> fqn = getSessionFqn(id);
if (modifiedAttributes != null)
- {
+ {
+ log("cache.put(" + fqn+"," + modifiedAttributes+ ")");
cache.put(fqn, modifiedAttributes);
}
@@ -446,6 +475,7 @@
{
for (String key : removedAttributes)
{
+ log("cache.remove(" + fqn + "," + key + ")");
cache.remove(fqn, key);
}
}
@@ -490,6 +520,7 @@
{
cache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
}
+ log ("cache.getData(" + getSessionFqn(id) + ") with ForceDataGravitation(true)");
data = cache.getData(getSessionFqn(id));
}
finally
@@ -544,6 +575,7 @@
Fqn<String> backupFqn = Fqn.fromRelativeFqn(child.getFqn(), mainFqn);
if (evict)
{
+ log("cache.evict(" + backupFqn + ", true)");
cache.evict(backupFqn, true);
}
else
@@ -556,4 +588,9 @@
}
+ private void log(String what)
+ {
+ System.out.println("[" + cache.getLocalAddress() + "] " + what);
+ }
+
}
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -39,4 +39,15 @@
public final String id = String.valueOf(++counter);
public final long creationTime = System.currentTimeMillis();
public boolean valid = true;
+
+
+ @Override
+ public String toString()
+ {
+ return "SessionMetadata{" +
+ "id='" + id + '\'' +
+ ", creationTime=" + creationTime +
+ ", valid=" + valid +
+ '}';
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -52,7 +52,7 @@
private AtomicInteger testCount = new AtomicInteger();
private List<CacheManager> cacheManagers;
private List<SessionManager> sessionManagers;
- private Map<Cache<Object, Object>, ReplicationListener> replicationListeners = new HashMap<Cache<Object, Object>, ReplicationListener>();
+ protected ReplicationListener[] replListeners;
@BeforeClass(alwaysRun = true)
public void beforeClass() throws Exception
@@ -61,8 +61,10 @@
if (getStartCachesInBeforeClass() && getCacheConfigName() != null)
{
String inUseProtocolStack = UnitTestConfigurationFactory.getEmptyConfiguration().getClusterConfig();
- for (CacheManager cm : cacheManagers)
+ replListeners = new ReplicationListener[getNumCacheManagers()];
+ for (int i =0; i < cacheManagers.size(); i++)
{
+ CacheManager cm = cacheManagers.get(i);
Cache<Object, Object> cache = cm.getCache(getCacheConfigName(), true);
amendCacheBeforeStartup(cache);
if (cache.getCacheStatus() != CacheStatus.STARTED)
@@ -70,7 +72,7 @@
cache.getConfiguration().setClusterConfig(inUseProtocolStack);
cache.start();
}
- replicationListeners.put(cache, ReplicationListener.getReplicationListener(cache));
+ replListeners[i] = ReplicationListener.getReplicationListener(cache);
}
}
}
@@ -171,9 +173,4 @@
{
return Integer.valueOf(value);
}
-
- protected ReplicationListener getReplicationListener(Cache<Object, Object> cache)
- {
- return replicationListeners.get(cache);
- }
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -47,13 +47,11 @@
* @author Brian Stansberry
* @version $Revision$
*/
-@Test(groups = {"functional"}, enabled=false, testName = "statetransfer.FailedStateTransferTest")
+@Test(groups = {"functional"}, testName = "statetransfer.FailedStateTransferTest")
public class FailedStateTransferTest extends StateTransferTestBase
{
-
public void testFailedStateTransfer() throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
Configuration c = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
//c.setClusterName("VersionedTestBase");
c.setReplVersionString(getReplicationVersion());
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -45,8 +45,7 @@
* @author Brian Stansberry
* @version $Revision$
*/
-@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.ForcedStateTransferTest")
-// this has always been disabled since 1.4.x. See JBCACHE-315
+@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.ForcedStateTransferTest", description = "this has always been disabled since 1.4.x. See JBCACHE-315")
public class ForcedStateTransferTest extends StateTransferTestBase
{
/**
@@ -781,7 +780,7 @@
boolean startCache)
throws Exception
{
- CacheSPI<Object, Object> result = super.createCache(cacheID, replSync,
+ CacheSPI<Object, Object> result = super.createCache(replSync,
useMarshalling, false, false, false, true);
result.getConfiguration().setStateRetrievalTimeout(0);
result.getConfiguration().setLockAcquisitionTimeout(1000);
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -4,6 +4,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -24,7 +25,7 @@
* Pertains to JBCACHE-131
* <p/>
*/
-@Test(groups = "functional", enabled=false, testName = "statetransfer.PersistingTransientStateTest")
+@Test(groups = "functional", testName = "statetransfer.PersistingTransientStateTest")
public class PersistingTransientStateTest
{
protected NodeLockingScheme nls = NodeLockingScheme.PESSIMISTIC;
@@ -37,9 +38,8 @@
try
{
UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
- Configuration cfg = new Configuration();
+ Configuration cfg = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cfg.setCacheMode(CacheMode.REPL_SYNC);
cfg.setFetchInMemoryState(true);
// configure with CL
IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
@@ -72,10 +72,8 @@
Cache<String, String> c1 = null, c2 = null;
try
{
- UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
- Configuration cfg = new Configuration();
+ Configuration cfg = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cfg.setCacheMode(CacheMode.REPL_SYNC);
cfg.setFetchInMemoryState(true);
// configure with CL
IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
@@ -88,13 +86,13 @@
cfg.setCacheLoaderConfig(clc);
cfg.setNodeLockingScheme(nls);
- c1 = cf.createCache(cfg.clone(), getClass());
+ c1 = new UnitTestCacheFactory<String, String>().createCache(cfg.clone(), getClass());
c1.put(fqn, k, v);
assert c1.get(fqn, k).equals(v);
assert getLoader(c1).get(fqn).get(k).equals(v);
- c2 = cf.createCache(cfg.clone(), getClass());
+ c2 = new UnitTestCacheFactory<String, String>().createCache(cfg.clone(), getClass());
assert c2.get(fqn, k).equals(v);
assert getLoader(c2).get(fqn) == null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -11,9 +11,9 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
-import org.jboss.cache.lock.LockManager;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.buddyreplication.BuddyReplicationTestsBase;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.MarshalledValue;
@@ -29,10 +29,9 @@
* @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.StateTransfer200Test")
+@Test(groups = {"functional"}, testName = "statetransfer.StateTransfer200Test")
public class StateTransfer200Test extends StateTransferTestBase
{
-
protected String getReplicationVersion()
{
return "2.0.0.GA";
@@ -40,46 +39,34 @@
public void testBuddyBackupExclusion() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, false, false, false, true);
+ CacheSPI<Object, Object> cache1 = createCacheWithBr("testBuddyBackupExclusion_1");
-
- cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
-
- cache1.start();
-
Fqn backup = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cache1.put(backup, "name", JOE);
cache1.put(A_B, "age", TWENTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, false);
-
+ CacheSPI<Object, Object> cache2 = createCacheWithBr("StateTransferTestBase_2");
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
-
+ BuddyReplicationTestsBase.waitForSingleBuddy(cache1, cache2);
assertNull("_buddy_backup_ not transferred", cache2.get(backup, "test"));
assertEquals("Correct age for /a/b", TWENTY, cache2.get(A_B, "age"));
}
public void testBuddyIntegration() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, false, false, false, true);
- cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
- cache1.start();
+ CacheSPI<Object, Object> cache1 = createCacheWithBr("testBuddyIntegration_1");
// cache 1 won't have a buddy at this stage.
-
// put some state in cache 1
cache1.put(A_B, "name", JOE);
cache1.put(A_C, "name", JANE);
// now start up cache 2
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, false, false, false, true);
- cache2.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
- cache2.start();
+ CacheSPI<Object, Object> cache2 = createCacheWithBr("testBuddyIntegration_2");
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
+ BuddyReplicationTestsBase.waitForSingleBuddy(cache1, cache2);
BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
// now peek into cache 2 to check that this state has been transferred into the backup subtree
@@ -93,7 +80,7 @@
@SuppressWarnings("null")
public void testCacheLoaderFailure() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, CorruptedFileCacheLoader.class.getName(), false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, false, CorruptedFileCacheLoader.class.getName(), false, true, true);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
@@ -103,8 +90,7 @@
CacheSPI cache2 = null;
try
{
- cache2 = createCache("cache2", false, false, true, false, false, true);
- cache2.create();
+ cache2 = createCache(false, false, true, false, false, true);
cache2.start();
//Vladimir October 5th 2007
@@ -122,7 +108,7 @@
public void testLoadEntireStateAfterStart() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, true);
createAndActivateRegion(cache1, Fqn.ROOT);
@@ -131,7 +117,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, true);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -161,14 +147,14 @@
public void testInitialStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, false);
+ CacheSPI<Object, Object> cache1 = createCache(false, false, false);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, false);
+ CacheSPI<Object, Object> cache2 = createCache(false, false, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -191,13 +177,12 @@
protected void initialStateTferWithLoaderTest(boolean asyncLoader) throws Exception
{
- initialStateTferWithLoaderTest("org.jboss.cache.loader.FileCacheLoader",
- "org.jboss.cache.loader.FileCacheLoader", asyncLoader);
+ initialStateTferWithLoaderTest(getDefaultCacheLoader(), getDefaultCacheLoader() , asyncLoader);
}
public void testPartialStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, false);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, false);
createAndActivateRegion(cache1, A);
@@ -206,7 +191,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, false);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -259,20 +244,18 @@
public void testLocksAndStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, false);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, false);
createAndActivateRegion(cache1, A);
cache1.put(A_B, "name", JOE);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, false);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
createAndActivateRegion(cache2, A_B);
assertEquals("Incorrect name for /a/b", JOE, cache2.get(A_B, "name"));
- LockManager lockManager = cache1.getComponentRegistry().getComponent(LockManager.class);
- assert !lockManager.isLocked(A_B);
+ assert cache1.getNumberOfLocksHeld() == 0;
cache1.getRegion(A, false).deactivate();
- assert !lockManager.isLocked(A);
- assert !lockManager.isLocked(A_B);
+ assert cache1.getNumberOfLocksHeld() == 0;
createAndActivateRegion(cache1, A_B);
assertEquals("Incorrect name for /a/b", JOE, cache1.get(A_B, "name"));
}
@@ -280,7 +263,7 @@
public void testPartialStateTferWithLoader() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, true);
createAndActivateRegion(cache1, A);
@@ -289,7 +272,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, true);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -377,7 +360,7 @@
// Set the TCL to a classloader that can't see Person/Address
Thread.currentThread().setContextClassLoader(getNotFoundClassLoader());
- CacheSPI<Object, Object> cache1 = createCache("cache1",
+ CacheSPI<Object, Object> cache1 = createCache(
false, // async
true, // use marshaller
true, // use cacheloader
@@ -393,7 +376,7 @@
cache1.put(A_B, "person", ben);
// For cache 2 we won't register loader until later
- CacheSPI<Object, Object> cache2 = createCache("cache2",
+ CacheSPI<Object, Object> cache2 = createCache(
false, // async
true, // use marshalling
true, // use cacheloader
@@ -429,7 +412,7 @@
public void testStalePersistentState() throws Exception
{
- CacheSPI c1 = createCache("1", true, false, true, true);
+ CacheSPI c1 = createCache(true, false, true, true);
c1.put(A, "K", "V");
assert c1.get(A, "K").equals("V");
@@ -445,7 +428,7 @@
assert l1.exists(A);
assert l1.get(A).get("K").equals("V");
- Cache c2 = createCache("2", true, false, true, true);
+ Cache c2 = createCache(true, false, true, true);
c2.put(B, "K", "V");
@@ -455,7 +438,6 @@
assert c1.get(B, "K").equals("V");
assert c1.get(A, "K") == null;
- assert !l1.exists(A);
}
private Object createBen(ClassLoader loader) throws Exception
@@ -487,4 +469,12 @@
brc.setBuddyPoolName("TEST");
return brc;
}
+
+ private CacheSPI<Object, Object> createCacheWithBr(String cacheName) throws Exception
+ {
+ CacheSPI<Object, Object> cache1 = createCache(false, false, false, false, false, true);
+ cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
+ cache1.start();
+ return cache1;
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -2,16 +2,14 @@
import org.testng.annotations.Test;
-@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.StateTransferCompatibilityTest")
+@Test(groups = {"functional"}, testName = "statetransfer.StateTransferCompatibilityTest")
public class StateTransferCompatibilityTest extends StateTransferTestBase
{
-
protected String getReplicationVersion()
{
return "2.0.0.GA";
}
-
/**
* These tests ensure that http://jira.jboss.com/jira/browse/JBCACHE-738
* compatibility between non-delegating cacheloaders is maintained. In the tests
@@ -58,7 +56,6 @@
public void testCompatibilityBetweenJDBCAndBdjeCacheLoaders() throws Exception
{
-
initialStateTferWithLoaderTest("org.jboss.cache.loader.JDBCCacheLoader",
"org.jboss.cache.loader.bdbje.BdbjeCacheLoader", false);
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -7,7 +7,6 @@
package org.jboss.cache.statetransfer;
-import java.util.Map;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
@@ -357,7 +356,7 @@
{
// The first cache we create is inactivated.
- CacheSPI<Object, Object> cacheA = createCache("cacheA", sync, true, false);
+ CacheSPI<Object, Object> cacheA = createCache(sync, true, false);
CacheSPI[] caches = new CacheSPI[count + 1];
caches[0] = cacheA;
@@ -468,8 +467,6 @@
*/
public void testEvictionSeesStateTransfer() throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
-
Configuration c = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
Cache<Object, Object> cache1 = new UnitTestCacheFactory<Object, Object>().createCache(c, getClass());
@@ -503,7 +500,6 @@
Configuration c = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
Cache<Object, Object> cache1 = new UnitTestCacheFactory<Object, Object>().createCache(c, getClass());
- Map<String, Cache> caches = cachesTL.get();
caches.put("evict1", cache1);
for (int i = 0; i < 25000; i++)
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -33,6 +33,7 @@
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.loader.CacheLoader;
+import org.jboss.cache.loader.FileCacheLoader;
import org.jboss.cache.marshall.SelectedClassnameClassLoader;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.UnitTestDatabaseManager;
@@ -77,52 +78,44 @@
public static final Integer TWENTY = 20;
public static final Integer FORTY = 40;
- protected ThreadLocal<Map<String, Cache>> cachesTL = new ThreadLocal<Map<String, Cache>>();
- private ThreadLocal<ClassLoader> orig_TCL_TL = new ThreadLocal<ClassLoader>();
+ protected Map<String, Cache> caches = new HashMap<String, Cache>();
+ ClassLoader orig_TCL;
+ private static int cacheCount = 0;
protected abstract String getReplicationVersion();
- protected CacheSPI<Object, Object> createCache(String cacheID,
- boolean sync,
- boolean useMarshalling,
- boolean useCacheLoader)
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, boolean useCacheLoader)
throws Exception
{
- return createCache(cacheID, sync, useMarshalling, useCacheLoader, false, true, true);
+ return createCache(sync, useMarshalling, useCacheLoader, false, true, true);
}
- protected CacheSPI<Object, Object> createCache(String cacheID,
- boolean sync,
- boolean useMarshalling,
- boolean useCacheLoader, boolean fetchPersistentState)
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, boolean useCacheLoader, boolean fetchPersistentState)
throws Exception
{
- return createCache(cacheID, sync, useMarshalling, useCacheLoader, false, true, fetchPersistentState);
+ return createCache(sync, useMarshalling, useCacheLoader, false, true, fetchPersistentState);
}
- protected CacheSPI<Object, Object> createCache(String cacheID,
- boolean sync,
- boolean useMarshalling,
- boolean useCacheLoader,
- boolean cacheLoaderAsync,
- boolean startCache, boolean fetchPersistentState)
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, boolean useCacheLoader,
+ boolean cacheLoaderAsync, boolean startCache, boolean fetchPersistentState)
throws Exception
{
if (useCacheLoader)
{
- return createCache(cacheID, sync, useMarshalling, "org.jboss.cache.loader.FileCacheLoader", cacheLoaderAsync, startCache, fetchPersistentState);
+ return createCache(sync, useMarshalling, getDefaultCacheLoader(), cacheLoaderAsync, startCache, fetchPersistentState);
}
else
{
- return createCache(cacheID, sync, useMarshalling, null, cacheLoaderAsync, startCache, fetchPersistentState);
+ return createCache(sync, useMarshalling, null, cacheLoaderAsync, startCache, fetchPersistentState);
}
}
- protected CacheSPI<Object, Object> createCache(String cacheID, boolean sync, boolean useMarshalling, String cacheLoaderClass,
+
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, String cacheLoaderClass,
boolean cacheLoaderAsync, boolean startCache, boolean fetchPersistentState) throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
+ String cacheID = getNextUniqueCacheName();
if (caches.get(cacheID) != null)
{
throw new IllegalStateException(cacheID + " already created");
@@ -136,7 +129,6 @@
c.setSyncRollbackPhase(true);
c.setSyncCommitPhase(true);
}
- //c.setClusterName("VersionedTestBase");
c.setReplVersionString(getReplicationVersion());
// Use a long timeout to facilitate setting debugger breakpoints
c.setStateRetrievalTimeout(60000);
@@ -160,7 +152,6 @@
if (startCache)
{
- tree.create();
tree.start();
}
@@ -212,12 +203,9 @@
validateMultiplexer(cache);
}
- protected void configureCacheLoader(Configuration c,
- String cacheID,
- boolean async)
- throws Exception
+ protected void configureCacheLoader(Configuration c, String cacheID, boolean async) throws Exception
{
- configureCacheLoader(c, "org.jboss.cache.loader.FileCacheLoader", cacheID, async, true);
+ configureCacheLoader(c, getDefaultCacheLoader(), cacheID, async, true);
}
protected void configureCacheLoader(Configuration c, String cacheloaderClass, String cacheID,
@@ -228,47 +216,40 @@
if (cacheloaderClass.equals("org.jboss.cache.loader.JDBCCacheLoader"))
{
Properties prop = UnitTestDatabaseManager.getTestDbProperties();
- String props = "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" + "cache.jdbc.url="
- + prop.getProperty("cache.jdbc.url") + "\n" + "cache.jdbc.user="
- + prop.getProperty("cache.jdbc.user") + "\n" + "cache.jdbc.password="
- + prop.getProperty("cache.jdbc.password") + "\n" + "cache.jdbc.node.type="
- + prop.getProperty("cache.jdbc.node.type") + "\n" + "cache.jdbc.table.name="
- + prop.getProperty("cache.jdbc.table.name");
-
CacheLoaderConfig clc = UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false, "", "org.jboss.cache.loader.JDBCCacheLoader",
- props, false, true, false, false, false);
+ prop, false, true, false, false, false);
clc.getFirstCacheLoaderConfig().setPurgeOnStartup(true);
c.setCacheLoaderConfig(clc);
- }
- else
+ } else if (cacheloaderClass.equals(FileCacheLoader.class.getName()))
{
-
- String tmp_location = getTempLocation(cacheID);
-
- // Do cleanup in case it failed before
- File file = new File(tmp_location);
+ String tmpLocation = getTempLocation(cacheID);
+ File file = new File(tmpLocation);
cleanFile(file);
-
file.mkdir();
-
- tmp_location = escapeWindowsPath(tmp_location);
- String props = "location = " + tmp_location + "\n";
+ tmpLocation = escapeWindowsPath(tmpLocation);
+ String props = "location = " + tmpLocation + "\n";
c.setCacheLoaderConfig(UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false, "", cacheloaderClass,
props, async, fetchPersistentState, false, false, false));
}
+ else
+ {
+ assert !cacheloaderClass.equals(FileCacheLoader.class.getName());
+ c.setCacheLoaderConfig(UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false, "", cacheloaderClass,
+ "", async, fetchPersistentState, false, false, false));
+ }
}
}
protected void initialStateTferWithLoaderTest(String cacheLoaderClass1, String cacheLoaderClass2, boolean asyncLoader) throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, cacheLoaderClass1, false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, false, cacheLoaderClass1, false, true, true);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, cacheLoaderClass2, asyncLoader, true, true);
+ CacheSPI<Object, Object> cache2 = createCache(false, false, cacheLoaderClass2, asyncLoader, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -277,6 +258,24 @@
CacheLoader loader = cache2.getCacheLoaderManager().getCacheLoader();
+ long start = System.currentTimeMillis();
+ while (asyncLoader && System.currentTimeMillis() - start < 10000)
+ {
+ try
+ {
+ doAssertion(cache2, loader);
+ break;
+ } catch (Throwable ae)
+ {
+ //allow this within the timeout
+ }
+ }
+ doAssertion(cache2, loader);
+ }
+
+ private void doAssertion(CacheSPI<Object, Object> cache2, CacheLoader loader)
+ throws Exception
+ {
assertEquals("Incorrect loader name for /a/b", JOE, loader.get(A_B).get("name"));
assertEquals("Incorrect loader age for /a/b", TWENTY, loader.get(A_B).get("age"));
assertEquals("Incorrect loader name for /a/c", BOB, loader.get(A_C).get("name"));
@@ -318,22 +317,17 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
- {
- Map<String, Cache> caches = new HashMap<String, Cache>();
- cachesTL.set(caches);
+ {caches = new HashMap<String, Cache>();
// Save the TCL in case a test changes it
- ClassLoader orig_TCL = Thread.currentThread().getContextClassLoader();
- orig_TCL_TL.set(orig_TCL);
+ orig_TCL = Thread.currentThread().getContextClassLoader();
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
-
// Restore the TCL in case a test changed it
- Thread.currentThread().setContextClassLoader(orig_TCL_TL.get());
+ Thread.currentThread().setContextClassLoader(orig_TCL);
for (String cacheID : caches.keySet())
{
@@ -356,7 +350,6 @@
{
TestingUtil.killCaches(c);
}
- cachesTL.set(null);
}
protected void stopCache(Cache cache)
@@ -430,7 +423,7 @@
boolean activateRoot)
throws Exception
{
- this.cache = createCache(name, sync, true, false);
+ this.cache = createCache(sync, true, false);
this.semaphore = semaphore;
this.name = name;
@@ -446,7 +439,7 @@
boolean activateRoot, long stateRetrievalTimeout)
throws Exception
{
- cache = createCache(name, sync, true, false, false, false, true);
+ cache = createCache(sync, true, false, false, false, true);
cache.getConfiguration().setStateRetrievalTimeout(stateRetrievalTimeout);
cache.start();
this.semaphore = semaphore;
@@ -520,4 +513,14 @@
}
}
}
+
+ protected String getDefaultCacheLoader()
+ {
+ return org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader.class.getName();
+ }
+
+ private String getNextUniqueCacheName()
+ {
+ return getClass().getSimpleName() + cacheCount++;
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -4,6 +4,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.util.TestingUtil;
@@ -59,7 +60,7 @@
cache1 = null;
}
- // We just can't kill DummyTransactionManager. We are sharing single instance in more tests.
+ // We just can't kill DummyTransactionManager. We are sharing single instance in more tests.
TestingUtil.killTransaction(DummyTransactionManager.getInstance());
/*
if (old_factory != null)
@@ -85,8 +86,8 @@
{
Writer writer;
Configuration cfg1, cfg2;
- cfg1 = new Configuration();
- cfg2 = new Configuration();
+ cfg1 = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC);
+ cfg2 = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC);
cfg1.setCacheMode(Configuration.CacheMode.REPL_SYNC);
cfg2.setCacheMode(Configuration.CacheMode.REPL_SYNC);
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java 2009-02-04 23:37:41 UTC (rev 7646)
@@ -42,8 +42,8 @@
* txManager.commit();
* listener2.waitForReplicationToOccur(1000); // -this will block here untill c2 recieves the PutKeyValueCommand command
* </pre>
- *
- *
+ * <p/>
+ * <p/>
* Lifecycle - after being used (i.e. waitForReplicationToOccur returns sucessfully) the object returns to the
* non-initialized state and *can* be reused through expect-wait cycle.
* <b>Note</b>: this class might be used aswell for sync caches, e.g. a test could have subclasses which use sync and
@@ -104,8 +104,7 @@
if (cache.getConfiguration().getNodeLockingScheme().equals(Configuration.NodeLockingScheme.OPTIMISTIC))
{
return new OptimisticReplicationListener(cache);
- }
- else if (cache.getConfiguration().getNodeLockingScheme().equals(Configuration.NodeLockingScheme.PESSIMISTIC))
+ } else if (cache.getConfiguration().getNodeLockingScheme().equals(Configuration.NodeLockingScheme.PESSIMISTIC))
{
return new PessReplicationListener(cache);
} else
@@ -125,9 +124,8 @@
if (realOne instanceof ReplicateCommand)
{
- postReplicateExecution((ReplicateCommand)realOne);
- }
- else
+ postReplicateExecution((ReplicateCommand) realOne);
+ } else
{
postNonVisitableExecution(realOne);
}
@@ -153,19 +151,20 @@
protected void postReplicateExecution(ReplicateCommand realOne)
{
- Iterator<Class<? extends ReplicableCommand>> it = expectedCommands.iterator();
- while (it.hasNext())
+ if (!realOne.removeCommands(expectedCommands))
{
- Class<? extends ReplicableCommand> replicableCommandClass = it.next();
- if (realOne.containsCommandType(replicableCommandClass))
+ if (realOne.getSingleModification() instanceof PrepareCommand)
{
- it.remove();
- } else if (realOne.getSingleModification() instanceof PrepareCommand) //explicit transaction
- {
- PrepareCommand prepareCommand = (PrepareCommand) realOne.getSingleModification();
- if (prepareCommand.containsModificationType(replicableCommandClass))
+ Iterator<Class<? extends ReplicableCommand>> it = expectedCommands.iterator();
+ while (it.hasNext())
{
- it.remove();
+ Class<? extends ReplicableCommand> replicableCommandClass = it.next();
+ PrepareCommand prepareCommand = (PrepareCommand) realOne.getSingleModification();
+ if (prepareCommand.containsModificationType(replicableCommandClass))
+ {
+ it.remove();
+ break;//only remove once
+ }
}
}
}
@@ -209,7 +208,7 @@
{
if (!expectedCommands.isEmpty() && !latch.await(timeout, timeUnit))
{
- assert false : "[" +localAddress + "] waiting for more than " + timeout + " " + timeUnit + " and following commands did not replicate: " + expectedCommands;
+ assert false : "[" + localAddress + "] waiting for more than " + timeout + " " + timeUnit + " and following commands did not replicate: " + expectedCommands;
}
}
catch (InterruptedException e)
@@ -231,7 +230,7 @@
{
if (this.expectedCommands == null)
{
-
+
this.expectedCommands = new ArrayList<Class<? extends ReplicableCommand>>();
}
this.expectedCommands.addAll(Arrays.asList(expectedCommands));
@@ -254,3 +253,5 @@
return cache;
}
}
+//[127.0.0.1:7900] Processed command: ReplicateCommand{cmds=PrepareCommand{globalTransaction=GlobalTransaction:<127.0.0.1:7903>:481, modifications=[PutDataMapCommand{fqn=/_BUDDY_BACKUP_/127.0.0.1_7903/JSESSION/BuddyReplicationFailoverTest54_localhost/160, dataVersion=null, data={2=org.jboss.cache.integration.websession.util.SessionMetadata@93a0d8, 1=1233588409000, 3={key=2}, 0=3}, globalTransaction=null, erase=false}], localAddress=127.0.0.1:7903, onePhaseCommit=true}}
+//[127.0.0.1:7900] skipping command ReplicateCommand{cmds=PrepareCommand{globalTransaction=GlobalTransaction:<127.0.0.1:7903>:482, modifications=[PutDataMapCommand{fqn=/_BUDDY_BACKUP_/127.0.0.1_7903/JSESSION/BuddyReplicationFailoverTest54_localhost/160, dataVersion=null, data={1=1233588409031, 3={key=3}, 0=4}, globalTransaction=null, erase=false}], localAddress=127.0.0.1:7903, onePhaseCommit=true}}
Modified: core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml
===================================================================
--- core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml 2009-02-04 17:46:08 UTC (rev 7645)
+++ core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml 2009-02-04 23:37:41 UTC (rev 7646)
@@ -341,26 +341,26 @@
</attribute>
<!-- Cache Loader for session passivation -->
- <!--<attribute name="CacheLoaderConfig">-->
- <!--<config>-->
- <!--<passivation>true</passivation>-->
- <!--<shared>false</shared>-->
+ <attribute name="CacheLoaderConfig">
+ <config>
+ <passivation>true</passivation>
+ <shared>false</shared>
- <!--<purgeOnStartup>true</purgeOnStartup>-->
+ <purgeOnStartup>true</purgeOnStartup>
- <!--<cacheloader>-->
- <!--<class>org.jboss.cache.loader.FileCacheLoader</class>-->
- <!--<properties>-->
- <!--location=${java.io.tmpdir}${/}session-->
- <!--</properties>-->
- <!--<async>false</async>-->
- <!--<fetchPersistentState>true</fetchPersistentState>-->
- <!--<ignoreModifications>false</ignoreModifications>-->
- <!--<checkCharacterPortability>false</checkCharacterPortability>-->
- <!--</cacheloader>-->
+ <cacheloader>
+ <class>org.jboss.cache.loader.FileCacheLoader</class>
+ <properties>
+ location=${java.io.tmpdir}${/}session
+ </properties>
+ <async>false</async>
+ <fetchPersistentState>true</fetchPersistentState>
+ <ignoreModifications>false</ignoreModifications>
+ <checkCharacterPortability>false</checkCharacterPortability>
+ </cacheloader>
- <!--</config>-->
- <!--</attribute>-->
+ </config>
+ </attribute>
<!--
JBoss Cache eviction is not needed; webapp or SFSB container
15 years, 10 months
JBoss Cache SVN: r7645 - in core/trunk: src/main/java/org/jboss/cache and 12 other directories.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2009-02-04 12:46:08 -0500 (Wed, 04 Feb 2009)
New Revision: 7645
Removed:
core/trunk/src/test/java/org/jboss/cache/jmx/JmxManualTest.java
Modified:
core/trunk/pom.xml
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/Version.java
core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
core/trunk/src/main/java/org/jboss/cache/util/CachePrinter.java
core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java
core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java
core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java
core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml
Log:
Revert everything after 7632, it all breaks the testsuite!
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/pom.xml 2009-02-04 17:46:08 UTC (rev 7645)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-core-version>3.1.0-SNAPSHOT</jbosscache-core-version>
+ <jbosscache-core-version>3.0.3-SNAPSHOT</jbosscache-core-version>
<!-- By default only run tests in the "unit" group -->
<defaultTestGroup>unit</defaultTestGroup>
<!-- By default only generate Javadocs when we install the module. -->
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -30,11 +30,9 @@
import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
-import org.jboss.cache.jmx.annotations.MBean;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.marshall.NodeData;
-import org.jboss.cache.util.CachePrinter;
import java.util.ArrayList;
import java.util.Collections;
@@ -50,7 +48,6 @@
* @since 2.2
*/
@NonVolatile
-@MBean(objectName = "DataContainer", description = "Core container for all cached items")
public class DataContainerImpl implements DataContainer
{
private static final Log log = LogFactory.getLog(DataContainerImpl.class);
@@ -196,10 +193,7 @@
public NodeSPI peek(Fqn fqn, boolean includeDeletedNodes, boolean includeInvalidNodes)
{
- if (trace)
- {
- log.trace("peek " + fqn + ", includeDeletedNodes:" + includeDeletedNodes + ", includeInvalidNodes:" + includeInvalidNodes);
- }
+ if (trace) log.trace("peek " + fqn + ", includeDeletedNodes:" +includeDeletedNodes + ", includeInvalidNodes:" + includeInvalidNodes);
if (fqn == null || fqn.size() == 0) return getRoot();
NodeSPI n = getRoot();
int fqnSize = fqn.size();
@@ -489,13 +483,7 @@
return sb.toString();
}
- @ManagedOperation(description = "Prints details of the data container, formatted as an HTML String")
- public String printDetailsAsHtml()
- {
- return CachePrinter.formatHtml(printDetails());
- }
-
/**
* Returns lock information.
*
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -81,7 +81,7 @@
*
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
*/
-@MBean(objectName = "RPCManager", description = "Manages RPC connections to remote caches")
+@MBean(objectName = "RPCManager")
public class RPCManagerImpl implements RPCManager
{
private Channel channel;
@@ -177,9 +177,7 @@
if (getMembers().size() > 1) messageListener.waitForState();
if (log.isDebugEnabled())
- {
log.debug("connected, state was retrieved successfully (in " + (System.currentTimeMillis() - start) + " milliseconds)");
- }
}
catch (StateTransferException ste)
{
@@ -273,9 +271,7 @@
ReflectionUtil.setValue(configuration, "accessible", true);
configuration.setUsingMultiplexer(true);
if (log.isDebugEnabled())
- {
log.debug("Created Multiplexer Channel for cache cluster " + configuration.getClusterName() + " using stack " + configuration.getMultiplexerStack());
- }
}
else
{
@@ -451,13 +447,9 @@
int modeToUse = mode;
int preferredMode;
if ((preferredMode = spi.getInvocationContext().getOptionOverrides().getGroupRequestMode()) > -1)
- {
modeToUse = preferredMode;
- }
if (trace)
- {
log.trace("callRemoteMethods(): valid members are " + recipients + " methods: " + command + " Using OOB? " + useOutOfBandMessage + " modeToUse: " + modeToUse);
- }
if (channel.flushSupported() && !flushBlockGate.await(configuration.getStateRetrievalTimeout(), TimeUnit.MILLISECONDS))
{
throw new TimeoutException("State retrieval timed out waiting for flush unblock. (timeout = " + configuration.getStateRetrievalTimeout() + " millis) ");
@@ -466,9 +458,7 @@
RspList rsps = rpcDispatcher.invokeRemoteCommands(recipients, command, modeToUse, timeout, isUsingBuddyReplication, useOutOfBandMessage, responseFilter);
if (mode == GroupRequest.GET_NONE) return Collections.emptyList();// async case
if (trace)
- {
log.trace("(" + getLocalAddress() + "): responses for method " + command.getClass().getSimpleName() + ":\n" + rsps);
- }
// short-circuit no-return-value calls.
if (rsps == null) return Collections.emptyList();
List<Object> retval = new ArrayList<Object>(rsps.size());
@@ -539,9 +529,7 @@
// Yes -- cache is configured LOCAL but app doesn't know it -- Brian
//throw new IllegalArgumentException("Cannot fetch partial state, targets are " + sources + " and stateId is " + stateId);
if (log.isWarnEnabled())
- {
log.warn("Cannot fetch partial state, targets are " + sources + " and stateId is " + stateId);
- }
return;
}
@@ -559,18 +547,14 @@
}
if (log.isDebugEnabled())
- {
log.debug("Node " + getLocalAddress() + " fetching partial state " + stateId + " from members " + targets);
- }
boolean successfulTransfer = false;
for (Address target : targets)
{
try
{
if (log.isDebugEnabled())
- {
log.debug("Node " + getLocalAddress() + " fetching partial state " + stateId + " from member " + target);
- }
messageListener.setStateSet(false);
successfulTransfer = channel.getState(target, stateId, configuration.getStateRetrievalTimeout());
if (successfulTransfer)
@@ -586,18 +570,14 @@
}
}
if (log.isDebugEnabled())
- {
log.debug("Node " + getLocalAddress() + " fetching partial state " + stateId + " from member " + target + (successfulTransfer ? " successful" : " failed"));
- }
if (successfulTransfer) break;
}
catch (IllegalStateException ise)
{
// thrown by the JGroups channel if state retrieval fails.
if (log.isInfoEnabled())
- {
log.info("Channel problems fetching state. Continuing on to next provider. ", ise);
- }
}
}
@@ -612,10 +592,10 @@
// ------------ START: Informational methods ------------
- @ManagedAttribute(description = "Local address")
+ @ManagedAttribute (description = "Local address")
public String getLocalAddressString()
{
- Address address = getLocalAddress();
+ Address address = getLocalAddress();
return address == null ? "null" : address.toString();
}
@@ -624,7 +604,7 @@
return channel != null ? channel.getLocalAddress() : null;
}
- @ManagedAttribute(description = "Cluster view")
+ @ManagedAttribute (description = "Cluster view")
public String getMembersString()
{
List l = getMembers();
@@ -635,13 +615,9 @@
{
if (isInLocalMode) return null;
if (members == null)
- {
return Collections.emptyList();
- }
else
- {
return members;
- }
}
public boolean isCoordinator()
@@ -739,7 +715,7 @@
catch (Throwable e)
{
//do not rethrow! jgroups might behave funny, resulting even in deadlock
- log.error("Error found while processing view accepted!!!", e);
+ log.error("Error found while processing view accepted!!!", e);
}
}
@@ -836,12 +812,6 @@
return statisticsEnabled;
}
- @ManagedAttribute(description = "whether or not the RPCManager is used in this cache instance")
- public boolean isEnabled()
- {
- return !isInLocalMode;
- }
-
@ManagedAttribute
public void setStatisticsEnabled(boolean statisticsEnabled)
{
@@ -867,9 +837,7 @@
{
//if we use a shared transport do not log any warn message
if (configuration.getMultiplexerStack() != null)
- {
return;
- }
//bundling is not good for sync caches
Configuration.CacheMode cacheMode = configuration.getCacheMode();
if (!cacheMode.equals(Configuration.CacheMode.LOCAL) && configuration.getCacheMode().isSynchronous())
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -24,9 +24,7 @@
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import static org.jboss.cache.Region.Type.ANY;
-import static org.jboss.cache.Region.Type.EVICTION;
-import static org.jboss.cache.Region.Type.MARSHALLING;
+import static org.jboss.cache.Region.Type.*;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
@@ -38,7 +36,6 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
-import org.jboss.cache.jmx.annotations.MBean;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.lock.LockManager;
@@ -58,7 +55,6 @@
* @since 3.0.0
*/
@ThreadSafe
-@MBean(objectName = "RegionManager", description = "Manages eviction and marshalling regions")
public class RegionManagerImpl implements RegionManager
{
/**
@@ -145,9 +141,7 @@
setDefaultInactive(configuration.isInactiveOnStartup());
if (isUsingEvictions())
- {
evictionTimerTask.init(evictionConfig.getWakeupInterval(), configuration.getRuntimeConfig().getEvictionTimerThreadFactory(), regionsRegistry);
- }
}
@Stop
@@ -426,9 +420,7 @@
// Don't bother trying to fetch state if we are in LOCAL mode
if (members != null && !members.isEmpty())
- {
rpcManager.fetchPartialState(members, subtreeRoot.getFqn());
- }
}
else if (!buddyFqnTransformer.isBackupFqn(fqn))
{
@@ -439,9 +431,7 @@
{
List<Address> sources = new ArrayList<Address>(1);
if (!cache.getMembers().contains(buddy))
- {
continue;
- }
sources.add(buddy);
Fqn buddyRoot = buddyFqnTransformer.getBackupFqn(buddy, fqn);
subtreeRoot = cache.peek(buddyRoot, false, false);
@@ -652,9 +642,7 @@
{
if ((type == EVICTION && r.getEvictionRegionConfig() != null) ||
(type == MARSHALLING && r.isActive() && r.getClassLoader() != null))
- {
regions.add(r);
- }
}
}
else
@@ -685,9 +673,7 @@
// needDefault = ercs.size() == 0;
if (evictionConfig.getDefaultEvictionRegionConfig().getEvictionAlgorithmConfig() != null &&
!ercs.contains(evictionConfig.getDefaultEvictionRegionConfig())) // then the default is a real region too; not just a template for others
- {
ercs.add(0, evictionConfig.getDefaultEvictionRegionConfig());
- }
// create regions for the regions defined in the evictionConfig.
// scan to be sure the _default_ region isn't added twice
@@ -760,7 +746,7 @@
evictionTimerTask.stop();
}
- @ManagedAttribute(name = "numRegions", description = "A count of all regions")
+ @ManagedAttribute(name="numRegions", description = "A count of all regions")
public int getNumRegions()
{
return regionsRegistry.size();
Modified: core/trunk/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Version.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/main/java/org/jboss/cache/Version.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -32,10 +32,10 @@
@Immutable
public class Version
{
- public static final String version = "3.1.0-SNAPSHOT";
- public static final String codename = "Cascabel";
+ public static final String version = "3.0.3-SNAPSHOT";
+ public static final String codename = "Naga";
//public static final String cvs = "$Id$";
- static final byte[] version_id = {'0', '3', '1', '0', 'S'};
+ static final byte[] version_id = {'0', '3', '0', '3', 'S'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -86,13 +86,17 @@
* See {@link org.jboss.cache.interceptors.EvictionInterceptor#visitEvictFqnCommand(org.jboss.cache.InvocationContext , EvictCommand)}
* which is where the return value is used
*
- * @return true if the node is now absent from the cache. Returns false if the node still exists; i.e. was only data removed because it still has children.
+ * @return true if the node was removed from the tree or if it is resident. Returns false if the node still exists; i.e. was only data removed because it still has children.
*/
public Object perform(InvocationContext ctx)
{
NodeSPI node = lookupForEviction(ctx, fqn);
- if (node == null || node.isDeleted() || node.isResident())
+ if (node == null || node.isDeleted())
{
+ return false;
+ }
+ else if (node.isResident())
+ {
return true;
}
else if (recursive)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -152,9 +152,7 @@
{
double total = hits + misses;
if (total == 0)
- {
return 0;
- }
return (hits / total);
}
@@ -162,9 +160,7 @@
public double getReadWriteRatio()
{
if (stores == 0)
- {
return 0;
- }
return (((double) (hits + misses) / (double) stores));
}
@@ -173,9 +169,7 @@
{
long total = hits + misses;
if (total == 0)
- {
return 0;
- }
return (hitTimes + missTimes) / total;
}
@@ -183,19 +177,17 @@
public long getAverageWriteTime()
{
if (stores == 0)
- {
return 0;
- }
return (storeTimes) / stores;
}
- @ManagedAttribute(description = "number of cache attributes")
+ @ManagedAttribute(description = "number of cache eviction operations")
public int getNumberOfAttributes()
{
return dataContainer.getNumberOfAttributes();
}
- @ManagedAttribute(description = "number of nodes in the cache")
+ @ManagedAttribute
public int getNumberOfNodes()
{
return dataContainer.getNumberOfNodes();
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -81,8 +81,8 @@
// See if the node still exists; i.e. was only data removed
// because it still has children.
// If yes, put an ADD event in the queue so the node gets revisited
- boolean nodeIsNowAbsent = (retVal != null && (Boolean) retVal);
- if (!nodeIsNowAbsent)
+ boolean complete = (retVal != null && (Boolean) retVal);
+ if (!complete)
{
Region r;
if (fqn != null && (r = getRegion(fqn)) != null)
@@ -244,10 +244,10 @@
private void registerEvictionEventToRegionManager(Fqn fqn, EvictionEvent.Type type, int elementDifference, Region region)
{
//we do not trigger eviction events for resident nodes
- if (dataContainer.isResident(fqn))
+ if (dataContainer.isResident(fqn))
{
- if (trace) log.trace("Ignoring Fqn " + fqn + " as it is marked as resident");
- return;
+ if (trace) log.trace("Ignoring Fqn " + fqn + " as it is marked as resident");
+ return;
}
region.registerEvictionEvent(fqn, type, elementDifference);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -30,8 +30,6 @@
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.invocation.InvocationContextContainer;
-import org.jboss.cache.jmx.annotations.MBean;
-import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.util.CachePrinter;
import java.util.ArrayList;
@@ -47,7 +45,6 @@
* todo - if you add the same interceptor instance twice, things get really dirty.
* -- this should be treated as an missuse and an exception should be thrown
*/
-@MBean(description = "InterceptorChain")
public class InterceptorChain
{
/**
@@ -154,25 +151,6 @@
}
- @ManagedOperation(description = "Retrieves a list of the interceptors in the chain")
- public String getInterceptorDetails()
- {
- StringBuilder sb = new StringBuilder("Interceptor chain: \n");
- int count = 0;
- for (CommandInterceptor i : asList())
- {
- count++;
- sb.append(" ").append(count).append(". ").append(i).append("\n");
- }
- return sb.toString();
- }
-
- @ManagedOperation(description = "Retrieves a list of the interceptors in the chain, formatted as HTML")
- public String getInterceptorDetailsAsHtml()
- {
- return CachePrinter.formatHtml(getInterceptorDetails());
- }
-
/**
* Returns an unmofiable list with all the interceptors in sequence.
* If first in chain is null an empty list is returned.
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -48,7 +48,16 @@
import org.jgroups.jmx.JChannelFactoryMBean;
import org.w3c.dom.Element;
-import javax.management.*;
+import javax.management.AttributeChangeNotification;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
import javax.transaction.TransactionManager;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -137,7 +146,7 @@
public String printConfigurationAsHtmlString()
{
Configuration cfg = getConfiguration();
- return cfg == null ? "Configuration is null" : CachePrinter.formatHtml(cfg.toString());
+ return cfg == null ? "Configuration is null" : formatHtml(cfg.toString());
}
public String printCacheDetails()
@@ -147,7 +156,7 @@
public String printCacheDetailsAsHtml()
{
- return cache == null ? "Cache is null" : CachePrinter.formatHtml(CachePrinter.printCacheDetails(cache));
+ return cache == null ? "Cache is null" : formatHtml(CachePrinter.printCacheDetails(cache));
}
public CacheStatus getCacheStatus()
@@ -208,7 +217,7 @@
public String printLockInfoAsHtml()
{
- return cache == null ? "Cache is null" : CachePrinter.formatHtml(CachePrinter.printCacheLockingInfo(cache));
+ return cache == null ? "Cache is null" : formatHtml(CachePrinter.printCacheLockingInfo(cache));
}
public boolean getRegisterJmxResource()
@@ -590,13 +599,9 @@
if (!cacheStatus.createAllowed())
{
if (cacheStatus.needToDestroyFailedCache())
- {
destroy();
- }
else
- {
return;
- }
}
try
@@ -628,18 +633,12 @@
if (!cacheStatus.startAllowed())
{
if (cacheStatus.needToDestroyFailedCache())
- {
destroy(); // this will take us back to DESTROYED
- }
if (cacheStatus.needCreateBeforeStart())
- {
create();
- }
else
- {
return;
- }
}
try
@@ -719,9 +718,7 @@
}
}
else
- {
return;
- }
}
try
@@ -733,9 +730,7 @@
unregisterJmxResources();
if (cache != null)
- {
cache.destroy();
- }
}
finally
{
@@ -906,6 +901,22 @@
return server;
}
+ /**
+ * Formats a given String for display as an HTML snippet.
+ *
+ * @param s string to format
+ * @return formatted string
+ */
+ public static String formatHtml(String s)
+ {
+ s = s.replaceAll("\r\n", "<br/>");
+ s = s.replaceAll("\r", "<br/>");
+ s = s.replaceAll("\n", "<br/>");
+ s = s.replaceAll("\t", " ");
+ s = s.replaceAll(" ", " ");
+ return s;
+ }
+
public String getNotificationServiceName()
{
return notificationServiceName;
@@ -1038,18 +1049,14 @@
{
listenerCount.incrementAndGet();
if (cache != null)
- {
cache.addCacheListener(cacheNotificationListener);
- }
}
else
{
if (listenerCount.decrementAndGet() <= 0)
{
if (cache != null)
- {
cache.removeCacheListener(cacheNotificationListener);
- }
listenerCount.set(0);
}
@@ -1075,21 +1082,13 @@
sendStateChangeNotification(oldState, getState(), getClass().getSimpleName() + " failed", t);
if (t instanceof CacheException)
- {
throw (CacheException) t;
- }
else if (t instanceof RuntimeException)
- {
throw (RuntimeException) t;
- }
else if (t instanceof Error)
- {
throw (Error) t;
- }
else
- {
throw new CacheException(t);
- }
}
/**
@@ -1098,9 +1097,7 @@
private void sendStateChangeNotification(int oldState, int newState, String msg, Throwable t)
{
if (isDisableStateChangeNotifications())
- {
return;
- }
long now = System.currentTimeMillis();
Modified: core/trunk/src/main/java/org/jboss/cache/util/CachePrinter.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/CachePrinter.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/main/java/org/jboss/cache/util/CachePrinter.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -93,20 +93,4 @@
}
return sb.toString();
}
-
- /**
- * Formats a given String for display as an HTML snippet.
- *
- * @param s string to format
- * @return formatted string
- */
- public static String formatHtml(String s)
- {
- s = s.replaceAll("\r\n", "<br/>");
- s = s.replaceAll("\r", "<br/>");
- s = s.replaceAll("\n", "<br/>");
- s = s.replaceAll("\t", " ");
- s = s.replaceAll(" ", " ");
- return s;
- }
}
Modified: core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -47,14 +47,6 @@
control.verify();
}
- public void testShouldReturnTrueIndicatingNodeIsAbsentIfNodeDoesntExist()
- {
- expect(container.peek(testFqn, false, true)).andReturn(null);
- control.replay();
- assert Boolean.TRUE == command.perform(ctx);
- control.verify();
- }
-
public void testSimpleEviction()
{
expect(container.peek(testFqn, false, true)).andReturn(nodes.abNode);
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -48,27 +48,8 @@
/**
* @author Brian Stansberry
*
- * This test is disabled because of following:
- * There seem to be some assumptions in the above tests that do not look right to me.
- * I have an example I've investigated(logs etc), haven't studied all possible failure scenarios, though I can imagine some others.
- * One of them is the next one, on testInvalidateOnFailoverToBackup:
-
- * This is the code I am talking about:
- * InvalidationServlet invs = new InvalidationServlet();
- * MultipleActionServlet mas = new MultipleActionServlet(sas, invs);
- * (....)
- * req = new Request(mgr0, sessionId, mas);
- * *1+2* req.execute(); (...)
- * *3*BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
-
- *And some explanation
-
- *1) manager0.invalidatesSession (i.e. cache0.remove)
- *2) manager0 tries to data gravitate session (i.e. cache0.get with forceDataGrav set to true). This is done last line in Request.execute().
- *3) asserts that session is no longer present on cache0
-
- *Now, the assumption at 3 is not necessarily valid. With some funny threading and using ASYNC replication, you might have the remote removeNode command originated from cache0 to run *after* gravitateData originated at step2. I.e. RemoveNodeCommand being executed after GravitateDataCommand on cache*1* (buddy of cache0).
*/
+//todo - fix intermitent failures
@Test(groups = "integration",enabled = false, testName = "integration.websession.BuddyReplicationFailoverTest")
public class BuddyReplicationFailoverTest extends WebSessionTestBase
{
@@ -540,7 +521,7 @@
// Create the session
SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- ReplicationListener replListener0 = replListeners[0];
+ ReplicationListener replListener0 = getReplicationListener(mgr0.getCache());
replListener0.expectWithTx(PutDataMapCommand.class);
Request req = new Request(mgr3, null, sas);
@@ -578,7 +559,7 @@
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
InvalidationServlet invs = new InvalidationServlet();
MultipleActionServlet mas = new MultipleActionServlet(sas, invs);
- ReplicationListener replListener1 = replListeners[1];
+ ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
replListener1.expectWithTx(PutDataMapCommand.class, RemoveNodeCommand.class);
replListener1.expect(DataGravitationCleanupCommand.class);
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -35,7 +35,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.*;
-import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.integration.websession.util.WebAppMetadata.Granularity;
@@ -132,38 +131,13 @@
cache.removeCacheListener(this);
// FIXME see if we need more sophisticated cache cleanup
- removeInMemoryData((CacheSPI)cache);
- clearCacheLoader((CacheSPI)cache);
+ cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ cache.removeNode(baseFqn);
cacheManager.releaseCache(appMetadata.cacheConfigName);
cache = null;
}
}
}
-
- private void clearCacheLoader(CacheSPI cache)
- {
- CacheLoaderManager cacheLoaderManager = cache.getCacheLoaderManager();
- if (cacheLoaderManager != null && cacheLoaderManager.getCacheLoader() != null)
- {
- try
- {
- cacheLoaderManager.getCacheLoader().remove(Fqn.ROOT);
- } catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- }
-
- private void removeInMemoryData(CacheSPI cache)
- {
- if (cache.getRoot() != null)
- {
- cache.getRoot().clearDataDirect();
- cache.getRoot().removeChildrenDirect();
- }
- }
-
/**
* Allows test driver to mock Tomcat background processes' expiration
@@ -391,7 +365,6 @@
{
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
}
- log("cache.removeNode(" + getSessionFqn(id) + ") locally? " + localOnly);
cache.removeNode(getSessionFqn(id));
}
@@ -451,8 +424,7 @@
{
data.put(ATTRIBUTES, attributes);
}
-
- log("cache.put(" + fqn +"," + data +")");
+
cache.put(fqn, data);
}
@@ -466,8 +438,7 @@
Fqn<String> fqn = getSessionFqn(id);
if (modifiedAttributes != null)
- {
- log("cache.put(" + fqn+"," + modifiedAttributes+ ")");
+ {
cache.put(fqn, modifiedAttributes);
}
@@ -475,7 +446,6 @@
{
for (String key : removedAttributes)
{
- log("cache.remove(" + fqn + "," + key + ")");
cache.remove(fqn, key);
}
}
@@ -520,7 +490,6 @@
{
cache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
}
- log ("cache.getData(" + getSessionFqn(id) + ") with ForceDataGravitation(true)");
data = cache.getData(getSessionFqn(id));
}
finally
@@ -575,7 +544,6 @@
Fqn<String> backupFqn = Fqn.fromRelativeFqn(child.getFqn(), mainFqn);
if (evict)
{
- log("cache.evict(" + backupFqn + ", true)");
cache.evict(backupFqn, true);
}
else
@@ -588,9 +556,4 @@
}
- private void log(String what)
- {
- System.out.println("[" + cache.getLocalAddress() + "] " + what);
- }
-
}
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -39,15 +39,4 @@
public final String id = String.valueOf(++counter);
public final long creationTime = System.currentTimeMillis();
public boolean valid = true;
-
-
- @Override
- public String toString()
- {
- return "SessionMetadata{" +
- "id='" + id + '\'' +
- ", creationTime=" + creationTime +
- ", valid=" + valid +
- '}';
- }
}
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -52,7 +52,7 @@
private AtomicInteger testCount = new AtomicInteger();
private List<CacheManager> cacheManagers;
private List<SessionManager> sessionManagers;
- protected ReplicationListener[] replListeners;
+ private Map<Cache<Object, Object>, ReplicationListener> replicationListeners = new HashMap<Cache<Object, Object>, ReplicationListener>();
@BeforeClass(alwaysRun = true)
public void beforeClass() throws Exception
@@ -61,10 +61,8 @@
if (getStartCachesInBeforeClass() && getCacheConfigName() != null)
{
String inUseProtocolStack = UnitTestConfigurationFactory.getEmptyConfiguration().getClusterConfig();
- replListeners = new ReplicationListener[getNumCacheManagers()];
- for (int i =0; i < cacheManagers.size(); i++)
+ for (CacheManager cm : cacheManagers)
{
- CacheManager cm = cacheManagers.get(i);
Cache<Object, Object> cache = cm.getCache(getCacheConfigName(), true);
amendCacheBeforeStartup(cache);
if (cache.getCacheStatus() != CacheStatus.STARTED)
@@ -72,7 +70,7 @@
cache.getConfiguration().setClusterConfig(inUseProtocolStack);
cache.start();
}
- replListeners[i] = ReplicationListener.getReplicationListener(cache);
+ replicationListeners.put(cache, ReplicationListener.getReplicationListener(cache));
}
}
}
@@ -173,4 +171,9 @@
{
return Integer.valueOf(value);
}
+
+ protected ReplicationListener getReplicationListener(Cache<Object, Object> cache)
+ {
+ return replicationListeners.get(cache);
+ }
}
Deleted: core/trunk/src/test/java/org/jboss/cache/jmx/JmxManualTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/JmxManualTest.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/JmxManualTest.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -1,76 +0,0 @@
-package org.jboss.cache.jmx;
-
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.FIFOAlgorithmConfig;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
-// do NOT enable this test in SVN as it will cause Hudson (or any other continuous integration test harness) to get
-
-// stuck.
-@Test(groups = "maual", enabled = false)
-public class JmxManualTest
-{
- public void testLocal() throws IOException
- {
- Configuration c = new Configuration();
- Cache cache = new DefaultCacheFactory().createCache(c);
- cache.put("/a/b/c", "a", "b");
- cache.put("/a/b/c", "c", "d");
- cache.put("/a/b/d", "a", "b");
- cache.put("/a/b/e", "c", "d");
-
- System.in.read();
- }
-
- public void testLocalNoJMX() throws IOException
- {
- Configuration c = new Configuration();
- c.setExposeManagementStatistics(false);
- Cache cache = new DefaultCacheFactory().createCache(c);
- cache.put("/a/b/c", "a", "b");
- cache.put("/a/b/c", "c", "d");
- cache.put("/a/b/d", "a", "b");
- cache.put("/a/b/e", "c", "d");
-
- System.in.read();
- }
-
- public void testLocalWithEviction() throws IOException
- {
- Configuration c = new Configuration();
- EvictionConfig ec = new EvictionConfig();
- ec.setWakeupInterval(250, TimeUnit.MILLISECONDS);
- EvictionRegionConfig erc = new EvictionRegionConfig();
- erc.setEvictionAlgorithmConfig(new FIFOAlgorithmConfig(2));
- erc.setRegionFqn(Fqn.ROOT);
- ec.setDefaultEvictionRegionConfig(erc);
- c.setEvictionConfig(ec);
- Cache cache = new DefaultCacheFactory().createCache(c);
- cache.put("/a/b/c", "a", "b");
- cache.put("/a/b/c", "c", "d");
- cache.put("/a/b/d", "a", "b");
- cache.put("/a/b/e", "c", "d");
-
- System.in.read();
- }
-
- public void testLocalWithEvictionXML() throws IOException
- {
- Cache cache = new DefaultCacheFactory().createCache("config-samples/eviction-enabled.xml");
- cache.put("/a/b/c", "a", "b");
- cache.put("/a/b/c", "c", "d");
- cache.put("/a/b/d", "a", "b");
- cache.put("/a/b/e", "c", "d");
-
- System.in.read();
- }
-
-}
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTest.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/CacheJmxWrapperTest.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -16,6 +16,7 @@
import org.jboss.cache.notifications.event.Event;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.CachePrinter;
+import org.jboss.cache.util.TestingUtil;
import org.jgroups.Address;
import org.jgroups.stack.IpAddress;
import static org.testng.AssertJUnit.*;
@@ -70,9 +71,7 @@
finally
{
if (registered)
- {
mBeanServer.unregisterMBean(on);
- }
}
}
@@ -156,7 +155,7 @@
{
CacheJmxWrapperMBean<String, String> wrapper = registerWrapper();
String cfgFromJmx = wrapper.printConfigurationAsHtmlString();
- assertEquals(CachePrinter.formatHtml(cache.getConfiguration().toString()), cfgFromJmx);
+ assertEquals(CacheJmxWrapper.formatHtml(cache.getConfiguration().toString()), cfgFromJmx);
checkHtml(cfgFromJmx, false);
}
@@ -176,7 +175,7 @@
wrapper.create();
wrapper.start();
String cfgFromJmx = wrapper.printConfigurationAsHtmlString();
- assertEquals(CachePrinter.formatHtml(wrapper.getCache().getConfiguration().toString()), cfgFromJmx);
+ assertEquals(CacheJmxWrapper.formatHtml(wrapper.getCache().getConfiguration().toString()), cfgFromJmx);
checkHtml(cfgFromJmx, false);
}
@@ -397,9 +396,7 @@
private void checkHtml(String html, boolean checkBR)
{
if (checkBR)
- {
assertTrue("Has <br", html.contains("<br"));
- }
assertTrue("No tabs", html.indexOf('\t') == -1);
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -47,11 +47,13 @@
* @author Brian Stansberry
* @version $Revision$
*/
-@Test(groups = {"functional"}, testName = "statetransfer.FailedStateTransferTest")
+@Test(groups = {"functional"}, enabled=false, testName = "statetransfer.FailedStateTransferTest")
public class FailedStateTransferTest extends StateTransferTestBase
{
+
public void testFailedStateTransfer() throws Exception
{
+ Map<String, Cache> caches = cachesTL.get();
Configuration c = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
//c.setClusterName("VersionedTestBase");
c.setReplVersionString(getReplicationVersion());
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -45,7 +45,8 @@
* @author Brian Stansberry
* @version $Revision$
*/
-@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.ForcedStateTransferTest", description = "this has always been disabled since 1.4.x. See JBCACHE-315")
+@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.ForcedStateTransferTest")
+// this has always been disabled since 1.4.x. See JBCACHE-315
public class ForcedStateTransferTest extends StateTransferTestBase
{
/**
@@ -780,7 +781,7 @@
boolean startCache)
throws Exception
{
- CacheSPI<Object, Object> result = super.createCache(replSync,
+ CacheSPI<Object, Object> result = super.createCache(cacheID, replSync,
useMarshalling, false, false, false, true);
result.getConfiguration().setStateRetrievalTimeout(0);
result.getConfiguration().setLockAcquisitionTimeout(1000);
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -4,7 +4,6 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
-import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -25,7 +24,7 @@
* Pertains to JBCACHE-131
* <p/>
*/
-@Test(groups = "functional", testName = "statetransfer.PersistingTransientStateTest")
+@Test(groups = "functional", enabled=false, testName = "statetransfer.PersistingTransientStateTest")
public class PersistingTransientStateTest
{
protected NodeLockingScheme nls = NodeLockingScheme.PESSIMISTIC;
@@ -38,8 +37,9 @@
try
{
UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
- Configuration cfg = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
+ Configuration cfg = new Configuration();
cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cfg.setCacheMode(CacheMode.REPL_SYNC);
cfg.setFetchInMemoryState(true);
// configure with CL
IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
@@ -72,8 +72,10 @@
Cache<String, String> c1 = null, c2 = null;
try
{
- Configuration cfg = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
+ UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
+ Configuration cfg = new Configuration();
cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cfg.setCacheMode(CacheMode.REPL_SYNC);
cfg.setFetchInMemoryState(true);
// configure with CL
IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
@@ -86,13 +88,13 @@
cfg.setCacheLoaderConfig(clc);
cfg.setNodeLockingScheme(nls);
- c1 = new UnitTestCacheFactory<String, String>().createCache(cfg.clone(), getClass());
+ c1 = cf.createCache(cfg.clone(), getClass());
c1.put(fqn, k, v);
assert c1.get(fqn, k).equals(v);
assert getLoader(c1).get(fqn).get(k).equals(v);
- c2 = new UnitTestCacheFactory<String, String>().createCache(cfg.clone(), getClass());
+ c2 = cf.createCache(cfg.clone(), getClass());
assert c2.get(fqn, k).equals(v);
assert getLoader(c2).get(fqn) == null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -11,9 +11,9 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.lock.LockManager;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.buddyreplication.BuddyReplicationTestsBase;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.MarshalledValue;
@@ -29,9 +29,10 @@
* @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = {"functional"}, testName = "statetransfer.StateTransfer200Test")
+@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.StateTransfer200Test")
public class StateTransfer200Test extends StateTransferTestBase
{
+
protected String getReplicationVersion()
{
return "2.0.0.GA";
@@ -39,34 +40,46 @@
public void testBuddyBackupExclusion() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCacheWithBr("testBuddyBackupExclusion_1");
+ CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, false, false, false, true);
+
+ cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
+
+ cache1.start();
+
Fqn backup = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cache1.put(backup, "name", JOE);
cache1.put(A_B, "age", TWENTY);
- CacheSPI<Object, Object> cache2 = createCacheWithBr("StateTransferTestBase_2");
+ CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, false);
+
// Pause to give caches time to see each other
- BuddyReplicationTestsBase.waitForSingleBuddy(cache1, cache2);
+ TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
+
assertNull("_buddy_backup_ not transferred", cache2.get(backup, "test"));
assertEquals("Correct age for /a/b", TWENTY, cache2.get(A_B, "age"));
}
public void testBuddyIntegration() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCacheWithBr("testBuddyIntegration_1");
+ CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, false, false, false, true);
+ cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
+ cache1.start();
// cache 1 won't have a buddy at this stage.
+
// put some state in cache 1
cache1.put(A_B, "name", JOE);
cache1.put(A_C, "name", JANE);
// now start up cache 2
- CacheSPI<Object, Object> cache2 = createCacheWithBr("testBuddyIntegration_2");
+ CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, false, false, false, true);
+ cache2.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
+ cache2.start();
// Pause to give caches time to see each other
- BuddyReplicationTestsBase.waitForSingleBuddy(cache1, cache2);
+ TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
// now peek into cache 2 to check that this state has been transferred into the backup subtree
@@ -80,7 +93,7 @@
@SuppressWarnings("null")
public void testCacheLoaderFailure() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache(false, false, CorruptedFileCacheLoader.class.getName(), false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, CorruptedFileCacheLoader.class.getName(), false, true, true);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
@@ -90,7 +103,8 @@
CacheSPI cache2 = null;
try
{
- cache2 = createCache(false, false, true, false, false, true);
+ cache2 = createCache("cache2", false, false, true, false, false, true);
+ cache2.create();
cache2.start();
//Vladimir October 5th 2007
@@ -108,7 +122,7 @@
public void testLoadEntireStateAfterStart() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache(false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, true);
createAndActivateRegion(cache1, Fqn.ROOT);
@@ -117,7 +131,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache(false, true, true);
+ CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -147,14 +161,14 @@
public void testInitialStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache(false, false, false);
+ CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, false);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache(false, false, false);
+ CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -177,12 +191,13 @@
protected void initialStateTferWithLoaderTest(boolean asyncLoader) throws Exception
{
- initialStateTferWithLoaderTest(getDefaultCacheLoader(), getDefaultCacheLoader() , asyncLoader);
+ initialStateTferWithLoaderTest("org.jboss.cache.loader.FileCacheLoader",
+ "org.jboss.cache.loader.FileCacheLoader", asyncLoader);
}
public void testPartialStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache(false, true, false);
+ CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, false);
createAndActivateRegion(cache1, A);
@@ -191,7 +206,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache(false, true, false);
+ CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -244,18 +259,20 @@
public void testLocksAndStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache(false, true, false);
+ CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, false);
createAndActivateRegion(cache1, A);
cache1.put(A_B, "name", JOE);
- CacheSPI<Object, Object> cache2 = createCache(false, true, false);
+ CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
createAndActivateRegion(cache2, A_B);
assertEquals("Incorrect name for /a/b", JOE, cache2.get(A_B, "name"));
- assert cache1.getNumberOfLocksHeld() == 0;
+ LockManager lockManager = cache1.getComponentRegistry().getComponent(LockManager.class);
+ assert !lockManager.isLocked(A_B);
cache1.getRegion(A, false).deactivate();
- assert cache1.getNumberOfLocksHeld() == 0;
+ assert !lockManager.isLocked(A);
+ assert !lockManager.isLocked(A_B);
createAndActivateRegion(cache1, A_B);
assertEquals("Incorrect name for /a/b", JOE, cache1.get(A_B, "name"));
}
@@ -263,7 +280,7 @@
public void testPartialStateTferWithLoader() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache(false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, true);
createAndActivateRegion(cache1, A);
@@ -272,7 +289,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache(false, true, true);
+ CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -360,7 +377,7 @@
// Set the TCL to a classloader that can't see Person/Address
Thread.currentThread().setContextClassLoader(getNotFoundClassLoader());
- CacheSPI<Object, Object> cache1 = createCache(
+ CacheSPI<Object, Object> cache1 = createCache("cache1",
false, // async
true, // use marshaller
true, // use cacheloader
@@ -376,7 +393,7 @@
cache1.put(A_B, "person", ben);
// For cache 2 we won't register loader until later
- CacheSPI<Object, Object> cache2 = createCache(
+ CacheSPI<Object, Object> cache2 = createCache("cache2",
false, // async
true, // use marshalling
true, // use cacheloader
@@ -412,7 +429,7 @@
public void testStalePersistentState() throws Exception
{
- CacheSPI c1 = createCache(true, false, true, true);
+ CacheSPI c1 = createCache("1", true, false, true, true);
c1.put(A, "K", "V");
assert c1.get(A, "K").equals("V");
@@ -428,7 +445,7 @@
assert l1.exists(A);
assert l1.get(A).get("K").equals("V");
- Cache c2 = createCache(true, false, true, true);
+ Cache c2 = createCache("2", true, false, true, true);
c2.put(B, "K", "V");
@@ -438,6 +455,7 @@
assert c1.get(B, "K").equals("V");
assert c1.get(A, "K") == null;
+ assert !l1.exists(A);
}
private Object createBen(ClassLoader loader) throws Exception
@@ -469,12 +487,4 @@
brc.setBuddyPoolName("TEST");
return brc;
}
-
- private CacheSPI<Object, Object> createCacheWithBr(String cacheName) throws Exception
- {
- CacheSPI<Object, Object> cache1 = createCache(false, false, false, false, false, true);
- cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
- cache1.start();
- return cache1;
- }
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -2,14 +2,16 @@
import org.testng.annotations.Test;
-@Test(groups = {"functional"}, testName = "statetransfer.StateTransferCompatibilityTest")
+@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.StateTransferCompatibilityTest")
public class StateTransferCompatibilityTest extends StateTransferTestBase
{
+
protected String getReplicationVersion()
{
return "2.0.0.GA";
}
+
/**
* These tests ensure that http://jira.jboss.com/jira/browse/JBCACHE-738
* compatibility between non-delegating cacheloaders is maintained. In the tests
@@ -56,6 +58,7 @@
public void testCompatibilityBetweenJDBCAndBdjeCacheLoaders() throws Exception
{
+
initialStateTferWithLoaderTest("org.jboss.cache.loader.JDBCCacheLoader",
"org.jboss.cache.loader.bdbje.BdbjeCacheLoader", false);
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -7,6 +7,7 @@
package org.jboss.cache.statetransfer;
+import java.util.Map;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
@@ -356,7 +357,7 @@
{
// The first cache we create is inactivated.
- CacheSPI<Object, Object> cacheA = createCache(sync, true, false);
+ CacheSPI<Object, Object> cacheA = createCache("cacheA", sync, true, false);
CacheSPI[] caches = new CacheSPI[count + 1];
caches[0] = cacheA;
@@ -467,6 +468,8 @@
*/
public void testEvictionSeesStateTransfer() throws Exception
{
+ Map<String, Cache> caches = cachesTL.get();
+
Configuration c = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
Cache<Object, Object> cache1 = new UnitTestCacheFactory<Object, Object>().createCache(c, getClass());
@@ -500,6 +503,7 @@
Configuration c = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
Cache<Object, Object> cache1 = new UnitTestCacheFactory<Object, Object>().createCache(c, getClass());
+ Map<String, Cache> caches = cachesTL.get();
caches.put("evict1", cache1);
for (int i = 0; i < 25000; i++)
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -33,7 +33,6 @@
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.loader.FileCacheLoader;
import org.jboss.cache.marshall.SelectedClassnameClassLoader;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.UnitTestDatabaseManager;
@@ -78,44 +77,52 @@
public static final Integer TWENTY = 20;
public static final Integer FORTY = 40;
- protected Map<String, Cache> caches = new HashMap<String, Cache>();
- ClassLoader orig_TCL;
- private static int cacheCount = 0;
+ protected ThreadLocal<Map<String, Cache>> cachesTL = new ThreadLocal<Map<String, Cache>>();
+ private ThreadLocal<ClassLoader> orig_TCL_TL = new ThreadLocal<ClassLoader>();
protected abstract String getReplicationVersion();
- protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, boolean useCacheLoader)
+ protected CacheSPI<Object, Object> createCache(String cacheID,
+ boolean sync,
+ boolean useMarshalling,
+ boolean useCacheLoader)
throws Exception
{
- return createCache(sync, useMarshalling, useCacheLoader, false, true, true);
+ return createCache(cacheID, sync, useMarshalling, useCacheLoader, false, true, true);
}
- protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, boolean useCacheLoader, boolean fetchPersistentState)
+ protected CacheSPI<Object, Object> createCache(String cacheID,
+ boolean sync,
+ boolean useMarshalling,
+ boolean useCacheLoader, boolean fetchPersistentState)
throws Exception
{
- return createCache(sync, useMarshalling, useCacheLoader, false, true, fetchPersistentState);
+ return createCache(cacheID, sync, useMarshalling, useCacheLoader, false, true, fetchPersistentState);
}
- protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, boolean useCacheLoader,
- boolean cacheLoaderAsync, boolean startCache, boolean fetchPersistentState)
+ protected CacheSPI<Object, Object> createCache(String cacheID,
+ boolean sync,
+ boolean useMarshalling,
+ boolean useCacheLoader,
+ boolean cacheLoaderAsync,
+ boolean startCache, boolean fetchPersistentState)
throws Exception
{
if (useCacheLoader)
{
- return createCache(sync, useMarshalling, getDefaultCacheLoader(), cacheLoaderAsync, startCache, fetchPersistentState);
+ return createCache(cacheID, sync, useMarshalling, "org.jboss.cache.loader.FileCacheLoader", cacheLoaderAsync, startCache, fetchPersistentState);
}
else
{
- return createCache(sync, useMarshalling, null, cacheLoaderAsync, startCache, fetchPersistentState);
+ return createCache(cacheID, sync, useMarshalling, null, cacheLoaderAsync, startCache, fetchPersistentState);
}
}
-
- protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, String cacheLoaderClass,
+ protected CacheSPI<Object, Object> createCache(String cacheID, boolean sync, boolean useMarshalling, String cacheLoaderClass,
boolean cacheLoaderAsync, boolean startCache, boolean fetchPersistentState) throws Exception
{
- String cacheID = getNextUniqueCacheName();
+ Map<String, Cache> caches = cachesTL.get();
if (caches.get(cacheID) != null)
{
throw new IllegalStateException(cacheID + " already created");
@@ -129,6 +136,7 @@
c.setSyncRollbackPhase(true);
c.setSyncCommitPhase(true);
}
+ //c.setClusterName("VersionedTestBase");
c.setReplVersionString(getReplicationVersion());
// Use a long timeout to facilitate setting debugger breakpoints
c.setStateRetrievalTimeout(60000);
@@ -152,6 +160,7 @@
if (startCache)
{
+ tree.create();
tree.start();
}
@@ -203,9 +212,12 @@
validateMultiplexer(cache);
}
- protected void configureCacheLoader(Configuration c, String cacheID, boolean async) throws Exception
+ protected void configureCacheLoader(Configuration c,
+ String cacheID,
+ boolean async)
+ throws Exception
{
- configureCacheLoader(c, getDefaultCacheLoader(), cacheID, async, true);
+ configureCacheLoader(c, "org.jboss.cache.loader.FileCacheLoader", cacheID, async, true);
}
protected void configureCacheLoader(Configuration c, String cacheloaderClass, String cacheID,
@@ -216,40 +228,47 @@
if (cacheloaderClass.equals("org.jboss.cache.loader.JDBCCacheLoader"))
{
Properties prop = UnitTestDatabaseManager.getTestDbProperties();
+ String props = "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" + "cache.jdbc.url="
+ + prop.getProperty("cache.jdbc.url") + "\n" + "cache.jdbc.user="
+ + prop.getProperty("cache.jdbc.user") + "\n" + "cache.jdbc.password="
+ + prop.getProperty("cache.jdbc.password") + "\n" + "cache.jdbc.node.type="
+ + prop.getProperty("cache.jdbc.node.type") + "\n" + "cache.jdbc.table.name="
+ + prop.getProperty("cache.jdbc.table.name");
+
CacheLoaderConfig clc = UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false, "", "org.jboss.cache.loader.JDBCCacheLoader",
- prop, false, true, false, false, false);
+ props, false, true, false, false, false);
clc.getFirstCacheLoaderConfig().setPurgeOnStartup(true);
c.setCacheLoaderConfig(clc);
- } else if (cacheloaderClass.equals(FileCacheLoader.class.getName()))
+ }
+ else
{
- String tmpLocation = getTempLocation(cacheID);
- File file = new File(tmpLocation);
+
+ String tmp_location = getTempLocation(cacheID);
+
+ // Do cleanup in case it failed before
+ File file = new File(tmp_location);
cleanFile(file);
+
file.mkdir();
- tmpLocation = escapeWindowsPath(tmpLocation);
- String props = "location = " + tmpLocation + "\n";
+
+ tmp_location = escapeWindowsPath(tmp_location);
+ String props = "location = " + tmp_location + "\n";
c.setCacheLoaderConfig(UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false, "", cacheloaderClass,
props, async, fetchPersistentState, false, false, false));
}
- else
- {
- assert !cacheloaderClass.equals(FileCacheLoader.class.getName());
- c.setCacheLoaderConfig(UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false, "", cacheloaderClass,
- "", async, fetchPersistentState, false, false, false));
- }
}
}
protected void initialStateTferWithLoaderTest(String cacheLoaderClass1, String cacheLoaderClass2, boolean asyncLoader) throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache(false, false, cacheLoaderClass1, false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, cacheLoaderClass1, false, true, true);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache(false, false, cacheLoaderClass2, asyncLoader, true, true);
+ CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, cacheLoaderClass2, asyncLoader, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -258,24 +277,6 @@
CacheLoader loader = cache2.getCacheLoaderManager().getCacheLoader();
- long start = System.currentTimeMillis();
- while (asyncLoader && System.currentTimeMillis() - start < 10000)
- {
- try
- {
- doAssertion(cache2, loader);
- break;
- } catch (Throwable ae)
- {
- //allow this within the timeout
- }
- }
- doAssertion(cache2, loader);
- }
-
- private void doAssertion(CacheSPI<Object, Object> cache2, CacheLoader loader)
- throws Exception
- {
assertEquals("Incorrect loader name for /a/b", JOE, loader.get(A_B).get("name"));
assertEquals("Incorrect loader age for /a/b", TWENTY, loader.get(A_B).get("age"));
assertEquals("Incorrect loader name for /a/c", BOB, loader.get(A_C).get("name"));
@@ -317,17 +318,22 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
- {caches = new HashMap<String, Cache>();
+ {
+ Map<String, Cache> caches = new HashMap<String, Cache>();
+ cachesTL.set(caches);
// Save the TCL in case a test changes it
- orig_TCL = Thread.currentThread().getContextClassLoader();
+ ClassLoader orig_TCL = Thread.currentThread().getContextClassLoader();
+ orig_TCL_TL.set(orig_TCL);
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
+ Map<String, Cache> caches = cachesTL.get();
+
// Restore the TCL in case a test changed it
- Thread.currentThread().setContextClassLoader(orig_TCL);
+ Thread.currentThread().setContextClassLoader(orig_TCL_TL.get());
for (String cacheID : caches.keySet())
{
@@ -350,6 +356,7 @@
{
TestingUtil.killCaches(c);
}
+ cachesTL.set(null);
}
protected void stopCache(Cache cache)
@@ -423,7 +430,7 @@
boolean activateRoot)
throws Exception
{
- this.cache = createCache(sync, true, false);
+ this.cache = createCache(name, sync, true, false);
this.semaphore = semaphore;
this.name = name;
@@ -439,7 +446,7 @@
boolean activateRoot, long stateRetrievalTimeout)
throws Exception
{
- cache = createCache(sync, true, false, false, false, true);
+ cache = createCache(name, sync, true, false, false, false, true);
cache.getConfiguration().setStateRetrievalTimeout(stateRetrievalTimeout);
cache.start();
this.semaphore = semaphore;
@@ -513,14 +520,4 @@
}
}
}
-
- protected String getDefaultCacheLoader()
- {
- return org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader.class.getName();
- }
-
- private String getNextUniqueCacheName()
- {
- return getClass().getSimpleName() + cacheCount++;
- }
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -4,7 +4,6 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.util.TestingUtil;
@@ -86,8 +85,8 @@
{
Writer writer;
Configuration cfg1, cfg2;
- cfg1 = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC);
- cfg2 = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC);
+ cfg1 = new Configuration();
+ cfg2 = new Configuration();
cfg1.setCacheMode(Configuration.CacheMode.REPL_SYNC);
cfg2.setCacheMode(Configuration.CacheMode.REPL_SYNC);
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java 2009-02-04 17:46:08 UTC (rev 7645)
@@ -159,15 +159,13 @@
Class<? extends ReplicableCommand> replicableCommandClass = it.next();
if (realOne.containsCommandType(replicableCommandClass))
{
- it.remove();//only remove once
- break;
+ it.remove();
} else if (realOne.getSingleModification() instanceof PrepareCommand) //explicit transaction
{
PrepareCommand prepareCommand = (PrepareCommand) realOne.getSingleModification();
if (prepareCommand.containsModificationType(replicableCommandClass))
{
it.remove();
- break;//only remove once
}
}
}
@@ -256,5 +254,3 @@
return cache;
}
}
-//[127.0.0.1:7900] Processed command: ReplicateCommand{cmds=PrepareCommand{globalTransaction=GlobalTransaction:<127.0.0.1:7903>:481, modifications=[PutDataMapCommand{fqn=/_BUDDY_BACKUP_/127.0.0.1_7903/JSESSION/BuddyReplicationFailoverTest54_localhost/160, dataVersion=null, data={2=org.jboss.cache.integration.websession.util.SessionMetadata@93a0d8, 1=1233588409000, 3={key=2}, 0=3}, globalTransaction=null, erase=false}], localAddress=127.0.0.1:7903, onePhaseCommit=true}}
-//[127.0.0.1:7900] skipping command ReplicateCommand{cmds=PrepareCommand{globalTransaction=GlobalTransaction:<127.0.0.1:7903>:482, modifications=[PutDataMapCommand{fqn=/_BUDDY_BACKUP_/127.0.0.1_7903/JSESSION/BuddyReplicationFailoverTest54_localhost/160, dataVersion=null, data={1=1233588409031, 3={key=3}, 0=4}, globalTransaction=null, erase=false}], localAddress=127.0.0.1:7903, onePhaseCommit=true}}
Modified: core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml
===================================================================
--- core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml 2009-02-04 17:33:49 UTC (rev 7644)
+++ core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml 2009-02-04 17:46:08 UTC (rev 7645)
@@ -263,7 +263,7 @@
<attribute name="IsolationLevel">REPEATABLE_READ</attribute>
<!-- Valid modes are REPL_ASYNC and REPL_SYNC -->
- <attribute name="CacheMode">REPL_SYNC</attribute>
+ <attribute name="CacheMode">REPL_ASYNC</attribute>
<!-- Name of cluster. Needs to be the same for all members, in order
to find each other -->
@@ -341,26 +341,26 @@
</attribute>
<!-- Cache Loader for session passivation -->
- <attribute name="CacheLoaderConfig">
- <config>
- <passivation>true</passivation>
- <shared>false</shared>
+ <!--<attribute name="CacheLoaderConfig">-->
+ <!--<config>-->
+ <!--<passivation>true</passivation>-->
+ <!--<shared>false</shared>-->
- <purgeOnStartup>true</purgeOnStartup>
+ <!--<purgeOnStartup>true</purgeOnStartup>-->
- <cacheloader>
- <class>org.jboss.cache.loader.FileCacheLoader</class>
- <properties>
- location=${java.io.tmpdir}${/}session
- </properties>
- <async>false</async>
- <fetchPersistentState>true</fetchPersistentState>
- <ignoreModifications>false</ignoreModifications>
- <checkCharacterPortability>false</checkCharacterPortability>
- </cacheloader>
+ <!--<cacheloader>-->
+ <!--<class>org.jboss.cache.loader.FileCacheLoader</class>-->
+ <!--<properties>-->
+ <!--location=${java.io.tmpdir}${/}session-->
+ <!--</properties>-->
+ <!--<async>false</async>-->
+ <!--<fetchPersistentState>true</fetchPersistentState>-->
+ <!--<ignoreModifications>false</ignoreModifications>-->
+ <!--<checkCharacterPortability>false</checkCharacterPortability>-->
+ <!--</cacheloader>-->
- </config>
- </attribute>
+ <!--</config>-->
+ <!--</attribute>-->
<!--
JBoss Cache eviction is not needed; webapp or SFSB container
15 years, 10 months
JBoss Cache SVN: r7644 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2009-02-04 12:33:49 -0500 (Wed, 04 Feb 2009)
New Revision: 7644
Modified:
core/trunk/src/main/java/org/jboss/cache/config/Option.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
Log:
Revert 7635, 7643 and 7642
Modified: core/trunk/src/main/java/org/jboss/cache/config/Option.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Option.java 2009-02-04 17:01:56 UTC (rev 7643)
+++ core/trunk/src/main/java/org/jboss/cache/config/Option.java 2009-02-04 17:33:49 UTC (rev 7644)
@@ -27,7 +27,6 @@
* Used to override characteristics of specific calls to the cache. The javadocs of each of the setters below detail functionality and behaviour.
*
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
- * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
* @since 1.3.0
*/
public class Option implements Cloneable
@@ -50,7 +49,6 @@
private int lockAcquisitionTimeout = -1;
private boolean suppressPersistence;
- private boolean suppressEventNotification;
/**
* @since 1.4.0
@@ -272,8 +270,6 @@
", skipDataGravitation=" + skipDataGravitation +
", forceAsynchronous=" + forceAsynchronous +
", forceSynchronous=" + forceSynchronous +
- ", suppressPersistence=" + suppressPersistence +
- ", suppressEventNotification=" + suppressEventNotification +
'}';
}
@@ -324,7 +320,6 @@
if (forceSynchronous != option.forceSynchronous) return false;
if (lockAcquisitionTimeout != option.lockAcquisitionTimeout) return false;
if (suppressPersistence != option.suppressPersistence) return false;
- if (suppressEventNotification != option.suppressEventNotification) return false;
return true;
}
@@ -343,7 +338,6 @@
result = 29 * result + (forceSynchronous ? 0 : 1);
result = 29 * result + (lockAcquisitionTimeout);
result = 29 * result + (suppressPersistence ? 0 : 1);
- result = 29 * result + (suppressEventNotification ? 0 : 1);
return result;
}
@@ -363,7 +357,6 @@
this.forceSynchronous = false;
this.lockAcquisitionTimeout = -1;
this.suppressPersistence = false;
- this.suppressEventNotification = false;
}
/**
@@ -482,29 +475,4 @@
{
this.suppressPersistence = suppressPersistence;
}
-
- /**
- * Get whether event notifications for this invocation will be suppresed. By
- * default is false which means that corresponding events are sent depending
- * on the type of invocation.
- *
- * @return true, if event notification will be suppressed for this invocation.
- */
- public boolean isSuppressEventNotification()
- {
- return suppressEventNotification;
- }
-
- /**
- * Set whether event notifications should be suppressed for this particular
- * cache or transaction invocation.
- *
- * @param suppressEventNotification <code>true</code> if event notification
- * should be skipped; <code>false</code> if events
- * should be notified if there're any listeners.
- */
- public void setSuppressEventNotification(boolean suppressEventNotification)
- {
- this.suppressEventNotification = suppressEventNotification;
- }
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2009-02-04 17:01:56 UTC (rev 7643)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2009-02-04 17:33:49 UTC (rev 7644)
@@ -74,7 +74,6 @@
*
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
* @author <a href="mailto:stevew@jofti.com">Steve Woodcock (stevew(a)jofti.com)</a>
- * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
public class TxInterceptor extends BaseTransactionalContextInterceptor
{
@@ -922,9 +921,6 @@
{
// this should ideally be set in beforeCompletion(), after compacting the list.
if (modifications == null) modifications = transactionContext.getModifications();
-// Option transactionalOptions = transactionContext.getOption();
-// Option originalOptions = ctx.getOptionOverrides();
-// transactionalOptions.setSuppressEventNotification(originalOptions.isSuppressEventNotification());
ctx.setOptionOverrides(transactionContext.getOption());
}
if (tx != null) transactions.remove(tx);
@@ -1055,7 +1051,6 @@
// set any transaction wide options as current for this thread, caching original options that would then be reset
originalOptions = ctx.getOptionOverrides();
transactionalOptions = transactionContext.getOption();
-// transactionalOptions.setSuppressEventNotification(originalOptions.isSuppressEventNotification());
ctx.setOptionOverrides(transactionalOptions);
try
Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2009-02-04 17:01:56 UTC (rev 7643)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2009-02-04 17:33:49 UTC (rev 7644)
@@ -64,7 +64,6 @@
* Helper class that handles all notifications to registered listeners.
*
* @author <a href="mailto:manik AT jboss DOT org">Manik Surtani (manik AT jboss DOT org)</a>
- * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
@NonVolatile
public class NotifierImpl implements Notifier
@@ -308,7 +307,7 @@
public void notifyNodeCreated(Fqn fqn, boolean pre, InvocationContext ctx)
{
- if (!nodeCreatedListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeCreatedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Transaction tx = ctx.getTransaction();
@@ -327,7 +326,7 @@
public void notifyNodeModified(Fqn fqn, boolean pre, NodeModifiedEvent.ModificationType modificationType, Map data, InvocationContext ctx)
{
- if (!nodeModifiedListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeModifiedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -354,7 +353,7 @@
public void notifyNodeRemoved(Fqn fqn, boolean pre, Map data, InvocationContext ctx)
{
- if (!nodeRemovedListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeRemovedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -375,7 +374,7 @@
public void notifyNodeVisited(Fqn fqn, boolean pre, InvocationContext ctx)
{
- if (!nodeVisitedListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeVisitedListeners.isEmpty())
{
Transaction tx = ctx.getTransaction();
InvocationContext backup = resetInvocationContext(ctx);
@@ -392,7 +391,7 @@
public void notifyNodeMoved(Fqn originalFqn, Fqn newFqn, boolean pre, InvocationContext ctx)
{
- if (!nodeMovedListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeMovedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Transaction tx = ctx.getTransaction();
@@ -412,7 +411,7 @@
public void notifyNodeEvicted(final Fqn fqn, final boolean pre, InvocationContext ctx)
{
- if (!nodeEvictedListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeEvictedListeners.isEmpty())
{
final boolean originLocal = ctx.isOriginLocal();
Transaction tx = ctx.getTransaction();
@@ -431,7 +430,7 @@
public void notifyNodeInvalidated(final Fqn fqn, final boolean pre, InvocationContext ctx)
{
- if (!nodeInvalidatedListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeInvalidatedListeners.isEmpty())
{
final boolean originLocal = ctx.isOriginLocal();
Transaction tx = ctx.getTransaction();
@@ -450,7 +449,7 @@
public void notifyNodeLoaded(Fqn fqn, boolean pre, Map data, InvocationContext ctx)
{
- if (!nodeLoadedListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeLoadedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -471,7 +470,7 @@
public void notifyNodeActivated(Fqn fqn, boolean pre, Map data, InvocationContext ctx)
{
- if (!nodeActivatedListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodeActivatedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -492,7 +491,7 @@
public void notifyNodePassivated(Fqn fqn, boolean pre, Map data, InvocationContext ctx)
{
- if (!nodePassivatedListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!nodePassivatedListeners.isEmpty())
{
Map dataCopy = copy(data, useMarshalledValueMaps);
Transaction tx = ctx.getTransaction();
@@ -568,7 +567,7 @@
public void notifyTransactionCompleted(Transaction transaction, boolean successful, InvocationContext ctx)
{
- if (!transactionCompletedListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!transactionCompletedListeners.isEmpty())
{
boolean isOriginLocal = ctx.isOriginLocal();
InvocationContext backup = resetInvocationContext(ctx);
@@ -585,7 +584,7 @@
public void notifyTransactionRegistered(Transaction transaction, InvocationContext ctx)
{
- if (!transactionRegisteredListeners.isEmpty() && !ctx.getOptionOverrides().isSuppressEventNotification())
+ if (!transactionRegisteredListeners.isEmpty())
{
boolean isOriginLocal = ctx.isOriginLocal();
InvocationContext backup = resetInvocationContext(ctx);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2009-02-04 17:01:56 UTC (rev 7643)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2009-02-04 17:33:49 UTC (rev 7644)
@@ -78,7 +78,7 @@
byte[] bytes = marshaller.objectToByteBuffer("Hello");
ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes));
- assertEquals("Version header short should be '31'", 31, in.readShort());
+ assertEquals("Version header short should be '30'", 30, in.readShort());
}
public void testVersionHeader210() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java 2009-02-04 17:01:56 UTC (rev 7643)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java 2009-02-04 17:33:49 UTC (rev 7644)
@@ -12,7 +12,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Option;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.notifications.event.Event;
import static org.jboss.cache.notifications.event.Event.Type.*;
@@ -39,7 +38,6 @@
* exercises the new CacheListener annotation.
*
* @since 2.0.0
- * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
@Test(groups = "functional", sequential = true, testName = "notifications.CacheListenerTest")
public class CacheListenerTest
@@ -70,7 +68,6 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- clearSuppressEventNotification();
Transaction t = tm.getTransaction();
if (t != null)
tm.rollback();
@@ -81,53 +78,32 @@
// simple tests first
- public void testCreation()
+ public void testCreation() throws Exception
{
- creation(false);
- eventLog.events.clear();
- creation(true);
- }
-
- protected void creation(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, "key", "value");
Map<Object, Object> data = new HashMap<Object, Object>();
data.put("key", "value");
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
+ expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, null, true, null, false, null, NODE_MODIFIED));
+ if (optLocking)
{
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
- expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
- expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, null, true, null, false, null, NODE_MODIFIED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
- assertEquals("value", cache.get(fqn, "key"));
+ assertEquals("value", cache.get(fqn, "key"));
}
- public void testOnlyModification()
+ public void testOnlyModification() throws Exception
{
- onlyModification(false);
- eventLog.events.clear();
- onlyModification(true);
- }
-
- protected void onlyModification(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
cache.put(fqn, "key", "value");
Map<Object, Object> oldData = new HashMap<Object, Object>();
@@ -138,42 +114,28 @@
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, "key", "value2");
Map<Object, Object> newData = new HashMap<Object, Object>();
newData.put("key", "value2");
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, PUT_DATA, oldData, fqn, null, true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_DATA, newData, fqn, null, true, null, false, null, NODE_MODIFIED));
+ if (optLocking)
{
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, PUT_DATA, oldData, fqn, null, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_DATA, newData, fqn, null, true, null, false, null, NODE_MODIFIED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected.size(), eventLog.events.size());
assertEquals(expected, eventLog.events);
}
- public void testOnlyRemoval()
+ public void testOnlyRemoval() throws Exception
{
- onlyRemoval(false);
- eventLog.events.clear();
- onlyRemoval(true);
- }
-
- protected void onlyRemoval(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
cache.put(fqn, "key", "value");
Map<Object, Object> oldData = new HashMap<Object, Object>();
@@ -186,25 +148,18 @@
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.removeNode(fqn);
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, oldData, fqn, null, true, null, false, null, NODE_REMOVED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_REMOVED));
+ if (optLocking)
{
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, oldData, fqn, null, true, null, false, null, NODE_REMOVED));
- expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_REMOVED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
@@ -213,42 +168,22 @@
assertNull("Should be null", cache.getRoot().getChild(fqn));
}
- public void testNonexistentRemove()
+ public void testNonexistentRemove() throws Exception
{
- nonexistentRemove(false);
- eventLog.events.clear();
- nonexistentRemove(true);
- }
-
- protected void nonexistentRemove(boolean supressEventNotification)
- {
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.removeNode("/does/not/exist");
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
+
+ if (optLocking)
{
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
}
- public void testRemoveData()
+ public void testRemoveData() throws Exception
{
- removeData(false);
- eventLog.events.clear();
- removeData(true);
- }
-
- protected void removeData(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
cache.put(fqn, "key", "value");
cache.put(fqn, "key2", "value2");
@@ -261,10 +196,6 @@
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.remove(fqn, "key2");
Map<Object, Object> removedData = new HashMap<Object, Object>();
removedData.put("key2", "value2");
@@ -272,17 +203,14 @@
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, REMOVE_DATA, oldData, fqn, null, true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, REMOVE_DATA, removedData, fqn, null, true, null, false, null, NODE_MODIFIED));
+ if (optLocking)
{
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, REMOVE_DATA, oldData, fqn, null, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, REMOVE_DATA, removedData, fqn, null, true, null, false, null, NODE_MODIFIED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
@@ -290,13 +218,6 @@
public void testPutMap() throws Exception
{
- putMap(false);
- eventLog.events.clear();
- putMap(true);
- }
-
- protected void putMap(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
Map<Object, Object> oldData = new HashMap<Object, Object>();
oldData.put("key", "value");
@@ -307,27 +228,20 @@
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, oldData);
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
- expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
- expected.add(new EventImpl(true, cache, PUT_MAP, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_MAP, oldData, fqn, null, true, null, false, null, NODE_MODIFIED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
+ expected.add(new EventImpl(true, cache, PUT_MAP, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_MAP, oldData, fqn, null, true, null, false, null, NODE_MODIFIED));
+ if (optLocking)
+ {
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
@@ -335,13 +249,6 @@
public void testMove()
{
- move(false);
- eventLog.events.clear();
- move(true);
- }
-
- protected void move(boolean supressEventNotification)
- {
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
Fqn newParent = Fqn.fromString("/a");
cache.put(fqn, "key", "value");
@@ -352,26 +259,19 @@
eventLog.events.clear();// clear events
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.move(n1.getFqn(), n2.getFqn());
//expected
Fqn newFqn = Fqn.fromRelativeElements(newParent, fqn.getLastElement());
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- if (optLocking)
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, null, true, newFqn, false, null, NODE_MOVED));
- expected.add(new EventImpl(false, cache, null, null, fqn, null, true, newFqn, false, null, NODE_MOVED));
- if (optLocking)
- {
- expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
- eventLog.scrubImplicitTransactions();
- }
+ if (optLocking)
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, null, fqn, null, true, newFqn, false, null, NODE_MOVED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, null, true, newFqn, false, null, NODE_MOVED));
+ if (optLocking)
+ {
+ expected.add(new EventImpl(false, cache, null, null, null, null, true, null, true, null, TRANSACTION_COMPLETED));
+ eventLog.scrubImplicitTransactions();
}
assertEquals(expected, eventLog.events);
@@ -381,138 +281,63 @@
public void testTxNonexistentRemove() throws Exception
{
- txNonexistentRemove(false);
- eventLog.events.clear();
-// txNonexistentRemove(true);
- }
-
- protected void txNonexistentRemove(boolean supressEventNotification) throws Exception
- {
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
cache.removeNode("/does/not/exist");
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.commit();
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
}
-
+
public void testTxCreationCommit() throws Exception
{
- txCreationCommit(false);
- eventLog.events.clear();
-// txCreationCommit(true);
- }
-
- protected void txCreationCommit(boolean supressEventNotification) throws Exception
- {
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, "key", "value");
//expected
Map<Object, Object> data = new HashMap<Object, Object>();
data.put("key", "value");
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
- expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
- expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn, tx, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, tx, true, null, false, null, NODE_MODIFIED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+ expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn, tx, true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, tx, true, null, false, null, NODE_MODIFIED));
assertEquals(expected, eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.commit();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
assertEquals("value", cache.get(fqn, "key"));
}
public void testTxCreationRollback() throws Exception
{
- txCreationRollback(false);
- eventLog.events.clear();
-// txCreationRollback(true);
- }
-
- protected void txCreationRollback(boolean supressEventNotification) throws Exception
- {
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, "key", "value");
//expected
Map<Object, Object> data = new HashMap<Object, Object>();
data.put("key", "value");
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
- expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
- expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn, tx, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, tx, true, null, false, null, NODE_MODIFIED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+ expected.add(new EventImpl(true, cache, PUT_DATA, Collections.emptyMap(), fqn, tx, true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_DATA, data, fqn, tx, true, null, false, null, NODE_MODIFIED));
assertEquals(expected, eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.rollback();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_COMPLETED));
- }
- assertEquals(expected, eventLog.events);
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_COMPLETED));
+ assertEquals(expected, eventLog.events);
}
public void testTxOnlyModification() throws Exception
{
- txOnlyModification(false);
- eventLog.events.clear();
-// txOnlyModification(true);
- }
-
- protected void txOnlyModification(boolean supressEventNotification) throws Exception
- {
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
cache.put(fqn, "key", "value");
Map<Object, Object> oldData = new HashMap<Object, Object>();
@@ -523,51 +348,26 @@
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.put(fqn, "key", "value2");
Map<Object, Object> newData = new HashMap<Object, Object>();
newData.put("key", "value2");
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, PUT_DATA, oldData, fqn, tx, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, PUT_DATA, newData, fqn, tx, true, null, false, null, NODE_MODIFIED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, PUT_DATA, oldData, fqn, tx, true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, PUT_DATA, newData, fqn, tx, true, null, false, null, NODE_MODIFIED));
assertEquals(expected, eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.commit();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
- }
+ }
public void testTxOnlyRemoval() throws Exception
{
- txOnlyRemoval(false);
- eventLog.events.clear();
-// txOnlyRemoval(true);
- }
-
- protected void txOnlyRemoval(boolean supressEventNotification) throws Exception
- {
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
cache.put(fqn, "key", "value");
Map<Object, Object> oldData = new HashMap<Object, Object>();
@@ -580,36 +380,19 @@
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.removeNode(fqn);
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, oldData, fqn, tx, true, null, false, null, NODE_REMOVED));
- expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_REMOVED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, null, oldData, fqn, tx, true, null, false, null, NODE_REMOVED));
+ expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_REMOVED));
+
assertEquals(expected, eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.commit();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
// test that the node has in fact been removed.
assertNull("Should be null", cache.getRoot().getChild(fqn));
@@ -617,13 +400,6 @@
public void testTxRemoveData() throws Exception
{
- txRemoveData(false);
- eventLog.events.clear();
-// txRemoveData(true);
- }
-
- protected void txRemoveData(boolean supressEventNotification) throws Exception
- {
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
cache.put(fqn, "key", "value");
cache.put(fqn, "key2", "value2");
@@ -636,38 +412,20 @@
assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
// modify existing node
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.begin();
Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
cache.remove(fqn, "key2");
Map<Object, Object> removedData = new HashMap<Object, Object>();
removedData.put("key2", "value2");
//expected
List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, REMOVE_DATA, oldData, fqn, tx, true, null, false, null, NODE_MODIFIED));
- expected.add(new EventImpl(false, cache, REMOVE_DATA, removedData, fqn, tx, true, null, false, null, NODE_MODIFIED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+ expected.add(new EventImpl(true, cache, REMOVE_DATA, oldData, fqn, tx, true, null, false, null, NODE_MODIFIED));
+ expected.add(new EventImpl(false, cache, REMOVE_DATA, removedData, fqn, tx, true, null, false, null, NODE_MODIFIED));
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
tm.commit();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
- }
+ expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
assertEquals(expected, eventLog.events);
@@ -700,64 +458,4 @@
expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
assertEquals(expected, eventLog.events);
}
-
- protected void txMove(boolean supressEventNotification) throws Exception
- {
- assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
- Fqn newParent = Fqn.fromString("/a");
- cache.put(fqn, "key", "value");
- cache.put(newParent, "key", "value");
-
- Node<Object, Object> n1 = cache.getRoot().getChild(fqn);
- Node<Object, Object> n2 = cache.getRoot().getChild(newParent);
- eventLog.events.clear();// clear events
- assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
-
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
- tm.begin();
- Transaction tx = tm.getTransaction();
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
- cache.move(n1.getFqn(), n2.getFqn());
- //expected
- Fqn newFqn = Fqn.fromRelativeElements(newParent, fqn.getLastElement());
- List<Event> expected = new ArrayList<Event>();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
- expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, newFqn, false, null, NODE_MOVED));
- expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, newFqn, false, null, NODE_MOVED));
- }
-
- assertEquals(expected, eventLog.events);
- if (supressEventNotification)
- {
- setSuppressEventNotification();
- }
- tm.commit();
- if (!supressEventNotification)
- {
- expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
- }
- assertEquals(expected, eventLog.events);
- }
-
- protected void setSuppressEventNotification()
- {
- Option option = new Option();
- option.setSuppressEventNotification(true);
- cache.getInvocationContext().setOptionOverrides(option);
- }
-
- protected void clearSuppressEventNotification()
- {
- Option option = new Option();
- option.setSuppressEventNotification(false);
- cache.getInvocationContext().setOptionOverrides(option);
- }
}
15 years, 10 months
JBoss Cache SVN: r7643 - core/trunk/src/test/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2009-02-04 12:01:56 -0500 (Wed, 04 Feb 2009)
New Revision: 7643
Modified:
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
Log:
Fixed test for version 3.1.x.
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2009-02-04 17:00:45 UTC (rev 7642)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2009-02-04 17:01:56 UTC (rev 7643)
@@ -78,7 +78,7 @@
byte[] bytes = marshaller.objectToByteBuffer("Hello");
ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes));
- assertEquals("Version header short should be '30'", 30, in.readShort());
+ assertEquals("Version header short should be '31'", 31, in.readShort());
}
public void testVersionHeader210() throws Exception
15 years, 10 months
JBoss Cache SVN: r7642 - in core/trunk/src: test/java/org/jboss/cache/notifications and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2009-02-04 12:00:45 -0500 (Wed, 04 Feb 2009)
New Revision: 7642
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
Log:
[JBCACHE-1470] Comment the transaction event notification related tests and the changes in TxInterceptor that caused a bit of havoc.
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2009-02-04 16:28:37 UTC (rev 7641)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2009-02-04 17:00:45 UTC (rev 7642)
@@ -922,9 +922,9 @@
{
// this should ideally be set in beforeCompletion(), after compacting the list.
if (modifications == null) modifications = transactionContext.getModifications();
- Option transactionalOptions = transactionContext.getOption();
- Option originalOptions = ctx.getOptionOverrides();
- transactionalOptions.setSuppressEventNotification(originalOptions.isSuppressEventNotification());
+// Option transactionalOptions = transactionContext.getOption();
+// Option originalOptions = ctx.getOptionOverrides();
+// transactionalOptions.setSuppressEventNotification(originalOptions.isSuppressEventNotification());
ctx.setOptionOverrides(transactionContext.getOption());
}
if (tx != null) transactions.remove(tx);
@@ -1055,7 +1055,7 @@
// set any transaction wide options as current for this thread, caching original options that would then be reset
originalOptions = ctx.getOptionOverrides();
transactionalOptions = transactionContext.getOption();
- transactionalOptions.setSuppressEventNotification(originalOptions.isSuppressEventNotification());
+// transactionalOptions.setSuppressEventNotification(originalOptions.isSuppressEventNotification());
ctx.setOptionOverrides(transactionalOptions);
try
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java 2009-02-04 16:28:37 UTC (rev 7641)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java 2009-02-04 17:00:45 UTC (rev 7642)
@@ -70,6 +70,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
+ clearSuppressEventNotification();
Transaction t = tm.getTransaction();
if (t != null)
tm.rollback();
@@ -382,7 +383,7 @@
{
txNonexistentRemove(false);
eventLog.events.clear();
- txNonexistentRemove(true);
+// txNonexistentRemove(true);
}
protected void txNonexistentRemove(boolean supressEventNotification) throws Exception
@@ -412,7 +413,7 @@
{
txCreationCommit(false);
eventLog.events.clear();
- txCreationCommit(true);
+// txCreationCommit(true);
}
protected void txCreationCommit(boolean supressEventNotification) throws Exception
@@ -460,7 +461,7 @@
{
txCreationRollback(false);
eventLog.events.clear();
- txCreationRollback(true);
+// txCreationRollback(true);
}
protected void txCreationRollback(boolean supressEventNotification) throws Exception
@@ -507,7 +508,7 @@
{
txOnlyModification(false);
eventLog.events.clear();
- txOnlyModification(true);
+// txOnlyModification(true);
}
protected void txOnlyModification(boolean supressEventNotification) throws Exception
@@ -562,7 +563,7 @@
{
txOnlyRemoval(false);
eventLog.events.clear();
- txOnlyRemoval(true);
+// txOnlyRemoval(true);
}
protected void txOnlyRemoval(boolean supressEventNotification) throws Exception
@@ -618,7 +619,7 @@
{
txRemoveData(false);
eventLog.events.clear();
- txRemoveData(true);
+// txRemoveData(true);
}
protected void txRemoveData(boolean supressEventNotification) throws Exception
@@ -752,4 +753,11 @@
option.setSuppressEventNotification(true);
cache.getInvocationContext().setOptionOverrides(option);
}
+
+ protected void clearSuppressEventNotification()
+ {
+ Option option = new Option();
+ option.setSuppressEventNotification(false);
+ cache.getInvocationContext().setOptionOverrides(option);
+ }
}
15 years, 10 months
JBoss Cache SVN: r7641 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-02-04 11:28:37 -0500 (Wed, 04 Feb 2009)
New Revision: 7641
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java
Log:
JBCACHE-1473 - Cache Regions lose capacity - EvictCommand.perform() causes dead entries in EvictionQueue (contributed by Roberto Tyley)
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2009-02-04 16:08:50 UTC (rev 7640)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2009-02-04 16:28:37 UTC (rev 7641)
@@ -86,17 +86,13 @@
* See {@link org.jboss.cache.interceptors.EvictionInterceptor#visitEvictFqnCommand(org.jboss.cache.InvocationContext , EvictCommand)}
* which is where the return value is used
*
- * @return true if the node was removed from the tree or if it is resident. Returns false if the node still exists; i.e. was only data removed because it still has children.
+ * @return true if the node is now absent from the cache. Returns false if the node still exists; i.e. was only data removed because it still has children.
*/
public Object perform(InvocationContext ctx)
{
NodeSPI node = lookupForEviction(ctx, fqn);
- if (node == null || node.isDeleted())
+ if (node == null || node.isDeleted() || node.isResident())
{
- return false;
- }
- else if (node.isResident())
- {
return true;
}
else if (recursive)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2009-02-04 16:08:50 UTC (rev 7640)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2009-02-04 16:28:37 UTC (rev 7641)
@@ -81,8 +81,8 @@
// See if the node still exists; i.e. was only data removed
// because it still has children.
// If yes, put an ADD event in the queue so the node gets revisited
- boolean complete = (retVal != null && (Boolean) retVal);
- if (!complete)
+ boolean nodeIsNowAbsent = (retVal != null && (Boolean) retVal);
+ if (!nodeIsNowAbsent)
{
Region r;
if (fqn != null && (r = getRegion(fqn)) != null)
@@ -244,10 +244,10 @@
private void registerEvictionEventToRegionManager(Fqn fqn, EvictionEvent.Type type, int elementDifference, Region region)
{
//we do not trigger eviction events for resident nodes
- if (dataContainer.isResident(fqn))
+ if (dataContainer.isResident(fqn))
{
- if (trace) log.trace("Ignoring Fqn " + fqn + " as it is marked as resident");
- return;
+ if (trace) log.trace("Ignoring Fqn " + fqn + " as it is marked as resident");
+ return;
}
region.registerEvictionEvent(fqn, type, elementDifference);
Modified: core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java 2009-02-04 16:08:50 UTC (rev 7640)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/EvictCommandTest.java 2009-02-04 16:28:37 UTC (rev 7641)
@@ -47,6 +47,14 @@
control.verify();
}
+ public void testShouldReturnTrueIndicatingNodeIsAbsentIfNodeDoesntExist()
+ {
+ expect(container.peek(testFqn, false, true)).andReturn(null);
+ control.replay();
+ assert Boolean.TRUE == command.perform(ctx);
+ control.verify();
+ }
+
public void testSimpleEviction()
{
expect(container.peek(testFqn, false, true)).andReturn(nodes.abNode);
15 years, 10 months
JBoss Cache SVN: r7640 - core/trunk.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-02-04 11:08:50 -0500 (Wed, 04 Feb 2009)
New Revision: 7640
Modified:
core/trunk/pom.xml
Log:
Reverted back to JGroups 2.6.7
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-02-04 15:54:47 UTC (rev 7639)
+++ core/trunk/pom.xml 2009-02-04 16:08:50 UTC (rev 7640)
@@ -27,7 +27,7 @@
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.7.0.GA</version>
+ <version>2.6.7.GA</version>
</dependency>
<!--
15 years, 10 months
JBoss Cache SVN: r7639 - in core/trunk: src/main/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-02-04 10:54:47 -0500 (Wed, 04 Feb 2009)
New Revision: 7639
Modified:
core/trunk/pom.xml
core/trunk/src/main/java/org/jboss/cache/Version.java
Log:
Updated version
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-02-04 14:32:09 UTC (rev 7638)
+++ core/trunk/pom.xml 2009-02-04 15:54:47 UTC (rev 7639)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-core-version>3.0.3-SNAPSHOT</jbosscache-core-version>
+ <jbosscache-core-version>3.1.0-SNAPSHOT</jbosscache-core-version>
<!-- By default only run tests in the "unit" group -->
<defaultTestGroup>unit</defaultTestGroup>
<!-- By default only generate Javadocs when we install the module. -->
@@ -27,7 +27,7 @@
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.6.7.GA</version>
+ <version>2.7.0.GA</version>
</dependency>
<!--
Modified: core/trunk/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Version.java 2009-02-04 14:32:09 UTC (rev 7638)
+++ core/trunk/src/main/java/org/jboss/cache/Version.java 2009-02-04 15:54:47 UTC (rev 7639)
@@ -32,10 +32,10 @@
@Immutable
public class Version
{
- public static final String version = "3.0.3-SNAPSHOT";
- public static final String codename = "Naga";
+ public static final String version = "3.1.0-SNAPSHOT";
+ public static final String codename = "Cascabel";
//public static final String cvs = "$Id$";
- static final byte[] version_id = {'0', '3', '0', '3', 'S'};
+ static final byte[] version_id = {'0', '3', '1', '0', 'S'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
15 years, 10 months
JBoss Cache SVN: r7638 - core/trunk/src/test/java/org/jboss/cache/statetransfer.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-02-04 09:32:09 -0500 (Wed, 04 Feb 2009)
New Revision: 7638
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
Log:
enable some of the state transfer tests
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2009-02-04 14:19:55 UTC (rev 7637)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2009-02-04 14:32:09 UTC (rev 7638)
@@ -47,13 +47,11 @@
* @author Brian Stansberry
* @version $Revision$
*/
-@Test(groups = {"functional"}, enabled=false, testName = "statetransfer.FailedStateTransferTest")
+@Test(groups = {"functional"}, testName = "statetransfer.FailedStateTransferTest")
public class FailedStateTransferTest extends StateTransferTestBase
{
-
public void testFailedStateTransfer() throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
Configuration c = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
//c.setClusterName("VersionedTestBase");
c.setReplVersionString(getReplicationVersion());
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java 2009-02-04 14:19:55 UTC (rev 7637)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java 2009-02-04 14:32:09 UTC (rev 7638)
@@ -45,8 +45,7 @@
* @author Brian Stansberry
* @version $Revision$
*/
-@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.ForcedStateTransferTest")
-// this has always been disabled since 1.4.x. See JBCACHE-315
+@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.ForcedStateTransferTest", description = "this has always been disabled since 1.4.x. See JBCACHE-315")
public class ForcedStateTransferTest extends StateTransferTestBase
{
/**
@@ -781,7 +780,7 @@
boolean startCache)
throws Exception
{
- CacheSPI<Object, Object> result = super.createCache(cacheID, replSync,
+ CacheSPI<Object, Object> result = super.createCache(replSync,
useMarshalling, false, false, false, true);
result.getConfiguration().setStateRetrievalTimeout(0);
result.getConfiguration().setLockAcquisitionTimeout(1000);
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2009-02-04 14:19:55 UTC (rev 7637)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/PersistingTransientStateTest.java 2009-02-04 14:32:09 UTC (rev 7638)
@@ -4,6 +4,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -24,7 +25,7 @@
* Pertains to JBCACHE-131
* <p/>
*/
-@Test(groups = "functional", enabled=false, testName = "statetransfer.PersistingTransientStateTest")
+@Test(groups = "functional", testName = "statetransfer.PersistingTransientStateTest")
public class PersistingTransientStateTest
{
protected NodeLockingScheme nls = NodeLockingScheme.PESSIMISTIC;
@@ -37,9 +38,8 @@
try
{
UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
- Configuration cfg = new Configuration();
+ Configuration cfg = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cfg.setCacheMode(CacheMode.REPL_SYNC);
cfg.setFetchInMemoryState(true);
// configure with CL
IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
@@ -72,10 +72,8 @@
Cache<String, String> c1 = null, c2 = null;
try
{
- UnitTestCacheFactory<String, String> cf = new UnitTestCacheFactory<String, String>();
- Configuration cfg = new Configuration();
+ Configuration cfg = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC);
cfg.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- cfg.setCacheMode(CacheMode.REPL_SYNC);
cfg.setFetchInMemoryState(true);
// configure with CL
IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
@@ -88,13 +86,13 @@
cfg.setCacheLoaderConfig(clc);
cfg.setNodeLockingScheme(nls);
- c1 = cf.createCache(cfg.clone(), getClass());
+ c1 = new UnitTestCacheFactory<String, String>().createCache(cfg.clone(), getClass());
c1.put(fqn, k, v);
assert c1.get(fqn, k).equals(v);
assert getLoader(c1).get(fqn).get(k).equals(v);
- c2 = cf.createCache(cfg.clone(), getClass());
+ c2 = new UnitTestCacheFactory<String, String>().createCache(cfg.clone(), getClass());
assert c2.get(fqn, k).equals(v);
assert getLoader(c2).get(fqn) == null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2009-02-04 14:19:55 UTC (rev 7637)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2009-02-04 14:32:09 UTC (rev 7638)
@@ -11,9 +11,9 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
-import org.jboss.cache.lock.LockManager;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.buddyreplication.BuddyReplicationTestsBase;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.MarshalledValue;
@@ -29,10 +29,9 @@
* @author <a href="mailto://brian.stansberry@jboss.com">Brian Stansberry</a>
* @version $Revision$
*/
-@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.StateTransfer200Test")
+@Test(groups = {"functional"}, testName = "statetransfer.StateTransfer200Test")
public class StateTransfer200Test extends StateTransferTestBase
{
-
protected String getReplicationVersion()
{
return "2.0.0.GA";
@@ -40,46 +39,34 @@
public void testBuddyBackupExclusion() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, false, false, false, true);
+ CacheSPI<Object, Object> cache1 = createCacheWithBr("testBuddyBackupExclusion_1");
-
- cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
-
- cache1.start();
-
Fqn backup = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cache1.put(backup, "name", JOE);
cache1.put(A_B, "age", TWENTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, false);
-
+ CacheSPI<Object, Object> cache2 = createCacheWithBr("StateTransferTestBase_2");
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
-
+ BuddyReplicationTestsBase.waitForSingleBuddy(cache1, cache2);
assertNull("_buddy_backup_ not transferred", cache2.get(backup, "test"));
assertEquals("Correct age for /a/b", TWENTY, cache2.get(A_B, "age"));
}
public void testBuddyIntegration() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, false, false, false, true);
- cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
- cache1.start();
+ CacheSPI<Object, Object> cache1 = createCacheWithBr("testBuddyIntegration_1");
// cache 1 won't have a buddy at this stage.
-
// put some state in cache 1
cache1.put(A_B, "name", JOE);
cache1.put(A_C, "name", JANE);
// now start up cache 2
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, false, false, false, true);
- cache2.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
- cache2.start();
+ CacheSPI<Object, Object> cache2 = createCacheWithBr("testBuddyIntegration_2");
// Pause to give caches time to see each other
- TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
+ BuddyReplicationTestsBase.waitForSingleBuddy(cache1, cache2);
BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
// now peek into cache 2 to check that this state has been transferred into the backup subtree
@@ -93,7 +80,7 @@
@SuppressWarnings("null")
public void testCacheLoaderFailure() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, CorruptedFileCacheLoader.class.getName(), false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, false, CorruptedFileCacheLoader.class.getName(), false, true, true);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
@@ -103,8 +90,7 @@
CacheSPI cache2 = null;
try
{
- cache2 = createCache("cache2", false, false, true, false, false, true);
- cache2.create();
+ cache2 = createCache(false, false, true, false, false, true);
cache2.start();
//Vladimir October 5th 2007
@@ -122,7 +108,7 @@
public void testLoadEntireStateAfterStart() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, true);
createAndActivateRegion(cache1, Fqn.ROOT);
@@ -131,7 +117,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, true);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -161,14 +147,14 @@
public void testInitialStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, false);
+ CacheSPI<Object, Object> cache1 = createCache(false, false, false);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, false);
+ CacheSPI<Object, Object> cache2 = createCache(false, false, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -191,13 +177,12 @@
protected void initialStateTferWithLoaderTest(boolean asyncLoader) throws Exception
{
- initialStateTferWithLoaderTest("org.jboss.cache.loader.FileCacheLoader",
- "org.jboss.cache.loader.FileCacheLoader", asyncLoader);
+ initialStateTferWithLoaderTest(getDefaultCacheLoader(), getDefaultCacheLoader() , asyncLoader);
}
public void testPartialStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, false);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, false);
createAndActivateRegion(cache1, A);
@@ -206,7 +191,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, false);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -259,20 +244,18 @@
public void testLocksAndStateTransfer() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, false);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, false);
createAndActivateRegion(cache1, A);
cache1.put(A_B, "name", JOE);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, false);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, false);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
createAndActivateRegion(cache2, A_B);
assertEquals("Incorrect name for /a/b", JOE, cache2.get(A_B, "name"));
- LockManager lockManager = cache1.getComponentRegistry().getComponent(LockManager.class);
- assert !lockManager.isLocked(A_B);
+ assert cache1.getNumberOfLocksHeld() == 0;
cache1.getRegion(A, false).deactivate();
- assert !lockManager.isLocked(A);
- assert !lockManager.isLocked(A_B);
+ assert cache1.getNumberOfLocksHeld() == 0;
createAndActivateRegion(cache1, A_B);
assertEquals("Incorrect name for /a/b", JOE, cache1.get(A_B, "name"));
}
@@ -280,7 +263,7 @@
public void testPartialStateTferWithLoader() throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, true, true);
createAndActivateRegion(cache1, A);
@@ -289,7 +272,7 @@
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, true, true);
+ CacheSPI<Object, Object> cache2 = createCache(false, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -377,7 +360,7 @@
// Set the TCL to a classloader that can't see Person/Address
Thread.currentThread().setContextClassLoader(getNotFoundClassLoader());
- CacheSPI<Object, Object> cache1 = createCache("cache1",
+ CacheSPI<Object, Object> cache1 = createCache(
false, // async
true, // use marshaller
true, // use cacheloader
@@ -393,7 +376,7 @@
cache1.put(A_B, "person", ben);
// For cache 2 we won't register loader until later
- CacheSPI<Object, Object> cache2 = createCache("cache2",
+ CacheSPI<Object, Object> cache2 = createCache(
false, // async
true, // use marshalling
true, // use cacheloader
@@ -429,7 +412,7 @@
public void testStalePersistentState() throws Exception
{
- CacheSPI c1 = createCache("1", true, false, true, true);
+ CacheSPI c1 = createCache(true, false, true, true);
c1.put(A, "K", "V");
assert c1.get(A, "K").equals("V");
@@ -445,7 +428,7 @@
assert l1.exists(A);
assert l1.get(A).get("K").equals("V");
- Cache c2 = createCache("2", true, false, true, true);
+ Cache c2 = createCache(true, false, true, true);
c2.put(B, "K", "V");
@@ -455,7 +438,6 @@
assert c1.get(B, "K").equals("V");
assert c1.get(A, "K") == null;
- assert !l1.exists(A);
}
private Object createBen(ClassLoader loader) throws Exception
@@ -487,4 +469,12 @@
brc.setBuddyPoolName("TEST");
return brc;
}
+
+ private CacheSPI<Object, Object> createCacheWithBr(String cacheName) throws Exception
+ {
+ CacheSPI<Object, Object> cache1 = createCache(false, false, false, false, false, true);
+ cache1.getConfiguration().setBuddyReplicationConfig(getBuddyConfig());
+ cache1.start();
+ return cache1;
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java 2009-02-04 14:19:55 UTC (rev 7637)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferCompatibilityTest.java 2009-02-04 14:32:09 UTC (rev 7638)
@@ -2,16 +2,14 @@
import org.testng.annotations.Test;
-@Test(groups = {"functional"}, enabled = false, testName = "statetransfer.StateTransferCompatibilityTest")
+@Test(groups = {"functional"}, testName = "statetransfer.StateTransferCompatibilityTest")
public class StateTransferCompatibilityTest extends StateTransferTestBase
{
-
protected String getReplicationVersion()
{
return "2.0.0.GA";
}
-
/**
* These tests ensure that http://jira.jboss.com/jira/browse/JBCACHE-738
* compatibility between non-delegating cacheloaders is maintained. In the tests
@@ -58,7 +56,6 @@
public void testCompatibilityBetweenJDBCAndBdjeCacheLoaders() throws Exception
{
-
initialStateTferWithLoaderTest("org.jboss.cache.loader.JDBCCacheLoader",
"org.jboss.cache.loader.bdbje.BdbjeCacheLoader", false);
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2009-02-04 14:19:55 UTC (rev 7637)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2009-02-04 14:32:09 UTC (rev 7638)
@@ -7,7 +7,6 @@
package org.jboss.cache.statetransfer;
-import java.util.Map;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
@@ -357,7 +356,7 @@
{
// The first cache we create is inactivated.
- CacheSPI<Object, Object> cacheA = createCache("cacheA", sync, true, false);
+ CacheSPI<Object, Object> cacheA = createCache(sync, true, false);
CacheSPI[] caches = new CacheSPI[count + 1];
caches[0] = cacheA;
@@ -468,8 +467,6 @@
*/
public void testEvictionSeesStateTransfer() throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
-
Configuration c = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
Cache<Object, Object> cache1 = new UnitTestCacheFactory<Object, Object>().createCache(c, getClass());
@@ -503,7 +500,6 @@
Configuration c = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
additionalConfiguration(c);
Cache<Object, Object> cache1 = new UnitTestCacheFactory<Object, Object>().createCache(c, getClass());
- Map<String, Cache> caches = cachesTL.get();
caches.put("evict1", cache1);
for (int i = 0; i < 25000; i++)
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2009-02-04 14:19:55 UTC (rev 7637)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2009-02-04 14:32:09 UTC (rev 7638)
@@ -33,6 +33,7 @@
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.loader.CacheLoader;
+import org.jboss.cache.loader.FileCacheLoader;
import org.jboss.cache.marshall.SelectedClassnameClassLoader;
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.UnitTestDatabaseManager;
@@ -77,52 +78,44 @@
public static final Integer TWENTY = 20;
public static final Integer FORTY = 40;
- protected ThreadLocal<Map<String, Cache>> cachesTL = new ThreadLocal<Map<String, Cache>>();
- private ThreadLocal<ClassLoader> orig_TCL_TL = new ThreadLocal<ClassLoader>();
+ protected Map<String, Cache> caches = new HashMap<String, Cache>();
+ ClassLoader orig_TCL;
+ private static int cacheCount = 0;
protected abstract String getReplicationVersion();
- protected CacheSPI<Object, Object> createCache(String cacheID,
- boolean sync,
- boolean useMarshalling,
- boolean useCacheLoader)
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, boolean useCacheLoader)
throws Exception
{
- return createCache(cacheID, sync, useMarshalling, useCacheLoader, false, true, true);
+ return createCache(sync, useMarshalling, useCacheLoader, false, true, true);
}
- protected CacheSPI<Object, Object> createCache(String cacheID,
- boolean sync,
- boolean useMarshalling,
- boolean useCacheLoader, boolean fetchPersistentState)
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, boolean useCacheLoader, boolean fetchPersistentState)
throws Exception
{
- return createCache(cacheID, sync, useMarshalling, useCacheLoader, false, true, fetchPersistentState);
+ return createCache(sync, useMarshalling, useCacheLoader, false, true, fetchPersistentState);
}
- protected CacheSPI<Object, Object> createCache(String cacheID,
- boolean sync,
- boolean useMarshalling,
- boolean useCacheLoader,
- boolean cacheLoaderAsync,
- boolean startCache, boolean fetchPersistentState)
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, boolean useCacheLoader,
+ boolean cacheLoaderAsync, boolean startCache, boolean fetchPersistentState)
throws Exception
{
if (useCacheLoader)
{
- return createCache(cacheID, sync, useMarshalling, "org.jboss.cache.loader.FileCacheLoader", cacheLoaderAsync, startCache, fetchPersistentState);
+ return createCache(sync, useMarshalling, getDefaultCacheLoader(), cacheLoaderAsync, startCache, fetchPersistentState);
}
else
{
- return createCache(cacheID, sync, useMarshalling, null, cacheLoaderAsync, startCache, fetchPersistentState);
+ return createCache(sync, useMarshalling, null, cacheLoaderAsync, startCache, fetchPersistentState);
}
}
- protected CacheSPI<Object, Object> createCache(String cacheID, boolean sync, boolean useMarshalling, String cacheLoaderClass,
+
+ protected CacheSPI<Object, Object> createCache(boolean sync, boolean useMarshalling, String cacheLoaderClass,
boolean cacheLoaderAsync, boolean startCache, boolean fetchPersistentState) throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
+ String cacheID = getNextUniqueCacheName();
if (caches.get(cacheID) != null)
{
throw new IllegalStateException(cacheID + " already created");
@@ -136,7 +129,6 @@
c.setSyncRollbackPhase(true);
c.setSyncCommitPhase(true);
}
- //c.setClusterName("VersionedTestBase");
c.setReplVersionString(getReplicationVersion());
// Use a long timeout to facilitate setting debugger breakpoints
c.setStateRetrievalTimeout(60000);
@@ -160,7 +152,6 @@
if (startCache)
{
- tree.create();
tree.start();
}
@@ -212,12 +203,9 @@
validateMultiplexer(cache);
}
- protected void configureCacheLoader(Configuration c,
- String cacheID,
- boolean async)
- throws Exception
+ protected void configureCacheLoader(Configuration c, String cacheID, boolean async) throws Exception
{
- configureCacheLoader(c, "org.jboss.cache.loader.FileCacheLoader", cacheID, async, true);
+ configureCacheLoader(c, getDefaultCacheLoader(), cacheID, async, true);
}
protected void configureCacheLoader(Configuration c, String cacheloaderClass, String cacheID,
@@ -228,47 +216,40 @@
if (cacheloaderClass.equals("org.jboss.cache.loader.JDBCCacheLoader"))
{
Properties prop = UnitTestDatabaseManager.getTestDbProperties();
- String props = "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" + "cache.jdbc.url="
- + prop.getProperty("cache.jdbc.url") + "\n" + "cache.jdbc.user="
- + prop.getProperty("cache.jdbc.user") + "\n" + "cache.jdbc.password="
- + prop.getProperty("cache.jdbc.password") + "\n" + "cache.jdbc.node.type="
- + prop.getProperty("cache.jdbc.node.type") + "\n" + "cache.jdbc.table.name="
- + prop.getProperty("cache.jdbc.table.name");
-
CacheLoaderConfig clc = UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false, "", "org.jboss.cache.loader.JDBCCacheLoader",
- props, false, true, false, false, false);
+ prop, false, true, false, false, false);
clc.getFirstCacheLoaderConfig().setPurgeOnStartup(true);
c.setCacheLoaderConfig(clc);
- }
- else
+ } else if (cacheloaderClass.equals(FileCacheLoader.class.getName()))
{
-
- String tmp_location = getTempLocation(cacheID);
-
- // Do cleanup in case it failed before
- File file = new File(tmp_location);
+ String tmpLocation = getTempLocation(cacheID);
+ File file = new File(tmpLocation);
cleanFile(file);
-
file.mkdir();
-
- tmp_location = escapeWindowsPath(tmp_location);
- String props = "location = " + tmp_location + "\n";
+ tmpLocation = escapeWindowsPath(tmpLocation);
+ String props = "location = " + tmpLocation + "\n";
c.setCacheLoaderConfig(UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false, "", cacheloaderClass,
props, async, fetchPersistentState, false, false, false));
}
+ else
+ {
+ assert !cacheloaderClass.equals(FileCacheLoader.class.getName());
+ c.setCacheLoaderConfig(UnitTestConfigurationFactory.buildSingleCacheLoaderConfig(false, "", cacheloaderClass,
+ "", async, fetchPersistentState, false, false, false));
+ }
}
}
protected void initialStateTferWithLoaderTest(String cacheLoaderClass1, String cacheLoaderClass2, boolean asyncLoader) throws Exception
{
- CacheSPI<Object, Object> cache1 = createCache("cache1", false, false, cacheLoaderClass1, false, true, true);
+ CacheSPI<Object, Object> cache1 = createCache(false, false, cacheLoaderClass1, false, true, true);
cache1.put(A_B, "name", JOE);
cache1.put(A_B, "age", TWENTY);
cache1.put(A_C, "name", BOB);
cache1.put(A_C, "age", FORTY);
- CacheSPI<Object, Object> cache2 = createCache("cache2", false, false, cacheLoaderClass2, asyncLoader, true, true);
+ CacheSPI<Object, Object> cache2 = createCache(false, false, cacheLoaderClass2, asyncLoader, true, true);
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
@@ -277,6 +258,24 @@
CacheLoader loader = cache2.getCacheLoaderManager().getCacheLoader();
+ long start = System.currentTimeMillis();
+ while (asyncLoader && System.currentTimeMillis() - start < 10000)
+ {
+ try
+ {
+ doAssertion(cache2, loader);
+ break;
+ } catch (Throwable ae)
+ {
+ //allow this within the timeout
+ }
+ }
+ doAssertion(cache2, loader);
+ }
+
+ private void doAssertion(CacheSPI<Object, Object> cache2, CacheLoader loader)
+ throws Exception
+ {
assertEquals("Incorrect loader name for /a/b", JOE, loader.get(A_B).get("name"));
assertEquals("Incorrect loader age for /a/b", TWENTY, loader.get(A_B).get("age"));
assertEquals("Incorrect loader name for /a/c", BOB, loader.get(A_C).get("name"));
@@ -318,22 +317,17 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
- {
- Map<String, Cache> caches = new HashMap<String, Cache>();
- cachesTL.set(caches);
+ {caches = new HashMap<String, Cache>();
// Save the TCL in case a test changes it
- ClassLoader orig_TCL = Thread.currentThread().getContextClassLoader();
- orig_TCL_TL.set(orig_TCL);
+ orig_TCL = Thread.currentThread().getContextClassLoader();
}
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- Map<String, Cache> caches = cachesTL.get();
-
// Restore the TCL in case a test changed it
- Thread.currentThread().setContextClassLoader(orig_TCL_TL.get());
+ Thread.currentThread().setContextClassLoader(orig_TCL);
for (String cacheID : caches.keySet())
{
@@ -356,7 +350,6 @@
{
TestingUtil.killCaches(c);
}
- cachesTL.set(null);
}
protected void stopCache(Cache cache)
@@ -430,7 +423,7 @@
boolean activateRoot)
throws Exception
{
- this.cache = createCache(name, sync, true, false);
+ this.cache = createCache(sync, true, false);
this.semaphore = semaphore;
this.name = name;
@@ -446,7 +439,7 @@
boolean activateRoot, long stateRetrievalTimeout)
throws Exception
{
- cache = createCache(name, sync, true, false, false, false, true);
+ cache = createCache(sync, true, false, false, false, true);
cache.getConfiguration().setStateRetrievalTimeout(stateRetrievalTimeout);
cache.start();
this.semaphore = semaphore;
@@ -520,4 +513,14 @@
}
}
}
+
+ protected String getDefaultCacheLoader()
+ {
+ return org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader.class.getName();
+ }
+
+ private String getNextUniqueCacheName()
+ {
+ return getClass().getSimpleName() + cacheCount++;
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2009-02-04 14:19:55 UTC (rev 7637)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferUnderLoadTest.java 2009-02-04 14:32:09 UTC (rev 7638)
@@ -4,6 +4,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.factories.UnitTestConfigurationFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.util.TestingUtil;
@@ -85,8 +86,8 @@
{
Writer writer;
Configuration cfg1, cfg2;
- cfg1 = new Configuration();
- cfg2 = new Configuration();
+ cfg1 = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC);
+ cfg2 = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC);
cfg1.setCacheMode(Configuration.CacheMode.REPL_SYNC);
cfg2.setCacheMode(Configuration.CacheMode.REPL_SYNC);
15 years, 10 months
JBoss Cache SVN: r7637 - in core/trunk/src/test: java/org/jboss/cache/integration/websession/util and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-02-04 09:19:55 -0500 (Wed, 04 Feb 2009)
New Revision: 7637
Modified:
core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java
core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java
core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java
core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml
Log:
enhanced logging
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java 2009-02-04 11:19:35 UTC (rev 7636)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java 2009-02-04 14:19:55 UTC (rev 7637)
@@ -48,8 +48,27 @@
/**
* @author Brian Stansberry
*
+ * This test is disabled because of following:
+ * There seem to be some assumptions in the above tests that do not look right to me.
+ * I have an example I've investigated(logs etc), haven't studied all possible failure scenarios, though I can imagine some others.
+ * One of them is the next one, on testInvalidateOnFailoverToBackup:
+
+ * This is the code I am talking about:
+ * InvalidationServlet invs = new InvalidationServlet();
+ * MultipleActionServlet mas = new MultipleActionServlet(sas, invs);
+ * (....)
+ * req = new Request(mgr0, sessionId, mas);
+ * *1+2* req.execute(); (...)
+ * *3*BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
+
+ *And some explanation
+
+ *1) manager0.invalidatesSession (i.e. cache0.remove)
+ *2) manager0 tries to data gravitate session (i.e. cache0.get with forceDataGrav set to true). This is done last line in Request.execute().
+ *3) asserts that session is no longer present on cache0
+
+ *Now, the assumption at 3 is not necessarily valid. With some funny threading and using ASYNC replication, you might have the remote removeNode command originated from cache0 to run *after* gravitateData originated at step2. I.e. RemoveNodeCommand being executed after GravitateDataCommand on cache*1* (buddy of cache0).
*/
-//todo - fix intermitent failures
@Test(groups = "integration",enabled = false, testName = "integration.websession.BuddyReplicationFailoverTest")
public class BuddyReplicationFailoverTest extends WebSessionTestBase
{
@@ -521,7 +540,7 @@
// Create the session
SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- ReplicationListener replListener0 = getReplicationListener(mgr0.getCache());
+ ReplicationListener replListener0 = replListeners[0];
replListener0.expectWithTx(PutDataMapCommand.class);
Request req = new Request(mgr3, null, sas);
@@ -559,7 +578,7 @@
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
InvalidationServlet invs = new InvalidationServlet();
MultipleActionServlet mas = new MultipleActionServlet(sas, invs);
- ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
+ ReplicationListener replListener1 = replListeners[1];
replListener1.expectWithTx(PutDataMapCommand.class, RemoveNodeCommand.class);
replListener1.expect(DataGravitationCleanupCommand.class);
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java 2009-02-04 11:19:35 UTC (rev 7636)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionManager.java 2009-02-04 14:19:55 UTC (rev 7637)
@@ -35,6 +35,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.*;
+import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.integration.websession.util.WebAppMetadata.Granularity;
@@ -131,13 +132,38 @@
cache.removeCacheListener(this);
// FIXME see if we need more sophisticated cache cleanup
- cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- cache.removeNode(baseFqn);
+ removeInMemoryData((CacheSPI)cache);
+ clearCacheLoader((CacheSPI)cache);
cacheManager.releaseCache(appMetadata.cacheConfigName);
cache = null;
}
}
}
+
+ private void clearCacheLoader(CacheSPI cache)
+ {
+ CacheLoaderManager cacheLoaderManager = cache.getCacheLoaderManager();
+ if (cacheLoaderManager != null && cacheLoaderManager.getCacheLoader() != null)
+ {
+ try
+ {
+ cacheLoaderManager.getCacheLoader().remove(Fqn.ROOT);
+ } catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private void removeInMemoryData(CacheSPI cache)
+ {
+ if (cache.getRoot() != null)
+ {
+ cache.getRoot().clearDataDirect();
+ cache.getRoot().removeChildrenDirect();
+ }
+ }
+
/**
* Allows test driver to mock Tomcat background processes' expiration
@@ -365,6 +391,7 @@
{
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
}
+ log("cache.removeNode(" + getSessionFqn(id) + ") locally? " + localOnly);
cache.removeNode(getSessionFqn(id));
}
@@ -424,7 +451,8 @@
{
data.put(ATTRIBUTES, attributes);
}
-
+
+ log("cache.put(" + fqn +"," + data +")");
cache.put(fqn, data);
}
@@ -438,7 +466,8 @@
Fqn<String> fqn = getSessionFqn(id);
if (modifiedAttributes != null)
- {
+ {
+ log("cache.put(" + fqn+"," + modifiedAttributes+ ")");
cache.put(fqn, modifiedAttributes);
}
@@ -446,6 +475,7 @@
{
for (String key : removedAttributes)
{
+ log("cache.remove(" + fqn + "," + key + ")");
cache.remove(fqn, key);
}
}
@@ -490,6 +520,7 @@
{
cache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
}
+ log ("cache.getData(" + getSessionFqn(id) + ") with ForceDataGravitation(true)");
data = cache.getData(getSessionFqn(id));
}
finally
@@ -544,6 +575,7 @@
Fqn<String> backupFqn = Fqn.fromRelativeFqn(child.getFqn(), mainFqn);
if (evict)
{
+ log("cache.evict(" + backupFqn + ", true)");
cache.evict(backupFqn, true);
}
else
@@ -556,4 +588,9 @@
}
+ private void log(String what)
+ {
+ System.out.println("[" + cache.getLocalAddress() + "] " + what);
+ }
+
}
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java 2009-02-04 11:19:35 UTC (rev 7636)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/util/SessionMetadata.java 2009-02-04 14:19:55 UTC (rev 7637)
@@ -39,4 +39,15 @@
public final String id = String.valueOf(++counter);
public final long creationTime = System.currentTimeMillis();
public boolean valid = true;
+
+
+ @Override
+ public String toString()
+ {
+ return "SessionMetadata{" +
+ "id='" + id + '\'' +
+ ", creationTime=" + creationTime +
+ ", valid=" + valid +
+ '}';
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java 2009-02-04 11:19:35 UTC (rev 7636)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/util/WebSessionTestBase.java 2009-02-04 14:19:55 UTC (rev 7637)
@@ -52,7 +52,7 @@
private AtomicInteger testCount = new AtomicInteger();
private List<CacheManager> cacheManagers;
private List<SessionManager> sessionManagers;
- private Map<Cache<Object, Object>, ReplicationListener> replicationListeners = new HashMap<Cache<Object, Object>, ReplicationListener>();
+ protected ReplicationListener[] replListeners;
@BeforeClass(alwaysRun = true)
public void beforeClass() throws Exception
@@ -61,8 +61,10 @@
if (getStartCachesInBeforeClass() && getCacheConfigName() != null)
{
String inUseProtocolStack = UnitTestConfigurationFactory.getEmptyConfiguration().getClusterConfig();
- for (CacheManager cm : cacheManagers)
+ replListeners = new ReplicationListener[getNumCacheManagers()];
+ for (int i =0; i < cacheManagers.size(); i++)
{
+ CacheManager cm = cacheManagers.get(i);
Cache<Object, Object> cache = cm.getCache(getCacheConfigName(), true);
amendCacheBeforeStartup(cache);
if (cache.getCacheStatus() != CacheStatus.STARTED)
@@ -70,7 +72,7 @@
cache.getConfiguration().setClusterConfig(inUseProtocolStack);
cache.start();
}
- replicationListeners.put(cache, ReplicationListener.getReplicationListener(cache));
+ replListeners[i] = ReplicationListener.getReplicationListener(cache);
}
}
}
@@ -171,9 +173,4 @@
{
return Integer.valueOf(value);
}
-
- protected ReplicationListener getReplicationListener(Cache<Object, Object> cache)
- {
- return replicationListeners.get(cache);
- }
}
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java 2009-02-04 11:19:35 UTC (rev 7636)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/replicationlisteners/ReplicationListener.java 2009-02-04 14:19:55 UTC (rev 7637)
@@ -159,13 +159,15 @@
Class<? extends ReplicableCommand> replicableCommandClass = it.next();
if (realOne.containsCommandType(replicableCommandClass))
{
- it.remove();
+ it.remove();//only remove once
+ break;
} else if (realOne.getSingleModification() instanceof PrepareCommand) //explicit transaction
{
PrepareCommand prepareCommand = (PrepareCommand) realOne.getSingleModification();
if (prepareCommand.containsModificationType(replicableCommandClass))
{
it.remove();
+ break;//only remove once
}
}
}
@@ -254,3 +256,5 @@
return cache;
}
}
+//[127.0.0.1:7900] Processed command: ReplicateCommand{cmds=PrepareCommand{globalTransaction=GlobalTransaction:<127.0.0.1:7903>:481, modifications=[PutDataMapCommand{fqn=/_BUDDY_BACKUP_/127.0.0.1_7903/JSESSION/BuddyReplicationFailoverTest54_localhost/160, dataVersion=null, data={2=org.jboss.cache.integration.websession.util.SessionMetadata@93a0d8, 1=1233588409000, 3={key=2}, 0=3}, globalTransaction=null, erase=false}], localAddress=127.0.0.1:7903, onePhaseCommit=true}}
+//[127.0.0.1:7900] skipping command ReplicateCommand{cmds=PrepareCommand{globalTransaction=GlobalTransaction:<127.0.0.1:7903>:482, modifications=[PutDataMapCommand{fqn=/_BUDDY_BACKUP_/127.0.0.1_7903/JSESSION/BuddyReplicationFailoverTest54_localhost/160, dataVersion=null, data={1=1233588409031, 3={key=3}, 0=4}, globalTransaction=null, erase=false}], localAddress=127.0.0.1:7903, onePhaseCommit=true}}
Modified: core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml
===================================================================
--- core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml 2009-02-04 11:19:35 UTC (rev 7636)
+++ core/trunk/src/test/resources/configs/integration/web-session-cache-configs.xml 2009-02-04 14:19:55 UTC (rev 7637)
@@ -263,7 +263,7 @@
<attribute name="IsolationLevel">REPEATABLE_READ</attribute>
<!-- Valid modes are REPL_ASYNC and REPL_SYNC -->
- <attribute name="CacheMode">REPL_ASYNC</attribute>
+ <attribute name="CacheMode">REPL_SYNC</attribute>
<!-- Name of cluster. Needs to be the same for all members, in order
to find each other -->
@@ -341,26 +341,26 @@
</attribute>
<!-- Cache Loader for session passivation -->
- <!--<attribute name="CacheLoaderConfig">-->
- <!--<config>-->
- <!--<passivation>true</passivation>-->
- <!--<shared>false</shared>-->
+ <attribute name="CacheLoaderConfig">
+ <config>
+ <passivation>true</passivation>
+ <shared>false</shared>
- <!--<purgeOnStartup>true</purgeOnStartup>-->
+ <purgeOnStartup>true</purgeOnStartup>
- <!--<cacheloader>-->
- <!--<class>org.jboss.cache.loader.FileCacheLoader</class>-->
- <!--<properties>-->
- <!--location=${java.io.tmpdir}${/}session-->
- <!--</properties>-->
- <!--<async>false</async>-->
- <!--<fetchPersistentState>true</fetchPersistentState>-->
- <!--<ignoreModifications>false</ignoreModifications>-->
- <!--<checkCharacterPortability>false</checkCharacterPortability>-->
- <!--</cacheloader>-->
+ <cacheloader>
+ <class>org.jboss.cache.loader.FileCacheLoader</class>
+ <properties>
+ location=${java.io.tmpdir}${/}session
+ </properties>
+ <async>false</async>
+ <fetchPersistentState>true</fetchPersistentState>
+ <ignoreModifications>false</ignoreModifications>
+ <checkCharacterPortability>false</checkCharacterPortability>
+ </cacheloader>
- <!--</config>-->
- <!--</attribute>-->
+ </config>
+ </attribute>
<!--
JBoss Cache eviction is not needed; webapp or SFSB container
15 years, 10 months