java.lang.Object
com.broadleafcommerce.search.provider.solr.util.zk.ZooKeeperUtil

public class ZooKeeperUtil extends Object
Simple utility to assist in basic operations related to Zookeeper.
Author:
Kelly Tisdell
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    deleteRecursive(String path, org.apache.zookeeper.ZooKeeper zk)
    Recursively deletes a path in Zookeeper.
    static boolean
    exists(String path, org.apache.solr.common.cloud.SolrZkClient zk)
    Execute SolrZkClient.exists(String, boolean) with retry.
    static boolean
    exists(String path, org.apache.zookeeper.ZooKeeper zk)
    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
    makePath(String path, byte[] data, org.apache.zookeeper.ZooKeeper zk)
     
    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)
    static void
    makePath(String path, org.apache.zookeeper.ZooKeeper zk)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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
      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 create
      data - the bytes to append to the final node of the path
      zk - the ZooKeeper client
      createMode - the create mode to use
      acls - the acls for the node
      Throws:
      org.apache.zookeeper.KeeperException - if there was an issue making the request
      InterruptedException - 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.
      Execute ZooKeeper.exists(String, boolean) with retry.
      Parameters:
      path - the path to check
      zk - the ZooKeeper client
      Returns:
      the result of the call
      Throws:
      org.apache.zookeeper.KeeperException - if there was an issue making the request
      InterruptedException - 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
      Execute SolrZkClient.exists(String, boolean) with retry.
      Parameters:
      path - the path to check
      zk - the ZooKeeper client
      Returns:
      the result of the call
      Throws:
      org.apache.zookeeper.KeeperException - if there was an issue making the request
      InterruptedException - if the thread was interrupted