Class ZKConfig

java.lang.Object
org.apache.hadoop.hbase.zookeeper.ZKConfig

@Private public final class ZKConfig extends Object
Utility methods for reading, and building the ZooKeeper configuration. The order and priority for reading the config are as follows:
  1. Property with "hbase.zookeeper.property." prefix from HBase XML.
  2. other zookeeper related properties in HBASE XML
  • Field Details

  • Constructor Details

  • Method Details

    • makeZKProps

      public static Properties makeZKProps(org.apache.hadoop.conf.Configuration conf)
      Make a Properties object holding ZooKeeper config. Parses the corresponding config options from the HBase XML configs and generates the appropriate ZooKeeper properties.
      Parameters:
      conf - Configuration to read from.
      Returns:
      Properties holding mappings representing ZooKeeper config file.
    • extractZKPropsFromHBaseConfig

      private static Properties extractZKPropsFromHBaseConfig(org.apache.hadoop.conf.Configuration conf)
      Directly map all the hbase.zookeeper.property.KEY properties. Synchronize on conf so no loading of configs while we iterate
    • makeZKPropsFromHbaseConfig

      private static Properties makeZKPropsFromHbaseConfig(org.apache.hadoop.conf.Configuration conf)
      Make a Properties object holding ZooKeeper config. Parses the corresponding config options from the HBase XML configs and generates the appropriate ZooKeeper properties.
      Parameters:
      conf - Configuration to read from.
      Returns:
      Properties holding mappings representing ZooKeeper config file.
    • getZKQuorumServersStringFromHbaseConfig

      private static String getZKQuorumServersStringFromHbaseConfig(org.apache.hadoop.conf.Configuration conf)
      Return the ZK Quorum servers string given the specified configuration
      Returns:
      Quorum servers String
    • getZKQuorumServersString

      public static String getZKQuorumServersString(org.apache.hadoop.conf.Configuration conf)
      Return the ZK Quorum servers string given the specified configuration.
      Returns:
      Quorum servers
    • buildZKQuorumServerString

      public static String buildZKQuorumServerString(String[] serverHosts, String clientPort)
      Build the ZK quorum server string with "server:clientport" list, separated by ','
      Parameters:
      serverHosts - a list of servers for ZK quorum
      clientPort - the default client port
      Returns:
      the string for a list of "server:port" separated by ","
    • validateClusterKey

      public static void validateClusterKey(String key) throws IOException
      Verifies that the given key matches the expected format for a ZooKeeper cluster key. The Quorum for the ZK cluster can have one the following formats (see examples below):
      1. s1,s2,s3 (no client port in the list, the client port could be obtained from clientPort)
      2. s1:p1,s2:p2,s3:p3 (with client port, which could be same or different for each server, in this case, the clientPort would be ignored)
      3. s1:p1,s2,s3:p3 (mix of (1) and (2) - if port is not specified in a server, it would use the clientPort; otherwise, it would use the specified port)
      Parameters:
      key - the cluster key to validate
      Throws:
      IOException - if the key could not be parsed
    • transformClusterKey

      Separate the given key into the three configurations it should contain: hbase.zookeeper.quorum, hbase.zookeeper.client.port and zookeeper.znode.parent
      Returns:
      the three configuration in the described order
      Throws:
      IOException
    • getZooKeeperClusterKey

      public static String getZooKeeperClusterKey(org.apache.hadoop.conf.Configuration conf)
      Get the key to the ZK ensemble for this configuration without adding a name at the end
      Parameters:
      conf - Configuration to use to build the key
      Returns:
      ensemble key without a name
    • getZooKeeperClusterKey

      public static String getZooKeeperClusterKey(org.apache.hadoop.conf.Configuration conf, String name)
      Get the key to the ZK ensemble for this configuration and append a name at the end
      Parameters:
      conf - Configuration to use to build the key
      name - Name that should be appended at the end if not empty or null
      Returns:
      ensemble key with a name (if any)
    • standardizeZKQuorumServerString

      public static String standardizeZKQuorumServerString(String quorumStringInput, String clientPort)
      Standardize the ZK quorum string: make it a "server:clientport" list, separated by ','
      Parameters:
      quorumStringInput - a string contains a list of servers for ZK quorum
      clientPort - the default client port
      Returns:
      the string for a list of "server:port" separated by ","
    • getZKClientConfig

      public static org.apache.zookeeper.client.ZKClientConfig getZKClientConfig(org.apache.hadoop.conf.Configuration conf)
    • getClientZKQuorumServersString

      public static String getClientZKQuorumServersString(org.apache.hadoop.conf.Configuration conf)
      Get the client ZK Quorum servers string
      Parameters:
      conf - the configuration to read
      Returns:
      Client quorum servers, or null if not specified