hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1563506 - /hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
Date Sat, 01 Feb 2014 23:03:03 GMT
Author: tedyu
Date: Sat Feb  1 23:03:02 2014
New Revision: 1563506

URL: http://svn.apache.org/r1563506
Log:
HBASE-10448 ZKUtil create and watch methods don't set watch in some cases (Jerry He)


Modified:
    hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java

Modified: hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java?rev=1563506&r1=1563505&r2=1563506&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
(original)
+++ hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
Sat Feb  1 23:03:02 2014
@@ -999,20 +999,21 @@ public class ZKUtil {
   public static boolean createEphemeralNodeAndWatch(ZooKeeperWatcher zkw,
       String znode, byte [] data)
   throws KeeperException {
+    boolean ret = true;
     try {
       zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
           CreateMode.EPHEMERAL);
     } catch (KeeperException.NodeExistsException nee) {
-      if(!watchAndCheckExists(zkw, znode)) {
-        // It did exist but now it doesn't, try again
-        return createEphemeralNodeAndWatch(zkw, znode, data);
-      }
-      return false;
+      ret = false;
     } catch (InterruptedException e) {
       LOG.info("Interrupted", e);
       Thread.currentThread().interrupt();
     }
-    return true;
+    if(!watchAndCheckExists(zkw, znode)) {
+      // It did exist but now it doesn't, try again
+      return createEphemeralNodeAndWatch(zkw, znode, data);
+    }
+    return ret;
   }
 
   /**
@@ -1038,22 +1039,23 @@ public class ZKUtil {
   public static boolean createNodeIfNotExistsAndWatch(
       ZooKeeperWatcher zkw, String znode, byte [] data)
   throws KeeperException {
+    boolean ret = true;
     try {
       zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
           CreateMode.PERSISTENT);
     } catch (KeeperException.NodeExistsException nee) {
-      try {
-        zkw.getRecoverableZooKeeper().exists(znode, zkw);
-      } catch (InterruptedException e) {
-        zkw.interruptedException(e);
-        return false;
-      }
+      ret = false;
+    } catch (InterruptedException e) {
+      zkw.interruptedException(e);
       return false;
+    }
+    try {
+      zkw.getRecoverableZooKeeper().exists(znode, zkw);
     } catch (InterruptedException e) {
       zkw.interruptedException(e);
       return false;
     }
-    return true;
+    return ret;
   }
 
   /**



Mime
View raw message