EstSubmissionClientApp in Standalone cluster Mode

Posted by mpiaser on Wed, 09 Oct 2019 06:45:19 +0200

Look at the code first. This class of code is relatively short. The directory is deploy/rest / below.

private[spark] class RestSubmissionClientApp extends SparkApplication {
  /** Submits a request to run the application and return the response. Visible for testing. */
  def run(
      appResource: String,
      mainClass: String,
      appArgs: Array[String],
      conf: SparkConf,
      env: Map[String, String] = Map()): SubmitRestProtocolResponse = {
    val master = conf.getOption("spark.master").getOrElse {
      throw new IllegalArgumentException("'spark.master' must be set.")
    }
    val sparkProperties = conf.getAll.toMap
    val client = new RestSubmissionClient(master)
    val submitRequest = client.constructSubmitRequest(
      appResource, mainClass, appArgs, sparkProperties, env)
    client.createSubmission(submitRequest)
  }

  override def start(args: Array[String], conf: SparkConf): Unit = {
    if (args.length < 2) {
      sys.error("Usage: RestSubmissionClient [app resource] [main class] [app args*]")
      sys.exit(1)
    }
    val appResource = args(0)
    val mainClass = args(1)
    val appArgs = args.slice(2, args.length)
    val env = RestSubmissionClient.filterSystemEnvironment(sys.env)
    run(appResource, mainClass, appArgs, conf, env)
  }
}

Create a RestSubmissionClient client and submit the message to the client in the form of:

( appResource, mainClass, appArgs, sparkProperties, env)

client.createSubmission(submitRequest)

What does the client.createSubmission command do? He submits the message to the server, and the real handler is the server, the RestSubmissionServer class or its subclass. For a stand-alone cluster, Standalone RestServer handles it. We just look at the processing logic of the submit command.

There are two related functions:

Private method buildDriverDescription and override interface method handleSubmit

The previous method is called in handleSubmit, and the key code is two lines:

val driverDescription = buildDriverDescription(submitRequest)
val response = masterEndpoint.askSync[DeployMessages.SubmitDriverResponse](
          DeployMessages.RequestSubmitDriver(driverDescription))

Generate a DriverDescription type message, then send the Master Request Submit Driver message, let Master to schedule and execute our spark program, which is the driver here.

Next, we enter the Master process.


   

Topics: Spark REST