JBoss Cache SVN: r5643 - in core/trunk/src/main/java/org/jboss/cache: interceptors and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-04-23 07:46:31 -0400 (Wed, 23 Apr 2008)
New Revision: 5643
Modified:
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
Log:
JBCACHE-1222 - bug fixing - marshalling
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-04-23 11:24:44 UTC (rev 5642)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-04-23 11:46:31 UTC (rev 5643)
@@ -277,6 +277,8 @@
if (gtx != null)
{
CreateNodeCommand createNodeCommand = commandsFactory.buildCreateNodeCommand(child_fqn);
+ //todo - [mmarkus] there are commands added to the modification list just for being able to rollback.
+ //todo make sure the commands are being compacted before replication takes place
transactionTable.addModification(gtx, createNodeCommand);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-04-23 11:24:44 UTC (rev 5642)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-04-23 11:46:31 UTC (rev 5643)
@@ -654,7 +654,7 @@
public Object handleDataVersionCommand(InvocationContext ctx, DataVersionCommand command) throws Throwable
{
- if (!injectDataVersions) handleDefault(ctx, command);
+ if (!injectDataVersions) return handleDefault(ctx, command);
Option originalOption = ctx.getOptionOverrides();
if (command.isVersioned())
{
16 years, 2 months
JBoss Cache SVN: r5642 - in core/tags/2.1.1.GA: src/main/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-23 07:24:44 -0400 (Wed, 23 Apr 2008)
New Revision: 5642
Modified:
core/tags/2.1.1.GA/pom.xml
core/tags/2.1.1.GA/src/main/java/org/jboss/cache/Version.java
Log:
Prepare for release
Modified: core/tags/2.1.1.GA/pom.xml
===================================================================
--- core/tags/2.1.1.GA/pom.xml 2008-04-23 11:22:05 UTC (rev 5641)
+++ core/tags/2.1.1.GA/pom.xml 2008-04-23 11:24:44 UTC (rev 5642)
@@ -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>2.1.1-SNAPSHOT</jbosscache-core-version>
+ <jbosscache-core-version>2.1.1.GA</jbosscache-core-version>
</properties>
<parent>
<groupId>org.jboss.cache</groupId>
@@ -342,7 +342,7 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
- <jbosscache-core-version>2.1.1-SNAPSHOT-JBossAS</jbosscache-core-version>
+ <jbosscache-core-version>2.1.1.GA-JBossAS</jbosscache-core-version>
</properties>
<dependencies>
<dependency>
Modified: core/tags/2.1.1.GA/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/tags/2.1.1.GA/src/main/java/org/jboss/cache/Version.java 2008-04-23 11:22:05 UTC (rev 5641)
+++ core/tags/2.1.1.GA/src/main/java/org/jboss/cache/Version.java 2008-04-23 11:24:44 UTC (rev 5642)
@@ -11,10 +11,10 @@
@Immutable
public class Version
{
- public static final String version = "2.1.1-SNAPSHOT";
+ public static final String version = "2.1.1.GA";
public static final String codename = "Alegrias";
//public static final String cvs = "$Id: Version.java 4592 2007-10-10 16:44:36Z manik.surtani(a)jboss.com $";
- static final byte[] version_id = {'0', '2', '1', '1', 'S'};
+ static final byte[] version_id = {'0', '2', '1', '1'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
16 years, 2 months
JBoss Cache SVN: r5641 - core/tags.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-23 07:22:05 -0400 (Wed, 23 Apr 2008)
New Revision: 5641
Added:
core/tags/2.1.1.GA/
Log:
Copied: core/tags/2.1.1.GA (from rev 5640, core/branches/2.1.X)
16 years, 2 months
JBoss Cache SVN: r5640 - in core/trunk/src: main/java/org/jboss/cache/invocation and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-23 07:14:17 -0400 (Wed, 23 Apr 2008)
New Revision: 5640
Added:
core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java
Log:
Compatibility with legacy interceptors
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-04-23 10:33:06 UTC (rev 5639)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-04-23 11:14:17 UTC (rev 5640)
@@ -22,20 +22,11 @@
package org.jboss.cache.interceptors;
import org.apache.commons.logging.Log;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.channel.BlockChannelCommand;
-import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.commands.remote.*;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
@@ -52,26 +43,15 @@
*/
public abstract class Interceptor extends ChainedInterceptor implements InterceptorMBean
{
- protected Interceptor next = null;
protected CacheSPI<?, ?> cache;
protected Log log = null;
protected Configuration configuration;
private boolean statsEnabled = false;
protected boolean trace;
-
- public void setNext(Interceptor i)
- {
- next = i;
- }
-
- public Interceptor getNext()
- {
- return next;
- }
-
public void setCache(CacheSPI cache)
{
+ this.cache = cache;
}
@Start
@@ -105,7 +85,8 @@
*/
public Object nextInterceptor(InvocationContext ctx) throws Throwable
{
- return next.invoke(ctx);
+// return getNext().invoke(ctx);
+ return invokeNextInterceptor(ctx, null);
}
public boolean getStatisticsEnabled()
@@ -180,105 +161,13 @@
public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
{
- if (command != null) //call originated from a command
+ if (command != null) //call originated from a command's accept() method.
{
return invoke(ctx);
}
- //this means that another Interceptor called this method, we have to dispatch the call to the appropriate method
- int methodId = ctx.getMethodCall().getId();
- switch (methodId)
- {
- case PutDataMapCommand.ERASE_METHOD_ID:
- case PutDataMapCommand.ERASE_VERSIONED_METHOD_ID:
- case PutDataMapCommand.METHOD_ID:
- case PutDataMapCommand.VERSIONED_METHOD_ID:
- return next.handlePutDataMapCommand(ctx, (PutDataMapCommand) command);
-
- case PutKeyValueCommand.METHOD_ID:
- case PutKeyValueCommand.VERSIONED_METHOD_ID:
- case PutKeyValueCommand.PUT_FOR_EXT_READ_METHOD_ID:
- case PutKeyValueCommand.PUT_FOR_EXT_READ_VERSIONED_METHOD_ID:
- return next.handlePutKeyValueCommand(ctx, (PutKeyValueCommand) command);
-
- case RemoveNodeCommand.METHOD_ID:
- case RemoveNodeCommand.VERSIONED_METHOD_ID:
- return next.handleRemoveNodeCommand(ctx, (RemoveNodeCommand) command);
-
- case RemoveDataCommand.METHOD_ID:
- case RemoveDataCommand.VERSIONED_METHOD_ID:
- return next.handleRemoveDataCommand(ctx, (RemoveDataCommand) command);
-
- case EvictNodeCommand.METHOD_ID:
- case EvictNodeCommand.VERSIONED_METHOD_ID:
- return next.handleEvictFqnCommand(ctx, (EvictNodeCommand) command);
-
- case InvalidateCommand.METHOD_ID:
- return next.handleInvalidateCommand(ctx, (InvalidateCommand) command);
-
- case RemoveKeyCommand.METHOD_ID:
- case RemoveKeyCommand.VERSIONED_METHOD_ID:
- return next.handleRemoveKeyCommand(ctx, (RemoveKeyCommand) command);
-
- case GetDataMapCommand.METHOD_ID:
- return next.handleGetDataMapCommand(ctx, (GetDataMapCommand) command);
-
- case RemoteExistsNodeCommand.METHOD_ID:
- return next.handleExistsNodeCommand(ctx, (RemoteExistsNodeCommand) command);
-
- case GetKeyValueCommand.METHOD_ID:
- return next.handleGetKeyValueCommand(ctx, (GetKeyValueCommand) command);
-
- case GetNodeCommand.METHOD_ID:
- return next.handleGetNodeCommand(ctx, (GetNodeCommand) command);
-
- case GetKeysCommand.METHOD_ID:
- return next.handleGetKeysCommand(ctx, (GetKeysCommand) command);
-
- case GetChildrenNamesCommand.METHOD_ID:
- return next.handleGetChildrenNamesCommand(ctx, (GetChildrenNamesCommand) command);
-
- case MoveCommand.METHOD_ID:
- return next.handleMoveCommand(ctx, (MoveCommand) command);
-
- case GravitateDataCommand.METHOD_ID:
- return next.handleGravitateDataCommand(ctx, (GravitateDataCommand) command);
-
- case PrepareCommand.METHOD_ID:
- return next.handlePrepareCommand(ctx, (PrepareCommand) command);
-
- case RollbackCommand.METHOD_ID:
- return next.handleRollbackCommand(ctx, (RollbackCommand) command);
-
- case CommitCommand.METHOD_ID:
- return next.handleCommitCommand(ctx, (CommitCommand) command);
-
- case OptimisticPrepareCommand.METHOD_ID:
- return next.handleOptimisticPrepareCommand(ctx, (OptimisticPrepareCommand) command);
-
- case ReplicateCommand.SINGLE_METHOD_ID:
- case ReplicateCommand.MULTIPLE_METHOD_ID:
- throw new CacheException("Replicate calls should never be passed up the interceptor chain!");
-
- case AnnounceBuddyPoolNameCommand.METHOD_ID:
- return next.handleAnnounceBuddyPoolName(ctx, (AnnounceBuddyPoolNameCommand) command);
-
- case RemoveFromBuddyGroupCommand.METHOD_ID:
- return next.handleRemoveFromBuddyGroupCommand(ctx, (RemoveFromBuddyGroupCommand) command);
-
- case AssignToBuddyGroupCommand.METHOD_ID:
- return next.handleAssignToBuddyGroupCommand(ctx, (AssignToBuddyGroupCommand) command);
-
- case DataGravitationCleanupCommand.METHOD_ID:
- return next.handleDataGravitationCleanupCommand(ctx, (DataGravitationCleanupCommand) command);
-
- case BlockChannelCommand.METHOD_ID:
- return next.handleBlockChannelCommand(ctx, (BlockChannelCommand) command);
-
- case UnblockChannelCommand.METHOD_ID:
- return next.handleUnblockChannelCommand(ctx, (UnblockChannelCommand) command);
-
- }
- return null;
+ //this means that another Interceptor called this method, we have to dispatch the call to the appropriate method. Probably called directly using super.invoke().
+ command = ctx.getExecutingCommand();
+ return command.accept(ctx, getNext());
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java 2008-04-23 10:33:06 UTC (rev 5639)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java 2008-04-23 11:14:17 UTC (rev 5640)
@@ -5,8 +5,10 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.functional.MarshallableCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.ChainedInterceptor;
+import org.jboss.cache.marshall.MethodCall;
import java.util.ArrayList;
import java.util.Collections;
@@ -227,9 +229,12 @@
/**
* Walks the command through the interceptor chain. The received ctx is being passed in.
*/
+ @SuppressWarnings("deprecated")
public Object invoke(InvocationContext ctx, CacheCommand command)
{
ctx.setExecutingCommand(command);
+ // ensure legacy MethodCall is available for interceptor implementations.
+ ctx.setMethodCall(createMethodCall((MarshallableCommand) command));
try
{
return command.accept(ctx, firstInChain);
@@ -248,6 +253,15 @@
}
}
+ @SuppressWarnings("deprecated")
+ private MethodCall createMethodCall(MarshallableCommand command)
+ {
+ MethodCall call = new MethodCall();
+ call.setMethodId(command.getCommandId());
+ call.setArgs(command.getParameters());
+ return call;
+ }
+
/**
* Similar to {@link #invoke(org.jboss.cache.InvocationContext, org.jboss.cache.commands.CacheCommand)}, but
* constructs a invocation context on the fly, using {@link InvocationContextContainer#get()}
Added: core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java 2008-04-23 11:14:17 UTC (rev 5640)
@@ -0,0 +1,108 @@
+package org.jboss.cache.interceptors;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
+import org.jboss.cache.misc.TestingUtil;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+/**
+ * This is to test that "old-style" interceptors from 2.0.x and 2.1.x will work with the new interceptor structure.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.2.0
+ */
+@Test(groups = "functional")
+public class LegacyInterceptorTest
+{
+ Cache cache;
+ static CountDownLatch interceptorResumeLatch, interceptorInvokedLatch;
+ TestInterceptor testInterceptor;
+ Executor testRunner;
+
+ @BeforeTest
+ public void setUp()
+ {
+ cache = new DefaultCacheFactory().createCache();
+ testInterceptor = new TestInterceptor();
+
+ ((CacheSPI) cache).addInterceptor(testInterceptor, TxInterceptor.class);
+ testRunner = Executors.newSingleThreadExecutor();
+ }
+
+ @BeforeMethod
+ public void createLatches()
+ {
+ interceptorResumeLatch = new CountDownLatch(1);
+ interceptorInvokedLatch = new CountDownLatch(1);
+ }
+
+ @AfterTest
+ public void tearDown()
+ {
+ TestingUtil.killCaches(cache);
+ }
+
+ public void testPut() throws Exception
+ {
+ testRunner.execute(new Runnable()
+ {
+ public void run()
+ {
+ cache.put("/a", "k", "v");
+ }
+ });
+
+ interceptorInvokedLatch.await();
+
+ // check that the context on the test interceptor is correct.
+ InvocationContext ctx = testInterceptor.ctx;
+ interceptorResumeLatch.countDown();
+
+ assert ctx.getMethodCall().getMethodId() == PutKeyValueCommand.METHOD_ID;
+ assert ctx.getMethodCall().getArgs()[0] == null; // gtx
+ assert ctx.getMethodCall().getArgs()[1].equals(Fqn.fromString("/a")); // fqn
+ assert ctx.getMethodCall().getArgs()[2].equals("k"); // key
+ assert ctx.getMethodCall().getArgs()[3].equals("v"); // value
+ assert ctx.getMethodCall().getArgs()[4] == Boolean.FALSE; //last boolean value
+ }
+
+ public static class TestInterceptor extends Interceptor
+ {
+ InvocationContext ctx;
+
+ @Override
+ public Object invoke(InvocationContext ctx) throws Throwable
+ {
+ if (ctx.isOriginLocal())
+ {
+ // copy the context so tests can inspect it
+ this.ctx = ctx;
+
+ // signal to the test that this has been invoked.
+ interceptorInvokedLatch.countDown();
+
+ // wait for tests to finish
+ interceptorResumeLatch.await();
+
+ // wipe class-level context variable
+ this.ctx = null;
+ }
+
+ // the "old-style" of passing up the interceptor chain
+ return super.invoke(ctx);
+ }
+ }
+
+}
+
16 years, 2 months
JBoss Cache SVN: r5639 - 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: 2008-04-23 06:33:06 -0400 (Wed, 23 Apr 2008)
New Revision: 5639
Modified:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
Log:
Fixed lock suppression
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-04-23 10:15:15 UTC (rev 5638)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-04-23 10:33:06 UTC (rev 5639)
@@ -190,7 +190,7 @@
*/
public void clearInvocationLocksAcquired()
{
- if (isSupressLocking()) return;
+ if (isLockingSuppressed()) return;
if (!isValidTransaction())
{ // no TX
List<NodeLock> locks = getInvocationLocksAcquired();
@@ -218,7 +218,10 @@
}
}
- public boolean isSupressLocking()
+ /**
+ * @return true if options exist to suppress locking - false otherwise. Note that this is only used by the {@link org.jboss.cache.interceptors.PessimisticLockInterceptor}.
+ */
+ public boolean isLockingSuppressed()
{
return getOptionOverrides() != null && getOptionOverrides().isSuppressLocking();
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-23 10:15:15 UTC (rev 5638)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-23 10:33:06 UTC (rev 5639)
@@ -50,11 +50,6 @@
private CacheData cacheData;
private LockManager lockManager;
private Configuration configuration;
-
- /**
- * Map<Thread, List<NodeLock>>. Keys = threads, values = lists of locks held by that thread
- */
- // private ThreadLocal<List<NodeLock>> lockTable;
private long lockAcquisitionTimeout;
@Inject
@@ -82,7 +77,7 @@
private Object handlePutCommand(InvocationContext ctx, CacheDataCommand command, boolean zeroAcquisitionTimeout)
throws Throwable
{
- if ((ctx.isSupressLocking()) || configuration.getIsolationLevel() == IsolationLevel.NONE)
+ if ((ctx.isLockingSuppressed()) || configuration.getIsolationLevel() == IsolationLevel.NONE)
{
if (trace) log.trace("Suppressing locking, creating nodes if necessary");
int treeNodeSize = command.getFqn().size();
@@ -107,18 +102,7 @@
return retVal;
}
- // TODO: This is unused. I'm guessing that is a bug?!?? This does need to be checked.
-
-// protected boolean skipMethodCall(InvocationContext ctx)
-// {
-// return (supressLocking(ctx) && !MethodDeclarations.isPutMethod(ctx.getMethodCall().getMethodId()));
-// }
-
-// private boolean supressLocking(InvocationContext ctx)
-// {
-// return ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSuppressLocking();
-// }
-
+ @Override
public Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
// 2-phase commit prepares are no-ops here.
@@ -131,6 +115,7 @@
return retVal;
}
+ @Override
public Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
{
commit(command.getGlobalTransaction());
@@ -140,6 +125,7 @@
return retVal;
}
+ @Override
public Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
TransactionEntry entry = txTable.get(command.getGlobalTransaction());
@@ -169,9 +155,10 @@
return retVal;
}
+ @Override
public Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
{
- if (ctx.isSupressLocking()) return invokeNextInterceptor(ctx, command);
+ if (ctx.isLockingSuppressed()) return invokeNextInterceptor(ctx, command);
long timeout = ctx.getContextLockAcquisitionTimeout(lockAcquisitionTimeout);
// this call will ensure the node gets a WL and it's current parent gets RL.
if (trace) log.trace("Attempting to get WL on node to be moved [" + command.getFqn() + "]");
@@ -202,9 +189,10 @@
return retValue;
}
+ @Override
public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
- if (ctx.isSupressLocking()) return invokeNextInterceptor(ctx, command);
+ if (ctx.isLockingSuppressed()) return invokeNextInterceptor(ctx, command);
// need to make a note of ALL nodes created here!!
List<NodeSPI> createdNodes = new LinkedList<NodeSPI>();
// we need to mark new nodes created as deleted since they are only created to form a path to the node being removed, to
@@ -251,6 +239,7 @@
return created ? false : retVal;
}
+ @Override
public Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.WRITE, false, false, false, false, null, false);
@@ -259,6 +248,7 @@
return retVal;
}
+ @Override
public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.WRITE, false, false, false, false, null, false);
@@ -267,6 +257,7 @@
return retVal;
}
+ @Override
public Object handleEvictFqnCommand(InvocationContext ctx, EvictNodeCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.WRITE, false, true, false, false, null, false);
@@ -275,6 +266,7 @@
return retVal;
}
+ @Override
public Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
@@ -283,6 +275,7 @@
return retVal;
}
+ @Override
public Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
@@ -291,6 +284,7 @@
return retVal;
}
+ @Override
public Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
@@ -299,6 +293,7 @@
return retVal;
}
+ @Override
public Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-23 10:15:15 UTC (rev 5638)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-23 10:33:06 UTC (rev 5639)
@@ -53,7 +53,8 @@
boolean acquireLockOnParent, boolean reverseRemoveCheck, List<NodeSPI> createdNodes, boolean skipNotification)
throws InterruptedException
{
- if (fqn == null || configuration.getIsolationLevel() == IsolationLevel.NONE) return false;
+ if (fqn == null || configuration.getIsolationLevel() == IsolationLevel.NONE || ctx.isLockingSuppressed())
+ return false;
boolean created;
long timeout = zeroLockTimeout ? 0 : ctx.getContextLockAcquisitionTimeout(lockAcquisitionTimeout);
16 years, 2 months
JBoss Cache SVN: r5638 - core/trunk/src/main/java/org/jboss/cache/commands/cachedata.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-23 06:15:15 -0400 (Wed, 23 Apr 2008)
New Revision: 5638
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/EvictNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/InvalidateCommand.java
Log:
Fixed broken commands
Modified: core/trunk/src/main/java/org/jboss/cache/commands/cachedata/EvictNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/cachedata/EvictNodeCommand.java 2008-04-23 10:15:07 UTC (rev 5637)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/EvictNodeCommand.java 2008-04-23 10:15:15 UTC (rev 5638)
@@ -23,7 +23,10 @@
public Object perform(InvocationContext ctx)
{
- return cacheData.evict(fqn);
+ notifier.notifyNodeEvicted(fqn, true, ctx);
+ boolean evicted = cacheData.evict(fqn);
+ notifier.notifyNodeEvicted(fqn, false, ctx);
+ return evicted;
}
public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
Modified: core/trunk/src/main/java/org/jboss/cache/commands/cachedata/InvalidateCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/cachedata/InvalidateCommand.java 2008-04-23 10:15:07 UTC (rev 5637)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/InvalidateCommand.java 2008-04-23 10:15:15 UTC (rev 5638)
@@ -128,7 +128,7 @@
return null;
}
- public void removeData()
+ private void removeData()
throws CacheException
{
// Find the node. This will lock it (if <tt>locking</tt> is true) and
16 years, 2 months
JBoss Cache SVN: r5637 - core/trunk/src/test/java/org/jboss/cache/options.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-23 06:15:07 -0400 (Wed, 23 Apr 2008)
New Revision: 5637
Modified:
core/trunk/src/test/java/org/jboss/cache/options/ForceCacheModeTest.java
Log:
Updated assertion msgs
Modified: core/trunk/src/test/java/org/jboss/cache/options/ForceCacheModeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/ForceCacheModeTest.java 2008-04-23 09:29:39 UTC (rev 5636)
+++ core/trunk/src/test/java/org/jboss/cache/options/ForceCacheModeTest.java 2008-04-23 10:15:07 UTC (rev 5637)
@@ -309,8 +309,8 @@
updater.start();
updater.join(250);
- assertTrue("Updater finished", updater.finished);
- assertNull("Updater succeeded", updater.failure);
+ assertTrue("Updater didn't finish", updater.finished);
+ assertNull("Updater failed", updater.failure);
for (int i = 0; i < 50; i++)
{
@@ -319,8 +319,8 @@
TestingUtil.sleepThread(10);
}
- assertTrue("Listener blocked", listener.blocked);
- assertEquals("Cache1 correct", removeTest ? null : VALUE2, cache1.get(FQNA, KEY));
+ assertTrue("Listener should have blocked!", listener.blocked);
+ assertEquals("Cache1 state incorrect!", removeTest ? null : VALUE2, cache1.get(FQNA, KEY));
latch.countDown();
@@ -335,7 +335,7 @@
TestingUtil.sleepThread(5);
CacheMode mode = cache2.getConfiguration().getCacheMode();
boolean expectNull = (removeTest || mode == CacheMode.INVALIDATION_ASYNC || mode == CacheMode.INVALIDATION_SYNC);
- assertEquals("Cache2 correct", expectNull ? null : VALUE2, cache2.get(FQNA, KEY));
+ assertEquals("Cache2 state incorrect!", expectNull ? null : VALUE2, cache2.get(FQNA, KEY));
}
/**
@@ -355,7 +355,7 @@
updater.start();
updater.join(250);
- assertFalse("Updater blocked", updater.finished);
+ assertFalse("Updater should have blocked!", updater.finished);
for (int i = 0; i < 50; i++)
{
@@ -364,7 +364,7 @@
TestingUtil.sleepThread(10);
}
- assertTrue("Listener blocked", listener.blocked);
+ assertTrue("Listener should have blocked", listener.blocked);
latch.countDown();
@@ -375,18 +375,18 @@
TestingUtil.sleepThread(10);
}
- assertTrue("Updater finished", updater.finished);
- assertFalse("Listener blocked", listener.blocked);
- assertNull("Updater succeeded", updater.failure);
+ assertTrue("Updater should have finished", updater.finished);
+ assertFalse("Listener should have blocked", listener.blocked);
+ assertNull("Updater should have succeeded", updater.failure);
- assertEquals("Cache1 correct", removeTest ? null : VALUE2, cache1.get(FQNA, KEY));
+ assertEquals("Cache1 state incorrect", removeTest ? null : VALUE2, cache1.get(FQNA, KEY));
// sleep a bit more to ensure the cache2 thread completes
TestingUtil.sleepThread(500);
CacheMode mode = cache2.getConfiguration().getCacheMode();
boolean expectNull = (removeTest || mode == CacheMode.INVALIDATION_ASYNC || mode == CacheMode.INVALIDATION_SYNC);
- assertEquals("Cache2 correct", expectNull ? null : VALUE2, cache2.get(FQNA, KEY));
+ assertEquals("Cache2 state incorrect", expectNull ? null : VALUE2, cache2.get(FQNA, KEY));
}
class Updater extends Thread
@@ -459,7 +459,7 @@
@NodeEvicted
public void block(NodeEvent event)
{
- log.warn("Received event notification " + event);
+ log.error("Received event notification " + event);
if (event.isPre() == false && FQNA.equals(event.getFqn()))
{
blocked = true;
16 years, 2 months
JBoss Cache SVN: r5636 - in core/trunk/src: test/java/org/jboss/cache/options/cachemodelocal and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-23 05:29:39 -0400 (Wed, 23 Apr 2008)
New Revision: 5636
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/AsyncInvalidationPessLocksTest.java
Log:
Fixed invalidation interceptor
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-23 08:57:14 UTC (rev 5635)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-23 09:29:39 UTC (rev 5636)
@@ -86,21 +86,19 @@
this.txTable = txTable;
}
- // todo: revisit. This is not used anywhere but it's functionality is necessary. Expecting a bug here.
+ private boolean skipInvalidation(InvocationContext ctx)
+ {
+ Option optionOverride = ctx.getOptionOverrides();
+ if (optionOverride != null && optionOverride.isCacheModeLocal() && (ctx.getTransaction() == null))
+ //|| MethodDeclarations.isTransactionLifecycleMethod(ctx.getMethodCall().getMethodId())))
+ {
+ // skip replication!!
+ return true;
+ }
+ if (trace) log.trace("(" + rpcManager.getLocalAddress() + ") method call " + ctx.getMethodCall());
+ return false;
+ }
-// protected boolean skipMethodCall(InvocationContext ctx)
-// {
-// Option optionOverride = ctx.getOptionOverrides();
-// if (optionOverride != null && optionOverride.isCacheModeLocal() && (ctx.getTransaction() == null ||
-// MethodDeclarations.isTransactionLifecycleMethod(ctx.getMethodCall().getMethodId())))
-// {
-// // skip replication!!
-// return true;
-// }
-// if (trace) log.trace("(" + rpcManager.getLocalAddress() + ") method call " + ctx.getMethodCall());
-// return false;
-// }
-
public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
return handleCrudMethod(ctx, command.getFqn(), null, command);
@@ -239,36 +237,39 @@
private void broadcastInvalidate(List<TxCacheCommand> modifications, GlobalTransaction gtx, Transaction tx, InvocationContext ctx) throws Throwable
{
- if (modifications == null || modifications.isEmpty()) return;
- InvalidationFilterVisitor filterVisitor = new InvalidationFilterVisitor(modifications.size());
- filterVisitor.visitCollection(null, modifications);
+ if (!skipInvalidation(ctx))
+ {
+ if (modifications == null || modifications.isEmpty()) return;
+ InvalidationFilterVisitor filterVisitor = new InvalidationFilterVisitor(modifications.size());
+ filterVisitor.visitCollection(null, modifications);
- if (filterVisitor.containsPutForExternalRead)
- {
- log.debug("Modification list contains a putForExternalRead operation. Not invalidating.");
- }
- else
- {
- try
+ if (filterVisitor.containsPutForExternalRead)
{
- TransactionWorkspace workspace = config.isNodeLockingOptimistic() ? getWorkspace(gtx) : null;
- for (Fqn fqn : filterVisitor.result) invalidateAcrossCluster(fqn, workspace, defaultSynchronous, ctx);
+ log.debug("Modification list contains a putForExternalRead operation. Not invalidating.");
}
- catch (Throwable t)
+ else
{
- log.warn("Unable to broadcast evicts as a part of the prepare phase. Rolling back.", t);
try
{
- tx.setRollbackOnly();
+ TransactionWorkspace workspace = config.isNodeLockingOptimistic() ? getWorkspace(gtx) : null;
+ for (Fqn fqn : filterVisitor.result) invalidateAcrossCluster(fqn, workspace, defaultSynchronous, ctx);
}
- catch (SystemException se)
+ catch (Throwable t)
{
- throw new RuntimeException("setting tx rollback failed ", se);
+ log.warn("Unable to broadcast evicts as a part of the prepare phase. Rolling back.", t);
+ try
+ {
+ tx.setRollbackOnly();
+ }
+ catch (SystemException se)
+ {
+ throw new RuntimeException("setting tx rollback failed ", se);
+ }
+ if (t instanceof RuntimeException)
+ throw (RuntimeException) t;
+ else
+ throw new RuntimeException("Unable to broadcast invalidation messages", t);
}
- if (t instanceof RuntimeException)
- throw (RuntimeException) t;
- else
- throw new RuntimeException("Unable to broadcast invalidation messages", t);
}
}
}
@@ -357,13 +358,16 @@
protected void invalidateAcrossCluster(Fqn fqn, TransactionWorkspace workspace, boolean synchronous, InvocationContext ctx) throws Throwable
{
- // increment invalidations counter if statistics maintained
- incrementInvalidations();
- InvalidateCommand call = commandsFactory.buildInvalidateCommand(fqn);
- call.setDataVersion(getNodeVersion(workspace, fqn));
- if (log.isDebugEnabled()) log.debug("Cache [" + rpcManager.getLocalAddress() + "] replicating " + call);
- // voila, invalidated!
- replicateCall(ctx, call, synchronous, ctx.getOptionOverrides());
+ if (!skipInvalidation(ctx))
+ {
+ // increment invalidations counter if statistics maintained
+ incrementInvalidations();
+ InvalidateCommand call = commandsFactory.buildInvalidateCommand(fqn);
+ call.setDataVersion(getNodeVersion(workspace, fqn));
+ if (log.isDebugEnabled()) log.debug("Cache [" + rpcManager.getLocalAddress() + "] replicating " + call);
+ // voila, invalidated!
+ replicateCall(ctx, call, synchronous, ctx.getOptionOverrides());
+ }
}
private void incrementInvalidations()
Modified: core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/AsyncInvalidationPessLocksTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/AsyncInvalidationPessLocksTest.java 2008-04-23 08:57:14 UTC (rev 5635)
+++ core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/AsyncInvalidationPessLocksTest.java 2008-04-23 09:29:39 UTC (rev 5636)
@@ -8,18 +8,20 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.misc.TestingUtil;
+import org.testng.annotations.Test;
+@Test(groups = "functional")
public class AsyncInvalidationPessLocksTest extends CacheModeLocalTestBase
{
- public AsyncInvalidationPessLocksTest()
- {
- cacheMode = Configuration.CacheMode.INVALIDATION_ASYNC;
- nodeLockingScheme = "PESSIMISTIC";
- isInvalidation = true;
- }
+ public AsyncInvalidationPessLocksTest()
+ {
+ cacheMode = Configuration.CacheMode.INVALIDATION_ASYNC;
+ nodeLockingScheme = "PESSIMISTIC";
+ isInvalidation = true;
+ }
- protected void delay()
- {
- TestingUtil.sleepThread(500);
- }
+ protected void delay()
+ {
+ TestingUtil.sleepThread(500);
+ }
}
16 years, 2 months
JBoss Cache SVN: r5635 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-04-23 04:57:14 -0400 (Wed, 23 Apr 2008)
New Revision: 5635
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
Log:
JBCACHE-1222 - bug fixing - marshalling
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java 2008-04-23 00:06:30 UTC (rev 5634)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java 2008-04-23 08:57:14 UTC (rev 5635)
@@ -66,9 +66,17 @@
Object value = createAndAddMarshalledValue(command.getValue(), marshalledValues, ctx);
command.setValue(value);
}
- return compactAndProcessRetVal(command, marshalledValues, command);
+ Object retVal = invokeNextInterceptor(ctx, command);
+ return compactAndProcessRetVal(command, marshalledValues, retVal);
}
+ @Override
+ public Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+ {
+ Object retVal = invokeNextInterceptor(ctx, command);
+ return processRetVal(retVal);
+ }
+
public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
Object retVal = invokeNextInterceptor(ctx, command);
16 years, 2 months
JBoss Cache SVN: r5634 - core/trunk/src/main/java/org/jboss/cache/commands/remote.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-22 20:06:30 -0400 (Tue, 22 Apr 2008)
New Revision: 5634
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
Log:
Fixed replication queue handling
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 2008-04-22 23:56:54 UTC (rev 5633)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-04-23 00:06:30 UTC (rev 5634)
@@ -80,15 +80,22 @@
{
if (trace) log.trace("Invoking command " + cacheCommand + ", with originLocal flag set to false.");
- Object retVal = invoker.invokeRemote(cacheCommand);
- // we only need to return values for a set of remote calls; not every call.
- if (returnValueForRemoteCall(cacheCommand))
+ if (cacheCommand instanceof DirectCommand)
{
- result = retVal;
+ result = ((DirectCommand) cacheCommand).performDirectly();
}
else
{
- result = null;
+ Object retVal = invoker.invokeRemote(cacheCommand);
+ // we only need to return values for a set of remote calls; not every call.
+ if (returnValueForRemoteCall(cacheCommand))
+ {
+ result = retVal;
+ }
+ else
+ {
+ result = null;
+ }
}
}
catch (Throwable ex)
16 years, 2 months