[SPARK-19545][YARN] Fix compile issue for Spark on Yarn when building against Hadoop 2.6.0~2.6.3
## What changes were proposed in this pull request? Due to the newly added API in Hadoop 2.6.4+, Spark builds against Hadoop 2.6.0~2.6.3 will meet compile error. So here still reverting back to use reflection to handle this issue. ## How was this patch tested? Manual verification. Author: jerryshao <sshao@hortonworks.com> Closes #16884 from jerryshao/SPARK-19545.
This commit is contained in:
parent
d5593f7f57
commit
8e8afb3a34
|
@ -445,7 +445,7 @@ To use a custom metrics.properties for the application master and executors, upd
|
|||
This will be used with YARN's rolling log aggregation, to enable this feature in YARN side
|
||||
<code>yarn.nodemanager.log-aggregation.roll-monitoring-interval-seconds</code> should be
|
||||
configured in yarn-site.xml.
|
||||
This feature can only be used with Hadoop 2.6.1+. The Spark log4j appender needs be changed to use
|
||||
This feature can only be used with Hadoop 2.6.4+. The Spark log4j appender needs be changed to use
|
||||
FileAppender or another appender that can handle the files being removed while its running. Based
|
||||
on the file name configured in the log4j configuration (like spark.log), the user should set the
|
||||
regex (spark*) to include all the log files that need to be aggregated.
|
||||
|
|
|
@ -245,12 +245,27 @@ private[spark] class Client(
|
|||
}
|
||||
|
||||
sparkConf.get(ROLLED_LOG_INCLUDE_PATTERN).foreach { includePattern =>
|
||||
try {
|
||||
val logAggregationContext = Records.newRecord(classOf[LogAggregationContext])
|
||||
logAggregationContext.setRolledLogsIncludePattern(includePattern)
|
||||
|
||||
// These two methods were added in Hadoop 2.6.4, so we still need to use reflection to
|
||||
// avoid compile error when building against Hadoop 2.6.0 ~ 2.6.3.
|
||||
val setRolledLogsIncludePatternMethod =
|
||||
logAggregationContext.getClass.getMethod("setRolledLogsIncludePattern", classOf[String])
|
||||
setRolledLogsIncludePatternMethod.invoke(logAggregationContext, includePattern)
|
||||
|
||||
sparkConf.get(ROLLED_LOG_EXCLUDE_PATTERN).foreach { excludePattern =>
|
||||
logAggregationContext.setRolledLogsExcludePattern(excludePattern)
|
||||
val setRolledLogsExcludePatternMethod =
|
||||
logAggregationContext.getClass.getMethod("setRolledLogsExcludePattern", classOf[String])
|
||||
setRolledLogsExcludePatternMethod.invoke(logAggregationContext, excludePattern)
|
||||
}
|
||||
|
||||
appContext.setLogAggregationContext(logAggregationContext)
|
||||
} catch {
|
||||
case NonFatal(e) =>
|
||||
logWarning(s"Ignoring ${ROLLED_LOG_INCLUDE_PATTERN.key} because the version of YARN " +
|
||||
"does not support it", e)
|
||||
}
|
||||
}
|
||||
|
||||
appContext
|
||||
|
|
Loading…
Reference in a new issue