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

    https://github.com/apache/spark/pull/4216#discussion_r23880057
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/rest/SubmitDriverRequest.scala ---
    @@ -0,0 +1,146 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.deploy.rest
    +
    +import scala.collection.mutable
    +import scala.collection.mutable.ArrayBuffer
    +
    +import com.fasterxml.jackson.annotation.{JsonIgnore, JsonProperty}
    +import org.json4s.jackson.JsonMethods._
    +
    +import org.apache.spark.util.JsonProtocol
    +
    +/**
    + * A request to submit a driver in the REST application submission 
protocol.
    + */
    +class SubmitDriverRequest extends SubmitRestProtocolRequest {
    +  private val appName = new SubmitRestProtocolField[String]("appName")
    +  private val appResource = new 
SubmitRestProtocolField[String]("appResource")
    +  private val mainClass = new SubmitRestProtocolField[String]("mainClass")
    +  private val jars = new SubmitRestProtocolField[String]("jars")
    +  private val files = new SubmitRestProtocolField[String]("files")
    +  private val pyFiles = new SubmitRestProtocolField[String]("pyFiles")
    +  private val driverMemory = new 
SubmitRestProtocolField[String]("driverMemory")
    +  private val driverCores = new SubmitRestProtocolField[Int]("driverCores")
    +  private val driverExtraJavaOptions = new 
SubmitRestProtocolField[String]("driverExtraJavaOptions")
    +  private val driverExtraClassPath = new 
SubmitRestProtocolField[String]("driverExtraClassPath")
    +  private val driverExtraLibraryPath = new 
SubmitRestProtocolField[String]("driverExtraLibraryPath")
    +  private val superviseDriver = new 
SubmitRestProtocolField[Boolean]("superviseDriver")
    +  private val executorMemory = new 
SubmitRestProtocolField[String]("executorMemory")
    +  private val totalExecutorCores = new 
SubmitRestProtocolField[Int]("totalExecutorCores")
    +
    +  // Special fields
    +  private val appArgs = new ArrayBuffer[String]
    +  private val sparkProperties = new mutable.HashMap[String, String]
    +  private val envVars = new mutable.HashMap[String, String]
    +
    +  def getAppName: String = appName.toString
    +  def getAppResource: String = appResource.toString
    +  def getMainClass: String = mainClass.toString
    +  def getJars: String = jars.toString
    +  def getFiles: String = files.toString
    +  def getPyFiles: String = pyFiles.toString
    +  def getDriverMemory: String = driverMemory.toString
    +  def getDriverCores: String = driverCores.toString
    +  def getDriverExtraJavaOptions: String = driverExtraJavaOptions.toString
    +  def getDriverExtraClassPath: String = driverExtraClassPath.toString
    +  def getDriverExtraLibraryPath: String = driverExtraLibraryPath.toString
    +  def getSuperviseDriver: String = superviseDriver.toString
    +  def getExecutorMemory: String = executorMemory.toString
    +  def getTotalExecutorCores: String = totalExecutorCores.toString
    +
    +  // Special getters required for JSON serialization
    +  @JsonProperty("appArgs")
    +  private def getAppArgsJson: String = arrayToJson(getAppArgs)
    --- End diff --
    
    I think you're still doing a lot more work to futz with the json than you 
to.  I dug into a little bit, and I think the problem is that the json4s 
wrapper around jackson is lacking a lot of features.  And to use jackson well, 
you need to add in the [scala 
module](http://search.maven.org/#artifactdetails%7Ccom.fasterxml.jackson.module%7Cjackson-module-scala_2.10%7C2.3.1%7Cbundle)
 (or just define these simple bean classes in java).  Eg.:
    
    ```
    class FooBar{
      var blah: String = _
      var ooga: Array[String] = _
      var wakka: Map[String,String] = _
    }
    val f = new FooBar
    f.blah = "hi"
    f.ooga = Array("flim", "flam", "floop")
    f.wakka = Map("bip" -> "bop", "beep" -> "boop")
    val mapper = new ObjectMapper()
    mapper.registerModule(com.fasterxml.jackson.module.scala.DefaultScalaModule)
    println(mapper.writeValueAsString(f))
    ```
    
    prints out 
`{"blah":"hi","ooga":["flim","flam","floop"],"wakka":{"bip":"bop","beep":"boop"}}`
    (it throws an exception w/out the scala module)



---
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