Repository: spark
Updated Branches:
  refs/heads/branch-1.3 dbfce30fc -> c294216cd


SPARK-5613: Catch the ApplicationNotFoundException exception to avoid thread 
from getting killed on yarn restart.

[SPARK-5613] Added a  catch block to catch the ApplicationNotFoundException. 
Without this catch block the thread gets killed on occurrence of this 
exception. This Exception occurs when yarn restarts and tries to find an 
application id for a spark job which got interrupted due to yarn getting 
stopped.
See the stacktrace in the bug for more details.

Author: Kashish Jain <kashish.j...@guavus.com>

Closes #4392 from kasjain/branch-1.2 and squashes the following commits:

4831000 [Kashish Jain] SPARK-5613: Catch the ApplicationNotFoundException 
exception to avoid thread from getting killed on yarn restart.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/c294216c
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/c294216c
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/c294216c

Branch: refs/heads/branch-1.3
Commit: c294216cde8abead4fe320382b751691c3fd2798
Parents: dbfce30
Author: Kashish Jain <kashish.j...@guavus.com>
Authored: Fri Feb 6 13:47:23 2015 -0800
Committer: Patrick Wendell <patr...@databricks.com>
Committed: Tue Feb 10 12:10:34 2015 -0800

----------------------------------------------------------------------
 .../scheduler/cluster/YarnClientSchedulerBackend.scala   | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/c294216c/yarn/src/main/scala/org/apache/spark/scheduler/cluster/YarnClientSchedulerBackend.scala
----------------------------------------------------------------------
diff --git 
a/yarn/src/main/scala/org/apache/spark/scheduler/cluster/YarnClientSchedulerBackend.scala
 
b/yarn/src/main/scala/org/apache/spark/scheduler/cluster/YarnClientSchedulerBackend.scala
index 690f927..f1b5aaf 100644
--- 
a/yarn/src/main/scala/org/apache/spark/scheduler/cluster/YarnClientSchedulerBackend.scala
+++ 
b/yarn/src/main/scala/org/apache/spark/scheduler/cluster/YarnClientSchedulerBackend.scala
@@ -20,6 +20,7 @@ package org.apache.spark.scheduler.cluster
 import scala.collection.mutable.ArrayBuffer
 
 import org.apache.hadoop.yarn.api.records.{ApplicationId, YarnApplicationState}
+import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException
 
 import org.apache.spark.{SparkException, Logging, SparkContext}
 import org.apache.spark.deploy.yarn.{Client, ClientArguments}
@@ -133,8 +134,14 @@ private[spark] class YarnClientSchedulerBackend(
     val t = new Thread {
       override def run() {
         while (!stopping) {
-          val report = client.getApplicationReport(appId)
-          val state = report.getYarnApplicationState()
+          var state: YarnApplicationState = null
+          try {
+            val report = client.getApplicationReport(appId)
+            state = report.getYarnApplicationState()
+          } catch {
+            case e: ApplicationNotFoundException =>
+              state = YarnApplicationState.KILLED
+          }
           if (state == YarnApplicationState.FINISHED ||
             state == YarnApplicationState.KILLED ||
             state == YarnApplicationState.FAILED) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to