Author: manik.surtani(a)jboss.com
Date: 2008-01-01 17:48:04 -0500 (Tue, 01 Jan 2008)
New Revision: 4929
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java
core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLocksTest.java
Log:
Fixed PLI issue with not differentiating between a 1 phase prepare and a 2 phase prepare.
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-01-01
22:27:17 UTC (rev 4928)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-01-01
22:48:04 UTC (rev 4929)
@@ -131,6 +131,9 @@
protected Object handlePrepareMethod(InvocationContext ctx, GlobalTransaction gtx,
List modification, Address coordinator, boolean onePhaseCommit) throws Throwable
{
+ // 2-phase commit prepares are no-ops here.
+ if (!onePhaseCommit) return nextInterceptor(ctx);
+
// commit propagated up from the tx interceptor
commit(ctx.getGlobalTransaction());
Object retVal = nextInterceptor(ctx);
@@ -140,16 +143,13 @@
protected Object handleOptimisticPrepareMethod(InvocationContext ctx,
GlobalTransaction gtx, List modifications, Map data, Address address, boolean
onePhaseCommit) throws Throwable
{
- return handlePrepareMethod(ctx, gtx, modifications, address, onePhaseCommit);
+ throw new UnsupportedOperationException("Optimistic prepare methods should
never be received by the pessimistic lock interceptor!!");
}
protected Object handleCommitMethod(InvocationContext ctx, GlobalTransaction
globalTransaction) throws Throwable
{
commit(globalTransaction);
- if (log.isTraceEnabled())
- {
- log.trace("bypassed locking as method commit() doesn't require
locking");
- }
+ log.trace("bypassed locking as method commit() doesn't require
locking");
Object retVal = nextInterceptor(ctx);
tx_table.cleanup(globalTransaction);
return retVal;
Modified: core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java 2008-01-01 22:27:17
UTC (rev 4928)
+++ core/trunk/src/test/java/org/jboss/cache/lock/AcquireAllTest.java 2008-01-01 22:48:04
UTC (rev 4929)
@@ -1,10 +1,12 @@
package org.jboss.cache.lock;
-import org.jboss.cache.CacheImpl;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -16,7 +18,7 @@
@Test(groups = {"functional"})
public class AcquireAllTest
{
- CacheImpl cache = null, cache2;
+ CacheSPI<Object, Object> cache = null, cache2;
final Fqn FQN = Fqn.fromString("/myNode");
final String KEY = "key";
final String VALUE = "value";
@@ -24,12 +26,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- if (cache != null)
- {
- cache.stop();
- cache.destroy();
- cache = null;
- }
+ TestingUtil.killCaches(cache, cache2);
}
@@ -82,12 +79,12 @@
}
- private CacheImpl createCache(Configuration.CacheMode mode, IsolationLevel level)
+ private CacheSPI<Object, Object> createCache(Configuration.CacheMode mode,
IsolationLevel level)
{
- CacheImpl c = (CacheImpl) new DefaultCacheFactory().createCache(false);
+ CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new
DefaultCacheFactory<Object, Object>().createCache(false);
c.getConfiguration().setCacheMode(mode);
c.getConfiguration().setIsolationLevel(level);
-
c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+
c.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
c.create();
c.start();
return c;
Modified: core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLocksTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLocksTest.java 2008-01-01
22:27:17 UTC (rev 4928)
+++ core/trunk/src/test/java/org/jboss/cache/lock/BreakDeadMemberLocksTest.java 2008-01-01
22:48:04 UTC (rev 4929)
@@ -22,7 +22,6 @@
package org.jboss.cache.lock;
-import org.jboss.cache.CacheImpl;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
@@ -176,20 +175,7 @@
protected void stopCache(String id)
{
- CacheImpl cache = (CacheImpl) caches.get(id);
- if (cache != null)
- {
- try
- {
- cache.stop();
- cache.destroy();
- }
- catch (Exception e)
- {
- System.out.println("Exception stopping cache " + e.getMessage());
- e.printStackTrace(System.out);
- }
- }
+ TestingUtil.killCaches(caches.get(id));
}
class HangSync implements Synchronization