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

vjasani pushed a commit to branch 5.1
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/5.1 by this push:
     new fe18170329 PHOENIX-7533 Fix broken compatibility for Zookeeper based 
ConnectionI… (#2121)
fe18170329 is described below

commit fe181703290d77284402ad192ae492bb3d1edd87
Author: Norbert Meszaros <meszinorbi2...@gmail.com>
AuthorDate: Sat Apr 26 02:17:04 2025 +0200

    PHOENIX-7533 Fix broken compatibility for Zookeeper based ConnectionI… 
(#2121)
---
 .../org/apache/phoenix/jdbc/ConnectionInfo.java    |  2 +-
 .../org/apache/phoenix/jdbc/RPCConnectionInfo.java |  2 +-
 .../org/apache/phoenix/jdbc/ZKConnectionInfo.java  |  1 +
 .../phoenix/query/ConnectionQueryServicesImpl.java | 26 +++++++++++++++
 .../phoenix/jdbc/PhoenixEmbeddedDriverTest.java    | 38 ++++++++++++++++++++++
 5 files changed, 67 insertions(+), 2 deletions(-)

diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java
index 641e12c19e..9c29a21471 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java
@@ -52,7 +52,7 @@ public abstract class ConnectionInfo {
             + " determined. Ignoring realm equivalency check.";
     protected static final String TERMINATOR = "" + 
PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
     protected static final String DELIMITERS = TERMINATOR + 
PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
-    protected static final String CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY =
+    public static final String CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY =
             "hbase.client.registry.impl";
 
     protected static final boolean HAS_MASTER_REGISTRY;
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/RPCConnectionInfo.java 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/RPCConnectionInfo.java
index 0837bc362e..74e5832196 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/RPCConnectionInfo.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/RPCConnectionInfo.java
@@ -36,7 +36,7 @@ import org.apache.phoenix.util.ReadOnlyProps;
 public class RPCConnectionInfo extends AbstractRPCConnectionInfo {
 
     // We may be on an older HBase version, which does not even have 
RpcConnectionRegistry
-    private static final String BOOTSTRAP_NODES = 
"hbase.client.bootstrap.servers";
+    public static final String BOOTSTRAP_NODES = 
"hbase.client.bootstrap.servers";
     private static final String RPC_REGISTRY_CLASS_NAME =
             "org.apache.hadoop.hbase.client.RpcConnectionRegistry";
 
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/ZKConnectionInfo.java 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/ZKConnectionInfo.java
index 1570fcd447..d16aa42ffe 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/ZKConnectionInfo.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/ZKConnectionInfo.java
@@ -82,6 +82,7 @@ public class ZKConnectionInfo extends ConnectionInfo {
         if (getZkHosts() != null) {
             //This has the highest priority
             connectionProps.put(HConstants.CLIENT_ZOOKEEPER_QUORUM, 
getZkHosts());
+            connectionProps.put(HConstants.ZOOKEEPER_QUORUM, getZkHosts());
         }
         //Port is already normalized into zkHosts
         if (getZkRootNode() != null) {
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index b6adfe07a1..977b6ce41d 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -22,6 +22,7 @@ import static 
org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder.KEEP_
 import static 
org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder.MAX_VERSIONS;
 import static 
org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder.REPLICATION_SCOPE;
 import static org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder.TTL;
+import static 
org.apache.hadoop.hbase.client.MetricsConnection.CLIENT_SIDE_METRICS_ENABLED_KEY;
 import static 
org.apache.phoenix.coprocessor.MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP;
 import static 
org.apache.phoenix.coprocessor.MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_15_0;
 import static 
org.apache.phoenix.coprocessor.MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_16_0;
@@ -222,6 +223,7 @@ import 
org.apache.phoenix.iterate.TableResultIterator.RenewLeaseStatus;
 import org.apache.phoenix.jdbc.ConnectionInfo;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.jdbc.RPCConnectionInfo;
 import org.apache.phoenix.log.QueryLoggerDisruptor;
 import org.apache.phoenix.parse.PFunction;
 import org.apache.phoenix.parse.PSchema;
@@ -429,6 +431,24 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
         // Without making a copy of the configuration we cons up, we lose some 
of our properties
         // on the server side during testing.
         this.config = 
HBaseFactoryProvider.getConfigurationFactory().getConfiguration(config);
+
+
+        LOGGER.info(
+                "CQS Configs {} = {} , {} = {} , {} = {} , {} = {} , {} = {} , 
{} = {} , {} = {}",
+                HConstants.ZOOKEEPER_QUORUM,
+                this.config.get(HConstants.ZOOKEEPER_QUORUM), 
HConstants.CLIENT_ZOOKEEPER_QUORUM,
+                this.config.get(HConstants.CLIENT_ZOOKEEPER_QUORUM),
+                HConstants.CLIENT_ZOOKEEPER_CLIENT_PORT,
+                this.config.get(HConstants.CLIENT_ZOOKEEPER_CLIENT_PORT),
+                HConstants.ZOOKEEPER_CLIENT_PORT,
+                this.config.get(HConstants.ZOOKEEPER_CLIENT_PORT),
+                RPCConnectionInfo.BOOTSTRAP_NODES,
+                this.config.get(RPCConnectionInfo.BOOTSTRAP_NODES),
+                HConstants.MASTER_ADDRS_KEY, 
this.config.get(HConstants.MASTER_ADDRS_KEY),
+                ConnectionInfo.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY,
+                
this.config.get(ConnectionInfo.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY));
+
+
         // set replication required parameter
         ConfigUtil.setReplicationConfigIfAbsent(this.config);
         this.props = new ReadOnlyProps(this.config.iterator());
@@ -468,6 +488,12 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
                 e.printStackTrace();
             }
         }
+        if (this.config.getBoolean(CLIENT_SIDE_METRICS_ENABLED_KEY, false)) {
+            // "hbase.client.metrics.scope" defined on
+            // 
org.apache.hadoop.hbase.client.MetricsConnection#METRICS_SCOPE_KEY
+            // however we cannot use the constant directly as long as we 
support HBase 2.4 profile.
+            this.config.set("hbase.client.metrics.scope", 
connectionInfo.getPrincipal());
+        }
 
     }
 
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java
 
b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java
index fe439d7462..cf41c1a45f 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixEmbeddedDriverTest.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.util.VersionInfo;
 import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.query.HBaseFactoryProvider;
+import org.apache.phoenix.util.ReadOnlyProps;
 import org.junit.Test;
 
 public class PhoenixEmbeddedDriverTest {
@@ -564,4 +565,41 @@ public class PhoenixEmbeddedDriverTest {
         assertFalse(ConnectionInfo.isSameName("user/localh...@apache.net", 
"user/_HOST", "localhost", "APACHE.ORG"));
         assertFalse(ConnectionInfo.isSameName("user/foo...@apache.net", 
"user/_HOST", "foobar", "APACHE.ORG"));
     }
+
+    @Test
+    public void testZkQuorumConfigs() throws Exception {
+        ConnectionInfo connectionInfo = 
ConnectionInfo.create("jdbc:phoenix+zk:"
+                + 
"localhost\\:2181,127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+                + "test=true", null, null);
+        ReadOnlyProps props = connectionInfo.asProps();
+        
assertEquals("127.23.45.678:7634,host123.48576:723,localhost:2181,v3:1",
+                props.get(HConstants.ZOOKEEPER_QUORUM));
+        
assertEquals("127.23.45.678:7634,host123.48576:723,localhost:2181,v3:1",
+                props.get(HConstants.CLIENT_ZOOKEEPER_QUORUM));
+
+        connectionInfo = ConnectionInfo.create("jdbc:phoenix:"
+                + 
"localhost\\:2181,127.23.45.678\\:7634,v3\\:1,host123.48576\\:723:/hbase;"
+                + "test=true", null, null);
+        props = connectionInfo.asProps();
+        
assertEquals("127.23.45.678:7634,host123.48576:723,localhost:2181,v3:1",
+                props.get(HConstants.ZOOKEEPER_QUORUM));
+        
assertEquals("127.23.45.678:7634,host123.48576:723,localhost:2181,v3:1",
+                props.get(HConstants.CLIENT_ZOOKEEPER_QUORUM));
+
+        connectionInfo = ConnectionInfo.create("jdbc:phoenix:"
+                + "localhost,v3,127.23.45.678,host987:12345:/hbase;"
+                + "test=true", null, null);
+        props = connectionInfo.asProps();
+        
assertEquals("127.23.45.678:12345,host987:12345,localhost:12345,v3:12345",
+                props.get(HConstants.ZOOKEEPER_QUORUM));
+        
assertEquals("127.23.45.678:12345,host987:12345,localhost:12345,v3:12345",
+                props.get(HConstants.CLIENT_ZOOKEEPER_QUORUM));
+
+        connectionInfo = ConnectionInfo.create("jdbc:phoenix+rpc:"
+                + 
"localhost\\:2181,127.23.45.678\\:7634,v3\\:1,host123.48576\\:723::;"
+                + "test=true", null, null);
+        props = connectionInfo.asProps();
+        assertNull(props.get(HConstants.ZOOKEEPER_QUORUM));
+        assertNull(props.get(HConstants.CLIENT_ZOOKEEPER_QUORUM));
+    }
 }

Reply via email to