[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`  ### _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 bc5e4b49 [Simon] Merge branch 'apache:master' into 1229 bb316e6a [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>
This commit is contained in:
parent
0f8ebb6006
commit
dc26f2128c
@ -22,6 +22,7 @@ import scala.collection.JavaConverters._
|
||||
import org.apache.hive.service.rpc.thrift.{TGetInfoType, TGetInfoValue, TProtocolVersion, TRowSet, TTableSchema}
|
||||
|
||||
import org.apache.kyuubi.{KyuubiSQLException, Logging}
|
||||
import org.apache.kyuubi.events.KyuubiEvent
|
||||
import org.apache.kyuubi.operation.{Operation, OperationHandle}
|
||||
import org.apache.kyuubi.operation.FetchOrientation.FetchOrientation
|
||||
import org.apache.kyuubi.operation.log.OperationLog
|
||||
@ -216,4 +217,6 @@ abstract class AbstractSession(
|
||||
override def open(): Unit = {
|
||||
OperationLog.createOperationLogRootDirectory(this)
|
||||
}
|
||||
|
||||
override def getSessionEvent: Option[KyuubiEvent] = None
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ package org.apache.kyuubi.session
|
||||
|
||||
import org.apache.hive.service.rpc.thrift.{TGetInfoType, TGetInfoValue, TProtocolVersion, TRowSet, TTableSchema}
|
||||
|
||||
import org.apache.kyuubi.events.KyuubiEvent
|
||||
import org.apache.kyuubi.operation.FetchOrientation.FetchOrientation
|
||||
import org.apache.kyuubi.operation.OperationHandle
|
||||
|
||||
@ -37,6 +38,7 @@ trait Session {
|
||||
def lastAccessTime: Long
|
||||
def lastIdleTime: Long
|
||||
def getNoOperationTime: Long
|
||||
def getSessionEvent: Option[KyuubiEvent]
|
||||
|
||||
def sessionManager: SessionManager
|
||||
|
||||
|
||||
@ -29,11 +29,11 @@ import io.swagger.v3.oas.annotations.tags.Tag
|
||||
import org.apache.hive.service.rpc.thrift.{TGetInfoType, TProtocolVersion}
|
||||
|
||||
import org.apache.kyuubi.Utils.error
|
||||
import org.apache.kyuubi.events.KyuubiSessionEvent
|
||||
import org.apache.kyuubi.events.KyuubiEvent
|
||||
import org.apache.kyuubi.operation.OperationHandle
|
||||
import org.apache.kyuubi.operation.OperationHandle.parseOperationHandle
|
||||
import org.apache.kyuubi.server.api.ApiRequestContext
|
||||
import org.apache.kyuubi.session.{AbstractSession, SessionHandle}
|
||||
import org.apache.kyuubi.session.SessionHandle
|
||||
import org.apache.kyuubi.session.SessionHandle.parseSessionHandle
|
||||
|
||||
@Tag(name = "Session")
|
||||
@ -61,11 +61,9 @@ private[v1] class SessionsResource extends ApiRequestContext {
|
||||
description = "get a session event via session handle identifier")
|
||||
@GET
|
||||
@Path("{sessionHandle}")
|
||||
def sessionInfo(@PathParam("sessionHandle") sessionHandleStr: String): KyuubiSessionEvent = {
|
||||
def sessionInfo(@PathParam("sessionHandle") sessionHandleStr: String): KyuubiEvent = {
|
||||
try {
|
||||
// TODO: need to use KyuubiSessionEvent in session
|
||||
KyuubiSessionEvent(fe.be.sessionManager.getSession(
|
||||
parseSessionHandle(sessionHandleStr)).asInstanceOf[AbstractSession])
|
||||
fe.be.sessionManager.getSession(parseSessionHandle(sessionHandleStr)).getSessionEvent.get
|
||||
} catch {
|
||||
case NonFatal(e) =>
|
||||
error(s"Invalid $sessionHandleStr", e)
|
||||
|
||||
@ -25,7 +25,7 @@ import org.apache.kyuubi.client.KyuubiSyncThriftClient
|
||||
import org.apache.kyuubi.config.KyuubiConf
|
||||
import org.apache.kyuubi.config.KyuubiConf._
|
||||
import org.apache.kyuubi.engine.EngineRef
|
||||
import org.apache.kyuubi.events.KyuubiSessionEvent
|
||||
import org.apache.kyuubi.events.{KyuubiEvent, KyuubiSessionEvent}
|
||||
import org.apache.kyuubi.ha.client.ZooKeeperClientProvider._
|
||||
import org.apache.kyuubi.metrics.MetricsConstants._
|
||||
import org.apache.kyuubi.metrics.MetricsSystem
|
||||
@ -58,6 +58,10 @@ class KyuubiSessionImpl(
|
||||
private val sessionEvent = KyuubiSessionEvent(this)
|
||||
EventLoggingService.onEvent(sessionEvent)
|
||||
|
||||
override def getSessionEvent: Option[KyuubiEvent] = {
|
||||
Option(sessionEvent)
|
||||
}
|
||||
|
||||
private var _client: KyuubiSyncThriftClient = _
|
||||
def client: KyuubiSyncThriftClient = _client
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user