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 d576d590a..d5e11189f 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 4f87afa38..7703e48b0 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 deca0ecf4..7246bdfce 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,