@InterfaceAudience.Private public abstract class ZKProcedureUtil extends ZooKeeperListener implements Closeable
Modifier and Type | Field and Description |
---|---|
static String |
ABORT_ZNODE_DEFAULT |
protected String |
abortZnode |
static String |
ACQUIRED_BARRIER_ZNODE_DEFAULT |
protected String |
acquiredZnode |
String |
baseZNode |
private static org.apache.commons.logging.Log |
LOG |
static String |
REACHED_BARRIER_ZNODE_DEFAULT |
protected String |
reachedZnode |
watcher
Constructor and Description |
---|
ZKProcedureUtil(ZooKeeperWatcher watcher,
String procDescription)
Top-level watcher/controller for procedures across the cluster.
|
Modifier and Type | Method and Description |
---|---|
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() |
(package private) boolean |
isAbortNode(String path)
Is this in the procedure barrier abort znode path
|
boolean |
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 |
logZKTree(String root)
Recursively print the current state of ZK (non-transactional)
|
protected void |
logZKTree(String root,
String prefix)
Helper method to print the current state of the ZK tree.
|
nodeChildrenChanged, nodeCreated, nodeDataChanged, nodeDeleted
private static final org.apache.commons.logging.Log LOG
public static final String ACQUIRED_BARRIER_ZNODE_DEFAULT
public static final String REACHED_BARRIER_ZNODE_DEFAULT
public static final String ABORT_ZNODE_DEFAULT
public final String baseZNode
protected final String acquiredZnode
protected final String reachedZnode
protected final String abortZnode
public ZKProcedureUtil(ZooKeeperWatcher watcher, String procDescription) throws org.apache.zookeeper.KeeperException
On instantiation, this ensures the procedure znodes exist. This however requires the passed in watcher has been started.
watcher
- watcher for the cluster ZK. Owned by this and closed via
close()
procDescription
- name of the znode describing the procedure to runorg.apache.zookeeper.KeeperException
- when the procedure znodes cannot be createdpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public String getAbortZnode()
public String getBaseZnode()
public String getAcquiredBarrier()
public static String getAcquireBarrierNode(ZKProcedureUtil controller, String opInstanceName)
controller
- controller running the procedureopInstanceName
- name of the running procedure instance (not the procedure description).public static String getReachedBarrierNode(ZKProcedureUtil controller, String opInstanceName)
controller
- controller running the procedureopInstanceName
- name of the running procedure instance (not the procedure description).public static String getAbortNode(ZKProcedureUtil controller, String opInstanceName)
controller
- controller running the procedureopInstanceName
- name of the running procedure instance (not the procedure description).public ZooKeeperWatcher getWatcher()
getWatcher
in class ZooKeeperListener
boolean isInProcedurePath(String path)
boolean isAcquiredNode(String path)
boolean isAcquiredPathNode(String path)
boolean isReachedNode(String path)
boolean isReachedPathNode(String path)
boolean isAbortNode(String path)
public boolean isAbortPathNode(String path)
void logZKTree(String root)
root
- name of the root directory in zk to printorg.apache.zookeeper.KeeperException
protected void logZKTree(String root, String prefix) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
- if an unexpected exception occurslogZKTree(String)
public void clearChildZNodes() throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public void clearZNodes(String procedureName) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.