Spark程序Yarn集群提交Executor反向注册在分析
一 前言
有了spark的通信框架的基础再去看CoarseGrainedExecutorBackend
类,才会明白提交任务的最后一步反向注册
二 反向注册
- 先看上次源码
private def run(
driverUrl: String,
executorId: String,
hostname: String,
cores: Int,
appId: String,
workerUrl: Option[String],
userClassPath: Seq[URL]) {
val env = SparkEnv.createExecutorEnv(
driverConf, executorId, hostname, port, cores, cfg.ioEncryptionKey, isLocal = false)
env.rpcEnv.setupEndpoint("Executor", new CoarseGrainedExecutorBackend(
env.rpcEnv, driverUrl, executorId, hostname, cores, userClassPath, env))
workerUrl.foreach {
url =>
env.rpcEnv.setupEndpoint("WorkerWatcher", new WorkerWatcher(env.rpcEnv, url))
}
env.rpcEnv.awaitTermination()
SparkHadoopUtil.get.stopCredentialUpdater()
}
}
- 进入到run方法中看到了这些
rpcEnv
的字眼,根据上篇文章讲述这是一个通信终端的运行环境,并且还设置了一个名为Executor的终端,进入到setupEndpoint()
方法查看
2.1 setupEndpoint()方法
def setupEndpoint(name: String, endpoint: RpcEndpoint): RpcEndpointRef
- 明显这是一个抽象方法
- 找到实现类
NettyRpcEnv
中的这个方法
override