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

    https://github.com/apache/spark/pull/1056#discussion_r15526822
  
    --- Diff: core/src/main/scala/org/apache/spark/executor/Executor.scala ---
    @@ -348,4 +353,48 @@ private[spark] class Executor(
           }
         }
       }
    +
    +  def stop() {
    +    isStopped = true
    +    threadPool.shutdown()
    +  }
    +
    +  def startDriverHeartbeater() {
    +    val interval = conf.getInt("spark.executor.heartbeatInterval", 2000)
    +    val timeout = AkkaUtils.lookupTimeout(conf)
    +    val retryAttempts = AkkaUtils.numRetries(conf)
    +    val retryIntervalMs = AkkaUtils.retryWaitMs(conf)
    +    val heartbeatReceiverRef = 
AkkaUtils.makeDriverRef("HeartbeatReceiver", conf, env.actorSystem)
    +
    +    val t = new Thread() {
    +      override def run() {
    +        // Sleep a random interval so the heartbeats don't end up in sync
    +        Thread.sleep(interval + (math.random * interval).asInstanceOf[Int])
    +
    +        while (!isStopped) {
    +          val tasksMetrics = new ArrayBuffer[(Long, TaskMetrics)]()
    +          for (taskRunner <- runningTasks.values()) {
    +            if (taskRunner.running) {
    +              Option(taskRunner.task).flatMap(_.metrics).foreach { metrics 
=>
    +                tasksMetrics += ((taskRunner.taskId, metrics))
    +              }
    +            }
    +          }
    +
    +          val message = Heartbeat(executorId, tasksMetrics.toArray,
    +            env.blockManager.blockManagerId)
    +          val response = 
AkkaUtils.askWithReply[HeartbeatResponse](message, heartbeatReceiverRef,
    --- End diff --
    
    The thread is a daemon thread, so it shouldn't hold things up.  The 
BlockManager heartbeat used to do pretty much the same thing.  I've tested on a 
cluster but didn't look at this specifically - I'll check again to make sure.


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

Reply via email to