aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorXiangrui Meng <meng@databricks.com>2015-11-12 16:43:04 -0800
committerXiangrui Meng <meng@databricks.com>2015-11-12 16:43:04 -0800
commitbc092966f8264c6685b3300461cb79dd6a509ecf (patch)
tree289c097a31be9b03576872503ed93a7367115264 /core
parent68ef61bb656bd9c08239726913ca8ab271d52786 (diff)
downloadspark-bc092966f8264c6685b3300461cb79dd6a509ecf.tar.gz
spark-bc092966f8264c6685b3300461cb79dd6a509ecf.tar.bz2
spark-bc092966f8264c6685b3300461cb79dd6a509ecf.zip
[SPARK-11709] include creation site info in SparkContext.assertNotStopped error message
This helps debug issues caused by multiple SparkContext instances. JoshRosen andrewor14 ~~~ scala> sc.stop() scala> sc.parallelize(0 until 10) java.lang.IllegalStateException: Cannot call methods on a stopped SparkContext. This stopped SparkContext was created at: org.apache.spark.SparkContext.<init>(SparkContext.scala:82) org.apache.spark.repl.SparkILoop.createSparkContext(SparkILoop.scala:1017) $iwC$$iwC.<init>(<console>:9) $iwC.<init>(<console>:18) <init>(<console>:20) .<init>(<console>:24) .<clinit>(<console>) .<init>(<console>:7) .<clinit>(<console>) $print(<console>) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.apache.spark.repl.SparkIMain$ReadEvalPrint.call(SparkIMain.scala:1065) org.apache.spark.repl.SparkIMain$Request.loadAndRun(SparkIMain.scala:1340) org.apache.spark.repl.SparkIMain.loadAndRunReq$1(SparkIMain.scala:840) org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:871) org.apache.spark.repl.SparkIMain.interpret(SparkIMain.scala:819) org.apache.spark.repl.SparkILoop.reallyInterpret$1(SparkILoop.scala:857) The active context was created at: (No active SparkContext.) ~~~ Author: Xiangrui Meng <meng@databricks.com> Closes #9675 from mengxr/SPARK-11709.
Diffstat (limited to 'core')
-rw-r--r--core/src/main/scala/org/apache/spark/SparkContext.scala18
1 files changed, 17 insertions, 1 deletions
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala
index 43a241686f..4bbd0b038c 100644
--- a/core/src/main/scala/org/apache/spark/SparkContext.scala
+++ b/core/src/main/scala/org/apache/spark/SparkContext.scala
@@ -96,7 +96,23 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
private def assertNotStopped(): Unit = {
if (stopped.get()) {
- throw new IllegalStateException("Cannot call methods on a stopped SparkContext")
+ val activeContext = SparkContext.activeContext.get()
+ val activeCreationSite =
+ if (activeContext == null) {
+ "(No active SparkContext.)"
+ } else {
+ activeContext.creationSite.longForm
+ }
+ throw new IllegalStateException(
+ s"""Cannot call methods on a stopped SparkContext.
+ |This stopped SparkContext was created at:
+ |
+ |${creationSite.longForm}
+ |
+ |The currently active SparkContext was created at:
+ |
+ |$activeCreationSite
+ """.stripMargin)
}
}