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

    https://github.com/apache/spark/pull/3483#discussion_r21008476
  
    --- Diff: 
core/src/main/scala/org/apache/spark/scheduler/cluster/CoarseGrainedSchedulerBackend.scala
 ---
    @@ -127,7 +127,13 @@ class CoarseGrainedSchedulerBackend(scheduler: 
TaskSchedulerImpl, val actorSyste
             makeOffers()
     
           case KillTask(taskId, executorId, interruptThread) =>
    -        executorDataMap(executorId).executorActor ! KillTask(taskId, 
executorId, interruptThread)
    +        executorDataMap.get(executorId) match {
    +          case Some(executorInfo) =>
    +            executorInfo.executorActor ! KillTask(taskId, executorId, 
interruptThread)
    +          case None =>
    +            // Ignoring the task kill since the executor is not registered.
    +            logWarning(s"Attempted to kill task $taskId for unknown 
executor $executorId.")
    +        }
    --- End diff --
    
    I understand the general objection (pattern matching is usually a cop-out 
to better functional style) but that's not the appropriate pattern here. map is 
specifically designed to apply a morphism from A -> B (in Scala, f: A => B) to 
describe Option[A] -> Option[B]. What we are doing here is applying a choice of 
side effect, not a value, depending on the concrete Option. The example is 
(Option[A] -> Option[Unit]) -> Unit with misuse of monadic operators. Also, 
this code applies patterns found consistently elsewhere in this class file. If 
you believe strongly in this pattern, would you mind opening a PR for review?


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