JBoss Cache SVN: r5381 - core/trunk/src/main/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-29 16:28:02 -0500 (Fri, 29 Feb 2008)
New Revision: 5381
Modified:
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
Log:
[JBCACHE-1302] Properly restore TCCL
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-02-29 20:31:11 UTC (rev 5380)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-02-29 21:28:02 UTC (rev 5381)
@@ -535,7 +535,7 @@
}
finally
{
- if (overrideContextClassloaderOnThread || old == null) currentThread.setContextClassLoader(null);
+ if (overrideContextClassloaderOnThread || old == null) currentThread.setContextClassLoader(old);
}
}
}
16 years, 10 months
JBoss Cache SVN: r5380 - core/trunk/src/test/java/org/jboss/cache/api/pfer.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-29 15:31:11 -0500 (Fri, 29 Feb 2008)
New Revision: 5380
Modified:
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
Log:
Remove unneeded condition that commit/rollback phase is sync
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 2008-02-29 20:20:17 UTC (rev 5379)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-02-29 20:31:11 UTC (rev 5380)
@@ -52,8 +52,8 @@
cache1 = (CacheSPI<String, String>) cf.createCache(UnitTestCacheConfigurationFactory.createConfiguration(cacheMode), false);
cache1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache1.getConfiguration().setNodeLockingScheme(optimistic ? Configuration.NodeLockingScheme.OPTIMISTIC : Configuration.NodeLockingScheme.PESSIMISTIC);
- cache1.getConfiguration().setSyncCommitPhase(optimistic);
- cache1.getConfiguration().setSyncRollbackPhase(optimistic);
+// cache1.getConfiguration().setSyncCommitPhase(optimistic);
+// cache1.getConfiguration().setSyncRollbackPhase(optimistic);
cache1.start();
tm1 = cache1.getConfiguration().getRuntimeConfig().getTransactionManager();
@@ -61,8 +61,8 @@
cache2 = (CacheSPI<String, String>) cf.createCache(UnitTestCacheConfigurationFactory.createConfiguration(cacheMode), false);
cache2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache2.getConfiguration().setNodeLockingScheme(optimistic ? Configuration.NodeLockingScheme.OPTIMISTIC : Configuration.NodeLockingScheme.PESSIMISTIC);
- cache2.getConfiguration().setSyncCommitPhase(optimistic);
- cache2.getConfiguration().setSyncRollbackPhase(optimistic);
+// cache2.getConfiguration().setSyncCommitPhase(optimistic);
+// cache2.getConfiguration().setSyncRollbackPhase(optimistic);
cache2.start();
tm2 = cache2.getConfiguration().getRuntimeConfig().getTransactionManager();
16 years, 10 months
JBoss Cache SVN: r5379 - core/trunk/src/test/java/org/jboss/cache/optimistic.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-29 15:20:17 -0500 (Fri, 29 Feb 2008)
New Revision: 5379
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java
Log:
Add a test of removal with a specified version
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java 2008-02-28 18:06:54 UTC (rev 5378)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticVersioningTest.java 2008-02-29 20:20:17 UTC (rev 5379)
@@ -6,8 +6,13 @@
*/
package org.jboss.cache.optimistic;
+import junit.framework.Assert;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
import static org.testng.AssertJUnit.assertEquals;
@@ -29,6 +34,8 @@
@Test(groups = "functional")
public class OptimisticVersioningTest extends AbstractOptimisticTestCase
{
+ private static final Log log = LogFactory.getLog(OptimisticVersioningTest.class);
+
CacheSPI cache1, cache2;
@BeforeMethod(alwaysRun = true)
@@ -123,4 +130,35 @@
assertEquals("Version info should have propagated", v1, v2);
}
+
+ public void testRemovalWithSpecifiedVersion() throws Exception
+ {
+ Fqn fqn = Fqn.fromString("/test/node");
+
+ Node root = cache1.getRoot();
+ cache1.getInvocationContext().getOptionOverrides().setDataVersion(new NonLockingDataVersion());
+ root.addChild(fqn);
+ cache1.getInvocationContext().getOptionOverrides().setDataVersion(new NonLockingDataVersion());
+ cache1.removeNode(fqn);
+
+ Assert.assertNull(cache1.getRoot().getChild(fqn));
+ }
+
+ private static class NonLockingDataVersion implements DataVersion {
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ public boolean newerThan(DataVersion dataVersion) {
+
+ if (dataVersion instanceof DefaultDataVersion) {
+ log.info("unexpectedly validating against a DefaultDataVersion", new Exception("Just a stack trace"));
+ }
+ else {
+ log.trace("non locking lock check...");
+ }
+ return false;
+ }
+
+ }
}
16 years, 10 months
JBoss Cache SVN: r5378 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-28 13:06:54 -0500 (Thu, 28 Feb 2008)
New Revision: 5378
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java
Log:
[JBCACHE-1299] Add extension point to CacheManagerImpl for actual cache creation
Modified: core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java 2008-02-27 20:23:40 UTC (rev 5377)
+++ core/trunk/src/main/java/org/jboss/cache/CacheManagerImpl.java 2008-02-28 18:06:54 UTC (rev 5378)
@@ -116,7 +116,7 @@
{
config.getRuntimeConfig().setMuxChannelFactory(channelFactory);
}
- cache = new DefaultCacheFactory().createCache(config, false);
+ cache = createCache(config);
registerCache(cache, configName);
}
else if (cache != null)
@@ -127,6 +127,20 @@
return cache;
}
+
+ /**
+ * Extension point for subclasses, where we actually use a
+ * {@link CacheFactory} to create a cache. This default implementation
+ * uses {@link DefaultCacheFactory}.
+ *
+ * @param config the Configuration for the cache
+ * @return the Cache
+ */
+ @SuppressWarnings("unchecked")
+ protected Cache<Object, Object> createCache(Configuration config)
+ {
+ return new DefaultCacheFactory().createCache(config, false);
+ }
public void releaseCache(String configName)
{
16 years, 10 months
JBoss Cache SVN: r5377 - core/trunk/src/test/java/org/jboss/cache/invalidation.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-27 15:23:40 -0500 (Wed, 27 Feb 2008)
New Revision: 5377
Modified:
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
Log:
[JBCACHE-1298] Test if removal of non-existent node leaves invalid tombstone on remote nodes
Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-02-27 17:37:38 UTC (rev 5376)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-02-27 20:23:40 UTC (rev 5377)
@@ -17,8 +17,10 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.xml.XmlHelper;
import static org.testng.AssertJUnit.*;
+
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -760,6 +762,11 @@
deleteNonExistentTest(false);
}
+ /**
+ * Test for JBCACHE-1297
+ *
+ * @throws Exception
+ */
public void testDeleteNonExistentOptimistic() throws Exception
{
deleteNonExistentTest(true);
@@ -807,7 +814,58 @@
assertHasBeenInvalidated(cache1.getNode(fqn), "Should have been invalidated");
assertNull("Should be null", cache2.getNode(fqn));
}
+
+ /**
+ * Test for JBCACHE-1298.
+ *
+ * @throws Exception
+ */
+ public void testAddOfDeletedNonExistent() throws Exception
+ {
+ List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>();
+ caches.add(createUnstartedCache(true));
+ caches.add(createUnstartedCache(true));
+ cache1 = caches.get(0);
+ cache2 = caches.get(1);
+ cache1.start();
+ cache2.start();
+
+ TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), 5000);
+
+ Fqn fqn = Fqn.fromString("/a/b");
+
+ assertNull("Should be null", cache1.getNode(fqn));
+ assertNull("Should be null", cache2.getNode(fqn));
+
+ // OK, here's the real test
+ TransactionManager tm = cache2.getTransactionManager();
+ tm.begin();
+ try
+ {
+ // Remove a node that doesn't exist in cache2
+ cache2.removeNode(fqn);
+ tm.commit();
+ }
+ catch (Exception e)
+ {
+ String msg = "Unable to remove non-existent node " + fqn;
+ log.error(msg, e);
+ fail(msg + " -- " + e);
+ }
+
+ // Actually, it shouldn't have been invalidated, should be null
+ // But, this assertion will pass if it is null, and we want
+ assertHasBeenInvalidated(cache1.getNode(fqn), "Should have been invalidated");
+ assertNull("Should be null", cache2.getNode(fqn));
+
+ cache1.getInvocationContext().getOptionOverrides().setDataVersion(new DefaultDataVersion());
+ cache1.put(fqn, "key", "value");
+
+ assertEquals("value", cache1.getNode(fqn).get("key"));
+ assertHasBeenInvalidated(cache2.getNode(fqn), "Should have been invalidated");
+ }
+
protected CacheSPI<Object, Object> createUnstartedCache(boolean optimistic) throws Exception
{
CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(false);
16 years, 10 months
JBoss Cache SVN: r5376 - core/trunk/src/test/java/org/jboss/cache/invalidation.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-27 12:37:38 -0500 (Wed, 27 Feb 2008)
New Revision: 5376
Modified:
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
Log:
[JBCACHE-1297] Add test for invalidation of locally non-existent Fqns
Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-02-27 15:52:37 UTC (rev 5375)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-02-27 17:37:38 UTC (rev 5376)
@@ -754,7 +754,60 @@
n = caches.get(0).getNode(fqn);
assertHasBeenInvalidated(n, "Should have been invalidated");
}
+
+ public void testDeleteNonExistentPessimistic() throws Exception
+ {
+ deleteNonExistentTest(false);
+ }
+
+ public void testDeleteNonExistentOptimistic() throws Exception
+ {
+ deleteNonExistentTest(true);
+ }
+
+ private void deleteNonExistentTest(boolean optimistic) throws Exception
+ {
+ List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>();
+ caches.add(createUnstartedCache(optimistic));
+ caches.add(createUnstartedCache(optimistic));
+ cache1 = caches.get(0);
+ cache2 = caches.get(1);
+ cache1.start();
+ cache2.start();
+
+ TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]), 5000);
+
+ Fqn fqn = Fqn.fromString("/a/b");
+
+ assertNull("Should be null", cache1.getNode(fqn));
+ assertNull("Should be null", cache2.getNode(fqn));
+
+ cache1.putForExternalRead(fqn, "key", "value");
+
+ assertEquals("value",cache1.getNode(fqn).get("key"));
+ assertNull("Should be null", cache2.getNode(fqn));
+
+ // OK, here's the real test
+ TransactionManager tm = cache2.getTransactionManager();
+ tm.begin();
+ try
+ {
+ // Remove a node that doesn't exist in cache2
+ cache2.removeNode(fqn);
+ tm.commit();
+ }
+ catch (Exception e)
+ {
+ String msg = "Unable to remove non-existent node " + fqn;
+ log.error(msg, e);
+ fail(msg + " -- " + e);
+ }
+
+ assertHasBeenInvalidated(cache1.getNode(fqn), "Should have been invalidated");
+ assertNull("Should be null", cache2.getNode(fqn));
+ }
+
protected CacheSPI<Object, Object> createUnstartedCache(boolean optimistic) throws Exception
{
CacheSPI<Object, Object> cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(false);
16 years, 10 months
JBoss Cache SVN: r5375 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-27 10:52:37 -0500 (Wed, 27 Feb 2008)
New Revision: 5375
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
Log:
[JBCACHE-1297] Avoid NPE in getNodeVersion
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-02-27 15:41:00 UTC (rev 5374)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-02-27 15:52:37 UTC (rev 5375)
@@ -344,6 +344,7 @@
{
if (w == null) return null;
WorkspaceNode wn = w.getNode(f);
+ if (wn == null) return null; // JBCACHE-1297
DataVersion v = wn.getVersion();
if (wn.isVersioningImplicit())
16 years, 10 months
JBoss Cache SVN: r5374 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-27 10:41:00 -0500 (Wed, 27 Feb 2008)
New Revision: 5374
Modified:
core/trunk/src/main/java/org/jboss/cache/RegionManager.java
Log:
Avoid RpcManagerImpl WARN when we activate a region in LOCAL mode
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-02-27 15:39:24 UTC (rev 5373)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-02-27 15:41:00 UTC (rev 5374)
@@ -422,7 +422,10 @@
}
List<Address> members = cache.getMembers();
- rpcManager.fetchPartialState(members, subtreeRoot.getFqn());
+
+ // 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 (!BuddyManager.isBackupFqn(fqn))
{
16 years, 10 months
JBoss Cache SVN: r5373 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-02-27 10:39:24 -0500 (Wed, 27 Feb 2008)
New Revision: 5373
Modified:
core/trunk/src/main/java/org/jboss/cache/RegionManager.java
Log:
Remove outdated JBCACHE-1265 workaround
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-02-26 15:46:14 UTC (rev 5372)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-02-27 15:39:24 UTC (rev 5373)
@@ -443,11 +443,7 @@
// need to obtain all necessary locks.
// needs to be a LOCAL call!
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- // FIXME -- restore the next line and remove the 2 following
- // when JBCACHE-1265 is fixed
- //subtreeRoot = cache.getRoot().addChild(buddyRoot);
- cache.put(buddyRoot, null);
- subtreeRoot = cache.getRoot().getChild(buddyRoot);
+ subtreeRoot = cache.getRoot().addChild(buddyRoot);
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(false);
}
rpcManager.fetchPartialState(sources, fqn, subtreeRoot.getFqn());
16 years, 10 months