-
Notifications
You must be signed in to change notification settings - Fork 976
Add FileSessionConfAdvisor to manage session level configuration #3742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
51729d1
When a kyuubi service connections to multiple engine clusters, we can…
ychris78 b524c22
add org.apache.kyuubi.plugin.YamlSessionConfAdvisor
ychris78 0cb7134
add org.apache.kyuubi.plugin.YamlSessionConfAdvisor
ychris78 5e50425
add org.apache.kyuubi.plugin.FileSessionConfAdvisor
ychris78 5f57b63
Modify according to suggestions
ychris78 9e8d313
Modify according to suggestions
ychris78 335250f
fix bug
ychris78 a050784
License info amendment
ychris78 1b1f9d6
scalastyle
ychris78 5c2f746
add cache and fix bug
ychris78 5ef5841
Cache upgrade
ychris78 30f8fde
Update kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiCo…
pan3793 1ee3c98
Update kyuubi-server/src/test/resources/kyuubi-session-cluster-a.conf
pan3793 cb644ab
Update docs/deployment/settings.md
pan3793 d332e2d
Update kyuubi-server/src/main/scala/org/apache/kyuubi/session/FileSes…
pan3793 5b4a6d7
Update kyuubi-server/src/main/scala/org/apache/kyuubi/session/FileSes…
pan3793 1c8daa8
Change the cache expiration time to 10 minutes and remove the manual …
ychris78 68bbfec
restructure
ychris78 e144986
Style
ychris78 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
kyuubi-server/src/main/scala/org/apache/kyuubi/session/FileSessionConfAdvisor.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.kyuubi.session | ||
|
|
||
| import java.util.{Map => JMap} | ||
| import java.util.Collections | ||
| import java.util.concurrent.TimeUnit | ||
|
|
||
| import scala.collection.JavaConverters._ | ||
|
|
||
| import com.google.common.cache.{CacheBuilder, CacheLoader, LoadingCache} | ||
|
|
||
| import org.apache.kyuubi.{Logging, Utils} | ||
| import org.apache.kyuubi.config.KyuubiConf | ||
| import org.apache.kyuubi.plugin.SessionConfAdvisor | ||
| import org.apache.kyuubi.session.FileSessionConfAdvisor.sessionConfCache | ||
|
|
||
| class FileSessionConfAdvisor extends SessionConfAdvisor { | ||
| override def getConfOverlay( | ||
| user: String, | ||
| sessionConf: JMap[String, String]): JMap[String, String] = { | ||
| val profile: String = sessionConf.get(KyuubiConf.SESSION_CONF_PROFILE.key) | ||
| profile match { | ||
| case null => Collections.emptyMap() | ||
| case _ => | ||
| sessionConfCache.get(profile) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| object FileSessionConfAdvisor extends Logging { | ||
| private val sessionConfCache: LoadingCache[String, JMap[String, String]] = | ||
| CacheBuilder.newBuilder() | ||
| .expireAfterWrite(10, TimeUnit.MINUTES) | ||
| .build(new CacheLoader[String, JMap[String, String]] { | ||
| override def load(profile: String): JMap[String, String] = { | ||
| val propsFile = Utils.getPropertiesFile(s"kyuubi-session-$profile.conf") | ||
| propsFile match { | ||
| case None => | ||
| error("File not found: $KYUUBI_CONF_DIR/" + s"kyuubi-session-$profile.conf") | ||
| Collections.emptyMap() | ||
| case Some(_) => | ||
| Utils.getPropertiesFromFile(propsFile).asJava | ||
| } | ||
| } | ||
| }) | ||
| } |
23 changes: 23 additions & 0 deletions
23
kyuubi-server/src/test/resources/kyuubi-session-cluster-a.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| kyuubi.ha.namespace kyuubi-ns-a | ||
| kyuubi.engine.type SPARK_SQL | ||
| kyuubi.engine.pool.balance.policy POLLING | ||
|
|
||
| kyuubi.engineEnv.SPARK_HOME /opt/spark30 | ||
| kyuubi.engineEnv.HADOOP_CONF_DIR /opt/hadoop_conf_dir |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.