-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-21428] Turn IsolatedClientLoader off while using builtin Hive jars for reusing CliSessionState #18648
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
394b471
set isolateOn to false while using builtin hive jars
yaooqinn 62049f5
add unit tests
yaooqinn d127f96
refacting code
yaooqinn d18bcc0
move suites to thriftserver module for bannedDependencies
yaooqinn 341964e
fix ut reduplicated derby metastore_db
yaooqinn 6c0bf70
review change
yaooqinn 51fac11
ut affect each other
yaooqinn c50a32f
thanks for reviewing
yaooqinn c6ed2d7
typo
yaooqinn 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 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 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
64 changes: 64 additions & 0 deletions
64
...rver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveCliSessionStateSuite.scala
This file contains 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,64 @@ | ||
/* | ||
* 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.spark.sql.hive.thriftserver | ||
|
||
import org.apache.hadoop.hive.cli.CliSessionState | ||
import org.apache.hadoop.hive.conf.HiveConf | ||
import org.apache.hadoop.hive.ql.session.SessionState | ||
|
||
import org.apache.spark.{SparkConf, SparkFunSuite} | ||
import org.apache.spark.deploy.SparkHadoopUtil | ||
import org.apache.spark.sql.hive.HiveUtils | ||
|
||
class HiveCliSessionStateSuite extends SparkFunSuite { | ||
|
||
def withSessionClear(f: () => Unit): Unit = { | ||
try f finally SessionState.detachSession() | ||
} | ||
|
||
test("CliSessionState will be reused") { | ||
withSessionClear { () => | ||
val hiveConf = new HiveConf(classOf[SessionState]) | ||
HiveUtils.newTemporaryConfiguration(useInMemoryDerby = false).foreach { | ||
case (key, value) => hiveConf.set(key, value) | ||
} | ||
val sessionState: SessionState = new CliSessionState(hiveConf) | ||
SessionState.start(sessionState) | ||
val s1 = SessionState.get | ||
val sparkConf = new SparkConf() | ||
val hadoopConf = SparkHadoopUtil.get.newConfiguration(sparkConf) | ||
val s2 = HiveUtils.newClientForMetadata(sparkConf, hadoopConf).getState | ||
assert(s1 === s2) | ||
assert(s2.isInstanceOf[CliSessionState]) | ||
} | ||
} | ||
|
||
test("SessionState will not be reused") { | ||
withSessionClear { () => | ||
val sparkConf = new SparkConf() | ||
val hadoopConf = SparkHadoopUtil.get.newConfiguration(sparkConf) | ||
HiveUtils.newTemporaryConfiguration(useInMemoryDerby = false).foreach { | ||
case (key, value) => hadoopConf.set(key, value) | ||
} | ||
val hiveClient = HiveUtils.newClientForMetadata(sparkConf, hadoopConf) | ||
val s1 = hiveClient.getState | ||
val s2 = hiveClient.newSession().getState | ||
assert(s1 !== s2) | ||
} | ||
} | ||
} |
This file contains 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 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 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the behavior change safe here? Previously, we switch the context ClassLoader for both conditions, while in this PR we only do that if
isolationOn
is true.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when isolation Off, we just switch a classloader to itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
SessionState.get()
is None, we should still callnewState()
and init frominitClassLoader
, should we also switch in that case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
SessionState.get
be null, then the IsolateOn will be turned on always. Only if we callSessionState.detachSession
, will this happens?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A user app new an CliSessionState instance with built in hive jars to trigger isolate off, then it detach this state, and then new a hive client again, this time isolate off and
SessionState.get()
will be None,newState()
will be called without changing the classloader, I think this is OK, because we never create a isolate class loader from beginning to end.