Class ZKProcedureUtil

java.lang.Object
org.apache.hadoop.hbase.zookeeper.ZKListener
org.apache.hadoop.hbase.procedure.ZKProcedureUtil
All Implemented Interfaces:
Closeable, AutoCloseable

@Private public abstract class ZKProcedureUtil extends ZKListener implements Closeable
This is a shared ZooKeeper-based znode management utils for distributed procedure. All znode operations should go through the provided methods in coordinators and members. Layout of nodes in ZK is /hbase/[op name]/acquired/ [op instance] - op data/ /[nodes that have acquired] /reached/ [op instance]/ /[nodes that have completed] /abort/ [op instance] - failure data NOTE: while acquired and completed are znode dirs, abort is actually just a znode. Assumption here that procedure names are unique
  • Field Details

  • Constructor Details

    • ZKProcedureUtil

      public ZKProcedureUtil(ZKWatcher watcher, String procDescription) throws org.apache.zookeeper.KeeperException
      Top-level watcher/controller for procedures across the cluster.

      On instantiation, this ensures the procedure znodes exist. This however requires the passed in watcher has been started.

      Parameters:
      watcher - watcher for the cluster ZK. Owned by this and closed via close()
      procDescription - name of the znode describing the procedure to run
      Throws:
      org.apache.zookeeper.KeeperException - when the procedure znodes cannot be created
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getAcquiredBarrierNode

      public String getAcquiredBarrierNode(String opInstanceName)
    • getReachedBarrierNode

      public String getReachedBarrierNode(String opInstanceName)
    • getAbortZNode

      public String getAbortZNode(String opInstanceName)
    • getAbortZnode

    • getBaseZnode

      public String getBaseZnode()
    • getAcquiredBarrier

    • getAcquireBarrierNode

      public static String getAcquireBarrierNode(ZKProcedureUtil controller, String opInstanceName)
      Get the full znode path for the node used by the coordinator to trigger a global barrier acquire on each subprocedure.
      Parameters:
      controller - controller running the procedure
      opInstanceName - name of the running procedure instance (not the procedure description).
      Returns:
      full znode path to the prepare barrier/start node
    • getReachedBarrierNode

      public static String getReachedBarrierNode(ZKProcedureUtil controller, String opInstanceName)
      Get the full znode path for the node used by the coordinator to trigger a global barrier execution and release on each subprocedure.
      Parameters:
      controller - controller running the procedure
      opInstanceName - name of the running procedure instance (not the procedure description).
      Returns:
      full znode path to the commit barrier
    • getAbortNode

      public static String getAbortNode(ZKProcedureUtil controller, String opInstanceName)
      Get the full znode path for the node used by the coordinator or member to trigger an abort of the global barrier acquisition or execution in subprocedures.
      Parameters:
      controller - controller running the procedure
      opInstanceName - name of the running procedure instance (not the procedure description).
      Returns:
      full znode path to the abort znode
    • getWatcher

      Description copied from class: ZKListener
      Returns The watcher associated with this listener
      Overrides:
      getWatcher in class ZKListener
    • isInProcedurePath

      boolean isInProcedurePath(String path)
      Is this a procedure related znode path? TODO: this is not strict, can return true if had name just starts with same prefix but is different zdir.
      Returns:
      true if starts with baseZnode
    • isAcquiredNode

      boolean isAcquiredNode(String path)
      Is this the exact procedure barrier acquired znode
    • isAcquiredPathNode

      boolean isAcquiredPathNode(String path)
      Is this in the procedure barrier acquired znode path
    • isReachedNode

      boolean isReachedNode(String path)
      Is this the exact procedure barrier reached znode
    • isReachedPathNode

      boolean isReachedPathNode(String path)
      Is this in the procedure barrier reached znode path
    • isMemberNode

      private boolean isMemberNode(String path, String statePath)
    • isAbortNode

      boolean isAbortNode(String path)
      Is this in the procedure barrier abort znode path
    • isAbortPathNode

      public boolean isAbortPathNode(String path)
      Is this in the procedure barrier abort znode path
    • logZKTree

      void logZKTree(String root)
      Recursively print the current state of ZK (non-transactional)
      Parameters:
      root - name of the root directory in zk to print
    • logZKTree

      protected void logZKTree(String root, String prefix) throws org.apache.zookeeper.KeeperException
      Helper method to print the current state of the ZK tree.
      Throws:
      org.apache.zookeeper.KeeperException - if an unexpected exception occurs
      See Also:
    • clearChildZNodes

      public void clearChildZNodes() throws org.apache.zookeeper.KeeperException
      Throws:
      org.apache.zookeeper.KeeperException
    • clearZNodes

      public void clearZNodes(String procedureName) throws org.apache.zookeeper.KeeperException
      Throws:
      org.apache.zookeeper.KeeperException