Kaynağa Gözat

ZOOKEEPER-1175. DataNode references parent node for no reason (Thomas Koch via phunt)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1170886 13f79535-47bb-0310-9956-ffa450edef68
Patrick D. Hunt 13 yıl önce
ebeveyn
işleme
81728143a7

+ 2 - 0
CHANGES.txt

@@ -19,6 +19,8 @@ IMPROVEMENTS:
   ZOOKEEPER-96. The jute parser should get generated from the jj files
   ZOOKEEPER-96. The jute parser should get generated from the jj files
   instead of checking in the generated sources (Thomas Koch via phunt)
   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 - 
 Release 3.4.0 - 
 
 

+ 1 - 5
src/java/main/org/apache/zookeeper/server/DataNode.java

@@ -36,9 +36,6 @@ import org.apache.zookeeper.data.StatPersisted;
  * 
  * 
  */
  */
 public class DataNode implements Record {
 public class DataNode implements Record {
-    /** the parent of this datanode */
-    DataNode parent;
-
     /** the data for this datanode */
     /** the data for this datanode */
     byte data[];
     byte data[];
 
 
@@ -78,8 +75,7 @@ public class DataNode implements Record {
      * @param stat
      * @param stat
      *            the stat for this node.
      *            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.data = data;
         this.acl = acl;
         this.acl = acl;
         this.stat = stat;
         this.stat = stat;

+ 7 - 11
src/java/main/org/apache/zookeeper/server/DataTree.java

@@ -256,21 +256,18 @@ public class DataTree {
      * This is a pointer to the root of the DataTree. It is the source of truth,
      * 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.
      * 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
      * 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
      * create a /zookeeper/quota node for maintaining quota properties for
      * zookeeper
      * 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() {
     public DataTree() {
         /* Rather than fight it, let root have an alias */
         /* Rather than fight it, let root have an alias */
@@ -461,7 +458,7 @@ public class DataTree {
             parent.stat.setCversion(parentCVersion);
             parent.stat.setCversion(parentCVersion);
             parent.stat.setPzxid(zxid);
             parent.stat.setPzxid(zxid);
             Long longval = convertAcls(acl);
             Long longval = convertAcls(acl);
-            DataNode child = new DataNode(parent, data, longval, stat);
+            DataNode child = new DataNode(data, longval, stat);
             parent.addChild(childName);
             parent.addChild(childName);
             nodes.put(path, child);
             nodes.put(path, child);
             if (ephemeralOwner != 0) {
             if (ephemeralOwner != 0) {
@@ -536,7 +533,6 @@ public class DataTree {
                     }
                     }
                 }
                 }
             }
             }
-            node.parent = null;
         }
         }
         if (parentName.startsWith(procZookeeper)) {
         if (parentName.startsWith(procZookeeper)) {
             // delete the node in the trie.
             // delete the node in the trie.
@@ -1147,12 +1143,12 @@ public class DataTree {
                 root = node;
                 root = node;
             } else {
             } else {
                 String parentPath = path.substring(0, lastSlash);
                 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 " +
                     throw new IOException("Invalid Datatree, unable to find " +
                             "parent " + parentPath + " of path " + path);
                             "parent " + parentPath + " of path " + path);
                 }
                 }
-                node.parent.addChild(path.substring(lastSlash + 1));
+                parent.addChild(path.substring(lastSlash + 1));
                 long eowner = node.stat.getEphemeralOwner();
                 long eowner = node.stat.getEphemeralOwner();
                 if (eowner != 0) {
                 if (eowner != 0) {
                     HashSet<String> list = ephemerals.get(eowner);
                     HashSet<String> list = ephemerals.get(eowner);

+ 1 - 1
src/java/main/org/apache/zookeeper/server/upgrade/UpgradeSnapShotV1.java

@@ -266,7 +266,7 @@ public class UpgradeSnapShotV1 implements UpgradeSnapShot {
     private DataNode convertDataNode(DataTree dt, DataNode parent, 
     private DataNode convertDataNode(DataTree dt, DataNode parent, 
             DataNodeV1 oldDataNode) {
             DataNodeV1 oldDataNode) {
         StatPersisted stat = convertStat(oldDataNode.stat);
         StatPersisted stat = convertStat(oldDataNode.stat);
-        DataNode dataNode =  new DataNode(parent, oldDataNode.data,
+        DataNode dataNode =  new DataNode(oldDataNode.data,
                 dt.convertAcls(oldDataNode.acl), stat);
                 dt.convertAcls(oldDataNode.acl), stat);
         dataNode.setChildren(oldDataNode.children);
         dataNode.setChildren(oldDataNode.children);
         return dataNode;
         return dataNode;