[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 23fc3b2b [Kent Yao] test 6cd86610 [Kent Yao] npe 6fb75d47 [Kent Yao] KyuubiSessionEvent shall always have Id Authored-by: Kent Yao <yao@apache.org> Signed-off-by: Kent Yao <yao@apache.org>
This commit is contained in:
parent
69efac59ef
commit
99e278ce76
@ -24,31 +24,31 @@ import org.apache.kyuubi.session.AbstractSession
|
||||
|
||||
/**
|
||||
* @param sessionId server session id
|
||||
* @param remoteSessionId remote engine session id
|
||||
* @param clientVersion client version
|
||||
* @param sessionName if user not specify it, we use empty string instead
|
||||
* @param user session user
|
||||
* @param clientIP client ip address
|
||||
* @param serverIP A unique Kyuubi server id, e.g. kyuubi server ip address and port,
|
||||
* it is useful if has multi-instance Kyuubi Server
|
||||
* @param clientVersion client version
|
||||
* @param conf session config
|
||||
* @param remoteSessionId remote engine session id
|
||||
* @param startTime session create time
|
||||
* @param conf session config
|
||||
* @param openedTime session opened time
|
||||
* @param endTime session end time
|
||||
* @param totalOperations how many queries and meta calls
|
||||
* @param engineId engine id. For engine on yarn, it is applicationId.
|
||||
*/
|
||||
case class KyuubiSessionEvent(
|
||||
sessionId: String,
|
||||
clientVersion: Int,
|
||||
sessionName: String,
|
||||
user: String,
|
||||
clientIP: String,
|
||||
serverIP: String,
|
||||
conf: Map[String, String],
|
||||
startTime: Long,
|
||||
var sessionId: String = "",
|
||||
var remoteSessionId: String = "",
|
||||
var engineId: String = "",
|
||||
var clientVersion: Int = -1,
|
||||
var openedTime: Long = -1L,
|
||||
var endTime: Long = -1L,
|
||||
var totalOperations: Int = 0) extends KyuubiServerEvent {
|
||||
@ -62,6 +62,8 @@ object KyuubiSessionEvent {
|
||||
val serverIP = KyuubiServer.kyuubiServer.frontendServices.head.connectionUrl
|
||||
val sessionName: String = session.normalizedConf.getOrElse(KyuubiConf.SESSION_NAME.key, "")
|
||||
KyuubiSessionEvent(
|
||||
session.handle.toString,
|
||||
session.protocol.getValue,
|
||||
sessionName,
|
||||
session.user,
|
||||
session.ipAddress,
|
||||
|
||||
@ -42,6 +42,7 @@ class KyuubiSessionImpl(
|
||||
sessionManager: KyuubiSessionManager,
|
||||
sessionConf: KyuubiConf)
|
||||
extends AbstractSession(protocol, user, password, ipAddress, conf, sessionManager) {
|
||||
override val handle: SessionHandle = SessionHandle(protocol)
|
||||
|
||||
// TODO: needs improve the hardcode
|
||||
normalizedConf.foreach {
|
||||
@ -60,7 +61,6 @@ class KyuubiSessionImpl(
|
||||
private var _client: KyuubiSyncThriftClient = _
|
||||
def client: KyuubiSyncThriftClient = _client
|
||||
|
||||
override val handle: SessionHandle = SessionHandle(protocol)
|
||||
private var _engineSessionHandle: SessionHandle = _
|
||||
|
||||
override def open(): Unit = {
|
||||
@ -83,9 +83,7 @@ class KyuubiSessionImpl(
|
||||
_engineSessionHandle = _client.openSession(protocol, user, passwd, normalizedConf)
|
||||
logSessionInfo(s"Connected to engine [$host:$port] with ${_engineSessionHandle}")
|
||||
sessionEvent.openedTime = System.currentTimeMillis()
|
||||
sessionEvent.sessionId = handle.identifier.toString
|
||||
sessionEvent.remoteSessionId = _engineSessionHandle.identifier.toString
|
||||
sessionEvent.clientVersion = handle.protocol.getValue
|
||||
_client.engineId.foreach(e => sessionEvent.engineId = e)
|
||||
EventLoggingService.onEvent(sessionEvent)
|
||||
}
|
||||
|
||||
@ -111,13 +111,13 @@ class EventLoggingServiceSuite extends WithKyuubiServer with HiveJDBCTestHelper
|
||||
assert(res.next())
|
||||
assert(res.getString("user") == Utils.currentUser)
|
||||
assert(res.getString("sessionName") == "test1")
|
||||
assert(res.getString("sessionId") == "")
|
||||
val sid = res.getString("sessionId")
|
||||
assert(res.getString("remoteSessionId") == "")
|
||||
assert(res.getLong("startTime") > 0)
|
||||
assert(res.getInt("totalOperations") == 0)
|
||||
assert(res.next())
|
||||
assert(res.getInt("totalOperations") == 0)
|
||||
assert(res.getString("sessionId") != "")
|
||||
assert(res.getString("sessionId") == sid)
|
||||
assert(res.getString("remoteSessionId") != "")
|
||||
assert(res.getLong("openedTime") > 0)
|
||||
assert(res.next())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user