-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19466][CORE][SCHEDULER] Improve Fair Scheduler Logging #16813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2ed8cad
Improve Fair Scheduler Logging
erenavsarogullari 64a88af
Review comments are addressed.
erenavsarogullari 790097e
Latest review comments are addressed.
erenavsarogullari 3da98c7
Review comments are addressed.
erenavsarogullari d508d92
Review comments are addressed.
erenavsarogullari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ package org.apache.spark.scheduler | |
| import java.io.{FileInputStream, InputStream} | ||
| import java.util.{NoSuchElementException, Properties} | ||
|
|
||
| import scala.util.control.NonFatal | ||
| import scala.xml.{Node, XML} | ||
|
|
||
| import org.apache.spark.SparkConf | ||
|
|
@@ -69,19 +70,31 @@ private[spark] class FairSchedulableBuilder(val rootPool: Pool, conf: SparkConf) | |
| val DEFAULT_WEIGHT = 1 | ||
|
|
||
| override def buildPools() { | ||
| var is: Option[InputStream] = None | ||
| var fileData: Option[(InputStream, String)] = None | ||
| try { | ||
| is = Option { | ||
| schedulerAllocFile.map { f => | ||
| new FileInputStream(f) | ||
| }.getOrElse { | ||
| Utils.getSparkClassLoader.getResourceAsStream(DEFAULT_SCHEDULER_FILE) | ||
| fileData = schedulerAllocFile.map { f => | ||
| val fis = new FileInputStream(f) | ||
| logInfo(s"Creating Fair Scheduler pools from $f") | ||
| Some((fis, f)) | ||
| }.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((is, DEFAULT_SCHEDULER_FILE)) | ||
| } else { | ||
| logWarning("Fair Scheduler configuration file not found so jobs will be scheduled " + | ||
| "in FIFO order") | ||
| None | ||
| } | ||
| } | ||
|
|
||
| is.foreach { i => buildFairSchedulerPool(i) } | ||
| fileData.foreach { case (is, fileName) => buildFairSchedulerPool(is, fileName) } | ||
| } catch { | ||
| case NonFatal(t) => | ||
| logError("Error while building the fair scheduler pools: ", t) | ||
|
||
| throw t | ||
| } finally { | ||
| is.foreach(_.close()) | ||
| fileData.foreach { case (is, fileName) => is.close() } | ||
| } | ||
|
|
||
| // finally create "default" pool | ||
|
|
@@ -93,36 +106,40 @@ private[spark] class FairSchedulableBuilder(val rootPool: Pool, conf: SparkConf) | |
| 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) { | ||
| private def buildFairSchedulerPool(is: InputStream, fileName: String) { | ||
| val xml = XML.load(is) | ||
| for (poolNode <- (xml \\ POOLS_PROPERTY)) { | ||
|
|
||
| val poolName = (poolNode \ POOL_NAME_PROPERTY).text | ||
|
|
||
| val schedulingMode = getSchedulingModeValue(poolNode, poolName, DEFAULT_SCHEDULING_MODE) | ||
| val minShare = getIntValue(poolNode, poolName, MINIMUM_SHARES_PROPERTY, DEFAULT_MINIMUM_SHARE) | ||
| val weight = getIntValue(poolNode, poolName, WEIGHT_PROPERTY, DEFAULT_WEIGHT) | ||
| val schedulingMode = getSchedulingModeValue(poolNode, poolName, | ||
| DEFAULT_SCHEDULING_MODE, fileName) | ||
| val minShare = getIntValue(poolNode, poolName, MINIMUM_SHARES_PROPERTY, | ||
| DEFAULT_MINIMUM_SHARE, fileName) | ||
| val weight = getIntValue(poolNode, poolName, WEIGHT_PROPERTY, | ||
| DEFAULT_WEIGHT, fileName) | ||
|
|
||
| rootPool.addSchedulable(new Pool(poolName, schedulingMode, minShare, weight)) | ||
|
|
||
| logInfo("Created pool %s, schedulingMode: %s, minShare: %d, weight: %d".format( | ||
| logInfo("Created pool: %s, schedulingMode: %s, minShare: %d, weight: %d".format( | ||
| poolName, schedulingMode, minShare, weight)) | ||
| } | ||
| } | ||
|
|
||
| private def getSchedulingModeValue( | ||
| poolNode: Node, | ||
| poolName: String, | ||
| defaultValue: SchedulingMode): SchedulingMode = { | ||
| defaultValue: SchedulingMode, fileName: String): SchedulingMode = { | ||
|
|
||
| val xmlSchedulingMode = (poolNode \ SCHEDULING_MODE_PROPERTY).text.trim.toUpperCase | ||
| val warningMessage = s"Unsupported schedulingMode: $xmlSchedulingMode, using the default " + | ||
| s"schedulingMode: $defaultValue for pool: $poolName" | ||
| val warningMessage = s"Unsupported schedulingMode: $xmlSchedulingMode found in " + | ||
| s"Fair Scheduler configuration file: $fileName, using " + | ||
| s"the default schedulingMode: $defaultValue for pool: $poolName" | ||
| try { | ||
| if (SchedulingMode.withName(xmlSchedulingMode) != SchedulingMode.NONE) { | ||
| SchedulingMode.withName(xmlSchedulingMode) | ||
|
|
@@ -140,14 +157,15 @@ private[spark] class FairSchedulableBuilder(val rootPool: Pool, conf: SparkConf) | |
| private def getIntValue( | ||
| poolNode: Node, | ||
| poolName: String, | ||
| propertyName: String, defaultValue: Int): Int = { | ||
| propertyName: String, | ||
| defaultValue: Int, fileName: String): Int = { | ||
|
||
|
|
||
| val data = (poolNode \ propertyName).text.trim | ||
| try { | ||
| data.toInt | ||
| } catch { | ||
| case e: NumberFormatException => | ||
| logWarning(s"Error while loading scheduler allocation file. " + | ||
| logWarning(s"Error while loading fair scheduler configuration from $fileName: " + | ||
| s"$propertyName is blank or invalid: $data, using the default $propertyName: " + | ||
| s"$defaultValue for pool: $poolName") | ||
| defaultValue | ||
|
|
@@ -166,7 +184,7 @@ private[spark] class FairSchedulableBuilder(val rootPool: Pool, conf: SparkConf) | |
| parentPool = new Pool(poolName, DEFAULT_SCHEDULING_MODE, | ||
| DEFAULT_MINIMUM_SHARE, DEFAULT_WEIGHT) | ||
| rootPool.addSchedulable(parentPool) | ||
| logInfo("Created pool %s, schedulingMode: %s, minShare: %d, weight: %d".format( | ||
| logInfo("Created pool: %s, schedulingMode: %s, minShare: %d, weight: %d".format( | ||
| poolName, DEFAULT_SCHEDULING_MODE, DEFAULT_MINIMUM_SHARE, DEFAULT_WEIGHT)) | ||
| } | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add "($DEFAULT_SCHEDULER_FILE)" after "file "?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case happens when
spark.scheduler.allocation.fileproperty is not set and default scheduler file does not exist in classpath so warning message is not specific for only default one. I think current generic message looks more suitable, WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm ok what about adding at the end "To use fair scheduling, configure pools in $DEFAULT_SCHEDULER_FILE, or set spark.scheduler.allocation.file to a file that contains the configuration." I think it's nice to give users as much info as possible about how to fix the problem, although I don't feel strongly so if you prefer the current message, that's fine too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, i totally agree for informing the user about how to fix the problem. Addressing by adding information.