You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by fe...@apache.org on 2023/02/25 14:05:52 UTC
[kyuubi] branch master updated: [KYUUBI #4412][FOLLOWUP] Fallback to new engine session handle for UT
This is an automated email from the ASF dual-hosted git repository.
feiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new 787f86c88 [KYUUBI #4412][FOLLOWUP] Fallback to new engine session handle for UT
787f86c88 is described below
commit 787f86c88af91eb1a13a29b56e86bf391fc2d099
Author: fwang12 <fw...@ebay.com>
AuthorDate: Sat Feb 25 22:05:42 2023 +0800
[KYUUBI #4412][FOLLOWUP] Fallback to new engine session handle for UT
### _Why are the changes needed?_
### _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
- [ ] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request
Closes #4414 from turboFei/get_or_else.
Closes #4412
e7d45ef24 [fwang12] refactor
f8583ec94 [fwang12] use different handle for alive probe
33a776cf0 [fwang12] launch sync
967ae41fa [fwang12] [KYUUBI #4412][FOLLOWUP] Fallback to new engine session handle for UT
Authored-by: fwang12 <fw...@ebay.com>
Signed-off-by: fwang12 <fw...@ebay.com>
---
.../engine/spark/session/SparkSQLSessionManager.scala | 3 ++-
.../kyuubi/engine/spark/session/SparkSessionImpl.scala | 3 ++-
.../org/apache/kyuubi/client/KyuubiSyncThriftClient.scala | 5 ++++-
.../handler/ServerJsonLoggingEventHandlerSuite.scala | 4 ++--
.../kyuubi/operation/KyuubiOperationPerUserSuite.scala | 14 +++++++++-----
5 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSQLSessionManager.scala b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSQLSessionManager.scala
index 091149d21..677af9a03 100644
--- a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSQLSessionManager.scala
+++ b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSQLSessionManager.scala
@@ -136,7 +136,8 @@ class SparkSQLSessionManager private (name: String, spark: SparkSession)
password: String,
ipAddress: String,
conf: Map[String, String]): Session = {
- getSessionOption(SessionHandle.fromUUID(conf(KYUUBI_SESSION_HANDLE_KEY))).getOrElse {
+ conf.get(KYUUBI_SESSION_HANDLE_KEY).map(SessionHandle.fromUUID).flatMap(
+ getSessionOption).getOrElse {
val sparkSession =
try {
getOrNewSparkSession(user)
diff --git a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala
index 30155c8f2..78164ff5f 100644
--- a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala
+++ b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/session/SparkSessionImpl.scala
@@ -40,7 +40,8 @@ class SparkSessionImpl(
val spark: SparkSession)
extends AbstractSession(protocol, user, password, ipAddress, conf, sessionManager) {
- override val handle: SessionHandle = SessionHandle.fromUUID(conf(KYUUBI_SESSION_HANDLE_KEY))
+ override val handle: SessionHandle =
+ conf.get(KYUUBI_SESSION_HANDLE_KEY).map(SessionHandle.fromUUID).getOrElse(SessionHandle())
private def setModifiableConfig(key: String, value: String): Unit = {
try {
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala
index dbca8ca32..e3e66960b 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala
@@ -17,6 +17,7 @@
package org.apache.kyuubi.client
+import java.util.UUID
import java.util.concurrent.{ExecutorService, ScheduledExecutorService, TimeUnit}
import java.util.concurrent.locks.ReentrantLock
@@ -183,7 +184,9 @@ class KyuubiSyncThriftClient private (
engineAliveProbeClient.foreach { aliveProbeClient =>
val sessionName = SessionHandle.apply(_remoteSessionHandle).identifier + "_aliveness_probe"
Utils.tryLogNonFatalError {
- req.setConfiguration((configs ++ Map(KyuubiConf.SESSION_NAME.key -> sessionName)).asJava)
+ req.setConfiguration((configs ++ Map(
+ KyuubiConf.SESSION_NAME.key -> sessionName,
+ KYUUBI_SESSION_HANDLE_KEY -> UUID.randomUUID().toString)).asJava)
val resp = aliveProbeClient.OpenSession(req)
ThriftUtils.verifyTStatus(resp.getStatus)
_aliveProbeSessionHandle = resp.getSessionHandle
diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/events/handler/ServerJsonLoggingEventHandlerSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/events/handler/ServerJsonLoggingEventHandlerSuite.scala
index d0c9924dc..df8ea1083 100644
--- a/kyuubi-server/src/test/scala/org/apache/kyuubi/events/handler/ServerJsonLoggingEventHandlerSuite.scala
+++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/events/handler/ServerJsonLoggingEventHandlerSuite.scala
@@ -157,7 +157,7 @@ class ServerJsonLoggingEventHandlerSuite extends WithKyuubiServer with HiveJDBCT
}
}
- test("engine session id is not same with server session id") {
+ test("engine session id is same with server session id") {
val name = UUID.randomUUID().toString
withSessionConf()(Map.empty)(Map(KyuubiConf.SESSION_NAME.key -> name)) {
withJdbcStatement() { statement =>
@@ -181,7 +181,7 @@ class ServerJsonLoggingEventHandlerSuite extends WithKyuubiServer with HiveJDBCT
val res2 = statement.executeQuery(
s"SELECT * FROM `json`.`$engineSessionEventPath` " +
s"where sessionId = '$serverSessionId' limit 1")
- assert(!res2.next())
+ assert(res2.next())
}
}
}
diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiOperationPerUserSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiOperationPerUserSuite.scala
index 26fc89ba2..56700759c 100644
--- a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiOperationPerUserSuite.scala
+++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiOperationPerUserSuite.scala
@@ -366,11 +366,15 @@ class KyuubiOperationPerUserSuite
}
test("align the server session handle and engine session handle for Spark engine") {
- withJdbcStatement() { _ =>
- val session =
- server.backendService.sessionManager.allSessions().head.asInstanceOf[KyuubiSessionImpl]
- val engineSessionHandle = SessionHandle.apply(session.client.remoteSessionHandle)
- assert(session.handle === engineSessionHandle)
+ withSessionConf(Map(
+ KyuubiConf.SESSION_ENGINE_LAUNCH_ASYNC.key -> "false"))(Map.empty)(Map.empty) {
+ withJdbcStatement() { _ =>
+ val session =
+ server.backendService.sessionManager.allSessions().head.asInstanceOf[KyuubiSessionImpl]
+ eventually(timeout(10.seconds)) {
+ assert(session.handle === SessionHandle.apply(session.client.remoteSessionHandle))
+ }
+ }
}
}
}