Repository: spark
Updated Branches:
  refs/heads/branch-1.4 e319719e0 -> 7dc0ff3f1


[SPARK-7504] [YARN] NullPointerException when initializing SparkContext in 
YARN-cluster mode

Added a simple checking for SparkContext.
Also added two rational checking against null at AM object.

Author: ehnalis <[email protected]>

Closes #6083 from ehnalis/cluster and squashes the following commits:

926bd96 [ehnalis] Moved check to SparkContext.
7c89b6e [ehnalis] Remove false line.
ea2a5fe [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing 
SparkContext in YARN-cluster mode
4924e01 [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing 
SparkContext in YARN-cluster mode
39e4fa3 [ehnalis] SPARK-7504 [YARN] NullPointerException when initializing 
SparkContext in YARN-cluster mode
9f287c5 [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing 
SparkContext in YARN-cluster mode

(cherry picked from commit 8e3822a0794b8b18436bd63d6859d40139a77090)
Signed-off-by: Andrew Or <[email protected]>


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

Branch: refs/heads/branch-1.4
Commit: 7dc0ff3f12f5eb622abe9bf67d636937c30b7f8c
Parents: e319719
Author: ehnalis <[email protected]>
Authored: Fri May 15 12:14:02 2015 -0700
Committer: Andrew Or <[email protected]>
Committed: Fri May 15 12:16:03 2015 -0700

----------------------------------------------------------------------
 core/src/main/scala/org/apache/spark/SparkContext.scala | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/7dc0ff3f/core/src/main/scala/org/apache/spark/SparkContext.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala 
b/core/src/main/scala/org/apache/spark/SparkContext.scala
index b59f562..af276e7 100644
--- a/core/src/main/scala/org/apache/spark/SparkContext.scala
+++ b/core/src/main/scala/org/apache/spark/SparkContext.scala
@@ -371,6 +371,14 @@ class SparkContext(config: SparkConf) extends Logging with 
ExecutorAllocationCli
       throw new SparkException("An application name must be set in your 
configuration")
     }
 
+    // System property spark.yarn.app.id must be set if user code ran by AM on 
a YARN cluster
+    // yarn-standalone is deprecated, but still supported
+    if ((master == "yarn-cluster" || master == "yarn-standalone") &&
+        !_conf.contains("spark.yarn.app.id")) {
+      throw new SparkException("Detected yarn-cluster mode, but isn't running 
on a cluster. " +
+        "Deployment to YARN is not supported directly by SparkContext. Please 
use spark-submit.")
+    }
+
     if (_conf.getBoolean("spark.logConf", false)) {
       logInfo("Spark configuration:\n" + _conf.toDebugString)
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to