[jboss-cvs] JBossCache/src/org/jboss/cache ...
Elias Ross
genman at noderunner.net
Sun Nov 26 15:35:13 EST 2006
User: genman
Date: 06/11/26 15:35:13
Modified: src/org/jboss/cache NodeImpl.java NodeSPI.java
TreeCache.java
Log:
JBCACHE-867 add setFqn() in NodeSPI
Revision Changes Path
1.19 +31 -33 JBossCache/src/org/jboss/cache/NodeImpl.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NodeImpl.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/NodeImpl.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- NodeImpl.java 20 Nov 2006 23:32:49 -0000 1.18
+++ NodeImpl.java 26 Nov 2006 20:35:13 -0000 1.19
@@ -410,12 +410,7 @@
public void printDetails(StringBuffer sb, int indent)
{
- Map tmp;
- synchronized (this)
- {
- tmp = data != null ? new HashMap(data) : null;
- }
- printDetailsInMap(sb, indent, tmp);
+ printDetailsInMap(sb, indent);
}
/**
@@ -555,6 +550,8 @@
public void move(Node newParent) throws NodeNotExistsException
{
+ if (log.isTraceEnabled())
+ log.trace(this.getFqn() + " move to " + newParent.getFqn());
// TODO
// move must be added to Cache
((TreeCacheProxyImpl) cache).treeCache.move(newParent.getFqn(), getFqn());
@@ -617,7 +614,7 @@
children.remove(child_name);
if (log.isTraceEnabled())
{
- log.trace("removed child " + child_name);
+ log.trace(getName() + " removed child " + child_name);
}
}
}
@@ -633,13 +630,10 @@
{
printIndent(sb, indent);
sb.append(Fqn.SEPARATOR).append(getName()).append(" ").append(getData().size());
- if (children != null && children.size() > 0)
- {
- Collection values = children.values();
- for (Iterator it = values.iterator(); it.hasNext();)
- {
+ if (children != null) {
+ for (Node node : children.values()) {
sb.append("\n");
- ((DataNode) it.next()).print(sb, indent + INDENT);
+ ((TreeNode)node).print(sb, indent + INDENT);
}
}
}
@@ -679,9 +673,22 @@
return fqn;
}
- public void setFqn(Fqn f)
+ public void setFqn(Fqn fqn)
+ {
+ if (log.isTraceEnabled())
+ log.trace(getFqn() + " set FQN " + fqn);
+ this.fqn = fqn;
+
+ if (children == null)
+ return;
+
+ // process children
+ for (Map.Entry<Object, Node> me : children.entrySet())
{
- fqn = f;
+ NodeSPI n = me.getValue().getNodeSPI();
+ Fqn cfqn = new Fqn(fqn, me.getKey());
+ n.setFqn(cfqn);
+ }
}
public TreeNode getChild(Object child_name)
@@ -723,28 +730,19 @@
/**
* Adds details of the node into a map as strings.
*/
- protected void printDetailsInMap(StringBuffer sb, int indent, Map map)
+ protected void printDetailsInMap(StringBuffer sb, int indent)
{
- Map.Entry entry;
printIndent(sb, indent);
indent += 2; // increse it
- sb.append(Fqn.SEPARATOR).append(getName());
- sb.append("\n");
- if (map != null)
- {
- for (Iterator it = map.entrySet().iterator(); it.hasNext();)
- {
- entry = (Map.Entry) it.next();
- sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
- }
- }
- if (children != null && children.size() > 0)
- {
- Collection values = children.values();
- for (Iterator it = values.iterator(); it.hasNext();)
- {
+ if (!(getFqn()).isRoot())
+ sb.append(Fqn.SEPARATOR);
+ sb.append(getName());
+ sb.append(" ");
+ sb.append(data());
+ if (children != null) {
+ for (Node n : children.values()) {
sb.append("\n");
- ((DataNode) it.next()).printDetails(sb, indent);
+ ((DataNode) n).printDetails(sb, indent);
}
}
}
1.4 +4 -0 JBossCache/src/org/jboss/cache/NodeSPI.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NodeSPI.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/NodeSPI.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- NodeSPI.java 20 Nov 2006 03:53:54 -0000 1.3
+++ NodeSPI.java 26 Nov 2006 20:35:13 -0000 1.4
@@ -78,4 +78,8 @@
NodeLock getLock();
+ /**
+ * Sets the FQN of this node and resets the names of all children as well.
+ */
+ void setFqn(Fqn f);
}
1.286 +13 -32 JBossCache/src/org/jboss/cache/TreeCache.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCache.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCache.java,v
retrieving revision 1.285
retrieving revision 1.286
diff -u -b -r1.285 -r1.286
--- TreeCache.java 21 Nov 2006 08:57:01 -0000 1.285
+++ TreeCache.java 26 Nov 2006 20:35:13 -0000 1.286
@@ -96,7 +96,7 @@
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
* @author Brian Stansberry
* @author Daniel Huang (dhuang at jboss.org)
- * @version $Id: TreeCache.java,v 1.285 2006/11/21 08:57:01 genman Exp $
+ * @version $Id: TreeCache.java,v 1.286 2006/11/26 20:35:13 genman Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
@@ -217,7 +217,9 @@
/**
* Uninitialized node key.
*/
- static public final String UNINITIALIZED = "jboss:internal:uninitialized";
+ static public final Object UNINITIALIZED = new Object() {
+ public String toString() { return "UNINITIALIZED"; }
+ };
/**
* Determines whether to use optimistic locking or not. Disabled by default.
@@ -1799,7 +1801,7 @@
*/
public String toString()
{
- return toString(false);
+ return toString(true);
}
@@ -1838,23 +1840,8 @@
public String printDetails()
{
StringBuffer sb = new StringBuffer();
- int indent = 2;
- Map children;
-
- children = root.getNodeSPI().getChildrenMap();
- if (children != null && children.size() > 0)
- {
- Collection nodes = children.values();
- for (Iterator it = nodes.iterator(); it.hasNext();)
- {
- ((DataNode) it.next()).printDetails(sb, indent);
+ ((TreeNode) getRoot()).printDetails(sb, 0);
sb.append("\n");
- }
- }
- else
- {
- sb.append(Fqn.SEPARATOR);
- }
return sb.toString();
}
@@ -2849,7 +2836,7 @@
public GravitateResult gravitateData(Fqn fqn, boolean searchSubtrees, boolean marshal)
throws CacheException
{
- // we need to get the state for this Fqn and it's sub-nodes.
+ // we need to get the state for this Fqn and its sub-nodes.
// for now, perform a very simple series of getData calls.
@@ -2901,7 +2888,8 @@
}
else
{
- return GravitateResult.subtreeResult(list, backupNodeFqn);
+ GravitateResult gr = GravitateResult.subtreeResult(list, backupNodeFqn);
+ return gr;
}
}
@@ -3197,17 +3185,10 @@
}
}
- private void moveFqns(NodeImpl node, Fqn newBase)
+ private void moveFqns(Node node, Fqn newBase)
{
- Fqn newFqn = new Fqn(newBase, node.getName());
- node.setFqn(newFqn);
-
- // process children
- for (Object n : node.getChildren())
- {
- NodeImpl child = (NodeImpl) n;
- moveFqns(child, newFqn);
- }
+ Fqn newFqn = new Fqn(newBase, ((TreeNode)node).getName());
+ node.getNodeSPI().setFqn(newFqn);
}
class MessageListenerAdaptor implements ExtendedMessageListener
More information about the jboss-cvs-commits
mailing list