Github user kayousterhout commented on a diff in the pull request:
https://github.com/apache/spark/pull/16813#discussion_r99944122
--- Diff:
core/src/main/scala/org/apache/spark/scheduler/SchedulableBuilder.scala ---
@@ -69,60 +72,81 @@ private[spark] class FairSchedulableBuilder(val
rootPool: Pool, conf: SparkConf)
val DEFAULT_WEIGHT = 1
override def buildPools() {
- var is: Option[InputStream] = None
+ var fileData: Option[FileData] = None
try {
- is = Option {
- schedulerAllocFile.map { f =>
- new FileInputStream(f)
- }.getOrElse {
-
Utils.getSparkClassLoader.getResourceAsStream(DEFAULT_SCHEDULER_FILE)
- }
- }
-
- is.foreach { i => buildFairSchedulerPool(i) }
+ fileData = getFileData()
+ fileData.foreach { data => buildFairSchedulerPool(data) }
+ } catch {
+ case NonFatal(t) =>
+ logError("Error while building the fair scheduler pools: ", t)
+ throw t
} finally {
- is.foreach(_.close())
+ fileData.foreach(_.inputStream.close())
}
// finally create "default" pool
buildDefaultPool()
}
+ private def getFileData(): Option[FileData] = {
+ schedulerAllocFile.map { f =>
+ val file = new File(f)
+ val fis = new FileInputStream(file)
+ logInfo(s"Creating Fair Scheduler pools from ${file.getName}")
+ Some(FileData(fis, file.getName))
+ }.getOrElse {
+ val is =
Utils.getSparkClassLoader.getResourceAsStream(DEFAULT_SCHEDULER_FILE)
+ if(is != null) {
+ logInfo(s"Creating Fair Scheduler pools from default file:
$DEFAULT_SCHEDULER_FILE")
+ Some(FileData(is, DEFAULT_SCHEDULER_FILE))
+ }
+ else {
+ logWarning("Fair Scheduler configuration file not found so jobs
will be scheduled " +
+ "in FIFO order")
+ None
+ }
+ }
+ }
+
private def buildDefaultPool() {
if (rootPool.getSchedulableByName(DEFAULT_POOL_NAME) == null) {
val pool = new Pool(DEFAULT_POOL_NAME, DEFAULT_SCHEDULING_MODE,
DEFAULT_MINIMUM_SHARE, DEFAULT_WEIGHT)
rootPool.addSchedulable(pool)
- logInfo("Created default pool %s, schedulingMode: %s, minShare: %d,
weight: %d".format(
+ logInfo("Created default pool: %s, schedulingMode: %s, minShare: %d,
weight: %d".format(
DEFAULT_POOL_NAME, DEFAULT_SCHEDULING_MODE, DEFAULT_MINIMUM_SHARE,
DEFAULT_WEIGHT))
}
}
- private def buildFairSchedulerPool(is: InputStream) {
- val xml = XML.load(is)
+ private def buildFairSchedulerPool(fileData: FileData) {
--- End diff --
it would be better to make this method unaware of the FileData class, and
instead just have two input params: the InputStream and the Filename
---
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]