Skip to content

Commit dc26f21

Browse files
simon824yaooqinn
authored andcommitted
[KYUUBI #1568] [FOLLOWUP] Add getSessionEvent in session
### _Why are the changes needed?_ KyuubiSessionEvent.apply will get incorrect info. The first one is from `Session.getSessionEvent`, the second one is `KyuubiSessionEvent.apply` ![image](https://user-images.githubusercontent.com/18065113/147657104-16247260-4b50-4485-843c-f5dbb0116c99.png) ### _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 #1644 from simon824/1229. Closes #1568 bc5e4b4 [Simon] Merge branch 'apache:master' into 1229 bb316e6 [simon] Add getSessionEvent in session Lead-authored-by: Simon <3656562@qq.com> Co-authored-by: simon <zhangshiming@cvte.com> Signed-off-by: Kent Yao <yao@apache.org>
1 parent 0f8ebb6 commit dc26f21

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

kyuubi-common/src/main/scala/org/apache/kyuubi/session/AbstractSession.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import scala.collection.JavaConverters._
2222
import org.apache.hive.service.rpc.thrift.{TGetInfoType, TGetInfoValue, TProtocolVersion, TRowSet, TTableSchema}
2323

2424
import org.apache.kyuubi.{KyuubiSQLException, Logging}
25+
import org.apache.kyuubi.events.KyuubiEvent
2526
import org.apache.kyuubi.operation.{Operation, OperationHandle}
2627
import org.apache.kyuubi.operation.FetchOrientation.FetchOrientation
2728
import org.apache.kyuubi.operation.log.OperationLog
@@ -216,4 +217,6 @@ abstract class AbstractSession(
216217
override def open(): Unit = {
217218
OperationLog.createOperationLogRootDirectory(this)
218219
}
220+
221+
override def getSessionEvent: Option[KyuubiEvent] = None
219222
}

kyuubi-common/src/main/scala/org/apache/kyuubi/session/Session.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package org.apache.kyuubi.session
1919

2020
import org.apache.hive.service.rpc.thrift.{TGetInfoType, TGetInfoValue, TProtocolVersion, TRowSet, TTableSchema}
2121

22+
import org.apache.kyuubi.events.KyuubiEvent
2223
import org.apache.kyuubi.operation.FetchOrientation.FetchOrientation
2324
import org.apache.kyuubi.operation.OperationHandle
2425

@@ -37,6 +38,7 @@ trait Session {
3738
def lastAccessTime: Long
3839
def lastIdleTime: Long
3940
def getNoOperationTime: Long
41+
def getSessionEvent: Option[KyuubiEvent]
4042

4143
def sessionManager: SessionManager
4244

kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ import io.swagger.v3.oas.annotations.tags.Tag
2929
import org.apache.hive.service.rpc.thrift.{TGetInfoType, TProtocolVersion}
3030

3131
import org.apache.kyuubi.Utils.error
32-
import org.apache.kyuubi.events.KyuubiSessionEvent
32+
import org.apache.kyuubi.events.KyuubiEvent
3333
import org.apache.kyuubi.operation.OperationHandle
3434
import org.apache.kyuubi.operation.OperationHandle.parseOperationHandle
3535
import org.apache.kyuubi.server.api.ApiRequestContext
36-
import org.apache.kyuubi.session.{AbstractSession, SessionHandle}
36+
import org.apache.kyuubi.session.SessionHandle
3737
import org.apache.kyuubi.session.SessionHandle.parseSessionHandle
3838

3939
@Tag(name = "Session")
@@ -61,11 +61,9 @@ private[v1] class SessionsResource extends ApiRequestContext {
6161
description = "get a session event via session handle identifier")
6262
@GET
6363
@Path("{sessionHandle}")
64-
def sessionInfo(@PathParam("sessionHandle") sessionHandleStr: String): KyuubiSessionEvent = {
64+
def sessionInfo(@PathParam("sessionHandle") sessionHandleStr: String): KyuubiEvent = {
6565
try {
66-
// TODO: need to use KyuubiSessionEvent in session
67-
KyuubiSessionEvent(fe.be.sessionManager.getSession(
68-
parseSessionHandle(sessionHandleStr)).asInstanceOf[AbstractSession])
66+
fe.be.sessionManager.getSession(parseSessionHandle(sessionHandleStr)).getSessionEvent.get
6967
} catch {
7068
case NonFatal(e) =>
7169
error(s"Invalid $sessionHandleStr", e)

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import org.apache.kyuubi.client.KyuubiSyncThriftClient
2525
import org.apache.kyuubi.config.KyuubiConf
2626
import org.apache.kyuubi.config.KyuubiConf._
2727
import org.apache.kyuubi.engine.EngineRef
28-
import org.apache.kyuubi.events.KyuubiSessionEvent
28+
import org.apache.kyuubi.events.{KyuubiEvent, KyuubiSessionEvent}
2929
import org.apache.kyuubi.ha.client.ZooKeeperClientProvider._
3030
import org.apache.kyuubi.metrics.MetricsConstants._
3131
import org.apache.kyuubi.metrics.MetricsSystem
@@ -58,6 +58,10 @@ class KyuubiSessionImpl(
5858
private val sessionEvent = KyuubiSessionEvent(this)
5959
EventLoggingService.onEvent(sessionEvent)
6060

61+
override def getSessionEvent: Option[KyuubiEvent] = {
62+
Option(sessionEvent)
63+
}
64+
6165
private var _client: KyuubiSyncThriftClient = _
6266
def client: KyuubiSyncThriftClient = _client
6367

0 commit comments

Comments
 (0)