You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2023/11/08 15:21:38 UTC

(phoenix-connectors) branch master updated: PHOENIX-7103 Phoenix-connectors uses the refactored ConnectionInfo class

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

stoty pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix-connectors.git


The following commit(s) were added to refs/heads/master by this push:
     new a465c90  PHOENIX-7103 Phoenix-connectors uses the refactored ConnectionInfo class
a465c90 is described below

commit a465c90f6e57af1e53650e1f1a67e5a02fca4b46
Author: Istvan Toth <st...@apache.org>
AuthorDate: Wed Nov 8 08:59:42 2023 +0100

    PHOENIX-7103 Phoenix-connectors uses the refactored ConnectionInfo class
---
 .../apache/phoenix/spark/ConfigurationUtil.scala    | 21 +++++++++++++++------
 .../apache/phoenix/spark/ConfigurationUtil.scala    | 21 +++++++++++++++------
 2 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/phoenix5-spark/src/main/scala/org/apache/phoenix/spark/ConfigurationUtil.scala b/phoenix5-spark/src/main/scala/org/apache/phoenix/spark/ConfigurationUtil.scala
index 9377986..dbd7b04 100644
--- a/phoenix5-spark/src/main/scala/org/apache/phoenix/spark/ConfigurationUtil.scala
+++ b/phoenix5-spark/src/main/scala/org/apache/phoenix/spark/ConfigurationUtil.scala
@@ -64,12 +64,21 @@ object ConfigurationUtil extends Serializable {
   }
 
   def setZookeeperURL(conf: Configuration, zkUrl: String) = {
-    val info = PhoenixEmbeddedDriver.ConnectionInfo.create(zkUrl)
-    conf.set(HConstants.ZOOKEEPER_QUORUM, info.getZookeeperQuorum)
-    if (info.getPort != null)
-      conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, info.getPort)
-    if (info.getRootNode != null)
-      conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, info.getRootNode)
+    var zk = zkUrl
+    if (zk.startsWith("jdbc:phoenix:")) {
+      zk = zk.substring("jdbc:phoenix:".length)
+    }
+    if (zk.startsWith("jdbc:phoenix+zk:")) {
+      zk = zk.substring("jdbc:phoenix+zk:".length)
+    }
+    val escapedUrl = zk.replaceAll("\\\\:","=")
+    val parts = escapedUrl.split(":")
+    if (parts.length >= 1 && parts(0).length()>0)
+      conf.set(HConstants.ZOOKEEPER_QUORUM, parts(0).replaceAll("=", "\\\\:"))
+    if (parts.length >= 2 && parts(1).length()>0)
+      conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.parseInt(parts(1).replaceAll("=", "\\\\:")))
+    if (parts.length >= 3 && parts(2).length()>0)
+      conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, parts(2).replaceAll("=", "\\\\:"))
   }
 
   def setTenantId(conf: Configuration, tenantId: String) = {
diff --git a/phoenix5-spark3/src/main/scala/org/apache/phoenix/spark/ConfigurationUtil.scala b/phoenix5-spark3/src/main/scala/org/apache/phoenix/spark/ConfigurationUtil.scala
index 9377986..dbd7b04 100644
--- a/phoenix5-spark3/src/main/scala/org/apache/phoenix/spark/ConfigurationUtil.scala
+++ b/phoenix5-spark3/src/main/scala/org/apache/phoenix/spark/ConfigurationUtil.scala
@@ -64,12 +64,21 @@ object ConfigurationUtil extends Serializable {
   }
 
   def setZookeeperURL(conf: Configuration, zkUrl: String) = {
-    val info = PhoenixEmbeddedDriver.ConnectionInfo.create(zkUrl)
-    conf.set(HConstants.ZOOKEEPER_QUORUM, info.getZookeeperQuorum)
-    if (info.getPort != null)
-      conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, info.getPort)
-    if (info.getRootNode != null)
-      conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, info.getRootNode)
+    var zk = zkUrl
+    if (zk.startsWith("jdbc:phoenix:")) {
+      zk = zk.substring("jdbc:phoenix:".length)
+    }
+    if (zk.startsWith("jdbc:phoenix+zk:")) {
+      zk = zk.substring("jdbc:phoenix+zk:".length)
+    }
+    val escapedUrl = zk.replaceAll("\\\\:","=")
+    val parts = escapedUrl.split(":")
+    if (parts.length >= 1 && parts(0).length()>0)
+      conf.set(HConstants.ZOOKEEPER_QUORUM, parts(0).replaceAll("=", "\\\\:"))
+    if (parts.length >= 2 && parts(1).length()>0)
+      conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.parseInt(parts(1).replaceAll("=", "\\\\:")))
+    if (parts.length >= 3 && parts(2).length()>0)
+      conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, parts(2).replaceAll("=", "\\\\:"))
   }
 
   def setTenantId(conf: Configuration, tenantId: String) = {