hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r786317 - in /hadoop/zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/ZooKeeperMain.java
Date Thu, 18 Jun 2009 22:22:44 GMT
Author: breed
Date: Thu Jun 18 22:22:44 2009
New Revision: 786317

URL: http://svn.apache.org/viewvc?rev=786317&view=rev
Log:
ZOOKEEPER-422. Java CLI should support ephemeral and sequential node creation

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=786317&r1=786316&r2=786317&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Thu Jun 18 22:22:44 2009
@@ -223,6 +223,8 @@
   ZOOKEEPER-428. logging should be makred as warn rathen than error in
 NIOServerCnxn. (phunt via mahadev)
 
+  ZOOKEEPER-422. Java CLI should support ephemeral and sequential node creation (henry via
breed)
+
 NEW FEATURES:
 
   ZOOKEEPER-371. jdiff documentation included in build/release (giri via phunt)

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java?rev=786317&r1=786316&r2=786317&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java Thu Jun 18
22:22:44 2009
@@ -63,7 +63,7 @@
     static void populateCommandMap() {
         commandMap.put("connect", "host:port");
         commandMap.put("close","");
-        commandMap.put("create", "path data acl");
+        commandMap.put("create", "[-s] [-e] path data acl");
         commandMap.put("delete","path [version]");
         commandMap.put("set","path data [version]");
         commandMap.put("get","path [watch]");
@@ -93,7 +93,6 @@
         public void process(WatchedEvent event) {
             if (getPrintWatches()) {
                 ZooKeeperMain.printMessage("WATCHER::");
-                ZooKeeperMain.printMessage("WATCHER::");
                 ZooKeeperMain.printMessage(event.toString());
             }
         }
@@ -661,12 +660,25 @@
         }
         
         if (cmd.equals("create") && args.length >= 3) {
-            if (args.length == 4) {
-                acl = parseACLs(args[3]);
-            }
-            path = args[1];
-            String newPath = zk.create(path, args[2].getBytes(), acl,
-                    CreateMode.PERSISTENT);
+            int first = 0;
+            CreateMode flags = CreateMode.PERSISTENT;
+            if ((args[1].equals("-e") && args[2].equals("-s"))
+                    || (args[1]).equals("-s") && (args[2].equals("-e"))) {
+                first+=2;
+                flags = CreateMode.EPHEMERAL_SEQUENTIAL;
+            } else if (args[1].equals("-e")) {
+                first++;
+                flags = CreateMode.EPHEMERAL;
+            } else if (args[1].equals("-s")) {
+                first++;
+                flags = CreateMode.PERSISTENT_SEQUENTIAL;
+            }
+            if (args.length == first + 4) {
+                acl = parseACLs(args[first+3]);
+            }
+            path = args[first + 1];
+            String newPath = zk.create(path, args[first+2].getBytes(), acl,
+                    flags);
             System.err.println("Created " + newPath);
         } else if (cmd.equals("delete") && args.length >= 2) {
             path = args[1];



Mime
View raw message