Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2516#discussion_r18065577
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala ---
    @@ -17,155 +17,195 @@
     
     package org.apache.spark.deploy
     
    -import java.io.{File, FileInputStream, IOException}
    -import java.util.Properties
    +import java.io.{InputStreamReader, File, FileInputStream, InputStream}
     import java.util.jar.JarFile
    +import java.util.Properties
     
    +import scala.collection._
    +import scala.collection.JavaConverters._
     import scala.collection.JavaConversions._
    -import scala.collection.mutable.{ArrayBuffer, HashMap}
    +import org.apache.commons.lang3.CharEncoding
     
    -import org.apache.spark.SparkException
    +import org.apache.spark.deploy.ConfigConstants._
     import org.apache.spark.util.Utils
     
    +
    +
     /**
    - * Parses and encapsulates arguments from the spark-submit script.
    - */
    + * Pulls configuration information together in order of priority
    + *
    + * Entries in the conf Map will be filled in the following priority order
    + * 1. entries specified on the command line (except from --conf entries)
    + * 2. Entries specified on the command line with --conf
    + * 3. Environment variables (including legacy variable mappings)
    + * 4. System config variables (eg by using -Dspark.var.name)
    + * 5  SPARK_DEFAULT_CONF/spark-defaults.conf or 
SPARK_HOME/conf/spark-defaults.conf if either exist
    + * 6. hard coded defaults in class path at spark-submit-defaults.prop
    + *
    + * A property file specified by one of the means listed above gets read in 
and the properties are
    + * considered to be at the priority of the method that specified the 
files. A property specified in
    + * a property file will not override an existing config value at that same 
level
    +*/
     private[spark] class SparkSubmitArguments(args: Seq[String]) {
    -  var master: String = null
    -  var deployMode: String = null
    -  var executorMemory: String = null
    -  var executorCores: String = null
    -  var totalExecutorCores: String = null
    -  var propertiesFile: String = null
    -  var driverMemory: String = null
    -  var driverExtraClassPath: String = null
    -  var driverExtraLibraryPath: String = null
    -  var driverExtraJavaOptions: String = null
    -  var driverCores: String = null
    -  var supervise: Boolean = false
    -  var queue: String = null
    -  var numExecutors: String = null
    -  var files: String = null
    -  var archives: String = null
    -  var mainClass: String = null
    -  var primaryResource: String = null
    -  var name: String = null
    -  var childArgs: ArrayBuffer[String] = new ArrayBuffer[String]()
    -  var jars: String = null
    -  var verbose: Boolean = false
    -  var isPython: Boolean = false
    -  var pyFiles: String = null
    -  val sparkProperties: HashMap[String, String] = new HashMap[String, 
String]()
    -
    -  /** Default properties present in the currently defined defaults file. */
    -  lazy val defaultSparkProperties: HashMap[String, String] = {
    -    val defaultProperties = new HashMap[String, String]()
    -    if (verbose) SparkSubmit.printStream.println(s"Using properties file: 
$propertiesFile")
    -    Option(propertiesFile).foreach { filename =>
    -      val file = new File(filename)
    -      SparkSubmitArguments.getPropertiesFromFile(file).foreach { case (k, 
v) =>
    -        if (k.startsWith("spark")) {
    -          defaultProperties(k) = v
    -          if (verbose) SparkSubmit.printStream.println(s"Adding default 
property: $k=$v")
    -        } else {
    -          SparkSubmit.printWarning(s"Ignoring non-spark config property: 
$k=$v")
    -        }
    -      }
    -    }
    -    defaultProperties
    -  }
    +  /**
    +   * Stores all configuration items except for child arguments,
    +   * referenced by the constants defined in ConfigConstants.scala
    +   */
    +  val conf = new mutable.HashMap[String, String]()
    +
    +  def master  = conf(SparkMaster)
    +  def master_= (value: String):Unit = conf.put(SparkMaster, value)
    +
    +  def deployMode = conf(SparkDeployMode)
    +  def deployMode_= (value: String):Unit = conf.put(SparkDeployMode, value)
    +
    +  def executorMemory = conf(SparkExecutorMemory)
    +  def executorMemory_= (value: String):Unit = 
conf.put(SparkExecutorMemory, value)
    +
    +  def executorCores = conf(SparkExecutorCores)
    +  def executorCores_= (value: String):Unit = conf.put(SparkExecutorCores, 
value)
    +
    +  def totalExecutorCores = conf.get(SparkCoresMax)
    +  def totalExecutorCores_= (value: String):Unit = conf.put(SparkCoresMax, 
value)
    +
    +  def driverMemory = conf(SparkDriverMemory)
    +  def driverMemory_= (value: String):Unit = conf.put(SparkDriverMemory, 
value)
    +
    +  def driverExtraClassPath = conf.get(SparkDriverExtraClassPath)
    +  def driverExtraClassPath_= (value: String):Unit = 
conf.put(SparkDriverExtraClassPath, value)
    +
    +  def driverExtraLibraryPath = conf.get(SparkDriverExtraLibraryPath)
    +  def driverExtraLibraryPath_= (value: String):Unit = 
conf.put(SparkDriverExtraLibraryPath, value)
    +
    +  def driverExtraJavaOptions = conf.get(SparkDriverExtraJavaOptions)
    +  def driverExtraJavaOptions_= (value: String):Unit = 
conf.put(SparkDriverExtraJavaOptions, value)
    +
    +  def driverCores = conf(SparkDriverCores)
    +  def driverCores_= (value: String):Unit = conf.put(SparkDriverCores, 
value)
    +
    +  def supervise = conf(SparkDriverSupervise) == true.toString
    +  def supervise_= (value: String):Unit = conf.put(SparkDriverSupervise, 
value)
    +
    +  def queue = conf(SparkYarnQueue)
    +  def queue_= (value: String):Unit = conf.put(SparkYarnQueue, value)
    +
    +  def numExecutors = conf(SparkExecutorInstances)
    +  def numExecutors_= (value: String):Unit = 
conf.put(SparkExecutorInstances, value)
    +
    +  def files = conf.get(SparkFiles)
    +  def files_= (value: String):Unit = conf.put(SparkFiles, value)
     
    -  // Respect SPARK_*_MEMORY for cluster mode
    -  driverMemory = sys.env.get("SPARK_DRIVER_MEMORY").orNull
    -  executorMemory = sys.env.get("SPARK_EXECUTOR_MEMORY").orNull
    +  def archives = conf.get(SparkYarnDistArchives)
    +  def archives_= (value: String):Unit = conf.put(SparkYarnDistArchives, 
value)
     
    -  parseOpts(args.toList)
    -  mergeSparkProperties()
    -  checkRequiredArguments()
    +  def mainClass = conf.get(SparkAppClass)
    +  def mainClass_= (value: String):Unit = conf.put(SparkAppClass, value)
     
    +  def primaryResource = conf.get(SparkAppPrimaryResource).get
    +  def primaryResource_= (value: String):Unit = 
conf.put(SparkAppPrimaryResource, value)
    +
    +  def name = conf.get(SparkAppName)
    +  def name_= (value: String):Unit = conf.put(SparkAppName, value)
    +
    +  def jars = conf.get(SparkJars)
    +  def jars_= (value: String):Unit = conf.put(SparkJars, value)
    +
    +  def pyFiles = conf.get(SparkSubmitPyFiles)
    +  def pyFiles_= (value: String):Unit = conf.put(SparkSubmitPyFiles, value)
    +
    +  lazy val verbose: Boolean =  SparkVerbose == true.toString
    +  lazy val isPython: Boolean = primaryResource != null &&
    --- End diff --
    
    nit: type is implicit. No need to declare it (as you haven't declared for 
the other vals in this file).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to