agrawaldevesh commented on a change in pull request #29579:
URL: https://github.com/apache/spark/pull/29579#discussion_r479868285



##########
File path: 
core/src/main/scala/org/apache/spark/scheduler/cluster/CoarseGrainedSchedulerBackend.scala
##########
@@ -390,16 +390,18 @@ class CoarseGrainedSchedulerBackend(scheduler: 
TaskSchedulerImpl, val rpcEnv: Rp
         case Some(executorInfo) =>
           // This must be synchronized because variables mutated
           // in this block are read when requesting executors
-          val killed = CoarseGrainedSchedulerBackend.this.synchronized {
+          val lossReason = CoarseGrainedSchedulerBackend.this.synchronized {
             addressToExecutorId -= executorInfo.executorAddress
             executorDataMap -= executorId
             executorsPendingLossReason -= executorId
-            executorsPendingDecommission -= executorId
-            executorsPendingToRemove.remove(executorId).getOrElse(false)
+            val decommissioned = 
executorsPendingDecommission.remove(executorId)
+            executorsPendingToRemove
+              .remove(executorId).filter(killedByDriver => 
killedByDriver).map(_ => ExecutorKilled)

Review comment:
       This scala statement is quite a mouthful ? Would an if condition make it 
simpler ? How about:
   
   ```
   if (executorsPendingToRemove.remove(executorId).isDefined) {
     ExecutorKilled
   } else if (decommissioned) {
     ExecutorDecommision()
   } else {
     reason
   }
   ```
   
   Personally, I find this easier to read.
   
   The part I find confusing is the `.filter(killedByDriver => killedByDriver)`




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

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