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 05:25:45 UTC

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

     [ https://issues.apache.org/jira/browse/SPARK-10426?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

cen yuhai updated SPARK-10426:
------------------------------
    Description: 
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 know the state of SparkContext,  maybe a method named isStopped().
So we can do it like this:

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





 

  was:
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()
   }
}





 


> 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.3.0, 1.3.1, 1.4.0, 1.4.1
>         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 know the state of SparkContext,  maybe a method named isStopped().
> So we can 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