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

yao pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/branch-1.4 by this push:
     new 9aff63e  [KYUUBI #1404] Decouple zookeeper persistentNode from other 
modules
9aff63e is described below

commit 9aff63e128477a652fb8b160f4d5007bf3263fef
Author: hongdongdong <[email protected]>
AuthorDate: Tue Nov 23 17:10:54 2021 +0800

    [KYUUBI #1404] Decouple zookeeper persistentNode from other modules
    
    <!--
    Thanks for sending a pull request!
    
    Here are some tips for you:
      1. If this is your first time, please read our contributor guidelines: 
https://kyuubi.readthedocs.io/en/latest/community/contributions.html
      2. If the PR is related to an issue in 
https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your 
PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
      3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., 
'[WIP][KYUUBI #XXXX] Your PR title ...'.
    -->
    
    ### _Why are the changes needed?_
    <!--
    Please clarify why the changes are needed. For instance,
      1. If you add a feature, you can talk about the use case of it.
      2. If you fix a bug, you can clarify why it is a bug.
    -->
    Decouple zookeeper persistentNode from other modules
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including 
negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [X] [Run 
test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #1405 from hddong/decouple-persistentNode.
    
    Closes #1404
    
    fcdce91d [hongdongdong] [KYUUBI #1404] Decouple zookeeper persistentNode 
from other modules
    
    Authored-by: hongdongdong <[email protected]>
    Signed-off-by: Kent Yao <[email protected]>
    (cherry picked from commit e19d463e85fdc252d74ea3d2cdf85b1a75ebacbb)
    Signed-off-by: Kent Yao <[email protected]>
---
 .../org/apache/kyuubi/ctl/ServiceControlCli.scala    |  4 ++--
 .../apache/kyuubi/ctl/ServiceControlCliSuite.scala   | 20 ++++++++++----------
 .../apache/kyuubi/ha/client/ServiceDiscovery.scala   | 12 +++++++++++-
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git 
a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/ServiceControlCli.scala 
b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/ServiceControlCli.scala
index d576d59..d5e1118 100644
--- a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/ServiceControlCli.scala
+++ b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/ServiceControlCli.scala
@@ -94,7 +94,7 @@ private[kyuubi] class ServiceControlCli extends Logging {
           currentServerNodes.foreach { sn =>
             info(s"Exposing server instance:${sn.instance} with 
version:${sn.version}" +
               s" from $fromNamespace to $toNamespace")
-            val newNode = createServiceNode(
+            val newNodePath = createAndGetServiceNode(
               kyuubiConf,
               zc,
               args.cliArgs.namespace,
@@ -103,7 +103,7 @@ private[kyuubi] class ServiceControlCli extends Logging {
               true)
             exposedServiceNodes += sn.copy(
               namespace = toNamespace,
-              nodeName = newNode.getActualPath.split("/").last)
+              nodeName = newNodePath.split("/").last)
           }
         }
 
diff --git 
a/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ServiceControlCliSuite.scala 
b/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ServiceControlCliSuite.scala
index 4f87afa..7703e48 100644
--- 
a/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ServiceControlCliSuite.scala
+++ 
b/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ServiceControlCliSuite.scala
@@ -197,8 +197,8 @@ class ServiceControlCliSuite extends KyuubiFunSuite with 
TestPrematureExit {
     System.setProperty(HA_ZK_NAMESPACE.key, uniqueNamespace)
 
     withZkClient(conf) { framework =>
-      createServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
-      createServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
+      createAndGetServiceNode(conf, framework, uniqueNamespace, 
"localhost:10000")
+      createAndGetServiceNode(conf, framework, uniqueNamespace, 
"localhost:10001")
 
       val newNamespace = getUniqueNamespace()
       val args = Array(
@@ -260,8 +260,8 @@ class ServiceControlCliSuite extends KyuubiFunSuite with 
TestPrematureExit {
       .set(KyuubiConf.FRONTEND_THRIFT_BINARY_BIND_PORT, 0)
 
     withZkClient(conf) { framework =>
-      createServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
-      createServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
+      createAndGetServiceNode(conf, framework, uniqueNamespace, 
"localhost:10000")
+      createAndGetServiceNode(conf, framework, uniqueNamespace, 
"localhost:10001")
 
       val args = Array(
         "list",
@@ -289,8 +289,8 @@ class ServiceControlCliSuite extends KyuubiFunSuite with 
TestPrematureExit {
       .set(KyuubiConf.FRONTEND_THRIFT_BINARY_BIND_PORT, 0)
 
     withZkClient(conf) { framework =>
-      createServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
-      createServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
+      createAndGetServiceNode(conf, framework, uniqueNamespace, 
"localhost:10000")
+      createAndGetServiceNode(conf, framework, uniqueNamespace, 
"localhost:10001")
 
       val args = Array(
         "get",
@@ -322,8 +322,8 @@ class ServiceControlCliSuite extends KyuubiFunSuite with 
TestPrematureExit {
 
     withZkClient(conf) { framework =>
       withZkClient(conf) { zc =>
-        createServiceNode(conf, zc, uniqueNamespace, "localhost:10000", 
external = true)
-        createServiceNode(conf, zc, uniqueNamespace, "localhost:10001", 
external = true)
+        createAndGetServiceNode(conf, zc, uniqueNamespace, "localhost:10000", 
external = true)
+        createAndGetServiceNode(conf, zc, uniqueNamespace, "localhost:10001", 
external = true)
       }
 
       val args = Array(
@@ -355,8 +355,8 @@ class ServiceControlCliSuite extends KyuubiFunSuite with 
TestPrematureExit {
       .set(KyuubiConf.FRONTEND_THRIFT_BINARY_BIND_PORT, 0)
 
     withZkClient(conf) { framework =>
-      createServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
-      createServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
+      createAndGetServiceNode(conf, framework, uniqueNamespace, 
"localhost:10000")
+      createAndGetServiceNode(conf, framework, uniqueNamespace, 
"localhost:10001")
 
       val args = Array(
         "list",
diff --git 
a/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/ServiceDiscovery.scala 
b/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/ServiceDiscovery.scala
index deca0ec..7246bdf 100644
--- 
a/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/ServiceDiscovery.scala
+++ 
b/kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/ServiceDiscovery.scala
@@ -225,7 +225,17 @@ object ServiceDiscovery extends Logging {
     }
   }
 
-  def createServiceNode(
+  def createAndGetServiceNode(
+      conf: KyuubiConf,
+      zkClient: CuratorFramework,
+      namespace: String,
+      instance: String,
+      version: Option[String] = None,
+      external: Boolean = false): String = {
+    createServiceNode(conf, zkClient, namespace, instance, version, 
external).getActualPath
+  }
+
+  private def createServiceNode(
       conf: KyuubiConf,
       zkClient: CuratorFramework,
       namespace: String,

Reply via email to