mridulm commented on code in PR #44340:
URL: https://github.com/apache/spark/pull/44340#discussion_r1428624893


##########
core/src/main/scala/org/apache/spark/scheduler/SparkListener.scala:
##########
@@ -289,7 +289,8 @@ case class SparkListenerApplicationStart(
     driverAttributes: Option[Map[String, String]] = None) extends 
SparkListenerEvent
 
 @DeveloperApi
-case class SparkListenerApplicationEnd(time: Long) extends SparkListenerEvent
+case class SparkListenerApplicationEnd(time: Long,
+                                       exitCode: Option[Int] = None) extends 
SparkListenerEvent

Review Comment:
   Fix indentation here.



##########
core/src/main/scala/org/apache/spark/util/JsonProtocol.scala:
##########
@@ -1065,7 +1069,11 @@ private[spark] object JsonProtocol extends JsonUtils {
   }
 
   def applicationEndFromJson(json: JsonNode): SparkListenerApplicationEnd = {
-    SparkListenerApplicationEnd(json.get("Timestamp").extractLong)
+    var exitCode: Option[Int] = None
+    if(json.has("ExitCode")) {
+      exitCode = Some(json.get("ExitCode").extractInt)
+    }

Review Comment:
   ```suggestion
       val exitCode = jsonOption(json.get("ExitCode")).map(_.extractInt)
   ```



##########
core/src/main/scala/org/apache/spark/util/JsonProtocol.scala:
##########
@@ -277,6 +277,10 @@ private[spark] object JsonProtocol extends JsonUtils {
     g.writeStartObject()
     g.writeStringField("Event", 
SPARK_LISTENER_EVENT_FORMATTED_CLASS_NAMES.applicationEnd)
     g.writeNumberField("Timestamp", applicationEnd.time)
+    applicationEnd.exitCode match {
+      case Some(exitCode) => g.writeNumberField("ExitCode", exitCode)
+      case _ => // No exit code provided
+    }

Review Comment:
   nit:
   
   ```suggestion
       // exit code, when available
       applicationEnd.exitCode.foreach(exitCode => 
g.writeNumberField("ExitCode", exitCode))
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to