Spark内核源码深度剖析:Master注册机制原理剖析与源码分析

1.Master注册机制原理剖析(图解)

Spark内核源码深度剖析:Master注册机制原理剖析与源码分析_第1张图片

2.部分源码分析

master.scala中的Application注册原理代码分析:

  case RegisterApplication(description) => {
  //如果master的状态是standby,就是当前的这个master,是standby master,
  //而不是Active Master,那么,当Application来请求注册时,会忽略请求。
  if (state == RecoveryState.STANDBY) {
    // ignore, don't send response
  } else {
    logInfo("Registering app " + description.name)
   //用ApplicationDescription信息,创建ApplicationInfo
    val app = createApplication(description, sender)
    //注册Application
   //将Application加入缓存中,并将Application加入等待调度的队列中-waitingApps
    registerApplication(app)
    logInfo("Registered app " + description.name + " with ID " + app.id)
    //使用持久化引擎,将Application进行持久化
    persistenceEngine.addApplication(app)
    //反向,向SparkDeploySchedulerBackend的APPClient的ClientActor,发送消息,也就是RegisterApplication
    sender ! RegisteredApplication(app.id, masterUrl)
    schedule()
  }

你可能感兴趣的:(spark,spark,源码)