Github user andrewor14 commented on a diff in the pull request: https://github.com/apache/spark/pull/1056#discussion_r14864470 --- Diff: core/src/main/scala/org/apache/spark/executor/Executor.scala --- @@ -341,4 +345,47 @@ 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() { + Thread.sleep(interval) + + while (!isStopped) { + val tasksMetrics = new ArrayBuffer[(Long, TaskMetrics)]() + for (taskRunner <- runningTasks.values()) { + val task = taskRunner.task + Option(task).flatMap(_.metrics).foreach { metrics => + tasksMetrics += ((taskRunner.taskId, metrics)) + } + } + + val message = Heartbeat(executorId, tasksMetrics.toArray, + env.blockManager.blockManagerId) + val reregister = !AkkaUtils.askWithReply[Boolean](message, heartbeatReceiverRef, + retryAttempts, retryIntervalMs, timeout) + if (reregister) { + env.blockManager.reregister() + } + Thread.sleep(interval) + } + } + } + t.setDaemon(true) + t.setName("Driver Heartbeater") + t.start() + } } + + --- End diff -- minor: 1 too many line here...
--- 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. ---