Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions core/src/main/scala/org/apache/spark/SparkConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
if (value == null) {
throw new NullPointerException("null value for " + key)
}
settings.put(translateConfKey(key, warn = true), value)
settings.put(key, value)
this
}

Expand Down Expand Up @@ -140,7 +140,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {

/** Set a parameter if it isn't already configured */
def setIfMissing(key: String, value: String): SparkConf = {
settings.putIfAbsent(translateConfKey(key, warn = true), value)
settings.putIfAbsent(key, value)
this
}

Expand Down Expand Up @@ -176,7 +176,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {

/** Get a parameter as an Option */
def getOption(key: String): Option[String] = {
Option(settings.get(translateConfKey(key)))
Option(settings.get(key))
}

/** Get all parameters as a list of pairs */
Expand Down Expand Up @@ -229,7 +229,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
def getAppId: String = get("spark.app.id")

/** Does the configuration contain a given parameter? */
def contains(key: String): Boolean = settings.containsKey(translateConfKey(key))
def contains(key: String): Boolean = settings.containsKey(key)

/** Copy this object */
override def clone: SparkConf = {
Expand Down Expand Up @@ -343,6 +343,13 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
}
}
}

// Warn against the use of deprecated configs
deprecatedConfigs.values.foreach { dc =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're doing this only once during the app's lifetime (this method is only called from SparkContext AFAICT), you could simplify the code that tracks whether warns have been printed in DeprecatedConfig. But ok to not do it if you want to limit the scope of the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah let's revamp this whole thing after the release

if (contains(dc.oldName)) {
dc.warn()
}
}
}

/**
Expand Down
13 changes: 9 additions & 4 deletions core/src/main/scala/org/apache/spark/executor/Executor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ private[spark] class Executor(
private val executorActor = env.actorSystem.actorOf(
Props(new ExecutorActor(executorId)), "ExecutorActor")

// Whether to load classes in user jars before those in Spark jars
private val userClassPathFirst: Boolean = {
conf.getBoolean("spark.executor.userClassPathFirst",
conf.getBoolean("spark.files.userClassPathFirst", false))
}

// Create our ClassLoader
// do this after SparkEnv creation so can access the SecurityManager
private val urlClassLoader = createClassLoader()
Expand Down Expand Up @@ -309,7 +315,7 @@ private[spark] class Executor(
val urls = userClassPath.toArray ++ currentJars.keySet.map { uri =>
new File(uri.split("/").last).toURI.toURL
}
if (conf.getBoolean("spark.executor.userClassPathFirst", false)) {
if (userClassPathFirst) {
new ChildFirstURLClassLoader(urls, currentLoader)
} else {
new MutableURLClassLoader(urls, currentLoader)
Expand All @@ -324,14 +330,13 @@ private[spark] class Executor(
val classUri = conf.get("spark.repl.class.uri", null)
if (classUri != null) {
logInfo("Using REPL class URI: " + classUri)
val userClassPathFirst: java.lang.Boolean =
conf.getBoolean("spark.executor.userClassPathFirst", false)
try {
val _userClassPathFirst: java.lang.Boolean = userClassPathFirst
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this? Feels like just referencing userClassPathFirst should work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not, but I'm just preserving what was already there before. This is later used in some reflection code so I think it would be safest to leave it as is. I'll feel better about removing it after the release.

val klass = Class.forName("org.apache.spark.repl.ExecutorClassLoader")
.asInstanceOf[Class[_ <: ClassLoader]]
val constructor = klass.getConstructor(classOf[SparkConf], classOf[String],
classOf[ClassLoader], classOf[Boolean])
constructor.newInstance(conf, classUri, parent, userClassPathFirst)
constructor.newInstance(conf, classUri, parent, _userClassPathFirst)
} catch {
case _: ClassNotFoundException =>
logError("Could not find org.apache.spark.repl.ExecutorClassLoader on classpath!")
Expand Down
12 changes: 0 additions & 12 deletions core/src/test/scala/org/apache/spark/SparkConfSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,6 @@ class SparkConfSuite extends FunSuite with LocalSparkContext with ResetSystemPro
serializer.newInstance().serialize(new StringBuffer())
}

test("deprecated config keys") {
val conf = new SparkConf()
.set("spark.files.userClassPathFirst", "true")
.set("spark.yarn.user.classpath.first", "true")
assert(conf.contains("spark.files.userClassPathFirst"))
assert(conf.contains("spark.executor.userClassPathFirst"))
assert(conf.contains("spark.yarn.user.classpath.first"))
assert(conf.getBoolean("spark.files.userClassPathFirst", false))
assert(conf.getBoolean("spark.executor.userClassPathFirst", false))
assert(conf.getBoolean("spark.yarn.user.classpath.first", false))
}

}

class Class1 {}
Expand Down
4 changes: 3 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ each line consists of a key and a value separated by whitespace. For example:
Any values specified as flags or in the properties file will be passed on to the application
and merged with those specified through SparkConf. Properties set directly on the SparkConf
take highest precedence, then flags passed to `spark-submit` or `spark-shell`, then options
in the `spark-defaults.conf` file.
in the `spark-defaults.conf` file. A few configuration keys have been renamed since earlier
versions of Spark; in such cases, the older key names are still accepted, but take lower
precedence than any instance of the newer key.

## Viewing Spark Properties

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,8 @@ object Client extends Logging {
if (isDriver) {
conf.getBoolean("spark.driver.userClassPathFirst", false)
} else {
conf.getBoolean("spark.executor.userClassPathFirst", false)
conf.getBoolean("spark.executor.userClassPathFirst",
conf.getBoolean("spark.files.userClassPathFirst", false))
}
}

Expand Down