hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Hadoop Wiki] Update of "ZooKeeper/Tutorial" by Flavio Junqueira
Date Thu, 24 Jul 2008 11:10:23 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Hadoop Wiki" for change notification.

The following page has been changed by Flavio Junqueira:
http://wiki.apache.org/hadoop/ZooKeeper/Tutorial

------------------------------------------------------------------------------
  
      String root;
  
-     SyncPrimitive(String address) {
+     SyncPrimitive(String address) 
+     throws KeeperException, IOException {
          if(zk == null){
-             try {
                  System.out.println("Starting ZK:");
                  zk = new ZooKeeper(address, 3000, this);
                  mutex = new Integer(-1);
                  System.out.println("Finished starting ZK: " + zk);
-             } catch (KeeperException e) {
-                 System.out.println("Keeper exception when starting new session: "
-                         + e.toString());
-                 zk = null;
-             } catch (IOException e) {
-                 System.out.println(e.toString());
-                 zk = null;
-             }
          }
      }
  
@@ -62, +54 @@

           * @param name
           * @param size
           */
-         Barrier(String address, String name, int size) {
+         Barrier(String address, String name, int size)
+         throws KeeperException, InterruptedException, UnknownHostException {
              super(address);
              this.root = name;
              this.size = size;
  
              // Create barrier node
              if (zk != null) {
-                 try {
                      Stat s = zk.exists(root, false);
                      if (s == null) {
                          zk.create(root, new byte[0], Ids.OPEN_ACL_UNSAFE, 0);
                      }
-                 } catch (KeeperException e) {
-                     System.out.println("Keeper exception when instantiating queue: " + e.toString());
-                 } catch (InterruptedException e) {
-                     System.out.println("Interrupted exception");
-                 }
              }
  
              // My node name
-             try {
-                 name = new String(InetAddress.getLocalHost().getCanonicalHostName().toString());
+             name = new String(InetAddress.getLocalHost().getCanonicalHostName().toString());
-             } catch (UnknownHostException e) {
-                 System.out.println(e.toString());
-             }
- 
          }
  }}}
  
@@ -162, +144 @@

           * @param address
           * @param name
           */
-         Queue(String address, String name) {
+         Queue(String address, String name)
+         throws KeeperException, InterruptedException {
              super(address);
              this.root = name;
              // Create ZK node name
              if (zk != null) {
-                 try {
                      Stat s = zk.exists(root, false);
                      if (s == null) {
                          zk.create(root, new byte[0], Ids.OPEN_ACL_UNSAFE, 0);
                      }
-                 } catch (KeeperException e) {
-                     System.out
-                             .println("Keeper exception when instantiating queue: "
-                                     + e.toString());
-                 } catch (InterruptedException e) {
-                     System.out.println("Interrupted exception");
-                 }
              }
          }
  }}}

Mime
View raw message