21
21
import java .util .List ;
22
22
import java .util .Map .Entry ;
23
23
import java .util .Properties ;
24
- import java .util .Set ;
25
24
import org .apache .commons .validator .routines .InetAddressValidator ;
26
25
import org .apache .hadoop .conf .Configuration ;
27
26
import org .apache .hadoop .hbase .HConstants ;
28
27
import org .apache .hadoop .util .StringUtils ;
29
28
import org .apache .yetus .audience .InterfaceAudience ;
30
29
31
30
import org .apache .hbase .thirdparty .com .google .common .base .Splitter ;
32
- import org .apache .hbase .thirdparty .com .google .common .collect .ImmutableSet ;
33
31
34
32
/**
35
33
* Utility methods for reading, and building the ZooKeeper configuration. The order and priority for
@@ -42,12 +40,6 @@ public final class ZKConfig {
42
40
private static final String VARIABLE_START = "${" ;
43
41
private static final String ZOOKEEPER_JAVA_PROPERTY_PREFIX = "zookeeper." ;
44
42
45
- /** Supported ZooKeeper client TLS properties */
46
- static final Set <String > ZOOKEEPER_CLIENT_TLS_PROPERTIES =
47
- ImmutableSet .of ("client.secure" , "clientCnxnSocket" , "ssl.keyStore.location" ,
48
- "ssl.keyStore.password" , "ssl.keyStore.passwordPath" , "ssl.trustStore.location" ,
49
- "ssl.trustStore.password" , "ssl.trustStore.passwordPath" );
50
-
51
43
private ZKConfig () {
52
44
}
53
45
@@ -62,16 +54,12 @@ public static Properties makeZKProps(Configuration conf) {
62
54
}
63
55
64
56
/**
65
- * Make a Properties object holding ZooKeeper config. Parses the corresponding config options from
66
- * the HBase XML configs and generates the appropriate ZooKeeper properties.
67
- * @param conf Configuration to read from.
68
- * @return Properties holding mappings representing ZooKeeper config file.
57
+ * Directly map all the hbase.zookeeper.property.KEY properties. Synchronize on conf so no loading
58
+ * of configs while we iterate
69
59
*/
70
- private static Properties makeZKPropsFromHbaseConfig ( Configuration conf ) {
60
+ private static Properties extractZKPropsFromHBaseConfig ( final Configuration conf ) {
71
61
Properties zkProperties = new Properties ();
72
62
73
- // Directly map all of the hbase.zookeeper.property.KEY properties.
74
- // Synchronize on conf so no loading of configs while we iterate
75
63
synchronized (conf ) {
76
64
for (Entry <String , String > entry : conf ) {
77
65
String key = entry .getKey ();
@@ -87,6 +75,18 @@ private static Properties makeZKPropsFromHbaseConfig(Configuration conf) {
87
75
}
88
76
}
89
77
78
+ return zkProperties ;
79
+ }
80
+
81
+ /**
82
+ * Make a Properties object holding ZooKeeper config. Parses the corresponding config options from
83
+ * the HBase XML configs and generates the appropriate ZooKeeper properties.
84
+ * @param conf Configuration to read from.
85
+ * @return Properties holding mappings representing ZooKeeper config file.
86
+ */
87
+ private static Properties makeZKPropsFromHbaseConfig (Configuration conf ) {
88
+ Properties zkProperties = extractZKPropsFromHBaseConfig (conf );
89
+
90
90
// If clientPort is not set, assign the default.
91
91
if (zkProperties .getProperty (HConstants .CLIENT_PORT_STR ) == null ) {
92
92
zkProperties .put (HConstants .CLIENT_PORT_STR , HConstants .DEFAULT_ZOOKEEPER_CLIENT_PORT );
@@ -343,24 +343,12 @@ public static String getClientZKQuorumServersString(Configuration conf) {
343
343
}
344
344
345
345
private static void setZooKeeperClientSystemProperties (String prefix , Configuration conf ) {
346
- synchronized (conf ) {
347
- for (Entry <String , String > entry : conf ) {
348
- String key = entry .getKey ();
349
- if (!key .startsWith (prefix )) {
350
- continue ;
351
- }
352
- String zkKey = key .substring (prefix .length ());
353
- if (!ZOOKEEPER_CLIENT_TLS_PROPERTIES .contains (zkKey )) {
354
- continue ;
355
- }
356
- String value = entry .getValue ();
357
- // If the value has variables substitutions, need to do a get.
358
- if (value .contains (VARIABLE_START )) {
359
- value = conf .get (key );
360
- }
361
- if (System .getProperty (ZOOKEEPER_JAVA_PROPERTY_PREFIX + zkKey ) == null ) {
362
- System .setProperty (ZOOKEEPER_JAVA_PROPERTY_PREFIX + zkKey , value );
363
- }
346
+ Properties zkProperties = extractZKPropsFromHBaseConfig (conf );
347
+ for (Entry <Object , Object > entry : zkProperties .entrySet ()) {
348
+ String key = entry .getKey ().toString ().trim ();
349
+ String value = entry .getValue ().toString ().trim ();
350
+ if (System .getProperty (ZOOKEEPER_JAVA_PROPERTY_PREFIX + key ) == null ) {
351
+ System .setProperty (ZOOKEEPER_JAVA_PROPERTY_PREFIX + key , value );
364
352
}
365
353
}
366
354
}
0 commit comments