private static Properties extractZKPropsFromHBaseConfig(final Configuration conf,
    final String targetPrefix) {
    Properties zkProperties = new Properties();

    synchronized (conf) {
      for (Entry<String, String> entry : conf) {
        String key = entry.getKey();
        if (key.startsWith(HConstants.ZK_CFG_PROPERTY_PREFIX)) {
          String zkKey = key.substring(HConstants.ZK_CFG_PROPERTY_PREFIX_LEN);
          String value = entry.getValue();
          // If the value has variables substitutions, need to do a get.
          if (value.contains(VARIABLE_START)) {
            value = conf.get(key);
          }
          zkProperties.setProperty(targetPrefix + zkKey, value);
        }
      }
    }

    return zkProperties;
  }
Map all hbase.zookeeper.property.KEY properties to targetPrefix.KEY. Synchronize on conf so no
loading of configs while we iterate This is rather messy, as we use the same prefix for both
ZKClientConfig and for the HQuorum properties. ZKClientConfig props all have the zookeeper.
prefix, while the HQuorum server props don't, and ZK automagically sets a system property
adding a zookeeper. prefix to the non HQuorum properties, so we need to add the "zookeeper."
prefix for ZKClientConfig but not for the HQuorum props.
hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java