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

进入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启动过程源码分析