spark源码解析5-executor启动和任务处理流程

  1. 在创建taskScheduler的时候SparkContext.createTaskScheduler(thismaster),进行了 new SparkDeploySchedulerBackend()的步骤,在SparkDeploySchedulerBackend的84行,执行了app运行使用的调度器为CoarseGrainedExecutorBackend
    val command = Command("org.apache.spark.executor.CoarseGrainedExecutorBackend", //-----------指定调用的executor是哪个
  2. 在下面的new AppClient()中,有传入commond
  3. 查看AppClient的onStart()方法,调用了registerWithMaster(),然后调用了tryRegisterAllMasters()方法
  4. 在tryRegisterAllMasters()方法中向master发送了消息RegisterApplication(appDescriptionself)
  5. master接收到消息后,向appclient发送消息RegisteredApplication,监听任务运行状态,然后调用schedule()方法
  6. schedule()方法中调用startExecutorOnWorks()方法,在worker上调度和启动executor,在此方法中计算每个worker上可用的资源,并且分配每个worker上需要启动的资源,调用allocateWorkerResourceExecutor方法启动executor
  7. allocateWorkerResourceExecutor方法中,调用lauchExecutor()方法,启动executor
  8. 向worker发送消息,启动executor,向appclient发送消息,改变executor的状态
原文地址:https://www.cnblogs.com/haoyy/p/6201938.html