进入Worker类源码:

spark内核揭秘-13-Worker中Executor启动过程源码分析

 


可以看出Worker本身是Akka中的一个Actor。

 

进入Worker类的LaunchExecutor:

spark内核揭秘-13-Worker中Executor启动过程源码分析

spark内核揭秘-13-Worker中Executor启动过程源码分析

从源代码可以看出Worker节点上要分配CPU和Memory给新的Executor,首先需要创建一个ExecutorRunner:

ExecutorRunner是用于维护executor进程的:

 

 

1、进入ExecutorRunner 的start方法:

spark内核揭秘-13-Worker中Executor启动过程源码分析

1.1、进入fetchAndRunExecutor()方法(核心方法):

spark内核揭秘-13-Worker中Executor启动过程源码分析

spark内核揭秘-13-Worker中Executor启动过程源码分析

spark内核揭秘-13-Worker中Executor启动过程源码分析

2、进入 master ! ExecutorStateChanged(appId, execId, manager.state, None, None)方法:

发送消息给Master:

spark内核揭秘-13-Worker中Executor启动过程源码分析

spark内核揭秘-13-Worker中Executor启动过程源码分析

我们再回到到launchExecutor方法:

 

spark内核揭秘-13-Worker中Executor启动过程源码分析

进入ExecutorAdded方法:

spark内核揭秘-13-Worker中Executor启动过程源码分析

上面代码利用Akka 发送ExecutorStateChanged方法给Master

 

进入 Master 的ExecutorStateChanged方法:

spark内核揭秘-13-Worker中Executor启动过程源码分析

spark内核揭秘-13-Worker中Executor启动过程源码分析

PS:感觉代码分析的有点乱,不是很理想,希望大家知道,谢谢

进入Worker类的LaunchExecutor:

spark内核揭秘-13-Worker中Executor启动过程源码分析

spark内核揭秘-13-Worker中Executor启动过程源码分析

1、进入ExecutorRunner 的start方法:

spark内核揭秘-13-Worker中Executor启动过程源码分析

2、进入fetchAndRunExecutor()方法:

spark内核揭秘-13-Worker中Executor启动过程源码分析

spark内核揭秘-13-Worker中Executor启动过程源码分析

spark内核揭秘-13-Worker中Executor启动过程源码分析

相关文章:

  • 2021-08-02
  • 2021-05-21
  • 2021-09-25
  • 2021-10-27
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2021-12-18
  • 2021-08-05
  • 2021-12-19
  • 2021-11-11
  • 2021-04-20
相关资源
相似解决方案