From d726a847038cad27523bf0c1de73e8f5142ccc1d Mon Sep 17 00:00:00 2001 From: fwang12 Date: Sun, 19 Nov 2023 11:58:35 +0800 Subject: [PATCH] catch all log session type --- .../kyuubi/session/SessionManager.scala | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala index a83335102a8..4a3d256890d 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala @@ -90,7 +90,7 @@ abstract class SessionManager(name: String) extends CompositeService(name) { conf: Map[String, String]): Session protected def logSessionCountInfo(session: Session, action: String): Unit = { - info(s"${session.user}'s session with" + + info(s"${session.user}'s ${session.getClass.getSimpleName} with" + s" ${session.handle}${session.name.map("/" + _).getOrElse("")} is $action," + s" current opening sessions $getOpenSessionCount") } @@ -303,20 +303,21 @@ abstract class SessionManager(name: String) extends CompositeService(name) { val checkTask = new Runnable { override def run(): Unit = { + info(s"Checking sessions timeout, current count: $getOpenSessionCount") val current = System.currentTimeMillis if (!shutdown) { for (session <- handleToSession.values().asScala) { - if (session.lastAccessTime + session.sessionIdleTimeoutThreshold <= current && - session.getNoOperationTime > session.sessionIdleTimeoutThreshold) { - info(s"Closing session ${session.handle.identifier} that has been idle for more" + - s" than ${session.sessionIdleTimeoutThreshold} ms") - try { + try { + if (session.lastAccessTime + session.sessionIdleTimeoutThreshold <= current && + session.getNoOperationTime > session.sessionIdleTimeoutThreshold) { + info(s"Closing session ${session.handle.identifier} that has been idle for more" + + s" than ${session.sessionIdleTimeoutThreshold} ms") closeSession(session.handle) - } catch { - case NonFatal(e) => warn(s"Error closing idle session ${session.handle}", e) + } else { + session.closeExpiredOperations() } - } else { - session.closeExpiredOperations() + } catch { + case NonFatal(e) => warn(s"Error checking session ${session.handle} timeout", e) } } }