[jboss-cvs] JBossCache/src/org/jboss/cache/interceptors ...
Manik Surtani
msurtani at jboss.com
Mon Dec 11 12:29:44 EST 2006
User: msurtani
Date: 06/12/11 12:29:44
Modified: src/org/jboss/cache/interceptors Tag:
Branch_JBossCache_1_4_0
OptimisticValidatorInterceptor.java
OptimisticCreateIfNotExistsInterceptor.java
OptimisticNodeInterceptor.java
OptimisticReplicationInterceptor.java
Log:
Fixed a bunch of problems with Optimistic data versioning related to JBCACHE-894
Updated logging libs JBCACHE-901
Revision Changes Path
No revision
No revision
1.25.2.11 +8 -5 JBossCache/src/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticValidatorInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java,v
retrieving revision 1.25.2.10
retrieving revision 1.25.2.11
diff -u -b -r1.25.2.10 -r1.25.2.11
--- OptimisticValidatorInterceptor.java 11 Dec 2006 14:46:54 -0000 1.25.2.10
+++ OptimisticValidatorInterceptor.java 11 Dec 2006 17:29:44 -0000 1.25.2.11
@@ -179,12 +179,13 @@
for (Iterator it = nodes.iterator(); it.hasNext();)
{
WorkspaceNode wrappedNode = (WorkspaceNode) it.next();
+ if (trace) log.trace("Analysing node " + wrappedNode.getFqn() + " in workspace.");
// short circuit if this node is deleted?
if (wrappedNode.isDeleted())
{
// handle notifications
- if (trace) log.trace("Workspace node " + wrappedNode.getFqn() + " deleted; removing");
+ if (trace) log.trace("Node's been deleted; removing");
DataNode dNode = wrappedNode.getNode();
cache.notifyNodeRemove(dNode.getFqn(), true);
@@ -213,11 +214,13 @@
// this could be done better to account for more subtle merges
current.setChildren(mergedChildren);
- if (log.isTraceEnabled()) log.trace("inserting merged data " + wrappedNode.getMergedData());
+ if (trace) log.trace("inserting merged data " + wrappedNode.getMergedData());
Map mergedData = wrappedNode.getMergedData();
current.put(mergedData, true);
- if (workspace.isVersioningImplicit() || wrappedNode.getVersion() instanceof DefaultDataVersion)
+
+ if (wrappedNode.isVersioningImplicit())
{
+ if (trace) log.trace("Versioning is implicit; incrementing.");
current.setVersion(((DefaultDataVersion)wrappedNode.getVersion()).increment());
}
else
@@ -225,13 +228,13 @@
if (trace) log.trace("Versioning is explicit; not attempting an increment.");
current.setVersion(wrappedNode.getVersion());
}
- if (trace) log.trace("Setting version of node " + current.getName() + " from " + wrappedNode.getVersion() + " to " + current.getVersion());
+ if (trace) log.trace("Setting version of node from " + wrappedNode.getVersion() + " to " + current.getVersion());
cache.notifyNodeModified(wrappedNode.getFqn());
cache.notifyNodeModify(wrappedNode.getFqn(), false);
}
else
{
- if (trace) log.trace("Merging node " + wrappedNode.getFqn() + " not necessary since the node is not dirty");
+ if (trace) log.trace("Merging not necessary since the node is not dirty");
cache.notifyNodeVisited(wrappedNode.getFqn());
}
}
1.21.2.3 +15 -6 JBossCache/src/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticCreateIfNotExistsInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java,v
retrieving revision 1.21.2.2
retrieving revision 1.21.2.3
diff -u -b -r1.21.2.2 -r1.21.2.3
--- OptimisticCreateIfNotExistsInterceptor.java 11 Dec 2006 14:46:54 -0000 1.21.2.2
+++ OptimisticCreateIfNotExistsInterceptor.java 11 Dec 2006 17:29:44 -0000 1.21.2.3
@@ -174,14 +174,13 @@
// get the version passed in, if we need to use explicit versioning.
DataVersion versionToPassIn = null;
- if (isTargetFqn && !workspace.isVersioningImplicit())
- {
- versionToPassIn = version;
- }
+ if (isTargetFqn && !workspace.isVersioningImplicit()) versionToPassIn = version;
DataNode tempNode = (DataNode) workspaceNode.createChild(childName, copy, workspaceNode.getNode(), cache, versionToPassIn);
childWorkspaceNode = NodeFactory.getInstance().createWorkspaceNode(tempNode, workspace);
+ childWorkspaceNode.setVersioningImplicit(versionToPassIn == null || !isTargetFqn);
+ if (log.isTraceEnabled()) log.trace("setting versioning of " + childWorkspaceNode.getFqn() + " to be " + (childWorkspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
// now add the wrapped child node into the transaction space
workspace.addNode(childWorkspaceNode);
@@ -200,7 +199,17 @@
{
if (log.isDebugEnabled()) log.debug("Child node "+tempChildNode.getFqn()+" doesn't exist in workspace or has been deleted. Adding to workspace in gtx " + gtx);
childWorkspaceNode = NodeFactory.getInstance().createWorkspaceNode(tempChildNode, workspace);
- if (isTargetFqn && !workspace.isVersioningImplicit()) childWorkspaceNode.setVersion(version);
+ if (isTargetFqn && !workspace.isVersioningImplicit())
+ {
+ childWorkspaceNode.setVersion(version);
+ childWorkspaceNode.setVersioningImplicit(false);
+ }
+ else
+ {
+ childWorkspaceNode.setVersioningImplicit(true);
+ }
+ if (log.isTraceEnabled()) log.trace("setting versioning of " + childWorkspaceNode.getFqn() + " to be " + (childWorkspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
+
}
else
{
@@ -211,7 +220,7 @@
workspaceNode = childWorkspaceNode;
}
- if (log.isDebugEnabled()) log.debug("left synchronized nodewrapper access for gtx " + gtx);
+ if (log.isTraceEnabled()) log.trace("left synchronized nodewrapper access for gtx " + gtx);
} // end sync block
// run the notify outside the synch block as we do not know what that
// code might do
1.21.2.7 +19 -16 JBossCache/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticNodeInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java,v
retrieving revision 1.21.2.6
retrieving revision 1.21.2.7
diff -u -b -r1.21.2.6 -r1.21.2.7
--- OptimisticNodeInterceptor.java 13 Nov 2006 14:06:23 -0000 1.21.2.6
+++ OptimisticNodeInterceptor.java 11 Dec 2006 17:29:44 -0000 1.21.2.7
@@ -66,31 +66,34 @@
throw new CacheException("Must be in a valid transaction " + m);
}
- // assign a global transaction here if we need to - should do all
- // this in the transaction interceptor
WorkspaceNode workspaceNode = getOrCreateWorkspaceNode(getFqn(args), workspace, cache);
+
+ if (workspaceNode != null)
+ {
// use explicit versioning
if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
{
workspace.setVersioningImplicit(false);
DataVersion version = ctx.getOptionOverrides().getDataVersion();
- // "fail-more-silently" patch thanks to Owen Taylor - JBCACHE-767
- // also, if this is a "remove", do we care if the node didn't exist?
-
- if (workspaceNode != null)
- {
workspaceNode.setVersion(version);
+ if (log.isTraceEnabled()) log.trace("Setting versioning for node " + workspaceNode.getFqn() + " to explicit");
+ workspaceNode.setVersioningImplicit(false);
}
else
{
+ if (log.isTraceEnabled()) log.trace("Setting versioning for node " + workspaceNode.getFqn() + " to implicit");
+ workspaceNode.setVersioningImplicit(true);
+ }
+ }
+ else
+ {
+ // "fail-more-silently" patch thanks to Owen Taylor - JBCACHE-767
if ((ctx.getOptionOverrides() == null || !ctx.getOptionOverrides().isFailSilently()) && MethodDeclarations.isOptimisticPutMethod(meth))
throw new CacheException("Unable to set node version for " + getFqn(args) + ", node is null.");
}
- }
-
switch (m.getMethodId())
{
case MethodDeclarations.putDataMethodLocal_id:
@@ -114,7 +117,7 @@
break;
case MethodDeclarations.dataGravitationCleanupMethod_id:
result = super.invoke(m);
- default :
+ default:
if (log.isInfoEnabled()) log.info("Cannot Handle Method " + m);
break;
}
1.21.2.5 +8 -2 JBossCache/src/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OptimisticReplicationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java,v
retrieving revision 1.21.2.4
retrieving revision 1.21.2.5
diff -u -b -r1.21.2.4 -r1.21.2.5
--- OptimisticReplicationInterceptor.java 6 Dec 2006 16:00:14 -0000 1.21.2.4
+++ OptimisticReplicationInterceptor.java 11 Dec 2006 17:29:44 -0000 1.21.2.5
@@ -243,14 +243,20 @@
private DataVersion getVersionToBroadcast(TransactionWorkspace w, Fqn f)
{
WorkspaceNode n = w.getNode(f);
- if (n == null) return null;
- if (w.isVersioningImplicit())
+ if (n == null)
+ {
+ if (log.isTraceEnabled()) log.trace("Fqn " + f + " not found in workspace; not using a data version.");
+ return null;
+ }
+ if (n.isVersioningImplicit())
{
DefaultDataVersion v = (DefaultDataVersion) n.getVersion();
+ if (log.isTraceEnabled()) log.trace("Fqn " + f + " has implicit versioning. Broadcasting an incremented version.");
return v.increment();
}
else
{
+ if (log.isTraceEnabled()) log.trace("Fqn " + f + " has explicit versioning. Broadcasting the version as-is.");
return n.getVersion();
}
}
More information about the jboss-cvs-commits
mailing list