You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "cen yuhai (JIRA)" <ji...@apache.org> on 2015/09/03 03:20:46 UTC

[jira] [Created] (SPARK-10426) Cannot call methods on a stopped SparkContext

cen yuhai created SPARK-10426:
---------------------------------

             Summary: Cannot call methods on a stopped SparkContext
                 Key: SPARK-10426
                 URL: https://issues.apache.org/jira/browse/SPARK-10426
             Project: Spark
          Issue Type: Bug
          Components: Spark Core
    Affects Versions: 1.4.1, 1.4.0, 1.3.1, 1.3.0
         Environment: Spark 1.4.1 
hadoop 2.2.0
            Reporter: cen yuhai
            Priority: Minor
             Fix For: 1.6.0, 1.5.1


Sometimes, we will see IllegalStateException("Cannot call methods on a stopped SparkContext")

In methods like parallelize, range, textFile... etc
It will first call method assertNotStopped() to check whether SparkContext is stopped or not, if stopped throws exception.
But for users, we do not want to catch IllegalStateException. We want to the state of SparkContext,  a method to know its state, maybe isStopped().
So we do do it like this:

def getSparkContext(): SparkContext: {
   if(sc == null || sc.isStopped()) {
       sc = new SparkContext()
   }
}





 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org