Scala中沒有靜態類型,但是有有“伴侶對象”,起到類似的作用。
Scala中類對象中不可有靜態變量和靜態方法,但是提供了“伴侶對象”的功能:在和類的同一個文件中定義同名的Object對象:(須在同一文件中;main方法定義在Object對象中)
private[spark] class Client( val args: ClientArguments, val hadoopConf: Configuration, val sparkConf: SparkConf) extends Logging {...} object Client extends Logging { def main(argStrings: Array[String]) { if (!sys.props.contains("SPARK_SUBMIT")) { logWarning("WARNING: This client is deprecated and will be removed in a " + "future version of Spark. Use ./bin/spark-submit with \"--master yarn\"") } // Set an env variable indicating we are running in YARN mode. // Note that any env variable with the SPARK_ prefix gets propagated to all (remote) processes System.setProperty("SPARK_YARN_MODE", "true") val sparkConf = new SparkConf val args = new ClientArguments(argStrings, sparkConf) // to maintain backwards-compatibility if (!Utils.isDynamicAllocationEnabled(sparkConf)) { sparkConf.setIfMissing("spark.executor.instances", args.numExecutors.toString) } new Client(args, sparkConf).run() } ...... }