->CoarseGrainedExecutorBackend::receiveWithLogging --接收CoarseGrainedSchedulerBackend发来的消息
->case LaunchTask(data) => 处理启动task的消息
->val taskDesc = ser.deserialize[TaskDescription](data.value) --将受到的taskDescription反序列化
->executor.launchTask(this, taskDesc.taskId, taskDesc.name, taskDesc.serializedTask) --调用executor的launchTask方法
->Executor::launchTask( --Executor执行task的方法
->val tr = new TaskRunner(context, taskId, taskName, serializedTask) --创建一个新的task,这样可以放到新的线程中执行
->override def run() {
->val (taskFiles, taskJars, taskBytes) = Task.deserializeWithDependencies(serializedTask) --解析task字段
->updateDependencies(taskFiles, taskJars) //Download any missing dependencies if we receive a new set of files
//and JARs from theSparkContext. Also adds any new JARs we fetched to the class loader. 更新并补全依赖
->for ((name, timestamp) <- newFiles if currentFiles.getOrElse(name, -1L) < timestamp) --获取依赖文件
->Utils.fetchFile(name, new File(SparkFiles.getRootDirectory), conf, env.securityManager)
->for ((name, timestamp) <- newJars if currentJars.getOrElse(name, -1L) < timestamp) --获取依赖jar包
->Utils.fetchFile(name, new File(SparkFiles.getRootDirectory), conf, env.securityManager)
->val url = new File(SparkFiles.getRootDirectory, localName).toURI.toURL
->urlClassLoader.addURL(url)
->task = ser.deserialize[Task[Any]](taskBytes, Thread.currentThread.getContextClassLoader) --反序列化task
->val value = task.run(taskId.toInt) --直接调用task的run函数。
->val valueBytes = resultSer.serialize(value) --序列化任务结果
->val directResult = new DirectTaskResult(valueBytes, accumUpdates, task.metrics.orNull) 生成会送给的task结果
->val serializedDirectResult = ser.serialize(directResult) --序列化回送的结果
->execBackend.statusUpdate(taskId, TaskState.FINISHED, serializedResult) --回送结果
->driver ! StatusUpdate(executorId, taskId, state, data) --CoarseGrainedSchedulerBackend实现
->env.shuffleMemoryManager.releaseMemoryForThisThread() // Release memory used by this thread for shuffles
->env.blockManager.memoryStore.releaseUnrollMemoryForThisThread()// Release memory used by this thread for unrolling blocks
->runningTasks.remove(taskId)
->runningTasks.put(taskId, tr)
->threadPool.execute(tr)
===========================end======================
CoarseGrainedExecutorBackend: 是直接与master的CoarseGrainedSchedulerBackend类对位的,它们直接通信来实现任务的传递和结果回送功能。