[ 
https://issues.apache.org/jira/browse/SPARK-10426?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15027538#comment-15027538
 ] 

DAVIDSUNNYKONDRU commented on SPARK-10426:
------------------------------------------

How do we implement the above change?


> Cannot call methods on a stopped SparkContext
> ---------------------------------------------
>
>                 Key: SPARK-10426
>                 URL: https://issues.apache.org/jira/browse/SPARK-10426
>             Project: Spark
>          Issue Type: Improvement
>          Components: Spark Core
>    Affects Versions: 1.3.1, 1.4.1
>         Environment: Spark 1.4.1 
> hadoop 2.2.0
>            Reporter: cen yuhai
>            Priority: Minor
>
> 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-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to