Return-Path: Delivered-To: apmail-hadoop-zookeeper-commits-archive@locus.apache.org Received: (qmail 43743 invoked from network); 28 Jul 2008 18:20:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Jul 2008 18:20:44 -0000 Received: (qmail 2130 invoked by uid 500); 28 Jul 2008 18:20:44 -0000 Delivered-To: apmail-hadoop-zookeeper-commits-archive@hadoop.apache.org Received: (qmail 2101 invoked by uid 500); 28 Jul 2008 18:20:44 -0000 Mailing-List: contact zookeeper-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: zookeeper-dev@ Delivered-To: mailing list zookeeper-commits@hadoop.apache.org Received: (qmail 2090 invoked by uid 99); 28 Jul 2008 18:20:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jul 2008 11:20:44 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jul 2008 18:19:57 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 84953238896E; Mon, 28 Jul 2008 11:19:53 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r680431 - in /hadoop/zookeeper/trunk/src/java: ChangeLog OldChangeLog main/org/apache/zookeeper/ZooKeeper.java Date: Mon, 28 Jul 2008 18:19:53 -0000 To: zookeeper-commits@hadoop.apache.org From: mahadev@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080728181953.84953238896E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mahadev Date: Mon Jul 28 11:19:53 2008 New Revision: 680431 URL: http://svn.apache.org/viewvc?rev=680431&view=rev Log: ZOOKEEPER-105. Catch Zookeeper exceptions and print on the stderr. (Anthony Urso via Mahadev) Added: hadoop/zookeeper/trunk/src/java/OldChangeLog - copied unchanged from r680424, hadoop/zookeeper/trunk/src/java/ChangeLog Removed: hadoop/zookeeper/trunk/src/java/ChangeLog Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java?rev=680431&r1=680430&r2=680431&view=diff ============================================================================== --- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java (original) +++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java Mon Jul 28 11:19:53 2008 @@ -1036,45 +1036,51 @@ String path = args[2]; List acl = Ids.OPEN_ACL_UNSAFE; System.out.println("Processing " + cmd); - if (cmd.equals("create") && args.length >= 4) { - if (args.length == 5) { - acl = parseACLs(args[4]); - } - String newPath = zooKeeper.create(path, args[3].getBytes(), acl, 0); - System.err.println("Created " + newPath); - } else if (cmd.equals("delete") && args.length >= 3) { - zooKeeper.delete(path, watch ? Integer.parseInt(args[3]) : -1); - } else if (cmd.equals("set") && args.length >= 4) { - stat = zooKeeper.setData(path, args[3].getBytes(), - args.length > 4 ? Integer.parseInt(args[4]) : -1); - printStat(stat); - } else if (cmd.equals("aget") && args.length >= 3) { - zooKeeper.getData(path, watch, dataCallback, path); - } else if (cmd.equals("get") && args.length >= 3) { - byte data[] = zooKeeper.getData(path, watch, stat); - System.out.println(new String(data)); - printStat(stat); - } else if (cmd.equals("ls") && args.length >= 3) { - List children = zooKeeper.getChildren(path, watch); - System.out.println(children); - } else if (cmd.equals("getAcl") && args.length >= 2) { - acl = zooKeeper.getACL(path, stat); - for (ACL a : acl) { - System.out.println(a.getId() + ": " - + getPermString(a.getPerms())); + try { + if (cmd.equals("create") && args.length >= 4) { + if (args.length == 5) { + acl = parseACLs(args[4]); + } + String newPath = zooKeeper.create(path, args[3].getBytes(), acl, 0); + System.err.println("Created " + newPath); + } else if (cmd.equals("delete") && args.length >= 3) { + zooKeeper.delete(path, watch ? Integer.parseInt(args[3]) : -1); + } else if (cmd.equals("set") && args.length >= 4) { + stat = zooKeeper.setData(path, args[3].getBytes(), + args.length > 4 ? Integer.parseInt(args[4]) : -1); + printStat(stat); + } else if (cmd.equals("aget") && args.length >= 3) { + zooKeeper.getData(path, watch, dataCallback, path); + } else if (cmd.equals("get") && args.length >= 3) { + byte data[] = zooKeeper.getData(path, watch, stat); + System.out.println(new String(data)); + printStat(stat); + } else if (cmd.equals("ls") && args.length >= 3) { + List children = zooKeeper.getChildren(path, watch); + System.out.println(children); + } else if (cmd.equals("getAcl") && args.length >= 2) { + acl = zooKeeper.getACL(path, stat); + for (ACL a : acl) { + System.out.println(a.getId() + ": " + + getPermString(a.getPerms())); + } + } else if (cmd.equals("setAcl") && args.length >= 4) { + + stat = zooKeeper.setACL(path, parseACLs(args[3]), + args.length > 4 ? Integer.parseInt(args[4]) : -1); + printStat(stat); + } else if (cmd.equals("stat") && args.length >= 3) { + stat = zooKeeper.exists(path, watch); + printStat(stat); + } else { + usage(); } - } else if (cmd.equals("setAcl") && args.length >= 4) { - stat = zooKeeper.setACL(path, parseACLs(args[3]), - args.length > 4 ? Integer.parseInt(args[4]) : -1); - printStat(stat); - } else if (cmd.equals("stat") && args.length >= 3) { - stat = zooKeeper.exists(path, watch); - printStat(stat); - } else { - usage(); - } - return watch; + return watch; + } catch (KeeperException e) { + System.err.println(e.getClass().getName() + ": " + e.getMessage()); + return false; + } } private static String getPermString(int perms) {