Author: manik.surtani(a)jboss.com
Date: 2008-11-27 12:52:43 -0500 (Thu, 27 Nov 2008)
New Revision: 7222
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java
Log:
Fixed failures to do with passivation
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java 2008-11-27
17:49:26 UTC (rev 7221)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java 2008-11-27
17:52:43 UTC (rev 7222)
@@ -106,7 +106,7 @@
public Object visitGetChildrenNamesCommand(InvocationContext ctx,
GetChildrenNamesCommand command) throws Throwable
{
Object returnValue = super.visitGetChildrenNamesCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
+ removeNodeFromCacheLoader(ctx, command.getFqn(), true);
return returnValue;
}
@@ -114,7 +114,7 @@
public Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command)
throws Throwable
{
Object returnValue = super.visitGetKeysCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
+ removeNodeFromCacheLoader(ctx, command.getFqn(), true);
return returnValue;
}
@@ -122,7 +122,7 @@
public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command)
throws Throwable
{
Object returnValue = super.visitGetNodeCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
+ removeNodeFromCacheLoader(ctx, command.getFqn(), true);
return returnValue;
}
@@ -130,7 +130,7 @@
public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand
command) throws Throwable
{
Object returnValue = super.visitGetKeyValueCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
+ removeNodeFromCacheLoader(ctx, command.getFqn(), true);
return returnValue;
}
@@ -144,7 +144,7 @@
public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand
command) throws Throwable
{
Object returnValue = super.visitPutKeyValueCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
+ removeNodeFromCacheLoader(ctx, command.getFqn(), true);
return returnValue;
}
@@ -152,7 +152,7 @@
public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command)
throws Throwable
{
Object returnValue = super.visitPutDataMapCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
+ removeNodeFromCacheLoader(ctx, command.getFqn(), true);
return returnValue;
}
@@ -160,7 +160,7 @@
public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command)
throws Throwable
{
Object returnValue = super.visitRemoveKeyCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
+ removeNodeFromCacheLoader(ctx, command.getFqn(), true);
return returnValue;
}
@@ -173,8 +173,8 @@
log.trace("This is a move operation; removing the FROM node from the
loader, no activation processing needed.");
}
loader.remove(command.getFqn());
- removeNodeFromCacheLoader(ctx, command.getFqn().getParent());
- removeNodeFromCacheLoader(ctx, command.getTo());
+ removeNodeFromCacheLoader(ctx, command.getFqn().getParent(), true);
+ removeNodeFromCacheLoader(ctx, command.getTo(), true);
return returnValue;
}
@@ -189,38 +189,50 @@
* its attributes have been initialized, its children have been loaded,
* AND it was found in the cache loader (nodeLoaded = true).
*/
- private void removeNodeFromCacheLoader(InvocationContext ctx, Fqn fqn) throws
Throwable
+ private void removeNodeFromCacheLoader(InvocationContext ctx, Fqn fqn, boolean
checkIfLoaded) throws Throwable
{
// only bother with this if the node has been loaded by the cache loader previous
to this call.
- if (fqn != null && wasLoadedIntoMemory(ctx, fqn))
+ if (fqn != null)
{
- NodeSPI n;
- if (((n = dataContainer.peek(fqn, true, false)) != null) &&
n.isDataLoaded() && loader.exists(fqn))
+ boolean remove = false;
+ if (!checkIfLoaded || wasLoadedIntoMemory(ctx, fqn))
{
- // node not null and attributes have been loaded?
- if (!n.getChildrenDirect().isEmpty())
+ NodeSPI n;
+ if (((n = dataContainer.peek(fqn, true, false)) != null) &&
n.isDataLoaded() && loader.exists(fqn))
{
- boolean result = childrenLoaded(n);
- if (result)
+ // node not null and attributes have been loaded?
+ if (!n.getChildrenDirect().isEmpty())
{
- log.debug("children all initialized");
+ boolean result = childrenLoaded(n);
+ if (result)
+ {
+ log.debug("children all initialized");
+ remove(fqn);
+ remove = true;
+ }
+ }
+ else if (loaderNoChildren(fqn))
+ {
+ if (log.isDebugEnabled()) log.debug("no children " + n);
remove(fqn);
+ remove = true;
}
}
- else if (loaderNoChildren(fqn))
- {
- if (log.isDebugEnabled()) log.debug("no children " + n);
- remove(fqn);
- }
}
+
+ if (!fqn.isRoot() && remove)
+ {
+ // check fqn parent, since the parent may not be needed on disk anymore
+ removeNodeFromCacheLoader(ctx, fqn.getParent(), false);
+ }
}
}
- private boolean childrenLoaded(NodeSPI<?, ?> node)
+ private boolean childrenLoaded(NodeSPI<?, ?> node) throws Exception
{
if (!node.isChildrenLoaded())
{
- return false;
+ if (loader.getChildrenNames(node.getFqn()) != null) return false;
}
for (NodeSPI child : node.getChildrenDirect())
{