Skip to content

Commit 99e278c

Browse files
committed
[KYUUBI #1623] KyuubiSessionEvent shall always have Id
<!-- 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. --> session id is a val ### _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/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1623 from yaooqinn/val. Closes #1623 23fc3b2 [Kent Yao] test 6cd8661 [Kent Yao] npe 6fb75d4 [Kent Yao] KyuubiSessionEvent shall always have Id Authored-by: Kent Yao <yao@apache.org> Signed-off-by: Kent Yao <yao@apache.org>
1 parent 69efac5 commit 99e278c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

kyuubi-server/src/main/scala/org/apache/kyuubi/events/KyuubiSessionEvent.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,31 @@ import org.apache.kyuubi.session.AbstractSession
2424

2525
/**
2626
* @param sessionId server session id
27-
* @param remoteSessionId remote engine session id
27+
* @param clientVersion client version
2828
* @param sessionName if user not specify it, we use empty string instead
2929
* @param user session user
3030
* @param clientIP client ip address
3131
* @param serverIP A unique Kyuubi server id, e.g. kyuubi server ip address and port,
3232
* it is useful if has multi-instance Kyuubi Server
33-
* @param clientVersion client version
34-
* @param conf session config
33+
* @param remoteSessionId remote engine session id
3534
* @param startTime session create time
35+
* @param conf session config
3636
* @param openedTime session opened time
3737
* @param endTime session end time
3838
* @param totalOperations how many queries and meta calls
3939
* @param engineId engine id. For engine on yarn, it is applicationId.
4040
*/
4141
case class KyuubiSessionEvent(
42+
sessionId: String,
43+
clientVersion: Int,
4244
sessionName: String,
4345
user: String,
4446
clientIP: String,
4547
serverIP: String,
4648
conf: Map[String, String],
4749
startTime: Long,
48-
var sessionId: String = "",
4950
var remoteSessionId: String = "",
5051
var engineId: String = "",
51-
var clientVersion: Int = -1,
5252
var openedTime: Long = -1L,
5353
var endTime: Long = -1L,
5454
var totalOperations: Int = 0) extends KyuubiServerEvent {
@@ -62,6 +62,8 @@ object KyuubiSessionEvent {
6262
val serverIP = KyuubiServer.kyuubiServer.frontendServices.head.connectionUrl
6363
val sessionName: String = session.normalizedConf.getOrElse(KyuubiConf.SESSION_NAME.key, "")
6464
KyuubiSessionEvent(
65+
session.handle.toString,
66+
session.protocol.getValue,
6567
sessionName,
6668
session.user,
6769
session.ipAddress,

kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class KyuubiSessionImpl(
4242
sessionManager: KyuubiSessionManager,
4343
sessionConf: KyuubiConf)
4444
extends AbstractSession(protocol, user, password, ipAddress, conf, sessionManager) {
45+
override val handle: SessionHandle = SessionHandle(protocol)
4546

4647
// TODO: needs improve the hardcode
4748
normalizedConf.foreach {
@@ -60,7 +61,6 @@ class KyuubiSessionImpl(
6061
private var _client: KyuubiSyncThriftClient = _
6162
def client: KyuubiSyncThriftClient = _client
6263

63-
override val handle: SessionHandle = SessionHandle(protocol)
6464
private var _engineSessionHandle: SessionHandle = _
6565

6666
override def open(): Unit = {
@@ -83,9 +83,7 @@ class KyuubiSessionImpl(
8383
_engineSessionHandle = _client.openSession(protocol, user, passwd, normalizedConf)
8484
logSessionInfo(s"Connected to engine [$host:$port] with ${_engineSessionHandle}")
8585
sessionEvent.openedTime = System.currentTimeMillis()
86-
sessionEvent.sessionId = handle.identifier.toString
8786
sessionEvent.remoteSessionId = _engineSessionHandle.identifier.toString
88-
sessionEvent.clientVersion = handle.protocol.getValue
8987
_client.engineId.foreach(e => sessionEvent.engineId = e)
9088
EventLoggingService.onEvent(sessionEvent)
9189
}

kyuubi-server/src/test/scala/org/apache/kyuubi/events/EventLoggingServiceSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ class EventLoggingServiceSuite extends WithKyuubiServer with HiveJDBCTestHelper
111111
assert(res.next())
112112
assert(res.getString("user") == Utils.currentUser)
113113
assert(res.getString("sessionName") == "test1")
114-
assert(res.getString("sessionId") == "")
114+
val sid = res.getString("sessionId")
115115
assert(res.getString("remoteSessionId") == "")
116116
assert(res.getLong("startTime") > 0)
117117
assert(res.getInt("totalOperations") == 0)
118118
assert(res.next())
119119
assert(res.getInt("totalOperations") == 0)
120-
assert(res.getString("sessionId") != "")
120+
assert(res.getString("sessionId") == sid)
121121
assert(res.getString("remoteSessionId") != "")
122122
assert(res.getLong("openedTime") > 0)
123123
assert(res.next())

0 commit comments

Comments
 (0)