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

    https://github.com/apache/spark/pull/4363#discussion_r24107824
  
    --- Diff: core/src/main/scala/org/apache/spark/HeartbeatReceiver.scala ---
    @@ -32,18 +33,56 @@ private[spark] case class Heartbeat(
         taskMetrics: Array[(Long, TaskMetrics)], // taskId -> TaskMetrics
         blockManagerId: BlockManagerId)
     
    +private[spark] case object ExpireDeadHosts 
    +    
     private[spark] case class HeartbeatResponse(reregisterBlockManager: 
Boolean)
     
     /**
      * Lives in the driver to receive heartbeats from executors..
      */
    -private[spark] class HeartbeatReceiver(scheduler: TaskScheduler)
    +private[spark] class HeartbeatReceiver(sc: SparkContext, scheduler: 
TaskScheduler)
       extends Actor with ActorLogReceive with Logging {
     
    +  val executorLastSeen = new mutable.HashMap[String, Long]
    +  
    +  import context.dispatcher
    +  var  timeoutCheckingTask = context.system.scheduler.schedule(0.seconds,
    +      10.milliseconds, self, ExpireDeadHosts)
    +      
    +  val slaveTimeout = 
sc.conf.getLong("spark.storage.blockManagerSlaveTimeoutMs",
    +    math.max(sc.conf.getInt("spark.executor.heartbeatInterval", 10000) * 
3, 120000))
    +  
       override def receiveWithLogging = {
         case Heartbeat(executorId, taskMetrics, blockManagerId) =>
           val response = HeartbeatResponse(
             !scheduler.executorHeartbeatReceived(executorId, taskMetrics, 
blockManagerId))
    +      heartbeatReceived(executorId)
           sender ! response
    +    case ExpireDeadHosts =>
    +      expireDeadHosts()
    +      
    +  }
    +  
    +  private def heartbeatReceived(executorId: String) = {
    +    executorLastSeen(executorId) = System.currentTimeMillis()
    +  }
    +  
    +  private def expireDeadHosts() {
    +    logTrace("Checking for hosts with no recent heart beats in 
HeartbeatReceiver.")
    +    val now = System.currentTimeMillis()
    +    val minSeenTime = now - slaveTimeout
    +    for ((executorId, lastSeenMs) <- executorLastSeen) {
    +      if (lastSeenMs < minSeenTime) {
    +        val msg = "Removing Executor " + executorId + " with no recent 
heart beats: "
    +            +(now - lastSeenMs) + "ms exceeds " + slaveTimeout + "ms"
    +        logWarning(msg)
    +        if 
(scheduler.isInstanceOf[org.apache.spark.scheduler.TaskSchedulerImpl]) {
    --- End diff --
    
    I think it would be better to add a method to `TaskScheduler` for this.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to