Skip to content

Commit e19d463

Browse files
hddongyaooqinn
authored andcommitted
[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 fcdce91 [hongdongdong] [KYUUBI #1404] Decouple zookeeper persistentNode from other modules Authored-by: hongdongdong <hongdongdong@cmss.chinamobile.com> Signed-off-by: Kent Yao <yao@apache.org>
1 parent 73eeea5 commit e19d463

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/ServiceControlCli.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private[kyuubi] class ServiceControlCli extends Logging {
9494
currentServerNodes.foreach { sn =>
9595
info(s"Exposing server instance:${sn.instance} with version:${sn.version}" +
9696
s" from $fromNamespace to $toNamespace")
97-
val newNode = createServiceNode(
97+
val newNodePath = createAndGetServiceNode(
9898
kyuubiConf,
9999
zc,
100100
args.cliArgs.namespace,
@@ -103,7 +103,7 @@ private[kyuubi] class ServiceControlCli extends Logging {
103103
true)
104104
exposedServiceNodes += sn.copy(
105105
namespace = toNamespace,
106-
nodeName = newNode.getActualPath.split("/").last)
106+
nodeName = newNodePath.split("/").last)
107107
}
108108
}
109109

kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ServiceControlCliSuite.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ class ServiceControlCliSuite extends KyuubiFunSuite with TestPrematureExit {
197197
System.setProperty(HA_ZK_NAMESPACE.key, uniqueNamespace)
198198

199199
withZkClient(conf) { framework =>
200-
createServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
201-
createServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
200+
createAndGetServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
201+
createAndGetServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
202202

203203
val newNamespace = getUniqueNamespace()
204204
val args = Array(
@@ -260,8 +260,8 @@ class ServiceControlCliSuite extends KyuubiFunSuite with TestPrematureExit {
260260
.set(KyuubiConf.FRONTEND_THRIFT_BINARY_BIND_PORT, 0)
261261

262262
withZkClient(conf) { framework =>
263-
createServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
264-
createServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
263+
createAndGetServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
264+
createAndGetServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
265265

266266
val args = Array(
267267
"list",
@@ -289,8 +289,8 @@ class ServiceControlCliSuite extends KyuubiFunSuite with TestPrematureExit {
289289
.set(KyuubiConf.FRONTEND_THRIFT_BINARY_BIND_PORT, 0)
290290

291291
withZkClient(conf) { framework =>
292-
createServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
293-
createServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
292+
createAndGetServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
293+
createAndGetServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
294294

295295
val args = Array(
296296
"get",
@@ -322,8 +322,8 @@ class ServiceControlCliSuite extends KyuubiFunSuite with TestPrematureExit {
322322

323323
withZkClient(conf) { framework =>
324324
withZkClient(conf) { zc =>
325-
createServiceNode(conf, zc, uniqueNamespace, "localhost:10000", external = true)
326-
createServiceNode(conf, zc, uniqueNamespace, "localhost:10001", external = true)
325+
createAndGetServiceNode(conf, zc, uniqueNamespace, "localhost:10000", external = true)
326+
createAndGetServiceNode(conf, zc, uniqueNamespace, "localhost:10001", external = true)
327327
}
328328

329329
val args = Array(
@@ -355,8 +355,8 @@ class ServiceControlCliSuite extends KyuubiFunSuite with TestPrematureExit {
355355
.set(KyuubiConf.FRONTEND_THRIFT_BINARY_BIND_PORT, 0)
356356

357357
withZkClient(conf) { framework =>
358-
createServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
359-
createServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
358+
createAndGetServiceNode(conf, framework, uniqueNamespace, "localhost:10000")
359+
createAndGetServiceNode(conf, framework, uniqueNamespace, "localhost:10001")
360360

361361
val args = Array(
362362
"list",

kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/ServiceDiscovery.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,17 @@ object ServiceDiscovery extends Logging {
225225
}
226226
}
227227

228-
def createServiceNode(
228+
def createAndGetServiceNode(
229+
conf: KyuubiConf,
230+
zkClient: CuratorFramework,
231+
namespace: String,
232+
instance: String,
233+
version: Option[String] = None,
234+
external: Boolean = false): String = {
235+
createServiceNode(conf, zkClient, namespace, instance, version, external).getActualPath
236+
}
237+
238+
private def createServiceNode(
229239
conf: KyuubiConf,
230240
zkClient: CuratorFramework,
231241
namespace: String,

0 commit comments

Comments
 (0)