You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2013/05/10 01:14:05 UTC

svn commit: r1480836 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java test/java/org/apache/hadoop/hbase/TestZooKeeper.java

Author: tedyu
Date: Thu May  9 23:14:05 2013
New Revision: 1480836

URL: http://svn.apache.org/r1480836
Log:
HBASE-8509 ZKUtil#createWithParents won't set data during znode creation when parent folder doesn't exit (Jefferey and Ted)


Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java?rev=1480836&r1=1480835&r2=1480836&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java Thu May  9 23:14:05 2013
@@ -1166,7 +1166,7 @@ public class ZKUtil {
       return;
     } catch(KeeperException.NoNodeException nne) {
       createWithParents(zkw, getParent(znode));
-      createWithParents(zkw, znode);
+      createWithParents(zkw, znode, data);
     } catch(InterruptedException ie) {
       zkw.interruptedException(ie);
     }

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java?rev=1480836&r1=1480835&r2=1480836&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java Thu May  9 23:14:05 2013
@@ -222,6 +222,27 @@ public class TestZooKeeper {
   }
 
   /**
+   * Create a znode with data
+   * @throws Exception
+   */
+  @Test
+  public void testCreateWithParents() throws Exception {
+    ZooKeeperWatcher zkw =
+        new ZooKeeperWatcher(new Configuration(TEST_UTIL.getConfiguration()),
+          TestZooKeeper.class.getName(), null);
+    byte[] expectedData = new byte[] { 1, 2, 3 };
+    ZKUtil.createWithParents(zkw, "/l1/l2/l3/l4/testCreateWithParents", expectedData);
+    byte[] data = ZKUtil.getData(zkw, "/l1/l2/l3/l4/testCreateWithParents");
+    assertEquals(Bytes.equals(expectedData, data), true);
+    ZKUtil.deleteNodeRecursively(zkw, "/l1");
+
+    ZKUtil.createWithParents(zkw, "/testCreateWithParents", expectedData);
+    data = ZKUtil.getData(zkw, "/testCreateWithParents");
+    assertEquals(Bytes.equals(expectedData, data), true);
+    ZKUtil.deleteNodeRecursively(zkw, "/testCreateWithParents");
+  }
+
+  /**
    * Create a bunch of znodes in a hierarchy, try deleting one that has childs
    * (it will fail), then delete it recursively, then delete the last znode
    * @throws Exception