org.apache.hadoop.hbase.procedure
Class ZKProcedureUtil

java.lang.Object
  extended by org.apache.hadoop.hbase.zookeeper.ZooKeeperListener
      extended by org.apache.hadoop.hbase.procedure.ZKProcedureUtil
All Implemented Interfaces:
Closeable

@InterfaceAudience.Private
public abstract class ZKProcedureUtil
extends ZooKeeperListener
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 Summary
static String ABORT_ZNODE_DEFAULT
           
protected  String abortZnode
           
static String ACQUIRED_BARRIER_ZNODE_DEFAULT
           
protected  String acquiredZnode
           
 String baseZNode
           
static String REACHED_BARRIER_ZNODE_DEFAULT
           
protected  String reachedZnode
           
 
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperListener
watcher
 
Constructor Summary
ZKProcedureUtil(ZooKeeperWatcher watcher, String procDescription)
          Top-level watcher/controller for procedures across the cluster.
 
Method Summary
 void clearChildZNodes()
           
 void clearZNodes(String procedureName)
           
 void close()
           
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.
 String getAbortZnode()
           
 String getAbortZNode(String opInstanceName)
           
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.
 String getAcquiredBarrier()
           
 String getAcquiredBarrierNode(String opInstanceName)
           
 String getBaseZnode()
           
 String getReachedBarrierNode(String opInstanceName)
           
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.
 ZooKeeperWatcher getWatcher()
           
 boolean isAbortPathNode(String path)
          Is this in the procedure barrier abort znode path
protected  void logZKTree(String root, String prefix)
          Helper method to print the current state of the ZK tree.
 
Methods inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperListener
nodeChildrenChanged, nodeCreated, nodeDataChanged, nodeDeleted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACQUIRED_BARRIER_ZNODE_DEFAULT

public static final String ACQUIRED_BARRIER_ZNODE_DEFAULT
See Also:
Constant Field Values

REACHED_BARRIER_ZNODE_DEFAULT

public static final String REACHED_BARRIER_ZNODE_DEFAULT
See Also:
Constant Field Values

ABORT_ZNODE_DEFAULT

public static final String ABORT_ZNODE_DEFAULT
See Also:
Constant Field Values

baseZNode

public final String baseZNode

acquiredZnode

protected final String acquiredZnode

reachedZnode

protected final String reachedZnode

abortZnode

protected final String abortZnode
Constructor Detail

ZKProcedureUtil

public ZKProcedureUtil(ZooKeeperWatcher 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 Detail

close

public void close()
           throws IOException
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

public String getAbortZnode()

getBaseZnode

public String getBaseZnode()

getAcquiredBarrier

public String 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

public ZooKeeperWatcher getWatcher()
Overrides:
getWatcher in class ZooKeeperListener
Returns:
The watcher associated with this listener

isAbortPathNode

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


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:
logZKTree(String)

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


Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.