Skip to content

Commit

Permalink
[ISPN-164] (clear() call with Flag.CACHE_MODE_LOCAL going remote) Che…
Browse files Browse the repository at this point in the history
…ck added to invalidation interceptor so that if forced, clear calls remain local.
  • Loading branch information
galderz committed Aug 19, 2009
1 parent e3ab62d commit 1d6a943
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) t

@Override
public Object visitClearCommand(InvocationContext ctx, ClearCommand command) throws Throwable {
// just broadcast the clear command - this is simplest!
Object retval = invokeNextInterceptor(ctx, command);
if (ctx.isOriginLocal()) rpcManager.broadcastRpcCommand(command, defaultSynchronous);
if (!isLocalModeForced(ctx)) {
// just broadcast the clear command - this is simplest!
if (ctx.isOriginLocal()) rpcManager.broadcastRpcCommand(command, defaultSynchronous);
}
return retval;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,17 @@ public void testReplaceWithOldVal() {
assert cache1.get("key").equals("value1");
assert cache2.get("key") == null;
}

public void testLocalOnlyClear() {
cache1.put("key", "value1", Flag.CACHE_MODE_LOCAL);
cache2.put("key", "value2", Flag.CACHE_MODE_LOCAL);
assert cache1.get("key").equals("value1");
assert cache2.get("key").equals("value2");

cache1.clear(Flag.CACHE_MODE_LOCAL);

assert cache1.get("key") == null;
assert cache2.get("key") != null;
assert cache2.get("key").equals("value2");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,17 @@ public void testReplaceWithOldVal() {
assert cache1.get("key").equals("value1");
assert cache2.get("key").equals("value1");
}

public void testLocalOnlyClear() {
cache1.put("key", "value1", Flag.CACHE_MODE_LOCAL);
cache2.put("key", "value2", Flag.CACHE_MODE_LOCAL);
assert cache1.get("key").equals("value1");
assert cache2.get("key").equals("value2");

cache1.clear(Flag.CACHE_MODE_LOCAL);

assert cache1.get("key") == null;
assert cache2.get("key") != null;
assert cache2.get("key").equals("value2");
}
}

0 comments on commit 1d6a943

Please sign in to comment.