GitHub user smallyard opened a pull request:

    https://github.com/apache/spark/pull/15794

    [SPARK-15659][YARN] Fail if SparkContext run a new Thread in yarn-clu…

    ## What changes were proposed in this pull request?
    
    Fix Program SparkContext can't run in user thread in yarn-cluster mode.
    
    logs
    ```
    16/11/02 11:16:47 INFO yarn.ApplicationMaster: Starting the user 
application in a separate Thread
    16/11/02 11:16:47 INFO yarn.ApplicationMaster: Waiting for spark context 
initialization
    16/11/02 11:16:47 INFO yarn.ApplicationMaster: Waiting for spark context 
initialization ... 
    16/11/02 11:16:47 INFO yarn.ApplicationMaster: Final app status: SUCCEEDED, 
exitCode: 0
    
    ```
    
    Please review 
https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark before 
opening a pull request.
    
    …ster mode.
    
    ```
    public static void main(String[] args) {
            
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(new Thread(new 
Runnable() {
                @Override
                public void run() {
                    SparkConf conf = new SparkConf();
                    conf.setAppName("SparkDemo");
                    JavaSparkContext sparkContext = new JavaSparkContext(conf);
                    JavaRDD<String> array = 
sparkContext.parallelize(Lists.newArrayList("1", "2", "3", "4"));
                    System.out.println(array.count());
                }
            }), 0, 5000, TimeUnit.MILLISECONDS);
        }
    ```
    Fix this program can't run correctly.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/smallyard/spark master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/15794.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #15794
    
----
commit 2c63972354c62221d504eb0d65d819b0adde707d
Author: smallyard <[email protected]>
Date:   2016-11-07T03:43:47Z

    [SPARK-15659][YARN] Fail if SparkContext run a new Thread in yarn-cluster 
mode.
    
    ```
    public static void main(String[] args) {
            
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(new Thread(new 
Runnable() {
                @Override
                public void run() {
                    SparkConf conf = new SparkConf();
                    conf.setAppName("SparkDemo");
                    JavaSparkContext sparkContext = new JavaSparkContext(conf);
                    JavaRDD<String> array = 
sparkContext.parallelize(Lists.newArrayList("1", "2", "3", "4"));
                    System.out.println(array.count());
                }
            }), 0, 5000, TimeUnit.MILLISECONDS);
        }
    ```
    Fix this program can't run correctly.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to