You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jm...@apache.org on 2013/02/13 20:01:22 UTC

svn commit: r1445855 - in /hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure: ZKProcedureCoordinatorRpcs.java ZKProcedureMemberRpcs.java ZKProcedureUtil.java

Author: jmhsieh
Date: Wed Feb 13 19:01:21 2013
New Revision: 1445855

URL: http://svn.apache.org/r1445855
Log:
HBASE-7616 NPE in ZKProcedure.nodeCreated


Modified:
    hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureCoordinatorRpcs.java
    hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureMemberRpcs.java
    hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureUtil.java

Modified: hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureCoordinatorRpcs.java
URL: http://svn.apache.org/viewvc/hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureCoordinatorRpcs.java?rev=1445855&r1=1445854&r2=1445855&view=diff
==============================================================================
--- hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureCoordinatorRpcs.java (original)
+++ hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureCoordinatorRpcs.java Wed Feb 13 19:01:21 2013
@@ -39,7 +39,7 @@ import com.google.protobuf.InvalidProtoc
 @InterfaceAudience.Public
 @InterfaceStability.Evolving
 public class ZKProcedureCoordinatorRpcs implements ProcedureCoordinatorRpcs {
-  public static final Log LOG = LogFactory.getLog(ZKProcedureUtil.class);
+  public static final Log LOG = LogFactory.getLog(ZKProcedureCoordinatorRpcs.class);
   private ZKProcedureUtil zkProc = null;
   protected ProcedureCoordinator coordinator = null;  // if started this should be non-null
 
@@ -165,20 +165,20 @@ public class ZKProcedureCoordinatorRpcs 
       this.zkProc = new ZKProcedureUtil(watcher, procedureType, coordName) {
         @Override
         public void nodeCreated(String path) {
-          if (!zkProc.isInProcedurePath(path)) return;
+          if (!isInProcedurePath(path)) return;
           LOG.debug("Node created: " + path);
           logZKTree(this.baseZNode);
-          if (zkProc.isAcquiredPathNode(path)) {
+          if (isAcquiredPathNode(path)) {
             // node wasn't present when we created the watch so zk event triggers acquire
             listener.memberAcquiredBarrier(ZKUtil.getNodeName(ZKUtil.getParent(path)), ZKUtil.getNodeName(path));
           }
-          if (zkProc.isReachedPathNode(path)) {
+          if (isReachedPathNode(path)) {
             // node wasn't present when we created the watch so zk event triggers the finished barrier.
 
             // TODO Nothing enforces that acquire and reached znodes from showing up in the wrong order.
             listener.memberFinishedBarrier(ZKUtil.getNodeName(ZKUtil.getParent(path)), ZKUtil.getNodeName(path));
           }
-          if (zkProc.isAbortPathNode(path)) {
+          if (isAbortPathNode(path)) {
             abort(path);
           }
         }

Modified: hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureMemberRpcs.java
URL: http://svn.apache.org/viewvc/hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureMemberRpcs.java?rev=1445855&r1=1445854&r2=1445855&view=diff
==============================================================================
--- hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureMemberRpcs.java (original)
+++ hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureMemberRpcs.java Wed Feb 13 19:01:21 2013
@@ -74,29 +74,31 @@ public class ZKProcedureMemberRpcs imple
     this.zkController = new ZKProcedureUtil(watcher, procType, memberName) {
       @Override
       public void nodeCreated(String path) {
-        if (path.startsWith(this.baseZNode)) {
-          LOG.info("Received created event:" + path);
-          // if it is a simple start/end/abort then we just rewatch the node
-          if (path.equals(this.acquiredZnode)) {
-            waitForNewProcedures();
-            return;
-          } else if (path.equals(this.abortZnode)) {
-            watchForAbortedProcedures();
-            return;
-          }
-          String parent = ZKUtil.getParent(path);
-          // if its the end barrier, the procedure can be completed
-          if (parent.equals(this.reachedZnode)) {
-            receivedReachedGlobalBarrier(path);
-            return;
-          } else if (parent.equals(this.abortZnode)) {
-            abort(path);
-            return;
-          } else if (parent.equals(this.acquiredZnode)) {
-            startNewSubprocedure(path);
-          } else {
-            LOG.debug("Ignoring created notification for node:" + path);
-          }
+        if (!isInProcedurePath(path)) {
+          return;
+        }
+
+        LOG.info("Received created event:" + path);
+        // if it is a simple start/end/abort then we just rewatch the node
+        if (isAcquiredNode(path)) {
+          waitForNewProcedures();
+          return;
+        } else if (isAbortNode(path)) {
+          watchForAbortedProcedures();
+          return;
+        }
+        String parent = ZKUtil.getParent(path);
+        // if its the end barrier, the procedure can be completed
+        if (isReachedNode(parent)) {
+          receivedReachedGlobalBarrier(path);
+          return;
+        } else if (isAbortNode(parent)) {
+          abort(path);
+          return;
+        } else if (isAcquiredNode(parent)) {
+          startNewSubprocedure(path);
+        } else {
+          LOG.debug("Ignoring created notification for node:" + path);
         }
       }
 

Modified: hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureUtil.java?rev=1445855&r1=1445854&r2=1445855&view=diff
==============================================================================
--- hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureUtil.java (original)
+++ hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/ZKProcedureUtil.java Wed Feb 13 19:01:21 2013
@@ -179,28 +179,51 @@ public abstract class ZKProcedureUtil
    *
    * @return true if starts with baseZnode
    */
-  public boolean isInProcedurePath(String path) {
+  boolean isInProcedurePath(String path) {
     return path.startsWith(baseZNode);
   }
 
   /**
+   * Is this the exact procedure barrier acquired znode
+   */
+  boolean isAcquiredNode(String path) {
+    return path.equals(acquiredZnode);
+  }
+
+  
+  /**
    * Is this in the procedure barrier acquired znode path
    */
-  public boolean isAcquiredPathNode(String path) {
+  boolean isAcquiredPathNode(String path) {
     return path.startsWith(this.acquiredZnode) && !path.equals(acquiredZnode);
   }
 
   /**
+   * Is this the exact procedure barrier reached znode
+   */
+  boolean isReachedNode(String path) {
+    return path.equals(reachedZnode);
+  }
+
+  /**
    * Is this in the procedure barrier reached znode path
    */
-  public boolean isReachedPathNode(String path) {
+  boolean isReachedPathNode(String path) {
     return path.startsWith(this.reachedZnode) && !path.equals(reachedZnode);
   }
 
+
+  /**
+   * Is this in the procedure barrier abort znode path
+   */
+  boolean isAbortNode(String path) {
+    return path.equals(abortZnode);
+  }
+
   /**
    * Is this in the procedure barrier abort znode path
    */
-    public boolean isAbortPathNode(String path) {
+  public boolean isAbortPathNode(String path) {
     return path.startsWith(this.abortZnode) && !path.equals(abortZnode);
   }