JBoss Cache SVN: r5633 - core/trunk/src/test/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-22 19:56:54 -0400 (Tue, 22 Apr 2008)
New Revision: 5633
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
Log:
Fixed test
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-04-22 23:47:00 UTC (rev 5632)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-04-22 23:56:54 UTC (rev 5633)
@@ -52,9 +52,9 @@
private static final Fqn BUDDY_BASE = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
- private static final Fqn BUDDY_PLUS_FQN = Fqn.fromRelativeElements(BUDDY_BASE, FQN);
+ private static final Fqn BUDDY_PLUS_FQN = Fqn.fromRelativeFqn(BUDDY_BASE, FQN);
- private static final Fqn BUDDY_PLUS_SUBTREE_FQN = Fqn.fromRelativeElements(BUDDY_BASE, SUBTREE_FQN);
+ private static final Fqn BUDDY_PLUS_SUBTREE_FQN = Fqn.fromRelativeFqn(BUDDY_BASE, SUBTREE_FQN);
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
16 years, 2 months
JBoss Cache SVN: r5632 - core/trunk/src/test/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-22 19:47:00 -0400 (Tue, 22 Apr 2008)
New Revision: 5632
Modified:
core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java
Log:
Fixed test
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java 2008-04-22 18:33:28 UTC (rev 5631)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java 2008-04-22 23:47:00 UTC (rev 5632)
@@ -6,9 +6,10 @@
import org.jboss.cache.Region;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
import org.jboss.cache.commands.cachedata.CacheDataCommand;
+import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
import org.jboss.cache.commands.remote.ClusteredGetCommand;
+import org.jboss.cache.commands.remote.GravitateDataCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.misc.TestingUtil;
import static org.testng.AssertJUnit.*;
@@ -98,8 +99,8 @@
assertSame(listClass, cache2.get(fqn, key).getClass());
- CacheDataCommand command = commandsFactory.buildGetKeyValueCommand(fqn, key, false);
- ClusteredGetCommand clusteredGet = commandsFactory.buildClusteredGetCommand(false, command);
+ CacheDataCommand command = new GetKeyValueCommand(fqn, key, false);
+ ClusteredGetCommand clusteredGet = new ClusteredGetCommand(false, command);
List responses = cache1.getRPCManager().callRemoteMethods(null, clusteredGet, true, true, 15000, false);
List response1 = (List) responses.get(0);// response from the first (and only) node
@@ -127,9 +128,9 @@
assertNotSame(MyList.class, cache2.get(fqn, key).getClass());
assertSame(listClass, cache2.get(fqn, key).getClass());
- GravitateDataCommand cdCc = commandsFactory.buildGravitateDataCacheCommand(fqn, false);
+ GravitateDataCommand gravitateDataCommand = new GravitateDataCommand(fqn, false);
- List responses = cache1.getRPCManager().callRemoteMethods(null, cdCc, true, true, 15000, false);
+ List responses = cache1.getRPCManager().callRemoteMethods(null, gravitateDataCommand, true, true, 15000, false);
GravitateResult data = (GravitateResult) responses.get(0);// response from the first (and only) node
assertTrue("Should have found remote data", data.isDataFound());
16 years, 2 months
JBoss Cache SVN: r5631 - in core/trunk/src: test/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-22 14:33:28 -0400 (Tue, 22 Apr 2008)
New Revision: 5631
Modified:
core/trunk/src/main/java/org/jboss/cache/Fqn.java
core/trunk/src/main/java/org/jboss/cache/StringFqn.java
core/trunk/src/test/java/org/jboss/cache/FqnTest.java
Log:
Cache loader fixes
Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-04-22 17:35:55 UTC (rev 5630)
+++ core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-04-22 18:33:28 UTC (rev 5631)
@@ -125,8 +125,11 @@
{
// if not safe make a defensive copy
elements = safe ? names : new ArrayList(names);
- if (elements.get(0).equals(SEPARATOR)) elements.remove(0);
- if (elements.get(0).equals("")) elements.remove(0);
+ if (elements.size() > 0)
+ {
+ if (SEPARATOR.equals(elements.get(0))) elements.remove(0);
+ if ("".equals(elements.get(0))) elements.remove(0);
+ }
size = elements.size();
}
else
@@ -509,19 +512,7 @@
{
if (stringRepresentation == null)
{
- if (isRoot())
- {
- stringRepresentation = SEPARATOR;
- }
- else
- {
- StringBuilder sb = new StringBuilder();
- for (E element : elements)
- {
- sb.append(SEPARATOR).append(element);
- }
- stringRepresentation = sb.toString();
- }
+ stringRepresentation = getStringRepresentation(elements);
}
return stringRepresentation;
}
@@ -545,6 +536,8 @@
E e = (E) in.readObject();
elements.add(e);
}
+
+ if (getClass().equals(StringFqn.class)) stringRepresentation = getStringRepresentation(elements);
}
@@ -605,6 +598,11 @@
*/
protected int calculateHashCode()
{
+ if (containsStrings(elements))
+ {
+ if (stringRepresentation == null) stringRepresentation = getStringRepresentation(elements);
+ return stringRepresentation.hashCode();
+ }
int hashCode = 0;
int count = 1;
Object o;
@@ -620,6 +618,21 @@
return hashCode;
}
+ protected String getStringRepresentation(List elements)
+ {
+ StringBuilder builder = new StringBuilder();
+ for (Object e : elements)
+ {
+ if (!e.equals(SEPARATOR) && !e.equals(""))
+ {
+ builder.append(SEPARATOR);
+ builder.append(e);
+ }
+ }
+ return builder.toString();
+ }
+
+
/**
* Returns the parent of this Fqn.
* The parent of the root node is {@link #ROOT}.
Modified: core/trunk/src/main/java/org/jboss/cache/StringFqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/StringFqn.java 2008-04-22 17:35:55 UTC (rev 5630)
+++ core/trunk/src/main/java/org/jboss/cache/StringFqn.java 2008-04-22 18:33:28 UTC (rev 5631)
@@ -50,21 +50,6 @@
this(Arrays.asList(stringRep.split("/")));
}
- private String getStringRepresentation(List<String> elements)
- {
- StringBuilder builder = new StringBuilder();
- for (String e : elements)
- {
- if (!e.equals(SEPARATOR) && !e.equals(""))
- {
- builder.append(SEPARATOR);
- // escape special chars.
- builder.append(e);
- }
- }
- return builder.toString();
- }
-
@Override
public boolean equals(Object other)
{
Modified: core/trunk/src/test/java/org/jboss/cache/FqnTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/FqnTest.java 2008-04-22 17:35:55 UTC (rev 5630)
+++ core/trunk/src/test/java/org/jboss/cache/FqnTest.java 2008-04-22 18:33:28 UTC (rev 5631)
@@ -18,6 +18,7 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.util.Arrays;
import java.util.HashMap;
/**
@@ -447,6 +448,30 @@
System.out.println("-- " + msg);
}
+ public void testDifferentFactories()
+ {
+ Fqn[] fqns = new Fqn[7];
+ int i = 0;
+ fqns[i++] = Fqn.fromString("/a/b/c");
+ fqns[i++] = Fqn.fromRelativeElements(Fqn.ROOT, "a", "b", "c");
+ fqns[i++] = Fqn.fromElements("a", "b", "c");
+ fqns[i++] = Fqn.fromList(Arrays.asList(new String[]{"a", "b", "c"}));
+ fqns[i++] = Fqn.fromRelativeList(Fqn.ROOT, Arrays.asList(new String[]{"a", "b", "c"}));
+ fqns[i++] = Fqn.fromRelativeFqn(Fqn.ROOT, Fqn.fromString("/a/b/c"));
+ fqns[i] = new Fqn("a", "b", "c"); // "old-style" Fqn
+
+ // all of the above should be equal to each other.
+ for (i = 0; i < fqns.length; i++)
+ {
+ for (int j = 0; j < fqns.length; j++)
+ {
+ assert fqns[i].equals(fqns[j]) : "Error on equals comparing " + i + " and " + j;
+ assert fqns[j].equals(fqns[i]) : "Error on equals comparing " + i + " and " + j;
+ assert fqns[i].hashCode() == fqns[j].hashCode() : "Error on hashcode comparing " + i + " and " + j;
+ }
+ }
+ }
+
@Test(enabled = false)
// TODO enable once String escaping is in place
public void testUnescapedString()
16 years, 2 months
JBoss Cache SVN: r5630 - in core/trunk/src: main/java/org/jboss/cache/commands/remote and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-22 13:35:55 -0400 (Tue, 22 Apr 2008)
New Revision: 5630
Modified:
core/trunk/src/main/java/org/jboss/cache/Fqn.java
core/trunk/src/main/java/org/jboss/cache/StringFqn.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
Log:
Cache loader fixes
Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-04-22 17:08:48 UTC (rev 5629)
+++ core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-04-22 17:35:55 UTC (rev 5630)
@@ -125,6 +125,8 @@
{
// if not safe make a defensive copy
elements = safe ? names : new ArrayList(names);
+ if (elements.get(0).equals(SEPARATOR)) elements.remove(0);
+ if (elements.get(0).equals("")) elements.remove(0);
size = elements.size();
}
else
Modified: core/trunk/src/main/java/org/jboss/cache/StringFqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/StringFqn.java 2008-04-22 17:08:48 UTC (rev 5629)
+++ core/trunk/src/main/java/org/jboss/cache/StringFqn.java 2008-04-22 17:35:55 UTC (rev 5630)
@@ -39,9 +39,9 @@
stringRepresentation = base.isRoot() ? relative.stringRepresentation : base.stringRepresentation + relative.stringRepresentation;
}
- protected StringFqn(List<String> elements)
+ protected StringFqn(List<String> stringElements)
{
- super(true, elements, false);
+ super(true, stringElements, false);
stringRepresentation = getStringRepresentation(elements);
}
@@ -55,9 +55,12 @@
StringBuilder builder = new StringBuilder();
for (String e : elements)
{
- builder.append(SEPARATOR);
- // escape special chars.
- builder.append(e);
+ if (!e.equals(SEPARATOR) && !e.equals(""))
+ {
+ builder.append(SEPARATOR);
+ // escape special chars.
+ builder.append(e);
+ }
}
return builder.toString();
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-04-22 17:08:48 UTC (rev 5629)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-04-22 17:35:55 UTC (rev 5630)
@@ -65,7 +65,10 @@
try
{
if (trace) log.trace("Clustered get: invoking call with Fqn " + cacheDataComand.getFqn());
- callResults = interceptorChain.invokeRemote(cacheDataComand);
+ InvocationContext ctx = interceptorChain.getInvocationContext();
+ ctx.setOriginLocal(false);
+ // very hacky to be calling this command directly.
+ callResults = cacheDataComand.perform(ctx);
boolean found = validResult(callResults);
if (trace) log.trace("Got result " + callResults + ", found=" + found);
if (found && callResults == null) callResults = createEmptyResults();
@@ -89,6 +92,7 @@
return results;
}
+
public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
{
return handler.handleClusteredGetCommand(ctx, this);
@@ -106,7 +110,7 @@
{
if (cacheDataComand instanceof GetDataMapCommand || cacheDataComand instanceof GetChildrenNamesCommand)
{
- return callResults != null || cacheData.exists(cacheDataComand.getFqn());
+ return callResults != null && cacheData.exists(cacheDataComand.getFqn());
}
return cacheDataComand instanceof RemoteExistsNodeCommand && (Boolean) callResults;
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-04-22 17:08:48 UTC (rev 5629)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-04-22 17:35:55 UTC (rev 5630)
@@ -59,8 +59,8 @@
cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.ClusteredCacheLoader", "timeout=500", false, false, false));
- cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.ClusteredCacheLoader", "timeout=500", false, false, false));
+ cache1.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.ClusteredCacheLoader", "timeout=5000", false, false, false));
+ cache2.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.ClusteredCacheLoader", "timeout=5000", false, false, false));
cache1.getConfiguration().setUseRegionBasedMarshalling(useRegionBasedMarshalling);
cache2.getConfiguration().setUseRegionBasedMarshalling(useRegionBasedMarshalling);
@@ -178,7 +178,9 @@
// now cache 1 should not have this but cache 2 should.
// loader1 looks at cache2 while loader2 looks at cache1
+ assert cache1.peek(fqn, false) == null;
childNames = loader1.getChildrenNames(fqn);
+ assert cache1.peek(fqn, false) == null;
assertEquals(3, childNames.size());
childNames = loader2.getChildrenNames(fqn);
16 years, 2 months
JBoss Cache SVN: r5629 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-22 13:08:48 -0400 (Tue, 22 Apr 2008)
New Revision: 5629
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
Log:
Logging
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-04-22 16:55:25 UTC (rev 5628)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-04-22 17:08:48 UTC (rev 5629)
@@ -2,7 +2,11 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.*;
+import org.jboss.cache.commands.cachedata.MoveCommand;
+import org.jboss.cache.commands.cachedata.PutDataMapCommand;
+import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
+import org.jboss.cache.commands.cachedata.RemoveDataCommand;
+import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
import org.jboss.cache.commands.functional.TxCacheCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -84,7 +88,7 @@
@Override
public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
{
- if (trace) log.trace("Executing command: " + command.getClass().getSimpleName() + " .");
+ if (trace) log.trace("Executing command: " + command.getClass().getSimpleName() + ".");
return invokeCommand(ctx, command);
}
16 years, 2 months
JBoss Cache SVN: r5628 - core/trunk/src/test/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-22 12:55:25 -0400 (Tue, 22 Apr 2008)
New Revision: 5628
Modified:
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
Log:
Updated test
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-04-22 16:37:30 UTC (rev 5627)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-04-22 16:55:25 UTC (rev 5628)
@@ -50,25 +50,25 @@
assertEquals(CacheMarshaller200.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.4.0.GA");
- assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.5.0.GA");
- assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.3.0.GA");
- assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.3.0.SP2");
- assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.3.1.GA");
- assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.2.4.SP2");
- assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.2.3");
- assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
}
public void testVersionHeaderDefaultCurrent() throws Exception
16 years, 2 months
JBoss Cache SVN: r5627 - core/trunk/src/test/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-22 12:37:30 -0400 (Tue, 22 Apr 2008)
New Revision: 5627
Modified:
core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
Log:
Got rid of hacky MethodCallWrapper and implemented a new rpc invoke method in CommandAwareRpcDispatcher
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-04-22 16:37:15 UTC (rev 5626)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-04-22 16:37:30 UTC (rev 5627)
@@ -153,7 +153,7 @@
public void testObjectFromByteBuffer() throws Exception
{
PutKeyValueCommand put = new PutKeyValueCommand(null, A_B, "name", "Joe", false, false);
- MethodCallWrapper replicate = new MethodCallWrapper(new ReplicateCommand(put));
+ ReplicateCommand replicate = new ReplicateCommand(put);
rman.setDefaultInactive(true);
// register A as an inactive marshalling region
16 years, 2 months
JBoss Cache SVN: r5626 - in core/trunk/src/main/java/org/jboss/cache: marshall and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-22 12:37:15 -0400 (Tue, 22 Apr 2008)
New Revision: 5626
Removed:
core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java
Modified:
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
Log:
Got rid of hacky MethodCallWrapper and implemented a new rpc invoke method in CommandAwareRpcDispatcher
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-22 16:36:40 UTC (rev 5625)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-22 16:37:15 UTC (rev 5626)
@@ -14,13 +14,15 @@
import org.jboss.cache.config.RuntimeConfig;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Stop;
+import org.jboss.cache.invocation.CacheLifecycleManager;
+import org.jboss.cache.invocation.InterceptorChain;
+import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.lock.LockUtil;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
import org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher;
import org.jboss.cache.marshall.Marshaller;
-import org.jboss.cache.marshall.MethodCallWrapper;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.remoting.jgroups.ChannelMessageListener;
import org.jboss.cache.statetransfer.StateTransferManager;
@@ -28,9 +30,6 @@
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.ThreadGate;
import org.jboss.cache.util.reflect.ReflectionUtil;
-import org.jboss.cache.invocation.InvocationContextContainer;
-import org.jboss.cache.invocation.InterceptorChain;
-import org.jboss.cache.invocation.CacheLifecycleManager;
import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.ChannelException;
@@ -40,7 +39,6 @@
import org.jgroups.StateTransferException;
import org.jgroups.View;
import org.jgroups.blocks.GroupRequest;
-import org.jgroups.blocks.RpcDispatcher;
import org.jgroups.blocks.RspFilter;
import org.jgroups.util.Rsp;
import org.jgroups.util.RspList;
@@ -76,7 +74,7 @@
/**
* JGroups RpcDispatcher in use.
*/
- private RpcDispatcher disp = null;
+ private CommandAwareRpcDispatcher disp = null;
/**
* JGroups message listener.
@@ -100,7 +98,7 @@
private void setupDependencies(ChannelMessageListener messageListener, Configuration configuration, Notifier notifier,
CacheSPI spi, Marshaller marshaller, TransactionTable txTable,
TransactionManager txManager, InvocationContextContainer container, InterceptorChain interceptorChain,
- CacheLifecycleManager lifecycleManager)
+ CacheLifecycleManager lifecycleManager)
{
this.messageListener = messageListener;
this.configuration = configuration;
@@ -410,10 +408,7 @@
validMembers = new Vector<Address>(recipients);
else
{
- synchronized (members)
- {
- validMembers = new Vector<Address>(members);
- }
+ validMembers = new Vector<Address>(members);
}
if (excludeSelf && !validMembers.isEmpty())
@@ -439,10 +434,7 @@
useOutOfBandMessage = false;
- //todo check whether we can get rid of the MethodCallWrapper and use the command directly
- rsps = responseFilter == null
- ? disp.callRemoteMethods(validMembers, new MethodCallWrapper(command), modeToUse, timeout, isUsingBuddyReplication, useOutOfBandMessage)
- : disp.callRemoteMethods(validMembers, new MethodCallWrapper(command), modeToUse, timeout, isUsingBuddyReplication, useOutOfBandMessage, responseFilter);
+ rsps = disp.invokeRemoteCommands(validMembers, command, modeToUse, timeout, isUsingBuddyReplication, useOutOfBandMessage, responseFilter);
// a null response is 99% likely to be due to a marshalling problem - we throw a NSE, this needs to be changed when
// JGroups supports http://jira.jboss.com/jira/browse/JGRP-193
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-04-22 16:36:40 UTC (rev 5625)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-04-22 16:37:15 UTC (rev 5626)
@@ -92,9 +92,9 @@
region = rrv.region;
o = rrv.returnValue;
}
- else if (o instanceof MethodCallWrapper)
+ else if (o instanceof MarshallableCommand)
{
- MarshallableCommand marshallableCommand = ((MethodCallWrapper) o).getCommand();
+ MarshallableCommand marshallableCommand = (MarshallableCommand) o;
region = extractFqnRegion(marshallableCommand);
}
@@ -268,9 +268,9 @@
out.writeByte(MAGICNUMBER_REF);
writeReference(out, refMap.get(o));
}
- else if (o instanceof MethodCallWrapper || o instanceof MarshallableCommand)
+ else if (o instanceof MarshallableCommand)
{
- MarshallableCommand command = o instanceof MethodCallWrapper ? ((MethodCallWrapper) o).getCommand() : (MarshallableCommand) o;
+ MarshallableCommand command = (MarshallableCommand) o;
if (command.getCommandId() > -1)
{
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-04-22 16:36:40 UTC (rev 5625)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-04-22 16:37:15 UTC (rev 5626)
@@ -2,6 +2,7 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.functional.MarshallableCommand;
import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
import org.jboss.cache.commands.remote.DirectCommand;
@@ -9,12 +10,17 @@
import org.jboss.cache.invocation.CacheLifecycleManager;
import org.jboss.cache.invocation.InterceptorChain;
import org.jboss.cache.invocation.InvocationContextContainer;
+import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.MembershipListener;
import org.jgroups.Message;
import org.jgroups.MessageListener;
import org.jgroups.blocks.RpcDispatcher;
+import org.jgroups.blocks.RspFilter;
+import org.jgroups.util.RspList;
+import java.util.Vector;
+
/**
* A JGroups RPC dispatcher that knows how to deal with {@link org.jboss.cache.commands.CacheCommand}s.
*
@@ -57,6 +63,42 @@
}
/**
+ * Similar to {@link #callRemoteMethods(java.util.Vector, org.jgroups.blocks.MethodCall, int, long, boolean, boolean, org.jgroups.blocks.RspFilter)} except that this version
+ * is aware of {@link org.jboss.cache.commands.CacheCommand} objects.
+ */
+ public RspList invokeRemoteCommands(Vector<Address> dests, MarshallableCommand command, int mode, long timeout,
+ boolean use_anycasting, boolean oob, RspFilter filter)
+ {
+ if (dests != null && dests.isEmpty())
+ {
+ // don't send if dest list is empty
+ if (trace) log.trace("Destination list is empty: no need to send message");
+ return new RspList();
+ }
+
+ if (trace)
+ log.trace(new StringBuilder("dests=").append(dests).append(", command=").append(command).
+ append(", mode=").append(mode).append(", timeout=").append(timeout));
+
+ byte[] buf;
+ try
+ {
+ buf = req_marshaller.objectToByteBuffer(command);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("failure to marshal argument(s)", e);
+ }
+
+ Message msg = new Message(null, null, buf);
+ if (oob)
+ msg.setFlag(Message.OOB);
+ RspList retval = super.castMessage(dests, msg, mode, timeout, use_anycasting, filter);
+ if (log.isTraceEnabled()) log.trace("responses: " + retval);
+ return retval;
+ }
+
+ /**
* Message contains a Command. Execute it against *this* object and return result.
*/
@Override
Deleted: core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java 2008-04-22 16:36:40 UTC (rev 5625)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java 2008-04-22 16:37:15 UTC (rev 5626)
@@ -1,53 +0,0 @@
-package org.jboss.cache.marshall;
-
-import org.jboss.cache.commands.functional.MarshallableCommand;
-
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-/**
- * This wrapper class is used when passing in {@link org.jboss.cache.commands.CacheCommand}s into JGroups RPC APIs.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @see org.jboss.cache.commands.CacheCommand
- * @since 2.2.0
- */
-public class MethodCallWrapper extends org.jgroups.blocks.MethodCall
-{
- private MarshallableCommand command;
-
- public MethodCallWrapper(MarshallableCommand command)
- {
- this.command = command;
- }
-
- public MethodCallWrapper()
- {
- throw new RuntimeException("Should never be invoked!");
- }
-
- @Override
- public void readExternal(ObjectInput in)
- {
- throw new RuntimeException("Should never be invoked!");
- }
-
- @Override
- public void writeExternal(ObjectOutput out)
- {
- throw new RuntimeException("Should never be invoked!");
- }
-
- public MarshallableCommand getCommand()
- {
- return command;
- }
-
- @Override
- public String toString()
- {
- return "MethodCallWrapper[" +
- "command wrapped=" + command +
- ']';
- }
-}
16 years, 2 months
JBoss Cache SVN: r5625 - core/trunk/src/test/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-22 12:36:40 -0400 (Tue, 22 Apr 2008)
New Revision: 5625
Modified:
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
Log:
Patched marshaller tests to be aware of CacheMarshaller220
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-04-22 16:21:02 UTC (rev 5624)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-04-22 16:36:40 UTC (rev 5625)
@@ -29,7 +29,7 @@
{
protected String currentVersion;
protected int currentVersionShort;
- protected Class expectedMarshallerClass, latestMarshallerClass = CacheMarshaller210.class;
+ protected Class expectedMarshallerClass, latestMarshallerClass = CacheMarshaller220.class;
protected VersionAwareMarshaller marshaller;
protected RegionManager regionManager;
protected Configuration c;
@@ -90,8 +90,9 @@
assertEquals(latestMarshallerClass, marshaller.getMarshaller(-1).getClass());
assertEquals(latestMarshallerClass, marshaller.getMarshaller(0).getClass());
assertEquals(CacheMarshaller200.class, marshaller.getMarshaller(20).getClass());
+ assertEquals(CacheMarshaller210.class, marshaller.getMarshaller(21).getClass());
- assert marshaller.marshallers.size() == 2 : "Should have 2 marshallers now";
+ assert marshaller.marshallers.size() == 3 : "Should have 3 marshallers now";
}
public void testStringBasedFqn() throws Exception
16 years, 2 months
JBoss Cache SVN: r5624 - in core/trunk/src: main/java/org/jboss/cache/marshall and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-22 12:21:02 -0400 (Tue, 22 Apr 2008)
New Revision: 5624
Modified:
core/trunk/src/main/java/org/jboss/cache/StringFqn.java
core/trunk/src/main/java/org/jboss/cache/marshall/NodeData.java
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
Log:
Optimised Fqns for String representation
Modified: core/trunk/src/main/java/org/jboss/cache/StringFqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/StringFqn.java 2008-04-22 16:09:06 UTC (rev 5623)
+++ core/trunk/src/main/java/org/jboss/cache/StringFqn.java 2008-04-22 16:21:02 UTC (rev 5624)
@@ -18,7 +18,9 @@
// TODO: Implement proper String escaping.
public class StringFqn extends Fqn
{
- protected StringFqn()
+ // Needs to be public because of NodeData serialization.
+ // TODO: Remove in 3.0.0 once we refactor NodeData to go through a cache marshaller instead of it's current serialization.
+ public StringFqn()
{
super(true);
stringRepresentation = SEPARATOR;
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/NodeData.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/NodeData.java 2008-04-22 16:09:06 UTC (rev 5623)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/NodeData.java 2008-04-22 16:21:02 UTC (rev 5624)
@@ -14,6 +14,7 @@
* @author Bela Ban
* @version $Id$
*/
+// TODO: In 3.0.0, remove Externalizable and rely on the CacheMarshaller.
public class NodeData implements Externalizable
{
private Fqn<?> fqn = null;
@@ -62,6 +63,7 @@
return false;
}
+ // TODO: Remove in 3.0.0 and replace with marshallNodeData/unmarshallNodeData methods in the CacheMarshaller so that we can use the same marshalling framework for Fqns.
public void writeExternal(ObjectOutput out) throws IOException
{
out.writeObject(fqn);
@@ -76,6 +78,7 @@
}
}
+ // TODO: Remove in 3.0.0 and replace with marshallNodeData/unmarshallNodeData methods in the CacheMarshaller so that we can use the same marshalling framework for Fqns.
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-04-22 16:09:06 UTC (rev 5623)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-04-22 16:21:02 UTC (rev 5624)
@@ -41,7 +41,7 @@
public void testMarshallerSelection()
{
VersionAwareMarshaller marshaller = createVAMandRestartCache("2.2.0.GA");
- assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("2.1.0.GA");
assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
16 years, 2 months