Github user sryza commented on a diff in the pull request:
https://github.com/apache/spark/pull/3233#discussion_r23738607
--- Diff: core/src/main/scala/org/apache/spark/SparkConf.scala ---
@@ -375,4 +390,64 @@ private[spark] object SparkConf {
def isSparkPortConf(name: String): Boolean = {
(name.startsWith("spark.") && name.endsWith(".port")) ||
name.startsWith("spark.port.")
}
+
+ /**
+ * Returns the configuration key to use for the given user-provided key,
translating
+ * deprecated keys.
+ *
+ * @param userKey Configuration key from the user / caller.
+ * @param warn Whether to print a warning if the key is depreated.
Warnings will be printed
+ * only once for each key.
+ */
+ def getConfKey(userKey: String, warn: Boolean = false): String = {
+ val deprecatedKey = deprecatedConfigs.getOrElse(userKey, null)
+ if (deprecatedKey != null) {
+ if (warn) {
+ deprecatedKey.warn()
+ }
+ if (deprecatedKey.newName != null) deprecatedKey.newName else userKey
+ } else {
+ userKey
+ }
+ }
+
+ /**
+ * Holds information about keys that have been deprecated or renamed.
+ *
+ * @param oldName Old configuration key.
+ * @param newName New configuration key, or `null` if key has no
replacement, in which case the
+ * deprecated key will be used (but the warning message
will still be printed).
+ * @param version Version of Spark where key was deprecated.
+ * @param deprecationMessage Message to include in the deprecation
warning; mandatory when
+ * `newName` is not provided.
+ */
+ private case class DeprecatedConfig(
+ oldName: String,
+ newName: String,
+ version: String,
+ deprecationMessage: String = null) {
+
+ private val warned = new AtomicBoolean(false)
+
+ if (newName == null && (deprecationMessage == null ||
deprecationMessage.isEmpty())) {
+ throw new IllegalArgumentException("Need new config name or
deprecation message.")
+ }
+
+ def warn() = {
--- End diff --
: Unit =
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]