一、初始化,
在SparkEnv中初始化
1.1、BlockManagerMaster初始化BlockMangerMaster负责对Block的管理和协调,
val blockManagerMaster = new BlockManagerMaster(registerOrLookupEndpoint(
BlockManagerMaster.DRIVER_ENDPOINT_NAME,
new BlockManagerMasterEndpoint(rpcEnv, isLocal, conf, listenerBus)),
conf, isDriver)
需要注册Endpoint
//注册或者查找EndPoint
def registerOrLookupEndpoint(
name: String, endpointCreator: => RpcEndpoint):
RpcEndpointRef = {
if (isDriver) { //Driver和Executor要区分
logInfo("Registering " + name)
rpcEnv.setupEndpoint(name, endpointCreator)
} else { // executor需要创建一个EndpointRef
RpcUtils.makeDriverRef(name, conf, rpcEnv)
}
}