Class ZKConfig
java.lang.Object
org.apache.hadoop.hbase.zookeeper.ZKConfig
Utility methods for reading, and building the ZooKeeper configuration. The order and priority for
reading the config are as follows:
- Property with "hbase.zookeeper.property." prefix from HBase XML.
- other zookeeper related properties in HBASE XML
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildZKQuorumServerString(String[] serverHosts, String clientPort) Build the ZK quorum server string with "server:clientport" list, separated by ','private static PropertiesextractZKPropsFromHBaseConfig(org.apache.hadoop.conf.Configuration conf) Directly map all the hbase.zookeeper.property.KEY properties.static StringgetClientZKQuorumServersString(org.apache.hadoop.conf.Configuration conf) Get the client ZK Quorum servers stringstatic org.apache.zookeeper.client.ZKClientConfiggetZKClientConfig(org.apache.hadoop.conf.Configuration conf) static StringgetZKQuorumServersString(org.apache.hadoop.conf.Configuration conf) Return the ZK Quorum servers string given the specified configuration.private static StringgetZKQuorumServersStringFromHbaseConfig(org.apache.hadoop.conf.Configuration conf) Return the ZK Quorum servers string given the specified configurationstatic StringgetZooKeeperClusterKey(org.apache.hadoop.conf.Configuration conf) Get the key to the ZK ensemble for this configuration without adding a name at the endstatic StringgetZooKeeperClusterKey(org.apache.hadoop.conf.Configuration conf, String name) Get the key to the ZK ensemble for this configuration and append a name at the endstatic PropertiesmakeZKProps(org.apache.hadoop.conf.Configuration conf) Make a Properties object holding ZooKeeper config.private static PropertiesmakeZKPropsFromHbaseConfig(org.apache.hadoop.conf.Configuration conf) Make a Properties object holding ZooKeeper config.static StringstandardizeZKQuorumServerString(String quorumStringInput, String clientPort) Standardize the ZK quorum string: make it a "server:clientport" list, separated by ','static ZKConfig.ZKClusterKeySeparate the given key into the three configurations it should contain: hbase.zookeeper.quorum, hbase.zookeeper.client.port and zookeeper.znode.parentstatic voidvalidateClusterKey(String key) Verifies that the given key matches the expected format for a ZooKeeper cluster key.
-
Field Details
-
VARIABLE_START
- See Also:
-
-
Constructor Details
-
ZKConfig
private ZKConfig()
-
-
Method Details
-
makeZKProps
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
Directly map all the hbase.zookeeper.property.KEY properties. Synchronize on conf so no loading of configs while we iterate -
makeZKPropsFromHbaseConfig
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
Return the ZK Quorum servers string given the specified configuration.- Returns:
- Quorum servers
-
buildZKQuorumServerString
Build the ZK quorum server string with "server:clientport" list, separated by ','- Parameters:
serverHosts- a list of servers for ZK quorumclientPort- the default client port- Returns:
- the string for a list of "server:port" separated by ","
-
validateClusterKey
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):- s1,s2,s3 (no client port in the list, the client port could be obtained from clientPort)
- 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)
- 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
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
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 keyname- Name that should be appended at the end if not empty or null- Returns:
- ensemble key with a name (if any)
-
standardizeZKQuorumServerString
Standardize the ZK quorum string: make it a "server:clientport" list, separated by ','- Parameters:
quorumStringInput- a string contains a list of servers for ZK quorumclientPort- 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
Get the client ZK Quorum servers string- Parameters:
conf- the configuration to read- Returns:
- Client quorum servers, or null if not specified
-