You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ya...@apache.org on 2022/01/11 14:24:31 UTC
[incubator-kyuubi] branch master updated: [KYUUBI #1730] Use getHostName instead of getCanonicalHostName
This is an automated email from the ASF dual-hosted git repository.
yao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new 4f9922b [KYUUBI #1730] Use getHostName instead of getCanonicalHostName
4f9922b is described below
commit 4f9922b3d8a1faec80b96149b2d6cc19ac83e195
Author: Kent Yao <ya...@apache.org>
AuthorDate: Tue Jan 11 22:24:21 2022 +0800
[KYUUBI #1730] Use getHostName instead of getCanonicalHostName
<!--
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.
-->
### _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 #1730 from yaooqinn/zk.
Closes #1730
37bfe10c [Kent Yao] do not merge
fbf05df7 [Kent Yao] do not merge
Authored-by: Kent Yao <ya...@apache.org>
Signed-off-by: Kent Yao <ya...@apache.org>
---
.../kyuubi/zookeeper/EmbeddedZookeeper.scala | 5 ++---
.../kyuubi/zookeeper/EmbeddedZookeeperSuite.scala | 26 +++++-----------------
2 files changed, 8 insertions(+), 23 deletions(-)
diff --git a/kyuubi-zookeeper/src/main/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeper.scala b/kyuubi-zookeeper/src/main/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeper.scala
index 24aaba2..72d65e8 100644
--- a/kyuubi-zookeeper/src/main/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeper.scala
+++ b/kyuubi-zookeeper/src/main/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeper.scala
@@ -43,8 +43,7 @@ class EmbeddedZookeeper extends AbstractService("EmbeddedZookeeper") {
val maxClientCnxns = conf.get(ZK_MAX_CLIENT_CONNECTIONS)
val minSessionTimeout = conf.get(ZK_MIN_SESSION_TIMEOUT)
val maxSessionTimeout = conf.get(ZK_MAX_SESSION_TIMEOUT)
- host = conf.get(ZK_CLIENT_PORT_ADDRESS)
- .getOrElse(findLocalInetAddress.getCanonicalHostName)
+ host = conf.get(ZK_CLIENT_PORT_ADDRESS).getOrElse(findLocalInetAddress.getHostName)
zks = new ZooKeeperServer(dataDirectory, dataDirectory, tickTime)
zks.setMinSessionTimeout(minSessionTimeout)
@@ -75,6 +74,6 @@ class EmbeddedZookeeper extends AbstractService("EmbeddedZookeeper") {
def getConnectString: String = synchronized {
assert(zks != null, s"$getName is in $getServiceState")
- s"${host}:${serverFactory.getLocalPort}"
+ s"$host:${serverFactory.getLocalPort}"
}
}
diff --git a/kyuubi-zookeeper/src/test/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeperSuite.scala b/kyuubi-zookeeper/src/test/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeperSuite.scala
index 837e0c3..518aa48 100644
--- a/kyuubi-zookeeper/src/test/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeperSuite.scala
+++ b/kyuubi-zookeeper/src/test/scala/org/apache/kyuubi/zookeeper/EmbeddedZookeeperSuite.scala
@@ -23,32 +23,18 @@ import org.apache.curator.retry.ExponentialBackoffRetry
import org.apache.kyuubi.KyuubiFunSuite
import org.apache.kyuubi.config.KyuubiConf
-import org.apache.kyuubi.service.ServiceState._
import org.apache.kyuubi.zookeeper.ZookeeperConf.{ZK_CLIENT_PORT, ZK_CLIENT_PORT_ADDRESS}
class EmbeddedZookeeperSuite extends KyuubiFunSuite {
+ private var zkServer: EmbeddedZookeeper = _
- test("embedded zookeeper server") {
- val zkServer = new EmbeddedZookeeper()
- assert(zkServer.getConf == null)
- assert(zkServer.getName === zkServer.getClass.getSimpleName)
- assert(zkServer.getServiceState === LATENT)
- val conf = KyuubiConf()
- conf.set(ZookeeperConf.ZK_CLIENT_PORT, 0)
- zkServer.stop() // only for test coverage
- zkServer.initialize(conf)
- assert(zkServer.getConf === conf)
- assert(zkServer.getServiceState === INITIALIZED)
- assert(zkServer.getStartTime === 0)
- zkServer.start()
- assert(zkServer.getServiceState === STARTED)
- assert(zkServer.getStartTime !== 0)
- zkServer.stop()
- assert(zkServer.getServiceState === STOPPED)
+ override def afterEach(): Unit = {
+ if (zkServer != null) zkServer.stop()
+ super.afterEach()
}
test("connect test with embedded zookeeper") {
- val zkServer = new EmbeddedZookeeper()
+ zkServer = new EmbeddedZookeeper()
intercept[AssertionError](zkServer.getConnectString)
zkServer.initialize(KyuubiConf().set(ZookeeperConf.ZK_CLIENT_PORT, 0))
zkServer.start()
@@ -65,7 +51,7 @@ class EmbeddedZookeeperSuite extends KyuubiFunSuite {
}
test("use zookeeper.embedded.client.port.address cover default hostname") {
- var zkServer = new EmbeddedZookeeper()
+ zkServer = new EmbeddedZookeeper()
// cover default hostname
var conf = KyuubiConf()
.set(ZK_CLIENT_PORT, 0)