Skip to content

Main

Main is the standalone application that is launched from spark-class shell script.

Launching Application

void main(
  String[] argsArray)

Note

main requires that at least the class name (className) is given as the first argument in the given argsArray.

For org.apache.spark.deploy.SparkSubmit class name, main creates a SparkSubmitCommandBuilder and builds a command (with the SparkSubmitCommandBuilder).

Otherwise, main creates a SparkClassCommandBuilder and builds a command (with the SparkClassCommandBuilder).

Class Name AbstractCommandBuilder
org.apache.spark.deploy.SparkSubmit SparkSubmitCommandBuilder
anything else SparkClassCommandBuilder

In the end, main prepareWindowsCommand or prepareBashCommand based on the operating system it runs on, MS Windows or non-Windows, respectively.

Building Command

List<String> buildCommand(
  AbstractCommandBuilder builder,
  Map<String, String> env,
  boolean printLaunchCommand)

buildCommand requests the given AbstractCommandBuilder to build a command.

With printLaunchCommand enabled, buildCommand prints out the command to standard error:

Spark Command: [cmd]
========================================

SPARK_PRINT_LAUNCH_COMMAND

printLaunchCommand is controlled by SPARK_PRINT_LAUNCH_COMMAND environment variable.