Github user tgravescs commented on a diff in the pull request:
https://github.com/apache/spark/pull/5321#discussion_r27880984
--- Diff: core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala
---
@@ -201,6 +199,30 @@ class SparkHadoopUtil extends Logging {
val baseStatus = fs.getFileStatus(basePath)
if (baseStatus.isDir) recurse(basePath) else Array(baseStatus)
}
+
+ private val varPattern = """(\$\{hadoop-[^\}\$\u0020]+\})""".r.unanchored
+
+ /**
+ * Substitute variables by looking them up in Hadoop configs. Only
variables that match the
+ * ${hadoop- .. } pattern are substituted.
+ */
+ def substituteHadoopVariables(text: String, hadoopConf: Configuration):
String = {
+ text match {
+ case varPattern(matched) => {
+ val key = matched.substring(9, matched.length() - 1) // remove
${hadoop- .. }
+ val eval = Option[String](hadoopConf.get(key))
+ .map { value => text.replace(matched, value) }
+ if (eval.isEmpty) {
+ // The variable was not found in Hadoop configs, so return text
as is.
--- End diff --
it might be nice to put logDebug in here in case someone trying to debug
the regex pattern
---
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]