-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-10790][YARN] Fix initial executor number not set issue and consolidate the codes #8910
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,7 +39,7 @@ import org.apache.hadoop.yarn.util.ConverterUtils | |
| import org.apache.spark.deploy.SparkHadoopUtil | ||
| import org.apache.spark.launcher.YarnCommandBuilderUtils | ||
| import org.apache.spark.{SecurityManager, SparkConf, SparkException} | ||
| import org.apache.spark.util.Utils | ||
| import org.apache.spark.util.{IntParam, Utils} | ||
|
|
||
| /** | ||
| * Contains util methods to interact with Hadoop from spark. | ||
|
|
@@ -314,5 +314,28 @@ object YarnSparkHadoopUtil { | |
| def getClassPathSeparator(): String = { | ||
| classPathSeparatorField.get(null).asInstanceOf[String] | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The refactoring is nice. This is a reasonable place for this code now, though eventually it may not be YARN-specific? |
||
| /** Get the initial target number of executors depends on dynamic allocation is enabled or not */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: "Getting the initial target number of executors depends on whether dynamic allocation is enabled." |
||
| def getTargetExecutorNumber(conf: SparkConf): Int = { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (Utils.isDynamicAllocationEnabled(conf)) { | ||
| val minNumExecutors = conf.getInt("spark.dynamicAllocation.minExecutors", 0) | ||
| val initialNumExecutors = | ||
| conf.getInt("spark.dynamicAllocation.initialExecutors", minNumExecutors) | ||
| val maxNumExecutors = conf.getInt("spark.dynamicAllocation.maxExecutors", Int.MaxValue) | ||
| require(initialNumExecutors >= minNumExecutors && initialNumExecutors <= maxNumExecutors, | ||
| s"initial executor number $initialNumExecutors must between min executor number" + | ||
| s"$minNumExecutors and max executor number $maxNumExecutors") | ||
|
|
||
| initialNumExecutors | ||
| } else { | ||
| var targetNumExecutors = DEFAULT_NUMBER_EXECUTORS | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: can this be a |
||
| if (System.getenv("SPARK_EXECUTOR_INSTANCES") != null) { | ||
| targetNumExecutors = IntParam.unapply(System.getenv("SPARK_EXECUTOR_INSTANCES")) | ||
| .getOrElse(targetNumExecutors) | ||
| } | ||
| // System property can override environment variable. | ||
| conf.getInt("spark.executor.instances", targetNumExecutors) | ||
| } | ||
| } | ||
| } | ||
|
|
||
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.
not necessary anymore?