org.apache.spark.deploy.SparkSubmit执行流程
SparkSubmit#doSubmit
// 解析参数并做参数验证,
val appArgs = parseArguments(args)
submit(appArgs, uninitLog)
//SparkSubmit#submit
// 环境准备
// childMainClass: org.apache.spark.deploy.yarn.YarnClusterApplication
val (childArgs, childClasspath, sparkConf, childMainClass) = prepareSubmitEnvironment(args)
// 根据准备的环境 执行child class的main方法
// mainClass 指定的情况并且是SparkApplication的子类: isYarnCluster 的情况, mainClass为org.apache.spark.deploy.yarn.YarnClusterApplication
val app: SparkApplication = if (classOf[SparkApplication].isAssignableFrom(mainClass)) {
mainClass.newInstance().asInstanceOf[SparkApplication]
} else {
// SPARK-4170
if (classOf[scala.App].isAssignableFrom(mainClass)) {
logWarning("Subclasses of scala.App may not work correctly. Use a main() method instead.")
}
new JavaMainApplication(mainClass)
}
// 当yarn cluster的场景,启动的是YarnClusterApplication
// 当yarn client的场景,启动的是JavaMainApplication