Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/4367#discussion_r24375405
--- Diff: core/src/main/scala/org/apache/spark/HeartbeatReceiver.scala ---
@@ -32,18 +36,64 @@ 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]
+
+ val slaveTimeout =
sc.conf.getLong("spark.storage.blockManagerSlaveTimeoutMs",
+ math.max(sc.conf.getInt("spark.executor.heartbeatInterval", 10000) *
3, 120000))
+
+ val checkTimeoutInterval =
sc.conf.getLong("spark.storage.blockManagerTimeoutIntervalMs", 60000)
+
+ var timeoutCheckingTask: Cancellable = null
+
+ override def preStart() {
+ import context.dispatcher
+ timeoutCheckingTask = context.system.scheduler.schedule(0.seconds,
+ checkTimeoutInterval.milliseconds, self, ExpireDeadHosts)
+ super.preStart()
+ }
+
override def receiveWithLogging = {
case Heartbeat(executorId, taskMetrics, blockManagerId) =>
+ heartbeatReceived(executorId)
val response = HeartbeatResponse(
!scheduler.executorHeartbeatReceived(executorId, taskMetrics,
blockManagerId))
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) {
+ logWarning("Removing Executor " + executorId + " with no recent
heart beats: "
+ + (now - lastSeenMs) + " ms exceeds " + slaveTimeout + "ms")
+ scheduler.executorLost(executorId, SlaveLost())
+ sc.killExecutor(executorId)
--- End diff --
this will fail an assertion in standalone / mesos mode
---
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]