Class ZKProcedureUtil
java.lang.Object
org.apache.hadoop.hbase.zookeeper.ZKListener
org.apache.hadoop.hbase.procedure.ZKProcedureUtil
- All Implemented Interfaces:
Closeable,AutoCloseable
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
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected final Stringstatic final Stringprotected final Stringfinal Stringprivate static final org.slf4j.Loggerstatic final Stringprotected final StringFields inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
watcher -
Constructor Summary
ConstructorsConstructorDescriptionZKProcedureUtil(ZKWatcher watcher, String procDescription) Top-level watcher/controller for procedures across the cluster. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclearZNodes(String procedureName) voidclose()static StringgetAbortNode(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.getAbortZNode(String opInstanceName) static StringgetAcquireBarrierNode(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.getAcquiredBarrierNode(String opInstanceName) getReachedBarrierNode(String opInstanceName) static StringgetReachedBarrierNode(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.Returns The watcher associated with this listener(package private) booleanisAbortNode(String path) Is this in the procedure barrier abort znode pathbooleanisAbortPathNode(String path) Is this in the procedure barrier abort znode path(package private) booleanisAcquiredNode(String path) Is this the exact procedure barrier acquired znode(package private) booleanisAcquiredPathNode(String path) Is this in the procedure barrier acquired znode path(package private) booleanisInProcedurePath(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.private booleanisMemberNode(String path, String statePath) (package private) booleanisReachedNode(String path) Is this the exact procedure barrier reached znode(package private) booleanisReachedPathNode(String path) Is this in the procedure barrier reached znode path(package private) voidRecursively print the current state of ZK (non-transactional)protected voidHelper method to print the current state of the ZK tree.Methods inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
nodeChildrenChanged, nodeCreated, nodeDataChanged, nodeDeleted
-
Field Details
-
LOG
-
ACQUIRED_BARRIER_ZNODE_DEFAULT
- See Also:
-
REACHED_BARRIER_ZNODE_DEFAULT
- See Also:
-
ABORT_ZNODE_DEFAULT
- See Also:
-
baseZNode
-
acquiredZnode
-
reachedZnode
-
abortZnode
-
-
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 viaclose()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
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getAcquiredBarrierNode
-
getReachedBarrierNode
-
getAbortZNode
-
getAbortZnode
-
getBaseZnode
-
getAcquiredBarrier
-
getAcquireBarrierNode
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 procedureopInstanceName- name of the running procedure instance (not the procedure description).- Returns:
- full znode path to the prepare barrier/start node
-
getReachedBarrierNode
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 procedureopInstanceName- name of the running procedure instance (not the procedure description).- Returns:
- full znode path to the commit barrier
-
getAbortNode
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 procedureopInstanceName- name of the running procedure instance (not the procedure description).- Returns:
- full znode path to the abort znode
-
getWatcher
Description copied from class:ZKListenerReturns The watcher associated with this listener- Overrides:
getWatcherin classZKListener
-
isInProcedurePath
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
Is this the exact procedure barrier acquired znode -
isAcquiredPathNode
Is this in the procedure barrier acquired znode path -
isReachedNode
Is this the exact procedure barrier reached znode -
isReachedPathNode
Is this in the procedure barrier reached znode path -
isMemberNode
-
isAbortNode
Is this in the procedure barrier abort znode path -
isAbortPathNode
Is this in the procedure barrier abort znode path -
logZKTree
Recursively print the current state of ZK (non-transactional)- Parameters:
root- name of the root directory in zk to print
-
logZKTree
Helper method to print the current state of the ZK tree.- Throws:
org.apache.zookeeper.KeeperException- if an unexpected exception occurs- See Also:
-
clearChildZNodes
- Throws:
org.apache.zookeeper.KeeperException
-
clearZNodes
- Throws:
org.apache.zookeeper.KeeperException
-