From 56d6e5ebba34410d5a4608a1b25715174c977280 Mon Sep 17 00:00:00 2001 From: Andrew Or Date: Wed, 20 May 2015 17:45:06 -0700 Subject: [PATCH] Avoid negative sleep --- .../org/apache/spark/deploy/yarn/ApplicationMaster.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala b/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala index 63a6f2e9472c1..13d9298ce0983 100644 --- a/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala +++ b/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala @@ -346,6 +346,9 @@ private[spark] class ApplicationMaster( val currentAllocationInterval = math.min(heartbeatInterval, nextAllocationInterval) nextAllocationInterval *= 2 + // avoid overflow + nextAllocationInterval = math.min( + nextAllocationInterval, ApplicationMaster.MAX_RM_HEARTBEAT_INTERVAL_MS) currentAllocationInterval } else { nextAllocationInterval = initialAllocationInterval @@ -577,6 +580,9 @@ object ApplicationMaster extends Logging { private val EXIT_SECURITY = 14 private val EXIT_EXCEPTION_USER_CLASS = 15 + // cap on heartbeat interval between us and the resource manager + private val MAX_RM_HEARTBEAT_INTERVAL_MS = 10000 + private var master: ApplicationMaster = _ def main(args: Array[String]): Unit = {