YarnSparkHadoopUtil
is…FIXME
It can only be created when SPARK_YARN_MODE flag is enabled.
Note
|
It belongs to org.apache.spark.deploy.yarn package.
|
Tip
|
Enable Add the following line to
Refer to Logging. |
expandEnvironment(environment: Environment): String
expandEnvironment
resolves environment
variable using YARN’s Environment.$
or Environment.$$
methods (depending on the version of Hadoop used).
getContainerId: ContainerId
getContainerId
is a private[spark]
method that gets YARN’s ContainerId
from the YARN environment variable ApplicationConstants.Environment.CONTAINER_ID
and converts it to the return object using YARN’s ConverterUtils.toContainerId
.
getInitialTargetExecutorNumber(
conf: SparkConf,
numExecutors: Int = DEFAULT_NUMBER_EXECUTORS): Int
getInitialTargetExecutorNumber
calculates the initial number of executors for Spark on YARN. It varies by whether dynamic allocation is enabled or not.
Note
|
The default number of executors (aka DEFAULT_NUMBER_EXECUTORS ) is 2 .
|
If dynamic allocation is enabled, getInitialTargetExecutorNumber
returns the value of spark.dynamicAllocation.initialExecutors or spark.dynamicAllocation.minExecutors or 0
.
If however dynamic allocation is disabled, getInitialTargetExecutorNumber
returns the value of spark.executor.instances setting or SPARK_EXECUTOR_INSTANCES
environment variable, or the default value (of the input parameter numExecutors
) 2
.
Note
|
It is used to calculate totalExpectedExecutors to start Spark on YARN in client mode or cluster mode. |