@InterfaceAudience.Private public class ZKUtil extends Object
Contains only static methods and constants.
Methods all throw KeeperException
if there is an unexpected
zookeeper exception, so callers of these methods must handle appropriately.
If ZK is required for the operation, the server will need to be aborted.
Modifier and Type | Class and Description |
---|---|
private static class |
ZKUtil.JaasConfiguration
A JAAS configuration that defines the login modules that we want to use for login.
|
static class |
ZKUtil.NodeAndData
Deprecated.
Unused
|
static class |
ZKUtil.ZKUtilOp
Represents an action taken by ZKUtil, e.g.
|
Modifier and Type | Field and Description |
---|---|
private static org.apache.commons.logging.Log |
LOG |
private static int |
zkDumpConnectionTimeOut |
static char |
ZNODE_PATH_SEPARATOR |
Constructor and Description |
---|
ZKUtil() |
Modifier and Type | Method and Description |
---|---|
private static void |
appendPeerState(ZooKeeperWatcher zkw,
String znodeToProcess,
StringBuilder sb) |
private static void |
appendPeersZnodes(ZooKeeperWatcher zkw,
String peersZnode,
StringBuilder sb) |
private static void |
appendRSZnodes(ZooKeeperWatcher zkw,
String znode,
StringBuilder sb) |
static void |
asyncCreate(ZooKeeperWatcher zkw,
String znode,
byte[] data,
org.apache.zookeeper.AsyncCallback.StringCallback cb,
Object ctx)
Async creates the specified node with the specified data.
|
static byte[] |
blockUntilAvailable(ZooKeeperWatcher zkw,
String znode,
long timeout) |
static int |
checkExists(ZooKeeperWatcher zkw,
String znode)
Check if the specified node exists.
|
static RecoverableZooKeeper |
connect(org.apache.hadoop.conf.Configuration conf,
String ensemble,
org.apache.zookeeper.Watcher watcher) |
static RecoverableZooKeeper |
connect(org.apache.hadoop.conf.Configuration conf,
String ensemble,
org.apache.zookeeper.Watcher watcher,
String identifier) |
static RecoverableZooKeeper |
connect(org.apache.hadoop.conf.Configuration conf,
org.apache.zookeeper.Watcher watcher)
Creates a new connection to ZooKeeper, pulling settings and ensemble config
from the specified configuration object using methods from
ZKConfig . |
static org.apache.zookeeper.KeeperException |
convert(DeserializationException e)
Convert a
DeserializationException to a more palatable KeeperException . |
private static ArrayList<org.apache.zookeeper.data.ACL> |
createACL(ZooKeeperWatcher zkw,
String node) |
static ArrayList<org.apache.zookeeper.data.ACL> |
createACL(ZooKeeperWatcher zkw,
String node,
boolean isSecureZooKeeper) |
static void |
createAndFailSilent(ZooKeeperWatcher zkw,
String znode)
Creates the specified node, iff the node does not exist.
|
static void |
createAndFailSilent(ZooKeeperWatcher zkw,
String znode,
byte[] data)
Creates the specified node containing specified data, iff the node does not exist.
|
private static void |
createAndFailSilent(ZooKeeperWatcher zkw,
ZKUtil.ZKUtilOp.CreateAndFailSilent cafs) |
static int |
createAndWatch(ZooKeeperWatcher zkw,
String znode,
byte[] data)
Creates the specified node with the specified data and watches it.
|
static boolean |
createEphemeralNodeAndWatch(ZooKeeperWatcher zkw,
String znode,
byte[] data)
Set the specified znode to be an ephemeral node carrying the specified
data.
|
static boolean |
createNodeIfNotExistsAndWatch(ZooKeeperWatcher zkw,
String znode,
byte[] data)
Creates the specified znode to be a persistent node carrying the specified
data.
|
static String |
createNodeIfNotExistsNoWatch(ZooKeeperWatcher zkw,
String znode,
byte[] data,
org.apache.zookeeper.CreateMode createMode)
Creates the specified znode with the specified data but does not watch it.
|
static void |
createSetData(ZooKeeperWatcher zkw,
String znode,
byte[] data)
Set data into node creating node if it doesn't yet exist.
|
static void |
createWithParents(ZooKeeperWatcher zkw,
String znode)
Creates the specified node and all parent nodes required for it to exist.
|
static void |
createWithParents(ZooKeeperWatcher zkw,
String znode,
byte[] data)
Creates the specified node and all parent nodes required for it to exist.
|
static void |
deleteChildrenRecursively(ZooKeeperWatcher zkw,
String node)
Delete all the children of the specified node but not the node itself.
|
static void |
deleteChildrenRecursivelyMultiOrSequential(ZooKeeperWatcher zkw,
boolean runSequentialOnMultiFailure,
String... pathRoots)
Delete all the children of the specified node but not the node itself.
|
static void |
deleteNode(ZooKeeperWatcher zkw,
String node)
Delete the specified node.
|
static boolean |
deleteNode(ZooKeeperWatcher zkw,
String node,
int version)
Delete the specified node with the specified version.
|
static void |
deleteNodeFailSilent(ZooKeeperWatcher zkw,
String node)
Deletes the specified node.
|
private static void |
deleteNodeFailSilent(ZooKeeperWatcher zkw,
ZKUtil.ZKUtilOp.DeleteNodeFailSilent dnfs) |
static void |
deleteNodeRecursively(ZooKeeperWatcher zkw,
String node)
Delete the specified node and all of it's children.
|
static void |
deleteNodeRecursivelyMultiOrSequential(ZooKeeperWatcher zkw,
boolean runSequentialOnMultiFailure,
String... pathRoots)
Delete the specified node and its children.
|
static String |
dump(ZooKeeperWatcher zkw) |
static List<ZKUtil.NodeAndData> |
getChildDataAndWatchForNewChildren(ZooKeeperWatcher zkw,
String baseNode)
Deprecated.
Unused
|
static byte[] |
getData(ZooKeeperWatcher zkw,
String znode)
Get znode data.
|
static byte[] |
getDataAndWatch(ZooKeeperWatcher zkw,
String znode)
Get the data at the specified znode and set a watch.
|
static byte[] |
getDataAndWatch(ZooKeeperWatcher zkw,
String znode,
org.apache.zookeeper.data.Stat stat)
Get the data at the specified znode and set a watch.
|
private static byte[] |
getDataInternal(ZooKeeperWatcher zkw,
String znode,
org.apache.zookeeper.data.Stat stat,
boolean watcherSet) |
static byte[] |
getDataNoWatch(ZooKeeperWatcher zkw,
String znode,
org.apache.zookeeper.data.Stat stat)
Get the data at the specified znode without setting a watch.
|
static String |
getNodeName(String path)
Get the name of the current node from the specified fully-qualified path.
|
static int |
getNumberOfChildren(ZooKeeperWatcher zkw,
String znode)
Get the number of children of the specified node.
|
static String |
getParent(String node)
Returns the full path of the immediate parent of the specified node.
|
private static void |
getReplicationZnodesDump(ZooKeeperWatcher zkw,
StringBuilder sb)
Appends replication znodes to the passed StringBuilder.
|
private static String |
getServerNameOrEmptyString(byte[] data) |
static String[] |
getServerStats(String server,
int timeout)
Gets the statistics from the given server.
|
static boolean |
isSecureZooKeeper(org.apache.hadoop.conf.Configuration conf)
Returns whether or not secure authentication is enabled
(whether
hbase.security.authentication is set to
kerberos . |
static String |
joinZNode(String prefix,
String suffix)
Join the prefix znode name with the suffix znode name to generate a proper
full znode name.
|
static List<String> |
listChildrenAndWatchForNewChildren(ZooKeeperWatcher zkw,
String znode)
Lists the children znodes of the specified znode.
|
static List<String> |
listChildrenAndWatchThem(ZooKeeperWatcher zkw,
String znode)
List all the children of the specified znode, setting a watch for children
changes and also setting a watch on every individual child in order to get
the NodeCreated and NodeDeleted events.
|
private static List<String> |
listChildrenBFSAndWatchThem(ZooKeeperWatcher zkw,
String znode)
BFS Traversal of all the children under path, with the entries in the list,
in the same order as that of the traversal.
|
private static List<String> |
listChildrenBFSNoWatch(ZooKeeperWatcher zkw,
String znode)
BFS Traversal of all the children under path, with the entries in the list,
in the same order as that of the traversal.
|
static List<String> |
listChildrenNoWatch(ZooKeeperWatcher zkw,
String znode)
Lists the children of the specified znode without setting any watches.
|
private static void |
login(org.apache.hadoop.conf.Configuration conf,
String keytabFileKey,
String userNameKey,
String hostname,
String loginContextProperty,
String loginContextName)
Log in the current process using the given configuration keys for the
credential file and login principal.
|
static void |
loginClient(org.apache.hadoop.conf.Configuration conf,
String keytabFileKey,
String userNameKey,
String hostname)
Log in the current zookeeper client using the given configuration
keys for the credential file and login principal.
|
static void |
loginServer(org.apache.hadoop.conf.Configuration conf,
String keytabFileKey,
String userNameKey,
String hostname)
Log in the current zookeeper server process using the given configuration
keys for the credential file and login principal.
|
private static void |
logRetrievedMsg(ZooKeeperWatcher zkw,
String znode,
byte[] data,
boolean watcherSet) |
static void |
logZKTree(ZooKeeperWatcher zkw,
String root)
Recursively print the current state of ZK (non-transactional)
|
protected static void |
logZKTree(ZooKeeperWatcher zkw,
String root,
String prefix)
Helper method to print the current state of the ZK tree.
|
static void |
multiOrSequential(ZooKeeperWatcher zkw,
List<ZKUtil.ZKUtilOp> ops,
boolean runSequentialOnMultiFailure)
If hbase.zookeeper.useMulti is true, use ZooKeeper's multi-update functionality.
|
static boolean |
nodeHasChildren(ZooKeeperWatcher zkw,
String znode)
Checks if the specified znode has any children.
|
static org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionStoreSequenceIds |
parseRegionStoreSequenceIds(byte[] bytes) |
static long |
parseWALPositionFrom(byte[] bytes) |
static byte[] |
positionToByteArray(long position) |
private static void |
processSequentially(ZooKeeperWatcher zkw,
List<ZKUtil.ZKUtilOp> ops) |
static byte[] |
regionSequenceIdsToByteArray(Long regionLastFlushedSequenceId,
Map<byte[],Long> storeSequenceIds) |
static void |
setData(ZooKeeperWatcher zkw,
String znode,
byte[] data)
Sets the data of the existing znode to be the specified data.
|
static boolean |
setData(ZooKeeperWatcher zkw,
String znode,
byte[] data,
int expectedVersion)
Sets the data of the existing znode to be the specified data.
|
private static void |
setData(ZooKeeperWatcher zkw,
ZKUtil.ZKUtilOp.SetData setData) |
static boolean |
setWatchIfNodeExists(ZooKeeperWatcher zkw,
String znode)
Watch the specified znode, but only if exists.
|
private static org.apache.zookeeper.Op |
toZooKeeperOp(ZooKeeperWatcher zkw,
ZKUtil.ZKUtilOp op)
Convert from ZKUtilOp to ZKOp
|
static void |
updateExistingNodeData(ZooKeeperWatcher zkw,
String znode,
byte[] data,
int expectedVersion)
Deprecated.
Unused
|
static void |
waitForBaseZNode(org.apache.hadoop.conf.Configuration conf)
Waits for HBase installation's base (parent) znode to become available.
|
static boolean |
watchAndCheckExists(ZooKeeperWatcher zkw,
String znode)
Watch the specified znode for delete/create/change events.
|
private static final org.apache.commons.logging.Log LOG
public static final char ZNODE_PATH_SEPARATOR
private static int zkDumpConnectionTimeOut
public static RecoverableZooKeeper connect(org.apache.hadoop.conf.Configuration conf, org.apache.zookeeper.Watcher watcher) throws IOException
ZKConfig
.
Sets the connection status monitoring watcher to the specified watcher.conf
- configuration to pull ensemble and other settings fromwatcher
- watcher to monitor connection changesIOException
- if unable to connect to zk or config problempublic static RecoverableZooKeeper connect(org.apache.hadoop.conf.Configuration conf, String ensemble, org.apache.zookeeper.Watcher watcher) throws IOException
IOException
public static RecoverableZooKeeper connect(org.apache.hadoop.conf.Configuration conf, String ensemble, org.apache.zookeeper.Watcher watcher, String identifier) throws IOException
IOException
public static void loginServer(org.apache.hadoop.conf.Configuration conf, String keytabFileKey, String userNameKey, String hostname) throws IOException
This is only applicable when running on secure hbase On regular HBase (without security features), this will safely be ignored.
conf
- The configuration data to usekeytabFileKey
- Property key used to configure the path to the credential fileuserNameKey
- Property key used to configure the login principalhostname
- Current hostname to use in any credentialsIOException
- underlying exception from SecurityUtil.login() callpublic static void loginClient(org.apache.hadoop.conf.Configuration conf, String keytabFileKey, String userNameKey, String hostname) throws IOException
This is only applicable when running on secure hbase On regular HBase (without security features), this will safely be ignored.
conf
- The configuration data to usekeytabFileKey
- Property key used to configure the path to the credential fileuserNameKey
- Property key used to configure the login principalhostname
- Current hostname to use in any credentialsIOException
- underlying exception from SecurityUtil.login() callprivate static void login(org.apache.hadoop.conf.Configuration conf, String keytabFileKey, String userNameKey, String hostname, String loginContextProperty, String loginContextName) throws IOException
This is only applicable when running on secure hbase On regular HBase (without security features), this will safely be ignored.
conf
- The configuration data to usekeytabFileKey
- Property key used to configure the path to the credential fileuserNameKey
- Property key used to configure the login principalhostname
- Current hostname to use in any credentialsloginContextProperty
- property name to expose the entry nameloginContextName
- jaas entry nameIOException
- underlying exception from SecurityUtil.login() callpublic static String joinZNode(String prefix, String suffix)
prefix
- beginning of znode namesuffix
- ending of znode namepublic static String getParent(String node)
node
- path to get parent ofpublic static String getNodeName(String path)
path
- fully-qualified pathpublic static boolean watchAndCheckExists(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of node to watchorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static boolean setWatchIfNodeExists(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of node to watchorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static int checkExists(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of node to watchorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static List<String> listChildrenAndWatchForNewChildren(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of node to list and watch children oforg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static List<String> listChildrenAndWatchThem(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- zookeeper referenceznode
- node to get children of and watchorg.apache.zookeeper.KeeperException
public static List<String> listChildrenNoWatch(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- zookeeper referenceznode
- node to get childrenorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static boolean nodeHasChildren(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of node to check for children oforg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static int getNumberOfChildren(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of node to count children oforg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static byte[] getData(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public static byte[] getDataAndWatch(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of nodeorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static byte[] getDataAndWatch(ZooKeeperWatcher zkw, String znode, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of nodestat
- object to populate the version of the znodeorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionprivate static byte[] getDataInternal(ZooKeeperWatcher zkw, String znode, org.apache.zookeeper.data.Stat stat, boolean watcherSet) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public static byte[] getDataNoWatch(ZooKeeperWatcher zkw, String znode, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of nodestat
- node status to get if node existsorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static List<ZKUtil.NodeAndData> getChildDataAndWatchForNewChildren(ZooKeeperWatcher zkw, String baseNode) throws org.apache.zookeeper.KeeperException
zkw
- zk referencebaseNode
- path of node to list and watch children oforg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static void updateExistingNodeData(ZooKeeperWatcher zkw, String znode, byte[] data, int expectedVersion) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- data
- expectedVersion
- org.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionKeeperException.BadVersionException
- if version mismatchpublic static boolean setData(ZooKeeperWatcher zkw, String znode, byte[] data, int expectedVersion) throws org.apache.zookeeper.KeeperException, org.apache.zookeeper.KeeperException.NoNodeException
If the node does not exist, a KeeperException.NoNodeException
will be thrown.
If their is a version mismatch, method returns null.
No watches are set but setting data will trigger other watchers of this node.
If there is another problem, a KeeperException will be thrown.
zkw
- zk referenceznode
- path of nodedata
- data to set for nodeexpectedVersion
- version expected when setting dataorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionorg.apache.zookeeper.KeeperException.NoNodeException
public static void createSetData(ZooKeeperWatcher zkw, String znode, byte[] data) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of nodedata
- data to set for nodeorg.apache.zookeeper.KeeperException
public static void setData(ZooKeeperWatcher zkw, String znode, byte[] data) throws org.apache.zookeeper.KeeperException, org.apache.zookeeper.KeeperException.NoNodeException
If the node does not exist, a KeeperException.NoNodeException
will be thrown.
No watches are set but setting data will trigger other watchers of this node.
If there is another problem, a KeeperException will be thrown.
zkw
- zk referenceznode
- path of nodedata
- data to set for nodeorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionorg.apache.zookeeper.KeeperException.NoNodeException
private static void setData(ZooKeeperWatcher zkw, ZKUtil.ZKUtilOp.SetData setData) throws org.apache.zookeeper.KeeperException, org.apache.zookeeper.KeeperException.NoNodeException
org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException.NoNodeException
public static boolean isSecureZooKeeper(org.apache.hadoop.conf.Configuration conf)
hbase.security.authentication
is set to
kerberos
.private static ArrayList<org.apache.zookeeper.data.ACL> createACL(ZooKeeperWatcher zkw, String node)
public static ArrayList<org.apache.zookeeper.data.ACL> createACL(ZooKeeperWatcher zkw, String node, boolean isSecureZooKeeper)
public static boolean createEphemeralNodeAndWatch(ZooKeeperWatcher zkw, String znode, byte[] data) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of nodedata
- data of nodeorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static boolean createNodeIfNotExistsAndWatch(ZooKeeperWatcher zkw, String znode, byte[] data) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of nodedata
- data of nodeorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static String createNodeIfNotExistsNoWatch(ZooKeeperWatcher zkw, String znode, byte[] data, org.apache.zookeeper.CreateMode createMode) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of nodedata
- data of nodecreateMode
- specifying whether the node to be created is ephemeral and/or sequentialorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static int createAndWatch(ZooKeeperWatcher zkw, String znode, byte[] data) throws org.apache.zookeeper.KeeperException, org.apache.zookeeper.KeeperException.NodeExistsException
Throws an exception if the node already exists.
The node created is persistent and open access.
Returns the version number of the created node if successful.
zkw
- zk referenceznode
- path of node to createdata
- data of node to createorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionKeeperException.NodeExistsException
- if node already existspublic static void asyncCreate(ZooKeeperWatcher zkw, String znode, byte[] data, org.apache.zookeeper.AsyncCallback.StringCallback cb, Object ctx)
Throws an exception if the node already exists.
The node created is persistent and open access.
zkw
- zk referenceznode
- path of node to createdata
- data of node to createcb
- ctx
- public static void createAndFailSilent(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of nodeorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static void createAndFailSilent(ZooKeeperWatcher zkw, String znode, byte[] data) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of nodedata
- a byte array data to store in the znodeorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionprivate static void createAndFailSilent(ZooKeeperWatcher zkw, ZKUtil.ZKUtilOp.CreateAndFailSilent cafs) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public static void createWithParents(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of nodeorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static void createWithParents(ZooKeeperWatcher zkw, String znode, byte[] data) throws org.apache.zookeeper.KeeperException
zkw
- zk referenceznode
- path of nodeorg.apache.zookeeper.KeeperException
- if unexpected zookeeper exceptionpublic static void deleteNode(ZooKeeperWatcher zkw, String node) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public static boolean deleteNode(ZooKeeperWatcher zkw, String node, int version) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public static void deleteNodeFailSilent(ZooKeeperWatcher zkw, String node) throws org.apache.zookeeper.KeeperException
zkw
- node
- org.apache.zookeeper.KeeperException
private static void deleteNodeFailSilent(ZooKeeperWatcher zkw, ZKUtil.ZKUtilOp.DeleteNodeFailSilent dnfs) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public static void deleteNodeRecursively(ZooKeeperWatcher zkw, String node) throws org.apache.zookeeper.KeeperException
If the node does not exist, just returns.
Sets no watches. Throws all exceptions besides dealing with deletion of children.
org.apache.zookeeper.KeeperException
public static void deleteChildrenRecursively(ZooKeeperWatcher zkw, String node) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public static void deleteChildrenRecursivelyMultiOrSequential(ZooKeeperWatcher zkw, boolean runSequentialOnMultiFailure, String... pathRoots) throws org.apache.zookeeper.KeeperException
Sets no watches. Throws all exceptions besides dealing with deletion of children.
If hbase.zookeeper.useMulti is true, use ZooKeeper's multi-update functionality. Otherwise, run the list of operations sequentially.
If all of the following are true:
zkw
- - zk referencerunSequentialOnMultiFailure
- - if true when we get a ZooKeeper exception that could retry the
operations one-by-one (sequentially)pathRoots
- - path of the parent node(s)KeeperException.NotEmptyException
- if node has children while deletingorg.apache.zookeeper.KeeperException
- if unexpected ZooKeeper exceptionIllegalArgumentException
- if an invalid path is specifiedpublic static void deleteNodeRecursivelyMultiOrSequential(ZooKeeperWatcher zkw, boolean runSequentialOnMultiFailure, String... pathRoots) throws org.apache.zookeeper.KeeperException
Sets no watches. Throws all exceptions besides dealing with deletion of children.
If hbase.zookeeper.useMulti is true, use ZooKeeper's multi-update functionality. Otherwise, run the list of operations sequentially.
If all of the following are true:
zkw
- - zk referencerunSequentialOnMultiFailure
- - if true when we get a ZooKeeper exception that could retry the
operations one-by-one (sequentially)pathRoots
- - path of the parent node(s)KeeperException.NotEmptyException
- if node has children while deletingorg.apache.zookeeper.KeeperException
- if unexpected ZooKeeper exceptionIllegalArgumentException
- if an invalid path is specifiedprivate static List<String> listChildrenBFSNoWatch(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- - zk referenceznode
- - path of nodeorg.apache.zookeeper.KeeperException
- if unexpected ZooKeeper exceptionprivate static List<String> listChildrenBFSAndWatchThem(ZooKeeperWatcher zkw, String znode) throws org.apache.zookeeper.KeeperException
zkw
- - zk referenceznode
- - path of nodeorg.apache.zookeeper.KeeperException
- if unexpected ZooKeeper exceptionprivate static org.apache.zookeeper.Op toZooKeeperOp(ZooKeeperWatcher zkw, ZKUtil.ZKUtilOp op) throws UnsupportedOperationException
UnsupportedOperationException
public static void multiOrSequential(ZooKeeperWatcher zkw, List<ZKUtil.ZKUtilOp> ops, boolean runSequentialOnMultiFailure) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
private static void processSequentially(ZooKeeperWatcher zkw, List<ZKUtil.ZKUtilOp> ops) throws org.apache.zookeeper.KeeperException, org.apache.zookeeper.KeeperException.NoNodeException
org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException.NoNodeException
public static String dump(ZooKeeperWatcher zkw)
private static void getReplicationZnodesDump(ZooKeeperWatcher zkw, StringBuilder sb) throws org.apache.zookeeper.KeeperException
zkw
- sb
- org.apache.zookeeper.KeeperException
private static void appendRSZnodes(ZooKeeperWatcher zkw, String znode, StringBuilder sb) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
private static void appendPeersZnodes(ZooKeeperWatcher zkw, String peersZnode, StringBuilder sb) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
private static void appendPeerState(ZooKeeperWatcher zkw, String znodeToProcess, StringBuilder sb) throws org.apache.zookeeper.KeeperException, com.google.protobuf.InvalidProtocolBufferException
org.apache.zookeeper.KeeperException
com.google.protobuf.InvalidProtocolBufferException
public static String[] getServerStats(String server, int timeout) throws IOException
server
- The server to get the statistics from.timeout
- The socket timeout to use.IOException
- When the socket communication fails.private static void logRetrievedMsg(ZooKeeperWatcher zkw, String znode, byte[] data, boolean watcherSet)
private static String getServerNameOrEmptyString(byte[] data)
public static void waitForBaseZNode(org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
- on ZK errorspublic static byte[] blockUntilAvailable(ZooKeeperWatcher zkw, String znode, long timeout) throws InterruptedException
InterruptedException
public static org.apache.zookeeper.KeeperException convert(DeserializationException e)
DeserializationException
to a more palatable KeeperException
.
Used when can't let a DeserializationException
out w/o changing public API.e
- Exception to convertpublic static void logZKTree(ZooKeeperWatcher zkw, String root)
root
- name of the root directory in zk to printprotected static void logZKTree(ZooKeeperWatcher zkw, String root, String prefix) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
- if an unexpected exception occurslogZKTree(ZooKeeperWatcher, String)
public static byte[] positionToByteArray(long position)
position
- position
with pb magic prefix prepended suitable
for use as content of an wal position in a replication queue.public static long parseWALPositionFrom(byte[] bytes) throws DeserializationException
bytes
- - Content of a WAL position znode.DeserializationException
public static byte[] regionSequenceIdsToByteArray(Long regionLastFlushedSequenceId, Map<byte[],Long> storeSequenceIds)
regionLastFlushedSequenceId
- the flushed sequence id of a region which is the min of its
store max seq idsstoreSequenceIds
- column family to sequence Id mapRegionSequenceIds
with pb magic prefix prepended
suitable for use to filter wal edits in distributedLogReplay modepublic static org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionStoreSequenceIds parseRegionStoreSequenceIds(byte[] bytes) throws DeserializationException
bytes
- Content of serialized data of RegionStoreSequenceIdsDeserializationException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.