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
Modifier and TypeFieldDescriptionstatic final String
protected final String
static final String
protected final String
final String
private static final org.slf4j.Logger
static final String
protected final String
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
watcher
-
Constructor Summary
ConstructorDescriptionZKProcedureUtil
(ZKWatcher watcher, String procDescription) Top-level watcher/controller for procedures across the cluster. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.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.getAcquiredBarrierNode
(String opInstanceName) 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.Returns The watcher associated with this listener(package private) boolean
isAbortNode
(String path) Is this in the procedure barrier abort znode pathboolean
isAbortPathNode
(String path) Is this in the procedure barrier abort znode path(package private) boolean
isAcquiredNode
(String path) Is this the exact procedure barrier acquired znode(package private) boolean
isAcquiredPathNode
(String path) Is this in the procedure barrier acquired znode path(package private) 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.private boolean
isMemberNode
(String path, String statePath) (package private) boolean
isReachedNode
(String path) Is this the exact procedure barrier reached znode(package private) boolean
isReachedPathNode
(String path) Is this in the procedure barrier reached znode path(package private) void
Recursively print the current state of ZK (non-transactional)protected void
Helper 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:
close
in interfaceAutoCloseable
- Specified by:
close
in 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:ZKListener
Returns The watcher associated with this listener- Overrides:
getWatcher
in 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
-