Spark Executor工作原理
ExecutorBackend注册
Executor实例化
Executor具体是如何工作的?
CoarseGrainedExecutorBac
Worker为什么要启动另外一个进程?
Worker本身是管理当前机器上的资源,变动资源的时候向Master汇报。有很多应用程序,就需要很多Executor。这样程序之间不会一个奔溃导致所有的都奔溃。
1.在CoarseGrainedExecutorBac
2.CoarseGrainedExecutorBac
3. CoarseGrainedExecutorBac
4. CoarseGrainedExecutorBac
5.在Driver进程中,有两个至关重要的Endpoint,
a)第一个就是ClientEndpoint,主要负责向Master注册当前的程序;是AppClient的内部成员。
b)另外一个就是DriverEndpoint,这是整个程序运行时候的驱动器!!是CoarseGrainedExecutorBac
6.在Driver中通过ExecutorData封装并注册ExecutorBackend的信息到Driver的内存数据结构ExecutorMapData中。ExecutorMapData是CoarseGrainedSchedulerBa
private[cluster]
)
7.实际在执行的时候,DriverEndpoint会把信息写入CoarseGrainedSchedulerBa
8.CoarseGrainedExecutorBac
Executor是如何工作的?
1.当Driver发送过来Task的时候,其实是发送给了CoarseGrainedExecutorBac
caseLaunchTask(data) =>
if (executor == null) {
"Received LaunchTask command but executor was null") logError(
1) System.exit(
else } {
val taskDesc = ser.deserialize[TaskDescription](data.value)
"Got assigned task " logInfo( + taskDesc.taskId)
executor.launchTask(this, taskId = taskDesc.taskId, attemptNumber = taskDesc.attemptNumber,
taskDesc.name, taskDesc.serializedTask)
}
2.ExecutorBackend在收到Driver中发送过来的消息后,会通过调用launchTask来交给Executor去执行。
caseLaunchTask(data) =>
if (executor == null) {
"Received LaunchTask command but executor was null") logError(
1) System.exit(
else } {
val taskDesc = ser.deserialize[TaskDescription](data.value)
"Got assigned task " logInfo( + taskDesc.taskId)
executor.launchTask(this, taskId = taskDesc.taskId, attemptNumber = taskDesc.attemptNumber,
taskDesc.name, taskDesc.serializedTask)
}