This is an automated email from the ASF dual-hosted git repository.

stoty pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new f5b063df4bc HBASE-29248 HBASE-28529 made an incompatible change to 
hbase.zookeeper.property handling (#6898)
f5b063df4bc is described below

commit f5b063df4bc7a992d883e6e1eb913fc0ea7527c3
Author: Istvan Toth <[email protected]>
AuthorDate: Mon Apr 14 06:52:31 2025 +0200

    HBASE-29248 HBASE-28529 made an incompatible change to 
hbase.zookeeper.property handling (#6898)
    
    Signed-off-by: Duo Zhang <[email protected]>
---
 .../apache/hadoop/hbase/zookeeper/ZKConfig.java    | 34 +++++++++++++++++-----
 .../hadoop/hbase/zookeeper/TestZKConfig.java       | 24 ++++++++++++++-
 2 files changed, 50 insertions(+), 8 deletions(-)

diff --git 
a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java 
b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java
index 0edde8da266..828e943cadb 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java
@@ -33,14 +33,19 @@ import 
org.apache.hbase.thirdparty.com.google.common.base.Splitter;
  * Utility methods for reading, and building the ZooKeeper configuration. The 
order and priority for
  * reading the config are as follows:
  * <ol>
- * <li>Property with "hbase.zookeeper.property." prefix from HBase XML.</li>
+ * <li>Property with "hbase.zookeeper.property." prefix from HBase XML is 
added with "zookeeper."
+ * prefix</li>
  * <li>other zookeeper related properties in HBASE XML</li>
  * </ol>
  */
+/**
+ *
+ */
 @InterfaceAudience.Private
 public final class ZKConfig {
 
   private static final String VARIABLE_START = "${";
+  private static final String ZOOKEEPER_JAVA_PROPERTY_PREFIX = "zookeeper.";
 
   private ZKConfig() {
   }
@@ -55,11 +60,26 @@ public final class ZKConfig {
     return makeZKPropsFromHbaseConfig(conf);
   }
 
+  private static Properties extractZKClientPropsFromHBaseConfig(final 
Configuration conf) {
+    return extractZKPropsFromHBaseConfig(conf, ZOOKEEPER_JAVA_PROPERTY_PREFIX);
+  }
+
+  // This is only used for the in-process ZK Quorums used mainly for testing, 
not for
+  // deployments with an external Zookeeper.
+  private static Properties extractZKServerPropsFromHBaseConfig(final 
Configuration conf) {
+    return extractZKPropsFromHBaseConfig(conf, "");
+  }
+
   /**
-   * Directly map all the hbase.zookeeper.property.KEY properties. Synchronize 
on conf so no loading
-   * of configs while we iterate
+   * 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.
    */
-  private static Properties extractZKPropsFromHBaseConfig(final Configuration 
conf) {
+  private static Properties extractZKPropsFromHBaseConfig(final Configuration 
conf,
+    final String targetPrefix) {
     Properties zkProperties = new Properties();
 
     synchronized (conf) {
@@ -72,7 +92,7 @@ public final class ZKConfig {
           if (value.contains(VARIABLE_START)) {
             value = conf.get(key);
           }
-          zkProperties.setProperty(zkKey, value);
+          zkProperties.setProperty(targetPrefix + zkKey, value);
         }
       }
     }
@@ -87,7 +107,7 @@ public final class ZKConfig {
    * @return Properties holding mappings representing ZooKeeper config file.
    */
   private static Properties makeZKPropsFromHbaseConfig(Configuration conf) {
-    Properties zkProperties = extractZKPropsFromHBaseConfig(conf);
+    Properties zkProperties = extractZKServerPropsFromHBaseConfig(conf);
 
     // If clientPort is not set, assign the default.
     if (zkProperties.getProperty(HConstants.CLIENT_PORT_STR) == null) {
@@ -302,7 +322,7 @@ public final class ZKConfig {
   }
 
   public static ZKClientConfig getZKClientConfig(Configuration conf) {
-    Properties zkProperties = extractZKPropsFromHBaseConfig(conf);
+    Properties zkProperties = extractZKClientPropsFromHBaseConfig(conf);
     ZKClientConfig zkClientConfig = new ZKClientConfig();
     zkProperties.forEach((k, v) -> zkClientConfig.setProperty(k.toString(), 
v.toString()));
     return zkClientConfig;
diff --git 
a/hbase-common/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKConfig.java
 
b/hbase-common/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKConfig.java
index 2a7b7bc2768..b5d52f44f81 100644
--- 
a/hbase-common/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKConfig.java
+++ 
b/hbase-common/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKConfig.java
@@ -106,6 +106,8 @@ public class TestZKConfig {
     Configuration conf = HBaseConfiguration.create();
     for (String p : ZOOKEEPER_CLIENT_TLS_PROPERTIES) {
       conf.set(HConstants.ZK_CFG_PROPERTY_PREFIX + p, p);
+      String zkprop = "zookeeper." + p;
+      System.clearProperty(zkprop);
     }
 
     // Act
@@ -113,7 +115,27 @@ public class TestZKConfig {
 
     // Assert
     for (String p : ZOOKEEPER_CLIENT_TLS_PROPERTIES) {
-      assertEquals("Invalid or unset system property: " + p, p, 
zkClientConfig.getProperty(p));
+      assertEquals("Invalid or unset system property: " + p, p,
+        zkClientConfig.getProperty("zookeeper." + p));
+    }
+  }
+
+  @Test
+  public void testZooKeeperTlsPropertiesHQuorumPeer() {
+    // Arrange
+    Configuration conf = HBaseConfiguration.create();
+    for (String p : ZOOKEEPER_CLIENT_TLS_PROPERTIES) {
+      conf.set(HConstants.ZK_CFG_PROPERTY_PREFIX + p, p);
+      String zkprop = "zookeeper." + p;
+      System.clearProperty(zkprop);
+    }
+
+    // Act
+    Properties zkProps = ZKConfig.makeZKProps(conf);
+
+    // Assert
+    for (String p : ZOOKEEPER_CLIENT_TLS_PROPERTIES) {
+      assertEquals("Invalid or unset system property: " + p, p, 
zkProps.getProperty(p));
     }
   }
 

Reply via email to