You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ji...@apache.org on 2022/11/21 06:47:34 UTC

[incubator-kyuubi] branch master updated: [KYUUBI #3814] Configurable interval for sessionConfCache in FileSessionConfAdvisor (#3815)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 47e1cfdf0 [KYUUBI #3814] Configurable interval for sessionConfCache in FileSessionConfAdvisor (#3815)
47e1cfdf0 is described below

commit 47e1cfdf08379db31df4c04ece4ad28cd26802c9
Author: jiaoqingbo <11...@qq.com>
AuthorDate: Mon Nov 21 14:47:29 2022 +0800

    [KYUUBI #3814] Configurable interval for sessionConfCache in FileSessionConfAdvisor (#3815)
    
    * [KYUUBI #3814] Make the duration of sessionConfCache in FileSessionConfAdvisor configurable instead of a fixed 10 minutes
    
    * fix ut
    
    * fix ut
    
    * fix doc
    
    * code review
    
    * update doc
    
    * update
    
    * update
---
 docs/deployment/settings.md                                    |  1 +
 .../src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala   |  9 +++++++++
 .../org/apache/kyuubi/session/FileSessionConfAdvisor.scala     | 10 ++++++----
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/docs/deployment/settings.md b/docs/deployment/settings.md
index 046aaf8f9..c9638af83 100644
--- a/docs/deployment/settings.md
+++ b/docs/deployment/settings.md
@@ -461,6 +461,7 @@ Key | Default | Meaning | Type | Since
 --- | --- | --- | --- | ---
 kyuubi.session.check.interval|PT5M|The check interval for session timeout.|duration|1.0.0
 kyuubi.session.conf.advisor|&lt;undefined&gt;|A config advisor plugin for Kyuubi Server. This plugin can provide some custom configs for different user or session configs and overwrite the session configs before open a new session. This config value should be a class which is a child of 'org.apache.kyuubi.plugin.SessionConfAdvisor' which has zero-arg constructor.|string|1.5.0
+kyuubi.session.conf.file.reload.interval|PT10M|When `FileSessionConfAdvisor` is used, this configuration defines the expired time of `$KYUUBI_CONF_DIR/kyuubi-session-<profile>.conf` in the cache. After exceeding this value, the file will be reloaded.|duration|1.7.0
 kyuubi.session.conf.ignore.list||A comma separated list of ignored keys. If the client connection contains any of them, the key and the corresponding value will be removed silently during engine bootstrap and connection setup. Note that this rule is for server-side protection defined via administrators to prevent some essential configs from tampering but will not forbid users to set dynamic configurations via SET syntax.|seq|1.2.0
 kyuubi.session.conf.profile|&lt;undefined&gt;|Specify a profile to load session-level configurations from `$KYUUBI_CONF_DIR/kyuubi-session-<profile>.conf`. This configuration will be ignored if the file does not exist. This configuration only has effect when `kyuubi.session.conf.advisor` is set as `org.apache.kyuubi.session.FileSessionConfAdvisor`.|string|1.7.0
 kyuubi.session.conf.restrict.list||A comma separated list of restricted keys. If the client connection contains any of them, the connection will be rejected explicitly during engine bootstrap and connection setup. Note that this rule is for server-side protection defined via administrators to prevent some essential configs from tampering but will not forbid users to set dynamic configurations via SET syntax.|seq|1.2.0
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 12efac049..33a209de1 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
@@ -1004,6 +1004,15 @@ object KyuubiConf {
       .stringConf
       .createOptional
 
+  val SESSION_CONF_FILE_RELOAD_INTERVAL: ConfigEntry[Long] =
+    buildConf("kyuubi.session.conf.file.reload.interval")
+      .doc("When `FileSessionConfAdvisor` is used, this configuration defines " +
+        "the expired time of `$KYUUBI_CONF_DIR/kyuubi-session-<profile>.conf` " +
+        "in the cache. After exceeding this value, the file will be reloaded.")
+      .version("1.7.0")
+      .timeConf
+      .createWithDefault(Duration.ofMinutes(10).toMillis)
+
   val ENGINE_SPARK_MAX_LIFETIME: ConfigEntry[Long] =
     buildConf("kyuubi.session.engine.spark.max.lifetime")
       .doc("Max lifetime for spark engine, the engine will self-terminate when it reaches the" +
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/FileSessionConfAdvisor.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/FileSessionConfAdvisor.scala
index a006753af..96569bc38 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/FileSessionConfAdvisor.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/FileSessionConfAdvisor.scala
@@ -17,8 +17,7 @@
 
 package org.apache.kyuubi.session
 
-import java.util.{Map => JMap}
-import java.util.Collections
+import java.util.{Collections, Map => JMap}
 import java.util.concurrent.TimeUnit
 
 import scala.collection.JavaConverters._
@@ -44,9 +43,12 @@ class FileSessionConfAdvisor extends SessionConfAdvisor {
 }
 
 object FileSessionConfAdvisor extends Logging {
-  private val sessionConfCache: LoadingCache[String, JMap[String, String]] =
+  private val reloadInterval: Long = KyuubiConf().get(KyuubiConf.SESSION_CONF_FILE_RELOAD_INTERVAL)
+  private lazy val sessionConfCache: LoadingCache[String, JMap[String, String]] =
     CacheBuilder.newBuilder()
-      .expireAfterWrite(10, TimeUnit.MINUTES)
+      .expireAfterWrite(
+        reloadInterval,
+        TimeUnit.MILLISECONDS)
       .build(new CacheLoader[String, JMap[String, String]] {
         override def load(profile: String): JMap[String, String] = {
           val propsFile = Utils.getPropertiesFile(s"kyuubi-session-$profile.conf")