Package org.broadleafcommerce.core.util
Class ZookeeperUtil
java.lang.Object
org.broadleafcommerce.core.util.ZookeeperUtil
Simple utility to assist in basic operations related to Zookeeper.
- Author:
- Kelly Tisdell
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddeleteRecursive(String path, org.apache.zookeeper.ZooKeeper zk) Recursively deletes a path in Zookeeper.static booleanstatic voidstatic voidmakePath(String path, byte[] data, org.apache.zookeeper.ZooKeeper zk, org.apache.zookeeper.CreateMode createMode) static voidmakePath(String path, byte[] data, org.apache.zookeeper.ZooKeeper zk, org.apache.zookeeper.CreateMode createMode, List<org.apache.zookeeper.data.ACL> acls) Creates a path in Zookeeper, specified by the path argument.static voidCreates 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.KeeperExceptionInterruptedException
-
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.KeeperExceptionInterruptedException
-
makePath
public static void makePath(String path, byte[] data, org.apache.zookeeper.ZooKeeper zk) throws org.apache.zookeeper.KeeperException, InterruptedException - Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
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.KeeperExceptionInterruptedException
-
makePath
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 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.KeeperExceptionInterruptedException
-
exists
public static boolean exists(String path, org.apache.zookeeper.ZooKeeper zk) throws org.apache.zookeeper.KeeperException, InterruptedException - Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-