You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ph...@apache.org on 2011/09/15 00:55:24 UTC

svn commit: r1170886 - in /zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/server/DataNode.java src/java/main/org/apache/zookeeper/server/DataTree.java src/java/main/org/apache/zookeeper/server/upgrade/UpgradeSnapShotV1.java

Author: phunt
Date: Wed Sep 14 22:55:24 2011
New Revision: 1170886

URL: http://svn.apache.org/viewvc?rev=1170886&view=rev
Log:
ZOOKEEPER-1175. DataNode references parent node for no reason (Thomas Koch via phunt)

Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/java/main/org/apache/zookeeper/server/DataNode.java
    zookeeper/trunk/src/java/main/org/apache/zookeeper/server/DataTree.java
    zookeeper/trunk/src/java/main/org/apache/zookeeper/server/upgrade/UpgradeSnapShotV1.java

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1170886&r1=1170885&r2=1170886&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Wed Sep 14 22:55:24 2011
@@ -19,6 +19,8 @@ IMPROVEMENTS:
   ZOOKEEPER-96. The jute parser should get generated from the jj files
   instead of checking in the generated sources (Thomas Koch via phunt)
 
+  ZOOKEEPER-1175. DataNode references parent node for no reason
+  (Thomas Koch via phunt)
 
 Release 3.4.0 - 
 

Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/server/DataNode.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/DataNode.java?rev=1170886&r1=1170885&r2=1170886&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/server/DataNode.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/server/DataNode.java Wed Sep 14 22:55:24 2011
@@ -36,9 +36,6 @@ import org.apache.zookeeper.data.StatPer
  * 
  */
 public class DataNode implements Record {
-    /** the parent of this datanode */
-    DataNode parent;
-
     /** the data for this datanode */
     byte data[];
 
@@ -78,8 +75,7 @@ public class DataNode implements Record 
      * @param stat
      *            the stat for this node.
      */
-    public DataNode(DataNode parent, byte data[], Long acl, StatPersisted stat) {
-        this.parent = parent;
+    public DataNode(byte data[], Long acl, StatPersisted stat) {
         this.data = data;
         this.acl = acl;
         this.stat = stat;

Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/server/DataTree.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/DataTree.java?rev=1170886&r1=1170885&r2=1170886&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/server/DataTree.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/server/DataTree.java Wed Sep 14 22:55:24 2011
@@ -256,21 +256,18 @@ public class DataTree {
      * This is a pointer to the root of the DataTree. It is the source of truth,
      * but we usually use the nodes hashmap to find nodes in the tree.
      */
-    private DataNode root = new DataNode(null, new byte[0], -1L,
-            new StatPersisted());
+    private DataNode root = new DataNode(new byte[0], -1L, new StatPersisted());
 
     /**
      * create a /zookeeper filesystem that is the proc filesystem of zookeeper
      */
-    private DataNode procDataNode = new DataNode(root, new byte[0], -1L,
-            new StatPersisted());
+    private DataNode procDataNode = new DataNode(new byte[0], -1L, new StatPersisted());
 
     /**
      * create a /zookeeper/quota node for maintaining quota properties for
      * zookeeper
      */
-    private DataNode quotaDataNode = new DataNode(procDataNode, new byte[0],
-            -1L, new StatPersisted());
+    private DataNode quotaDataNode = new DataNode(new byte[0], -1L, new StatPersisted());
 
     public DataTree() {
         /* Rather than fight it, let root have an alias */
@@ -461,7 +458,7 @@ public class DataTree {
             parent.stat.setCversion(parentCVersion);
             parent.stat.setPzxid(zxid);
             Long longval = convertAcls(acl);
-            DataNode child = new DataNode(parent, data, longval, stat);
+            DataNode child = new DataNode(data, longval, stat);
             parent.addChild(childName);
             nodes.put(path, child);
             if (ephemeralOwner != 0) {
@@ -536,7 +533,6 @@ public class DataTree {
                     }
                 }
             }
-            node.parent = null;
         }
         if (parentName.startsWith(procZookeeper)) {
             // delete the node in the trie.
@@ -1147,12 +1143,12 @@ public class DataTree {
                 root = node;
             } else {
                 String parentPath = path.substring(0, lastSlash);
-                node.parent = nodes.get(parentPath);
-                if (node.parent == null) {
+                DataNode parent = nodes.get(parentPath);
+                if (parent == null) {
                     throw new IOException("Invalid Datatree, unable to find " +
                             "parent " + parentPath + " of path " + path);
                 }
-                node.parent.addChild(path.substring(lastSlash + 1));
+                parent.addChild(path.substring(lastSlash + 1));
                 long eowner = node.stat.getEphemeralOwner();
                 if (eowner != 0) {
                     HashSet<String> list = ephemerals.get(eowner);

Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/server/upgrade/UpgradeSnapShotV1.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/upgrade/UpgradeSnapShotV1.java?rev=1170886&r1=1170885&r2=1170886&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/server/upgrade/UpgradeSnapShotV1.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/server/upgrade/UpgradeSnapShotV1.java Wed Sep 14 22:55:24 2011
@@ -266,7 +266,7 @@ public class UpgradeSnapShotV1 implement
     private DataNode convertDataNode(DataTree dt, DataNode parent, 
             DataNodeV1 oldDataNode) {
         StatPersisted stat = convertStat(oldDataNode.stat);
-        DataNode dataNode =  new DataNode(parent, oldDataNode.data,
+        DataNode dataNode =  new DataNode(oldDataNode.data,
                 dt.convertAcls(oldDataNode.acl), stat);
         dataNode.setChildren(oldDataNode.children);
         return dataNode;