Class ZooKeeperUtil
java.lang.Object
com.broadleafcommerce.search.provider.solr.util.zk.ZooKeeperUtil
Simple utility to assist in basic operations related to Zookeeper.
- Author:
- Kelly Tisdell
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
deleteRecursive
(String path, org.apache.zookeeper.ZooKeeper zk) Recursively deletes a path in Zookeeper.static boolean
ExecuteSolrZkClient.exists(String, boolean)
with retry.static boolean
Deprecated.static void
makePath
(String path, byte[] data, org.apache.solr.common.cloud.SolrZkClient zk, org.apache.zookeeper.CreateMode createMode, List<org.apache.zookeeper.data.ACL> acls) Creates a path in Zookeeper, specified by the path argument.static void
static void
makePath
(String path, byte[] data, org.apache.zookeeper.ZooKeeper zk, org.apache.zookeeper.CreateMode createMode) static void
makePath
(String path, byte[] data, org.apache.zookeeper.ZooKeeper zk, org.apache.zookeeper.CreateMode createMode, List<org.apache.zookeeper.data.ACL> acls) Deprecated.static void
Creates a path in Zookeeper, if it does not already exist, with CreateMode.PERSISTENT for the create mode and ZooDefs.Ids.OPEN_ACL_UNSAFE for ACLs.
-
Constructor Details
-
ZooKeeperUtil
public ZooKeeperUtil()
-
-
Method Details
-
deleteRecursive
public static void deleteRecursive(String path, org.apache.zookeeper.ZooKeeper zk) throws org.apache.zookeeper.KeeperException, InterruptedException Recursively deletes a path in Zookeeper. For example, if you have a path like /path/to/my/element, then passing "/path" to this method will delete the directory tree recursively.- Parameters:
path
-zk
-- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
makePath
public static void makePath(String path, org.apache.zookeeper.ZooKeeper zk) throws org.apache.zookeeper.KeeperException, InterruptedException Creates a path in Zookeeper, if it does not already exist, with CreateMode.PERSISTENT for the create mode and ZooDefs.Ids.OPEN_ACL_UNSAFE for ACLs. If any part of the path exists, then the rest of this path will be appended to it..- Parameters:
path
-zk
-- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
makePath
public static void makePath(String path, byte[] data, org.apache.zookeeper.ZooKeeper zk) throws org.apache.zookeeper.KeeperException, InterruptedException - Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
makePath
public static void makePath(String path, byte[] data, org.apache.zookeeper.ZooKeeper zk, org.apache.zookeeper.CreateMode createMode) throws org.apache.zookeeper.KeeperException, InterruptedException - Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
makePath
@Deprecated public static void makePath(String path, byte[] data, org.apache.zookeeper.ZooKeeper zk, org.apache.zookeeper.CreateMode createMode, List<org.apache.zookeeper.data.ACL> acls) throws org.apache.zookeeper.KeeperException, InterruptedException Deprecated.Creates a path in Zookeeper, specified by the path argument. For example: /path/to/my/element. If part or all of the path already exists, then it will not be created. If the data byte array is not null and has a size greater than 0, then it will be added to the final node of the path. If the final node of the path already exists, then the data will be ignored. If the ACLs are null or empty, then ZooDefs.Ids.OPEN_ACL_UNSAFE will be used. If createMode is null, then CreateMode.PERSISTENT will be used.- Parameters:
path
-data
-zk
-createMode
-acls
-- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
makePath
public static void makePath(String path, byte[] data, org.apache.solr.common.cloud.SolrZkClient zk, org.apache.zookeeper.CreateMode createMode, List<org.apache.zookeeper.data.ACL> acls) throws org.apache.zookeeper.KeeperException, InterruptedException Creates a path in Zookeeper, specified by the path argument. For example: /path/to/my/element. If part or all of the path already exists, then it will not be created. If the data byte array is not null and has a size greater than 0, then it will be added to the final node of the path. If the final node of the path already exists, then the data will be ignored. If the ACLs are null or empty, then ZooDefs.Ids.OPEN_ACL_UNSAFE will be used. If createMode is null, then CreateMode.PERSISTENT will be used.- Parameters:
path
- the path to createdata
- the bytes to append to the final node of the pathzk
- the ZooKeeper clientcreateMode
- the create mode to useacls
- the acls for the node- Throws:
org.apache.zookeeper.KeeperException
- if there was an issue making the requestInterruptedException
- if the thread was interrupted
-
exists
@Deprecated public static boolean exists(String path, org.apache.zookeeper.ZooKeeper zk) throws org.apache.zookeeper.KeeperException, InterruptedException Deprecated.useexists(String, SolrZkClient)
insteadExecuteZooKeeper.exists(String, boolean)
with retry.- Parameters:
path
- the path to checkzk
- the ZooKeeper client- Returns:
- the result of the call
- Throws:
org.apache.zookeeper.KeeperException
- if there was an issue making the requestInterruptedException
- if the thread was interrupted
-
exists
public static boolean exists(String path, org.apache.solr.common.cloud.SolrZkClient zk) throws org.apache.zookeeper.KeeperException, InterruptedException ExecuteSolrZkClient.exists(String, boolean)
with retry.- Parameters:
path
- the path to checkzk
- the ZooKeeper client- Returns:
- the result of the call
- Throws:
org.apache.zookeeper.KeeperException
- if there was an issue making the requestInterruptedException
- if the thread was interrupted
-
exists(String, SolrZkClient)
instead