This is an automated email from the ASF dual-hosted git repository.

feiwang pushed a commit to branch branch-1.6
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/branch-1.6 by this push:
     new ea6480a5c [KYUUBI #4153] Unify the log information format for 
open/close session
ea6480a5c is described below

commit ea6480a5c366cf904e622e1fd569fc25da363091
Author: fwang12 <[email protected]>
AuthorDate: Fri Jan 13 12:38:54 2023 +0800

    [KYUUBI #4153] Unify the log information format for open/close session
    
    ### _Why are the changes needed?_
    
    ### _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.apache.org/docs/latest/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #4153 from turboFei/log_user_close.
    
    Closes #4153
    
    d55cbcdc6 [fwang12] logSessionCountInfo
    7cdb1f45f [fwang12] log more session info
    
    Authored-by: fwang12 <[email protected]>
    Signed-off-by: fwang12 <[email protected]>
    (cherry picked from commit 3f4d136500948d590ad849e24ea744fc22ea71c1)
    Signed-off-by: fwang12 <[email protected]>
---
 .../scala/org/apache/kyuubi/session/SessionManager.scala     | 12 ++++++++----
 .../org/apache/kyuubi/session/KyuubiSessionManager.scala     |  3 +--
 2 files changed, 9 insertions(+), 6 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 19866f5ad..a914448d6 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
@@ -88,6 +88,12 @@ abstract class SessionManager(name: String) extends 
CompositeService(name) {
       ipAddress: String,
       conf: Map[String, String]): Session
 
+  protected def logSessionCountInfo(session: Session, action: String): Unit = {
+    info(s"${session.user}'s session with" +
+      s" ${session.handle}${session.name.map("/" + _).getOrElse("")} is 
$action," +
+      s" current opening sessions $getOpenSessionCount")
+  }
+
   def openSession(
       protocol: TProtocolVersion,
       user: String,
@@ -100,8 +106,7 @@ abstract class SessionManager(name: String) extends 
CompositeService(name) {
       val handle = session.handle
       session.open()
       setSession(handle, session)
-      info(s"$user's session with $handle${session.name.map("/" + 
_).getOrElse("")} is opened," +
-        s" current opening sessions $getOpenSessionCount")
+      logSessionCountInfo(session, "opened")
       handle
     } catch {
       case e: Exception =>
@@ -121,8 +126,7 @@ abstract class SessionManager(name: String) extends 
CompositeService(name) {
     if (session == null) {
       throw KyuubiSQLException(s"Invalid $sessionHandle")
     }
-    info(s"$sessionHandle${session.name.map("/" + _).getOrElse("")} is 
closed," +
-      s" current opening sessions $getOpenSessionCount")
+    logSessionCountInfo(session, "closed")
     try {
       session.close()
     } finally {
diff --git 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala
 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala
index 54b4faf35..88fe1e837 100644
--- 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala
+++ 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala
@@ -140,8 +140,7 @@ class KyuubiSessionManager private (name: String) extends 
SessionManager(name) {
     try {
       batchSession.open()
       setSession(handle, batchSession)
-      info(s"$user's batch session with $handle is opened, current opening 
sessions" +
-        s" $getOpenSessionCount")
+      logSessionCountInfo(batchSession, "opened")
       handle
     } catch {
       case e: Exception =>

Reply via email to