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

chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new d7417ce44 [KYUUBI #4791] Add helper method to simplify REST enabled 
judgment
d7417ce44 is described below

commit d7417ce44fd38daf75352acaaac3cac2e16cb5b8
Author: Cheng Pan <[email protected]>
AuthorDate: Fri May 5 14:15:54 2023 +0800

    [KYUUBI #4791] Add helper method to simplify REST enabled judgment
    
    ### _Why are the changes needed?_
    
    The REST enabled judgment will be used in other places, e.g. the developing 
batch API v2
    
    ### _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
    
    - [x] [Run 
test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #4791 from pan3793/conf.
    
    Closes #4791
    
    264566569 [Cheng Pan] Add helper method to simplify REST enabled judgement
    
    Authored-by: Cheng Pan <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 .../main/scala/org/apache/kyuubi/config/KyuubiConf.scala  |  2 ++
 .../org/apache/kyuubi/session/KyuubiSessionManager.scala  | 15 +++++----------
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git 
a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala 
b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
index e90dbe239..63a9ea648 100644
--- a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
+++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala
@@ -188,6 +188,8 @@ case class KyuubiConf(loadSysDefault: Boolean = true) 
extends Logging {
             s"and may be removed in the future. $comment")
     }
   }
+
+  def isRESTEnabled: Boolean = 
get(FRONTEND_PROTOCOLS).contains(FrontendProtocols.REST.toString)
 }
 
 /**
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 73248cd56..b0ed144a5 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
@@ -47,16 +47,11 @@ class KyuubiSessionManager private (name: String) extends 
SessionManager(name) {
   val operationManager = new KyuubiOperationManager()
   val credentialsManager = new HadoopCredentialsManager()
   val applicationManager = new KyuubiApplicationManager()
-  private lazy val metadataManager: Option[MetadataManager] = {
-    // Currently, the metadata manager is used by the REST frontend which 
provides batch job APIs,
-    // so we initialize it only when Kyuubi starts with the REST frontend.
-    if (conf.get(FRONTEND_PROTOCOLS).map(FrontendProtocols.withName)
-        .contains(FrontendProtocols.REST)) {
-      Option(new MetadataManager())
-    } else {
-      None
-    }
-  }
+
+  // Currently, the metadata manager is used by the REST frontend which 
provides batch job APIs,
+  // so we initialize it only when Kyuubi starts with the REST frontend.
+  lazy val metadataManager: Option[MetadataManager] =
+    if (conf.isRESTEnabled) Some(new MetadataManager()) else None
 
   // lazy is required for plugins since the conf is null when this class 
initialization
   lazy val sessionConfAdvisor: SessionConfAdvisor = 
PluginLoader.loadSessionConfAdvisor(conf)

Reply via email to