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);