You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by kishorvpatil <gi...@git.apache.org> on 2016/09/08 03:34:35 UTC

[GitHub] spark pull request #15009: [SPARK-17443] Stop Spark Application if launcher ...

GitHub user kishorvpatil opened a pull request:

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

    [SPARK-17443] Stop Spark Application if launcher goes down and use reflection

    ## What changes were proposed in this pull request?
    
    1. `SparkLauncher` provides `stopIfInterrupted` method to allow ensuring `SparkApplication` stops if tracking process dies. 
    2.  `SparkLauncher` provides `startApplicationInProcess` method to start application using reflection in another Thread instead of launching childProcess and relying on `spark-submit` binary.
    
    (Please fill in changes proposed in this fix)
    
    
    ## How was this patch tested?
    
    Manual tests.
    


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

    $ git pull https://github.com/kishorvpatil/spark SPARK-17443

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

    https://github.com/apache/spark/pull/15009.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 #15009
    
----
commit 8986aa9b1cde7e116874eb4b9bf5cf6142a244a4
Author: Kishor Patil <kp...@yahoo-inc.com>
Date:   2016-09-08T03:25:51Z

    Stop Spark Application if launcher goes down and use reflection

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    test this please



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84788565
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/LauncherProtocol.java ---
    @@ -32,6 +32,9 @@
       /** Environment variable where the secret for connecting back to the server is stored. */
       static final String ENV_LAUNCHER_SECRET = "_SPARK_LAUNCHER_SECRET";
     
    +  /** Environment variable where the stop if Launcher is stored. */
    +  static final String ENV_LAUNCHER_STOP_FLAG = "_SPARK_LAUNCHER_STOP_FLAG";
    --- End diff --
    
    Same comment about the name here.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #74498 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74498/testReport)** for PR 15009 at commit [`a3d18b4`](https://github.com/apache/spark/commit/a3d18b4119f9a3aa4c018b5cc49bc0093e5008da).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75056/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r119738802
  
    --- Diff: core/src/test/java/org/apache/spark/launcher/SparkLauncherSuite.java ---
    @@ -183,12 +185,38 @@ public void testChildProcLauncher() throws Exception {
         assertEquals(0, app.waitFor());
       }
     
    +  @Test
    +  public void testThreadLauncher() throws Exception {
    +    // This test is failed on Windows due to the failure of initiating executors
    +    // by the path length limitation. See SPARK-18718.
    +    assumeTrue(!Utils.isWindows());
    +
    +    launcher = new SparkLauncher();
    +    launcher
    +      .setMaster("local")
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS,
    +        "-Dfoo=bar -Dtest.appender=childproc")
    +      .setConf(SparkLauncher.DRIVER_EXTRA_CLASSPATH, System.getProperty("java.class.path"))
    +      .setMainClass(SparkLauncherTestApp.class.getName())
    +      .launchAsThread(true)
    +      .addAppArgs("thread");
    +    final SparkAppHandle app = launcher.startApplication();
    +    sleep(3000);
    +    AbstractSparkAppHandle handle = (AbstractSparkAppHandle)app;
    --- End diff --
    
    You don't need this. `SparkAppHandle` is a `AbstractSparkAppHandle`, isn't it? You should also make `waitFor()` package private instead of protected.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/68286/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r86870416
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/ChildThreadAppHandle.java ---
    @@ -0,0 +1,53 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.util.logging.Logger;
    +
    +public class ChildThreadAppHandle extends AbstractSparkAppHandle {
    +  private static final Logger LOG = Logger.getLogger(ChildThreadAppHandle.class.getName());
    +  private Thread childThread;
    +
    +  public ChildThreadAppHandle(String secret, LauncherServer server) {
    +    super(server, secret);
    +  }
    +
    +  @Override
    +  public synchronized void kill() {
    +    if (!disposed) {
    +      disconnect();
    +    }
    +    if (childThread != null) {
    +      try {
    +        childThread.join(3000);
    --- End diff --
    
    `disconnect()` does not, but if shopIfShutdown is setup, we would like to give sufficient time for `childTread` to run shutdownHook as it detects the launcherserver is disconnected.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84787094
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -110,12 +146,14 @@ private[spark] abstract class LauncherBackend {
         override def close(): Unit = {
           try {
             super.close()
    +        if (stopFlag) {
    --- End diff --
    
    This seems to be overloading the meaning of `stopFlag`. Does it mean "stop the app when the launcher goes down", or "stop the app when the launcher is closed"? This code is implementing the latter, while the earlier shutdown hook is implementing the former. I don't think the latter is desired in the API; there is already an explicit API for that.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #75109 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75109/testReport)** for PR 15009 at commit [`677edf7`](https://github.com/apache/spark/commit/677edf7f091beab92e1ca42d24a20ad4c5254002).
     * This patch **fails to build**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #76278 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76278/testReport)** for PR 15009 at commit [`3f060b6`](https://github.com/apache/spark/commit/3f060b66f32f5d8b3dc3c8cb8de63a4afd51384d).
     * This patch **fails from timeout after a configured wait of \`250m\`**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r113086177
  
    --- Diff: core/src/test/java/org/apache/spark/launcher/SparkLauncherSuite.java ---
    @@ -183,6 +183,28 @@ public void testChildProcLauncher() throws Exception {
         assertEquals(0, app.waitFor());
       }
     
    +  @Test
    +  public void testThreadLauncher() throws Exception {
    +    // This test is failed on Windows due to the failure of initiating executors
    +    // by the path length limitation. See SPARK-18718.
    +    assumeTrue(!Utils.isWindows());
    +
    +    launcher
    +      .setMaster("local")
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS,
    +        "-Dfoo=bar -Dtest.appender=childproc")
    +      .setConf(SparkLauncher.DRIVER_EXTRA_CLASSPATH, System.getProperty("java.class.path"))
    +      .setMainClass(SparkLauncherTestApp.class.getName())
    +      .launchAsThread(true)
    +      .addAppArgs("proc");
    +    final Process app = launcher.launch();
    --- End diff --
    
    What is this testing? `launch()` will always launch a child process. Which indicates two problems:
    
    - this test is not testing anything that hasn't been tested before.
    - `SparkLauncher` should probably be throwing an error if you use `.launchAsThread(true)` and then call `launch()`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r108788606
  
    --- Diff: resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/config.scala ---
    @@ -355,5 +356,4 @@ package object config {
         CACHED_FILES_VISIBILITIES,
         CACHED_FILES_TYPES,
         CACHED_CONF_ARCHIVE)
    -
    --- End diff --
    
    nit: noisy unnecessary change


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106234319
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -528,13 +579,42 @@ public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) thr
         pb.environment().put(LauncherProtocol.ENV_LAUNCHER_PORT,
           String.valueOf(LauncherServer.getServerInstance().getPort()));
         pb.environment().put(LauncherProtocol.ENV_LAUNCHER_SECRET, handle.getSecret());
    +    pb.environment().put(LauncherProtocol.ENV_LAUNCHER_STOP_IF_SHUTDOWN, String.valueOf(stopOnShutdown));
         try {
           handle.setChildProc(pb.start(), loggerName);
         } catch (IOException ioe) {
           handle.kill();
           throw ioe;
         }
    +    return handle;
    +  }
    +
    +  private SparkAppHandle startApplicationAsThread(SparkAppHandle.Listener... listeners) throws IOException {
    --- End diff --
    
    nit: line > 100 chars


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Jenkins, this is okay to test


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r111229344
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/package-info.java ---
    @@ -49,6 +51,35 @@
      * </pre>
      *
      * <p>
    + * Here is example of launching application in thread mode for YARN cluster mode
    + * with the auto shutdown option enabled. Showing use case of both
    + * {@link org.apache.spark.launcher.SparkLauncher#autoShutdown(boolean)} and
    + * {@link org.apache.spark.launcher.SparkLauncher#launchAsThread(boolean)} methods
    + * </p>
    + *
    + * <pre>
    + * {@code
    + *   import org.apache.spark.launcher.SparkAppHandle;
    + *   import org.apache.spark.launcher.SparkLauncher;
    + *
    + *   public class MyLauncher {
    + *     public static void main(String[] args) throws Exception {
    + *       SparkAppHandle handle = new SparkLauncher()
    + *         .setAppResource("/my/app.jar")
    + *         .setMainClass("my.spark.app.Main")
    + *         .setMaster("yarn")
    + *         .setDeployMode("cluster")
    + *         .autoShutdown()
    --- End diff --
    
    `.autoShutdown(true)`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/77263/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    do all the options work in thread mode and client mode?  For instance there were some things add in 2.x like redirectOutput and redirecterror that do processbuilder stuff and I assume don't work in thread mode currently.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78379526
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkSubmitRunner.java ---
    @@ -0,0 +1,59 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.lang.reflect.InvocationTargetException;
    +import java.lang.reflect.Method;
    +import java.util.List;
    +
    +class SparkSubmitRunner implements Runnable {
    +  private Method main;
    +  private final List<String> args;
    +
    +  SparkSubmitRunner(Method main, List<String> args) {
    +    this.main = main;
    +    this.args = args;
    +  }
    +  /**
    +   *  Trying to see if method is available in the classpath.
    +   */
    +  protected static Method getSparkSubmitMain() throws ClassNotFoundException, NoSuchMethodException {
    +      Class<?> cls = Class.forName("org.apache.spark.deploy.SparkSubmit");
    +      return cls.getDeclaredMethod("main", String[].class);
    +  }
    +
    +  @Override
    +  public void run() {
    +    try {
    +      if(main == null) {
    --- End diff --
    
    space after if


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443] Stop Spark Application if launcher ...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78005411
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -29,26 +31,63 @@ import org.apache.spark.util.{ThreadUtils, Utils}
      *
      * See `LauncherServer` for an explanation of how launcher communication works.
      */
    -private[spark] abstract class LauncherBackend {
    +private[spark] abstract class LauncherBackend extends Logging {
     
       private var clientThread: Thread = _
       private var connection: BackendConnection = _
       private var lastState: SparkAppHandle.State = _
    +  private var stopFlag: Boolean = false
       @volatile private var _isConnected = false
     
       def connect(): Unit = {
         val port = sys.env.get(LauncherProtocol.ENV_LAUNCHER_PORT).map(_.toInt)
         val secret = sys.env.get(LauncherProtocol.ENV_LAUNCHER_SECRET)
    +    val stopFlag = sys.env.get(LauncherProtocol.ENV_LAUNCHER_STOP_FLAG).map(_.toBoolean)
         if (port != None && secret != None) {
    -      val s = new Socket(InetAddress.getLoopbackAddress(), port.get)
    +      if(stopFlag != None) {
    +        connect(port.get, secret.get, stopFlag.get)
    --- End diff --
    
    can't we just set this.stopFlag here and have one connect method since that is all this one is doing?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443] Stop Spark Application if launcher ...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78005678
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -29,26 +31,63 @@ import org.apache.spark.util.{ThreadUtils, Utils}
      *
      * See `LauncherServer` for an explanation of how launcher communication works.
      */
    -private[spark] abstract class LauncherBackend {
    +private[spark] abstract class LauncherBackend extends Logging {
     
       private var clientThread: Thread = _
       private var connection: BackendConnection = _
       private var lastState: SparkAppHandle.State = _
    +  private var stopFlag: Boolean = false
       @volatile private var _isConnected = false
     
       def connect(): Unit = {
         val port = sys.env.get(LauncherProtocol.ENV_LAUNCHER_PORT).map(_.toInt)
         val secret = sys.env.get(LauncherProtocol.ENV_LAUNCHER_SECRET)
    +    val stopFlag = sys.env.get(LauncherProtocol.ENV_LAUNCHER_STOP_FLAG).map(_.toBoolean)
         if (port != None && secret != None) {
    -      val s = new Socket(InetAddress.getLoopbackAddress(), port.get)
    +      if(stopFlag != None) {
    +        connect(port.get, secret.get, stopFlag.get)
    +      } else {
    +        connect(port.get, secret.get)
    +      }
    +    }
    +  }
    +
    +  def connect(port: Int, secret: String): Unit = {
    +    if (port != None && secret != None) {
    +      val s = new Socket(InetAddress.getLoopbackAddress(), port)
           connection = new BackendConnection(s)
    -      connection.send(new Hello(secret.get, SPARK_VERSION))
    +      connection.send(new Hello(secret, SPARK_VERSION))
           clientThread = LauncherBackend.threadFactory.newThread(connection)
           clientThread.start()
           _isConnected = true
    +      if(stopFlag) {
    +        val shutdownHook: Runnable = new Runnable() {
    +          def run {
    +            logInfo("LauncherBackend shutdown hook invoked..")
    +            try {
    +              if(_isConnected && stopFlag) {
    --- End diff --
    
    space after if


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #65395 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/65395/consoleFull)** for PR 15009 at commit [`57defa9`](https://github.com/apache/spark/commit/57defa950532c04420c6ae39ac680cdfa1bcaf13).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #66392 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/66392/consoleFull)** for PR 15009 at commit [`a3250ac`](https://github.com/apache/spark/commit/a3250acf96640568633a6b9270e1461b454aa313).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r81983674
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -59,20 +59,36 @@ import org.apache.spark.util.Utils
     private[spark] class Client(
         val args: ClientArguments,
         val hadoopConf: Configuration,
    -    val sparkConf: SparkConf)
    +    val sparkConf: SparkConf,
    +    val sysEnvironmentInput: Map[String, String])
       extends Logging {
     
       import Client._
       import YarnSparkHadoopUtil._
     
    +  def this(clientArgs: ClientArguments, spConf: SparkConf, sysenvironment: Map[String, String]) =
    --- End diff --
    
    rename sysenvironment to sysEnv


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78400270
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -538,6 +539,71 @@ public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) thr
         return handle;
       }
     
    +  private String getAppName() throws IOException {
    +    String appName = builder.getEffectiveConfig().get(CHILD_PROCESS_LOGGER_NAME);
    +    if (appName == null) {
    +      if (builder.appName != null) {
    +        appName = builder.appName;
    +      } else if (builder.mainClass != null) {
    +        int dot = builder.mainClass.lastIndexOf(".");
    +        if (dot >= 0 && dot < builder.mainClass.length() - 1) {
    +          appName = builder.mainClass.substring(dot + 1, builder.mainClass.length());
    +        } else {
    +          appName = builder.mainClass;
    +        }
    +      } else if (builder.appResource != null) {
    +        appName = new File(builder.appResource).getName();
    +      } else {
    +        appName = String.valueOf(COUNTER.incrementAndGet());
    +      }
    +    }
    +    return appName;
    +  }
    +
    +  /**
    +   * Starts a Spark application.
    +   * <p>
    +   * This method returns a handle that provides information about the running application and can
    +   * be used to do basic interaction with it.
    +   * <p>
    +   * The returned handle assumes that the application will instantiate a single SparkContext
    +   * during its lifetime. Once that context reports a final state (one that indicates the
    +   * SparkContext has stopped), the handle will not perform new state transitions, so anything
    +   * that happens after that cannot be monitored. The underlying application is launched as
    +   * a Thread, {@link SparkAppHandle#kill()} can still be used to kill the spark application.
    +   * <p>
    +   * @since 2.1.0
    +   * @param listeners Listeners to add to the handle before the app is launched.
    +   * @return A handle for the launched application.
    +   */
    +  public SparkAppHandle startApplicationInProcess(SparkAppHandle.Listener... listeners) throws IOException {
    +
    +    ChildThreadAppHandle handle = LauncherServer.newAppThreadHandle();
    +    for (SparkAppHandle.Listener l : listeners) {
    +      handle.addListener(l);
    +    }
    +
    +    String appName = getAppName();
    +    setConf(LAUNCHER_INTERNAL_PORT,String.valueOf(LauncherServer.getServerInstance().getPort()));
    +    setConf(CHILD_PROCESS_LAUNCHER_INTERNAL_SECRET, handle.getSecret());
    +    setConf(CHILD_PROCESS_LAUNCHER_STOP_FLAG, String.valueOf(stopIfInterrupted));
    +    try {
    +      //trying to see if method is available in the classpath.
    +      Method main = SparkSubmitRunner.getSparkSubmitMain();
    +      Thread submitJobThread = new Thread(new SparkSubmitRunner(main, builder.buildSparkSubmitArgs()));
    --- End diff --
    
    we should be making this a daemon thread


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/74497/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #74272 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74272/testReport)** for PR 15009 at commit [`b098ecd`](https://github.com/apache/spark/commit/b098ecd6e21b60ae3db13adc81d02522c2fa9391).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443] Stop Spark Application if launcher ...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78005004
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -29,26 +31,63 @@ import org.apache.spark.util.{ThreadUtils, Utils}
      *
      * See `LauncherServer` for an explanation of how launcher communication works.
      */
    -private[spark] abstract class LauncherBackend {
    +private[spark] abstract class LauncherBackend extends Logging {
     
       private var clientThread: Thread = _
       private var connection: BackendConnection = _
       private var lastState: SparkAppHandle.State = _
    +  private var stopFlag: Boolean = false
       @volatile private var _isConnected = false
     
       def connect(): Unit = {
         val port = sys.env.get(LauncherProtocol.ENV_LAUNCHER_PORT).map(_.toInt)
         val secret = sys.env.get(LauncherProtocol.ENV_LAUNCHER_SECRET)
    +    val stopFlag = sys.env.get(LauncherProtocol.ENV_LAUNCHER_STOP_FLAG).map(_.toBoolean)
         if (port != None && secret != None) {
    -      val s = new Socket(InetAddress.getLoopbackAddress(), port.get)
    +      if(stopFlag != None) {
    +        connect(port.get, secret.get, stopFlag.get)
    +      } else {
    +        connect(port.get, secret.get)
    +      }
    +    }
    +  }
    +
    +  def connect(port: Int, secret: String): Unit = {
    +    if (port != None && secret != None) {
    --- End diff --
    
    doing the same check here as line 46 above, don't need both.
    



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #77263 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/77263/testReport)** for PR 15009 at commit [`d906072`](https://github.com/apache/spark/commit/d9060724b4f9a2dd3f4c9b0f77c2a09cb14b4671).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/72201/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106236820
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -73,6 +74,12 @@
       /** Logger name to use when launching a child process. */
       public static final String CHILD_PROCESS_LOGGER_NAME = "spark.launcher.childProcLoggerName";
     
    +  public static final String LAUNCHER_INTERNAL_PORT = "spark.launcher.internal.port";
    --- End diff --
    
    I'm not a fan of having these public variables. This is a public class so we should try to hide anything that is internal to Spark from the API.
    
    A way of doing this would be to leave this as package-private, and move the code that connects to the launcher from `Client.scala` to `YarnCommandBuilderUtils.scala`, since the latter is in the launcher package. And perhaps rename the latter to `YarnLauncherUtils.scala` since it would be doing more than just what it does now.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/74492/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r108780813
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -735,7 +749,12 @@ object SparkSubmit extends CommandLineUtils {
         }
     
         try {
    -      mainMethod.invoke(null, childArgs.toArray)
    +      if (isSparkApp) {
    +        val envvars = Map[String, String]() ++ sys.env
    +        mainMethod.invoke(null, childArgs.toArray, childSparkConf, envvars.toMap)
    --- End diff --
    
    My comment is not exactly about Spark's usage of environment variables or not. It's about the code being added here not serving any purpose.
    
    ```
    val envvars = Map[String, String]() ++ sys.env
    ```
    
    That means that regardless of the `SparkLauncher` configuration, you'll always be using the process's environment. So this whole exercise in adding an argument to specify the env map is futile.
    
    So there are two options here:
    
    - actually pass env variables customized by `SparkLauncher` here. this is not happening currently.
    - remove all this code and declare that "the env map passed to the `SparkLauncher` constructor has no effect when running Spark in the same process".
    
    I'm fine with either of those. But currently the PR is adding a bunch of dead code that is just not necessary.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r111222050
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkApp.scala ---
    @@ -0,0 +1,38 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark
    +
    +/**
    + * A client that SparkSubmit uses to launch spark Application.
    --- End diff --
    
    This comment seems very specific to the YARN "Client" class.
    
    Instead: "An interface that can be implemented by applications launched by SparkSubmit which exposes the Spark job configuration explicitly."


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r99850931
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -17,38 +17,67 @@
     
     package org.apache.spark.launcher
     
    +import java.io.IOException
     import java.net.{InetAddress, Socket}
     
     import org.apache.spark.SPARK_VERSION
    +import org.apache.spark.internal.Logging
     import org.apache.spark.launcher.LauncherProtocol._
    -import org.apache.spark.util.{ThreadUtils, Utils}
    +import org.apache.spark.util.{ShutdownHookManager, ThreadUtils, Utils}
     
     /**
      * A class that can be used to talk to a launcher server. Users should extend this class to
      * provide implementation for the abstract methods.
      *
      * See `LauncherServer` for an explanation of how launcher communication works.
      */
    -private[spark] abstract class LauncherBackend {
    +private[spark] abstract class LauncherBackend extends Logging {
     
       private var clientThread: Thread = _
       private var connection: BackendConnection = _
       private var lastState: SparkAppHandle.State = _
    +  private var stopOnShutdown: Boolean = false
       @volatile private var _isConnected = false
     
       def connect(): Unit = {
         val port = sys.env.get(LauncherProtocol.ENV_LAUNCHER_PORT).map(_.toInt)
         val secret = sys.env.get(LauncherProtocol.ENV_LAUNCHER_SECRET)
    +    val stopFlag = sys.env.get(LauncherProtocol.ENV_LAUNCHER_STOP_FLAG).map(_.toBoolean)
         if (port != None && secret != None) {
    -      val s = new Socket(InetAddress.getLoopbackAddress(), port.get)
    -      connection = new BackendConnection(s)
    -      connection.send(new Hello(secret.get, SPARK_VERSION))
    -      clientThread = LauncherBackend.threadFactory.newThread(connection)
    -      clientThread.start()
    -      _isConnected = true
    +      connect(port.get, secret.get, stopFlag.getOrElse(false))
         }
       }
     
    +  def connect(port: Int, secret: String): Unit = {
    +    val s = new Socket(InetAddress.getLoopbackAddress(), port)
    +    connection = new BackendConnection(s)
    +    connection.send(new Hello(secret, SPARK_VERSION))
    +    clientThread = LauncherBackend.threadFactory.newThread(connection)
    +    clientThread.start()
    +    _isConnected = true
    +    if (stopOnShutdown) {
    +      logDebug("Adding shutdown hook") // force eager creation of logger
    +      var _shutdownHookRef = ShutdownHookManager.addShutdownHook(
    +        ShutdownHookManager.SPARK_CONTEXT_SHUTDOWN_PRIORITY) { () =>
    +        logInfo("Invoking onStopRequest() from shutdown hook")
    +        try {
    +          if (_isConnected && stopOnShutdown) {
    +            onStopRequest()
    +          }
    +        }
    +        catch {
    +          case anotherIOE: IOException =>
    +            logError("Error while running LauncherBackend shutdownHook...", anotherIOE)
    +        }
    +      }
    +    }
    +  }
    +
    +  def connect(port: Int, secret: String, stopFlag: Boolean): Unit = {
    --- End diff --
    
    This addressed now.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443] Stop Spark Application if launcher goes do...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    @kishorvpatil  Can you please describe in more detail what manual testing you did?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Jenkins, test this please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78378891
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -538,6 +539,71 @@ public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) thr
         return handle;
       }
     
    +  private String getAppName() throws IOException {
    +    String appName = builder.getEffectiveConfig().get(CHILD_PROCESS_LOGGER_NAME);
    +    if (appName == null) {
    +      if (builder.appName != null) {
    +        appName = builder.appName;
    +      } else if (builder.mainClass != null) {
    +        int dot = builder.mainClass.lastIndexOf(".");
    +        if (dot >= 0 && dot < builder.mainClass.length() - 1) {
    +          appName = builder.mainClass.substring(dot + 1, builder.mainClass.length());
    +        } else {
    +          appName = builder.mainClass;
    +        }
    +      } else if (builder.appResource != null) {
    +        appName = new File(builder.appResource).getName();
    +      } else {
    +        appName = String.valueOf(COUNTER.incrementAndGet());
    +      }
    +    }
    +    return appName;
    +  }
    +
    +  /**
    +   * Starts a Spark application.
    +   * <p>
    +   * This method returns a handle that provides information about the running application and can
    +   * be used to do basic interaction with it.
    +   * <p>
    +   * The returned handle assumes that the application will instantiate a single SparkContext
    +   * during its lifetime. Once that context reports a final state (one that indicates the
    +   * SparkContext has stopped), the handle will not perform new state transitions, so anything
    +   * that happens after that cannot be monitored. The underlying application is launched as
    +   * a Thread, {@link SparkAppHandle#kill()} can still be used to kill the spark application.
    +   * <p>
    +   * @since 2.1.0
    +   * @param listeners Listeners to add to the handle before the app is launched.
    +   * @return A handle for the launched application.
    +   */
    +  public SparkAppHandle startApplicationInProcess(SparkAppHandle.Listener... listeners) throws IOException {
    +
    +    ChildThreadAppHandle handle = LauncherServer.newAppThreadHandle();
    +    for (SparkAppHandle.Listener l : listeners) {
    +      handle.addListener(l);
    +    }
    +
    +    String appName = getAppName();
    +    setConf(LAUNCHER_INTERNAL_PORT,String.valueOf(LauncherServer.getServerInstance().getPort()));
    +    setConf(CHILD_PROCESS_LAUNCHER_INTERNAL_SECRET, handle.getSecret());
    +    setConf(CHILD_PROCESS_LAUNCHER_STOP_FLAG, String.valueOf(stopIfInterrupted));
    +    try {
    +      //trying to see if method is available in the classpath.
    +      Method main = SparkSubmitRunner.getSparkSubmitMain();
    +      Thread submitJobThread = new Thread(new SparkSubmitRunner(main, builder.buildSparkSubmitArgs()));
    +      submitJobThread.setName(appName);
    +      handle.setChildThread(submitJobThread);
    +      submitJobThread.start();
    +    } catch (ClassNotFoundException cnfe) {
    +      throw new IOException(cnfe);
    +    } catch (NoSuchMethodException nsme) {
    +      throw new IOException(nsme);
    +    }
    +    return handle;
    +
    --- End diff --
    
    remove extra newline


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443] Stop Spark Application if launcher goes do...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78388796
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkSubmitRunner.java ---
    @@ -0,0 +1,59 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.lang.reflect.InvocationTargetException;
    +import java.lang.reflect.Method;
    +import java.util.List;
    +
    +class SparkSubmitRunner implements Runnable {
    +  private Method main;
    +  private final List<String> args;
    +
    +  SparkSubmitRunner(Method main, List<String> args) {
    +    this.main = main;
    +    this.args = args;
    +  }
    +  /**
    +   *  Trying to see if method is available in the classpath.
    +   */
    +  protected static Method getSparkSubmitMain() throws ClassNotFoundException, NoSuchMethodException {
    +      Class<?> cls = Class.forName("org.apache.spark.deploy.SparkSubmit");
    +      return cls.getDeclaredMethod("main", String[].class);
    +  }
    +
    +  @Override
    +  public void run() {
    +    try {
    +      if(main == null) {
    +        main = getSparkSubmitMain();
    +      }
    +      Object argsObj = args.toArray(new String[args.size()]);
    +      main.invoke(null, argsObj);
    +    } catch (IllegalAccessException illAcEx) {
    --- End diff --
    
    is there a reason to catch these since we are catching all Exception below and doing same thign?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/72610/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by justinuang <gi...@git.apache.org>.
Github user justinuang commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    That would be incredible. Launching a new jvm and loading all of hadoop takes about 4 seconds extra each time, versus reusing the launcher jvm, which is really significant for us since we launch a lot of jobs and users have to wait on this.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r108786329
  
    --- Diff: core/src/test/java/org/apache/spark/launcher/SparkLauncherSuite.java ---
    @@ -175,6 +175,33 @@ public void testChildProcLauncher() throws Exception {
           .setConf(SparkLauncher.DRIVER_EXTRA_CLASSPATH, System.getProperty("java.class.path"))
           .addSparkArg(opts.CLASS, "ShouldBeOverriddenBelow")
           .setMainClass(SparkLauncherTestApp.class.getName())
    +      .autoShutdown(true)
    --- End diff --
    
    I remember mentioning that this isn't testing anything, maybe I forgot to send the comment...
    
    But since the parent process is not dying, this isn't actually doing anything. If you want to test this here (and not just with the YARN tests you added), you'll need to write a different test.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    retest this please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r107498853
  
    --- Diff: resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnClusterSuite.scala ---
    @@ -201,6 +210,152 @@ class YarnClusterSuite extends BaseYarnClusterSuite {
         finalState should be (SparkAppHandle.State.FAILED)
       }
     
    +  test("monitor app using launcher library for thread") {
    +    val env = new JHashMap[String, String]()
    +    env.put("YARN_CONF_DIR", hadoopConfDir.getAbsolutePath())
    +
    +    val propsFile = createConfFile()
    +    val handle = new SparkLauncher(env)
    +      .setSparkHome(sys.props("spark.test.home"))
    +      .setConf("spark.ui.enabled", "false")
    +      .setPropertiesFile(propsFile)
    +      .setMaster("yarn")
    +      .setDeployMode("cluster")
    +      .launchAsThread(true)
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setMainClass(mainClassName(YarnLauncherTestApp.getClass))
    +      .startApplication()
    +
    +    try {
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.RUNNING)
    +      }
    +
    +      handle.getAppId() should not be (null)
    +      handle.getAppId() should startWith ("application_")
    +      handle.stop()
    +
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.KILLED)
    +      }
    +    } finally {
    +      handle.kill()
    +    }
    +  }
    +
    +  test("monitor app using launcher library for proc with auto shutdown") {
    +    val env = new JHashMap[String, String]()
    +    env.put("YARN_CONF_DIR", hadoopConfDir.getAbsolutePath())
    +
    +    val propsFile = createConfFile()
    +    val handle = new SparkLauncher(env)
    +      .setSparkHome(sys.props("spark.test.home"))
    +      .setConf("spark.ui.enabled", "false")
    +      .setPropertiesFile(propsFile)
    +      .setMaster("yarn")
    +      .setDeployMode("cluster")
    +      .autoShutdown()
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setMainClass(mainClassName(YarnLauncherTestApp.getClass))
    +      .startApplication()
    +
    +    try {
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.RUNNING)
    +      }
    +
    +      handle.getAppId() should not be (null)
    +      handle.getAppId() should startWith ("application_")
    +      handle.disconnect()
    +      val applicationId = ConverterUtils.toApplicationId(handle.getAppId)
    +      val yarnClient: YarnClient = getYarnClient
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.LOST)
    +        var status = yarnClient.getApplicationReport(applicationId).getFinalApplicationStatus()
    +        status should be (FinalApplicationStatus.KILLED)
    +      }
    +
    +    } finally {
    +      handle.kill()
    +    }
    +  }
    +
    +  test("monitor app using launcher library for thread with auto shutdown") {
    --- End diff --
    
    refactored


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r112597680
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkAppHandle.java ---
    @@ -95,7 +95,8 @@ public boolean isFinal() {
       void kill();
     
       /**
    -   * Disconnects the handle from the application, without stopping it. After this method is called,
    +   * Disconnects the handle from the application. If using {@link SparkLauncher#autoShutdown()}
    --- End diff --
    
    It looks the documentation generation for Javadoc 8 is being failed due to this line - 
    
    ```
    [error] /home/jenkins/workspace/SparkPullRequestBuilder/launcher/src/main/java/org/apache/spark/launcher/SparkAppHandle.java:98: error: reference not found
    [error]    * Disconnects the handle from the application. If using {@link SparkLauncher#autoShutdown()}
    [error]                                                                   ^
    ```
    
    Probably, wrap it with `` `... ` `` as I did before - https://github.com/apache/spark/pull/16013 or find a way to make the link properly.
    
    The other errors seem spurious. Please refer my observation - https://github.com/apache/spark/pull/17389#issuecomment-288438704


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106234167
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -488,11 +545,21 @@ public Process launch() throws IOException {
        * In all cases, the logger name will start with "org.apache.spark.launcher.app", to fit more
        * easily into the configuration of commonly-used logging systems.
        *
    +   * If the application is launched as a thread, the log redirection methods are not supported,
    +   * and the parent process's output and log configuration will be used.
    +   *
        * @since 1.6.0
        * @param listeners Listeners to add to the handle before the app is launched.
        * @return A handle for the launched application.
        */
       public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) throws IOException {
    +    if (launchAsThread) {
    +      return startApplicationAsThread(listeners);
    +    }
    +    return startApplicationAsChildProc(listeners);
    +  }
    +
    +  private SparkAppHandle startApplicationAsChildProc(SparkAppHandle.Listener[] listeners) throws IOException {
    --- End diff --
    
    nit: line > 100 chars


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #74338 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74338/testReport)** for PR 15009 at commit [`b66243d`](https://github.com/apache/spark/commit/b66243dd0644b6c80cece4a9995f9fe256d6cb21).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r81981021
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -710,7 +724,12 @@ object SparkSubmit {
           printWarning("Subclasses of scala.App may not work correctly. Use a main() method instead.")
         }
     
    -    val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
    +    val mainMethod =
    +    if (threadEnabled ) {
    --- End diff --
    
    remove extra space before )


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84782701
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkApp.scala ---
    @@ -0,0 +1,29 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark
    +
    +/**
    + * A client that SparkSubmit uses to launch spark Application.
    + * This is currently supported only in YARN mode.
    + */
    +trait SparkApp {
    +  this: Singleton =>
    +
    +  def sparkMain(args: Array[String], conf: scala.collection.mutable.Map[String, String]): Unit
    --- End diff --
    
    Having a mutable parameter is generally weird.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    I'm not worried about the multiple spark contexts, I say we just say this is cluster mode only since we don't support multiple spark context for anything. 
    
    Thanks for pointing out the multiple apps launched though, I hadn't thought of that use case since we were thinking about oozie launcher which only launches one per process.
    
    Changing SparkSubmit to not use system properties looks like a pretty big task. We then need to figure out how things will get passed. I would think passing on the command line could get to big so then you are looking at writing a file and then with that you have to configure where that file goes, etc.  Really the SparkSubmit front end is a bit clunky since its really like we have a Client calling another Client which then finally does the work.  Ideally we would get rid of that second wrapper.   Did you have ideas on this?
    
    one other option would be for us just to only support thread mode if launching a single app for cluster mode.  I'm not super fond of it as it could confuse users but it at least gets us more functionality then now and we can do the system properties change separate.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #72201 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/72201/consoleFull)** for PR 15009 at commit [`6a7ba5b`](https://github.com/apache/spark/commit/6a7ba5bfdd2cb165956992907f681ab3ad85154e).
     * This patch passes all tests.
     * This patch **does not merge cleanly**.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r99849329
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -71,6 +100,9 @@ private[spark] abstract class LauncherBackend {
         if (connection != null && lastState != state) {
           connection.send(new SetState(state))
           lastState = state
    +      if (!_isConnected && stopOnShutdown) {
    --- End diff --
    
    The `LauncherBackend` is supposed to run within `Spark App` JVM.  The `connection` is `LauncherConnection` used to report back Spark Job status to User App.  So, if this connection is lost - the User App requesting/waiting for the job completion is no longer available.  So User app is not available shutdown flag would decide whether to kill the Spark job or not.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78379337
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkSubmitRunner.java ---
    @@ -0,0 +1,59 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.lang.reflect.InvocationTargetException;
    +import java.lang.reflect.Method;
    +import java.util.List;
    +
    --- End diff --
    
    please add description


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r81999426
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -1197,12 +1229,22 @@ private object Client extends Logging {
         // Set an env variable indicating we are running in YARN mode.
         // Note that any env variable with the SPARK_ prefix gets propagated to all (remote) processes
         System.setProperty("SPARK_YARN_MODE", "true")
    +
    +    val threadEnabled: Boolean = env.get("spark.launcher.internal.thread.enabled").
    +      getOrElse("false").toBoolean
    +
         val sparkConf = new SparkConf
    +    if( threadEnabled) {
    +      for ((key, value) <- env if key.startsWith("spark.")) {
    +        sparkConf.set(key, value, true)
    +      }
    +    }
     
         val args = new ClientArguments(argStrings)
    -    new Client(args, sparkConf).run()
    +    new Client(args, sparkConf, env).run()
       }
     
    +
    --- End diff --
    
    remove extra line


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    test this please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75516/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100316424
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -94,6 +103,13 @@
     
       static final Map<String, String> launcherConfig = new HashMap<>();
     
    +
    --- End diff --
    
    remove extra line


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100312242
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkApp.scala ---
    @@ -0,0 +1,40 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark
    +
    +/**
    + * A client that SparkSubmit uses to launch spark Application.
    + * This is currently supported only in YARN mode.
    + */
    +private[spark] trait SparkApp {
    +  this: Singleton =>
    +
    +  /**
    +   * The Client should implement this as entry method to provide application,
    +   * spark conf and system configuration.
    +   *
    +   * @param args    - all argouments for SparkApp.
    +   * @param conf    - Spark Configuration.
    +   * @param envVars - system environment Variables.
    --- End diff --
    
    change to lower case variables


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106258149
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -735,7 +749,12 @@ object SparkSubmit extends CommandLineUtils {
         }
     
         try {
    -      mainMethod.invoke(null, childArgs.toArray)
    +      if (isSparkApp) {
    +        val envvars = Map[String, String]() ++ sys.env
    +        mainMethod.invoke(null, childArgs.toArray, childSparkConf, envvars.toMap)
    --- End diff --
    
    ah, thanks for catching this. everything should be passed in the confs now and we've deprecated all the env configs


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84783078
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -676,8 +678,19 @@ object SparkSubmit {
           addJarToClasspath(jar, loader)
         }
     
    -    for ((key, value) <- sysProps) {
    -      System.setProperty(key, value)
    +    val threadEnabled = sysProps.getOrElse("spark.launcher.internal.launcher.thread.enabled",
    +       "false").toBoolean
    +    if (!threadEnabled) {
    --- End diff --
    
    nit: could you invert the order of the `if..else` to avoid the negation?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    @tgravescs @vanzin , Thanks for all the comments.
    I added `SparkApp` trait, more documentation and minor code fixes based on our suggestion.
    Please review and let me know if I need any other changes. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75316/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    we should update javadoc for package in launcher/src/main/java/org/apache/spark/launcher/package-info.java


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    test this please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #77263 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/77263/testReport)** for PR 15009 at commit [`d906072`](https://github.com/apache/spark/commit/d9060724b4f9a2dd3f4c9b0f77c2a09cb14b4671).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r114173041
  
    --- Diff: resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnClusterSuite.scala ---
    @@ -162,29 +172,10 @@ class YarnClusterSuite extends BaseYarnClusterSuite {
       }
     
       test("monitor app using launcher library") {
    -    val env = new JHashMap[String, String]()
    -    env.put("YARN_CONF_DIR", hadoopConfDir.getAbsolutePath())
    -
    -    val propsFile = createConfFile()
    -    val handle = new SparkLauncher(env)
    -      .setSparkHome(sys.props("spark.test.home"))
    -      .setConf("spark.ui.enabled", "false")
    -      .setPropertiesFile(propsFile)
    -      .setMaster("yarn")
    -      .setDeployMode("client")
    -      .setAppResource(SparkLauncher.NO_RESOURCE)
    -      .setMainClass(mainClassName(YarnLauncherTestApp.getClass))
    -      .startApplication()
    -
    +    var handle : SparkAppHandle = null
         try {
    -      eventually(timeout(30 seconds), interval(100 millis)) {
    -        handle.getState() should be (SparkAppHandle.State.RUNNING)
    -      }
    -
    -      handle.getAppId() should not be (null)
    -      handle.getAppId() should startWith ("application_")
    +      handle = launchSparkAppWithConf(false, false, "client")
    --- End diff --
    
    You need to initialize the handle outside the `try`, otherwise you will get an NPE in the `finally` block.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100937651
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/LauncherServer.java ---
    @@ -89,11 +89,31 @@
       private static volatile LauncherServer serverInstance;
     
       /**
    -   * Creates a handle for an app to be launched. This method will start a server if one hasn't been
    +   * Creates a handle for an app to be launched using ChildProc.
    --- End diff --
    
    Could you re-align the whole comment so that it doesn't look weird (short and long lines all mixed up)?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #75992 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75992/testReport)** for PR 15009 at commit [`ab50dd8`](https://github.com/apache/spark/commit/ab50dd8b7e7dbc25f5f06c4220ae3270b7fc1e53).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443] Stop Spark Application if launcher goes do...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #65103 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/65103/consoleFull)** for PR 15009 at commit [`8986aa9`](https://github.com/apache/spark/commit/8986aa9b1cde7e116874eb4b9bf5cf6142a244a4).
     * This patch **fails Scala style tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `public abstract class AbstractSparkAppHandle implements SparkAppHandle `
      * `class ChildProcAppHandle extends AbstractSparkAppHandle `
      * `public class ChildThreadAppHandle extends AbstractSparkAppHandle `
      * `class SparkSubmitRunner implements Runnable `


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106243726
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -107,6 +119,30 @@ public static void setConfig(String name, String value) {
         launcherConfig.put(name, value);
       }
     
    +  /**
    +   * Specifies that Spark Application be stopped if current process goes away.
    +   * It tries stop/kill Spark Application if {@link LauncherServer} goes away.
    +   *
    +   * @since 2.2.0
    +   * @return This launcher.
    +   */
    +  public SparkLauncher autoShutdown() {
    --- End diff --
    
    This is inconsistent with `launchAsThread` which takes a boolean. I think adding the parameter is better.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    @kishorvpatil I'll try to look at the changes soon, but since my last round of comments, 2.1 was branched so versions need to be updated to "2.2.0"...


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #65150 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/65150/consoleFull)** for PR 15009 at commit [`bac5cd2`](https://github.com/apache/spark/commit/bac5cd26c6b5778b449fb7665365b4773b93ae9e).
     * This patch **fails to build**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r111222319
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkApp.scala ---
    @@ -0,0 +1,38 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark
    +
    +/**
    + * A client that SparkSubmit uses to launch spark Application.
    + * This is currently supported only in YARN mode.
    + */
    +private[spark] trait SparkApp {
    +  this: Singleton =>
    +
    +  /**
    +   * The Client should implement this as entry method to provide application,
    --- End diff --
    
    Instead: "Method executed by SparkSubmit to run the application."


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r82063538
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -113,8 +115,8 @@ object SparkSubmit {
       }
       // scalastyle:on println
     
    -  def main(args: Array[String]): Unit = {
    -    val appArgs = new SparkSubmitArguments(args)
    +  def main(argStrings: Array[String]) {
    --- End diff --
    
    can we revert this back to args since I don't think it affects anything here


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    @vanzin I modified the test with sleep for SparkApp to run.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/67219/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #67216 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/67216/consoleFull)** for PR 15009 at commit [`1fe498b`](https://github.com/apache/spark/commit/1fe498b5bc5ab903d93fd6ec278a5358059d1d90).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #67221 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/67221/consoleFull)** for PR 15009 at commit [`14050f5`](https://github.com/apache/spark/commit/14050f5d16b01d5081b456b92afbe78cd79b8d25).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r82075274
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -488,11 +546,22 @@ public Process launch() throws IOException {
        * In all cases, the logger name will start with "org.apache.spark.launcher.app", to fit more
        * easily into the configuration of commonly-used logging systems.
        *
    +   * If the applications are launched as a thread, the {@link SparkLauncher#redirectError} and
    +   * {@link SparkLauncher#redirectToLog}, are not supported at this time. The existing process
    +   * stdout and stderr will get all the log entries.
    +   *
        * @since 1.6.0
        * @param listeners Listeners to add to the handle before the app is launched.
        * @return A handle for the launched application.
        */
       public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) throws IOException {
    +    if(launchSparkSubmitAsThread) {
    --- End diff --
    
    add space after if


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r87463639
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -719,7 +721,27 @@ object SparkSubmit {
           printWarning("Subclasses of scala.App may not work correctly. Use a main() method instead.")
         }
     
    -    val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
    +    val isSparkApp = mainClass.getMethods().filter(_.getName() == "sparkMain").length > 0
    +
    +    val childSparkConf = sysProps.filter( p => p._1.startsWith("spark.")).toMap
    --- End diff --
    
    nit: `.filter { p => ... }`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84787477
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/AbstractSparkAppHandle.java ---
    @@ -0,0 +1,133 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.io.IOException;
    +import java.lang.reflect.Method;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.logging.Level;
    +import java.util.logging.Logger;
    +
    +
    +public abstract class AbstractSparkAppHandle implements SparkAppHandle {
    +  private static final Logger LOG = Logger.getLogger(AbstractSparkAppHandle.class.getName());
    +  protected final String secret;
    --- End diff --
    
    nit: please add a blank line between static and non-static fields.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r82064795
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -59,20 +59,36 @@ import org.apache.spark.util.Utils
     private[spark] class Client(
         val args: ClientArguments,
         val hadoopConf: Configuration,
    -    val sparkConf: SparkConf)
    +    val sparkConf: SparkConf,
    +    val sysEnvironmentInput: Map[String, String])
       extends Logging {
     
       import Client._
       import YarnSparkHadoopUtil._
     
    +  def this(clientArgs: ClientArguments, spConf: SparkConf, sysenvironment: Map[String, String]) =
    +    this(clientArgs, SparkHadoopUtil.get.newConfiguration(spConf), spConf, sysenvironment)
    +
    +  def this(clientArgs: ClientArguments, hadoopConf: Configuration, spConf: SparkConf) =
    +    this(clientArgs, hadoopConf, spConf, Map() ++ sys.env)
    +
       def this(clientArgs: ClientArguments, spConf: SparkConf) =
    -    this(clientArgs, SparkHadoopUtil.get.newConfiguration(spConf), spConf)
    +    this(clientArgs, spConf, Map() ++  sys.env)
    --- End diff --
    
    remove extra spaces around ++


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84782648
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkApp.scala ---
    @@ -0,0 +1,29 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark
    +
    +/**
    + * A client that SparkSubmit uses to launch spark Application.
    + * This is currently supported only in YARN mode.
    + */
    +trait SparkApp {
    --- End diff --
    
    This should be `private[spark]`, at least for the moment.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r113086519
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -488,11 +549,24 @@ public Process launch() throws IOException {
        * In all cases, the logger name will start with "org.apache.spark.launcher.app", to fit more
        * easily into the configuration of commonly-used logging systems.
        *
    +   * If the application is launched as a thread, the log redirection methods are not supported,
    +   * and the parent process's output and log configuration will be used.
    +   *
        * @since 1.6.0
        * @param listeners Listeners to add to the handle before the app is launched.
        * @return A handle for the launched application.
        */
       public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) throws IOException {
    +    if (launchAsThread) {
    +      checkArgument(builder.childEnv.isEmpty(),
    +        "Environment variables are not supported while launching as Thread");
    --- End diff --
    
    s/Environment variables/Custom environment variables
    s/as Thread/in a thread.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #67219 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/67219/consoleFull)** for PR 15009 at commit [`25c3258`](https://github.com/apache/spark/commit/25c3258d9d1c67b308d44578045dcd3ab9706c2d).
     * This patch **fails Scala style tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/72475/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #72610 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/72610/testReport)** for PR 15009 at commit [`2707d21`](https://github.com/apache/spark/commit/2707d219f3f2c3fa1e89553809cf3a8d118fc084).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r111223894
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkApp.scala ---
    @@ -0,0 +1,38 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark
    +
    +/**
    + * A client that SparkSubmit uses to launch spark Application.
    + * This is currently supported only in YARN mode.
    + */
    +private[spark] trait SparkApp {
    +  this: Singleton =>
    +
    +  /**
    +   * The Client should implement this as entry method to provide application,
    +   * spark conf and system configuration.
    +   *
    +   * @param args    - all arguments for SparkApp.
    +   * @param conf    - Spark Configuration.
    +   */
    +  def sparkMain(
    +    args: Array[String],
    --- End diff --
    
    nit: the method declaration now fits in a single line


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #76274 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76274/testReport)** for PR 15009 at commit [`7ee465f`](https://github.com/apache/spark/commit/7ee465fa45bb3537bc819fb3249d3da0d2826803).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r111225286
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -720,7 +717,24 @@ object SparkSubmit extends CommandLineUtils {
           printWarning("Subclasses of scala.App may not work correctly. Use a main() method instead.")
         }
     
    -    val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
    +    val sparkAppMainMethodArr = mainClass.getMethods().filter(_.getName == "sparkMain")
    +    val isSparkApp = sparkAppMainMethodArr.length > 0
    +
    +    val childSparkConf = sysProps.filter{p => p._1.startsWith("spark.")}.toMap
    --- End diff --
    
    nit: `.filter { p => ... }.toMap` (note the extra spacing).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r111228432
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkSubmitRunner.java ---
    @@ -0,0 +1,64 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.lang.reflect.InvocationTargetException;
    +import java.lang.reflect.Method;
    +import java.util.List;
    +
    +/**
    + * This class used to by {@link SparkLauncher#startApplicationAsThread(SparkAppHandle.Listener...)}
    + * <p>
    + * This class to start Spark applications programmatically as a Thread. This uses reflection and relies
    + * on the SparkSubmit main class being in the classpath.
    + * </p>
    + */
    +class SparkSubmitRunner implements Runnable {
    +  private Method main;
    +  private final List<String> args;
    +
    +  SparkSubmitRunner(Method main, List<String> args) {
    +    this.main = main;
    +    this.args = args;
    +  }
    +
    +  /**
    +   * Trying to see if "org.apache.spark.deploy.SparkSubmit#Main" method is available in the classpath.
    +   *
    +   * @return Method to execute for starting Spark Application
    +   * @throws ClassNotFoundException
    +   * @throws NoSuchMethodException
    +   */
    +  protected static Method getSparkSubmitMain() throws ClassNotFoundException, NoSuchMethodException {
    +    Class<?> cls = Class.forName("org.apache.spark.deploy.SparkSubmit");
    +    return cls.getDeclaredMethod("main", String[].class);
    +  }
    +
    +  @Override
    +  public void run() {
    +    try {
    +      if (main == null) {
    +        main = getSparkSubmitMain();
    +      }
    +      Object argsObj = args.toArray(new String[args.size()]);
    +      main.invoke(null, argsObj);
    +    } catch (IllegalAccessException|InvocationTargetException|ClassNotFoundException|NoSuchMethodException illEx) {
    --- End diff --
    
    I'm almost sure this will trigger style checks which are not run in the PR builder... might as well just catch all exceptions:
    
    ```
    } catch (RuntimeException re) {
      throw re;
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    ```



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r111229901
  
    --- Diff: resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -58,14 +58,24 @@ import org.apache.spark.util.{CallerContext, Utils}
     private[spark] class Client(
         val args: ClientArguments,
         val hadoopConf: Configuration,
    -    val sparkConf: SparkConf)
    +    val sparkConf: SparkConf,
    +    val sysEnvironment: scala.collection.immutable.Map[String, String])
    --- End diff --
    
    So, when I requested that you made up your mind about whether to support custom envs or not, *this* is what I meant. You can revert all changes to this file that now use `sysEnvironment` instead of `sys.env`, including the new constructor that takes an env map and the new parameter to `populateClasspath`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75954/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106243822
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -107,6 +119,30 @@ public static void setConfig(String name, String value) {
         launcherConfig.put(name, value);
       }
     
    +  /**
    +   * Specifies that Spark Application be stopped if current process goes away.
    +   * It tries stop/kill Spark Application if {@link LauncherServer} goes away.
    --- End diff --
    
    `LauncherServer` is not a public class so it shouldn't be mentioned in public javadocs.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #76229 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76229/testReport)** for PR 15009 at commit [`04e56fc`](https://github.com/apache/spark/commit/04e56fcd2cc62b4e651b1016300a9ca5704248c2).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100317631
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkSubmitRunner.java ---
    @@ -0,0 +1,65 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.lang.reflect.InvocationTargetException;
    +import java.lang.reflect.Method;
    +import java.util.List;
    +
    +/**
    + * This class used to by {@link SparkLauncher#startApplicationAsThread(SparkAppHandle.Listener...)}
    + * <p>
    + * This class to start Spark applications programmatically as a Thread. This uses reflection and relies
    + * on find SparkSubmit main class.
    --- End diff --
    
    relies on the SparkSubmit main class being in the classpath.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r113086469
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -107,6 +119,34 @@ public static void setConfig(String name, String value) {
         launcherConfig.put(name, value);
       }
     
    +
    +
    +  /**
    +   * Specifies that Spark Application be stopped if current process goes away.
    +   * It tries stop/kill Spark Application if launching process goes away.
    +   *
    +   * @since 2.2.0
    +   * @param autoShutdown Flag for shutdown Spark Application if launcher process goes away.
    +   * @return This launcher.
    +   */
    +  public SparkLauncher autoShutdown(boolean autoShutdown) {
    +    this.autoShutdown = autoShutdown;
    +    return this;
    +  }
    +
    +  /**
    +   * Specifies that Spark Submit be launched as a daemon thread. Please note
    +   * this feature is currently supported only for YARN cluster deployment mode.
    +   *
    +   * @since 2.2.0
    +   * @param launchAsThread Flag for launching app as a thread.
    --- End diff --
    
    "Whether to launch the Spark application in a new thread in the same process."


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    It would also be nice to have unit tests for this. I see there are unit tests for launch but not startApplication, but I"m not sure why.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84788283
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/ChildThreadAppHandle.java ---
    @@ -0,0 +1,53 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.util.logging.Logger;
    +
    +public class ChildThreadAppHandle extends AbstractSparkAppHandle {
    +  private static final Logger LOG = Logger.getLogger(ChildThreadAppHandle.class.getName());
    +  private Thread childThread;
    +
    +  public ChildThreadAppHandle(String secret, LauncherServer server) {
    +    super(server, secret);
    +  }
    +
    +  @Override
    +  public synchronized void kill() {
    +    if (!disposed) {
    +      disconnect();
    +    }
    +    if (childThread != null) {
    +      try {
    +        childThread.join(3000);
    --- End diff --
    
    Why join before interrupting? This is a kill, you're not really expecting the thread to already be exiting or something. `disconnect()` is not expected to stop the application.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/76278/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106230295
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -17,35 +17,60 @@
     
     package org.apache.spark.launcher
     
    +import java.io.IOException
     import java.net.{InetAddress, Socket}
     
     import org.apache.spark.SPARK_VERSION
    +import org.apache.spark.internal.Logging
     import org.apache.spark.launcher.LauncherProtocol._
    -import org.apache.spark.util.{ThreadUtils, Utils}
    +import org.apache.spark.util.{ShutdownHookManager, ThreadUtils, Utils}
     
     /**
      * A class that can be used to talk to a launcher server. Users should extend this class to
      * provide implementation for the abstract methods.
      *
      * See `LauncherServer` for an explanation of how launcher communication works.
      */
    -private[spark] abstract class LauncherBackend {
    +private[spark] abstract class LauncherBackend extends Logging {
     
       private var clientThread: Thread = _
       private var connection: BackendConnection = _
       private var lastState: SparkAppHandle.State = _
    +  private var stopOnShutdown: Boolean = false
       @volatile private var _isConnected = false
     
       def connect(): Unit = {
         val port = sys.env.get(LauncherProtocol.ENV_LAUNCHER_PORT).map(_.toInt)
         val secret = sys.env.get(LauncherProtocol.ENV_LAUNCHER_SECRET)
    +    val stopFlag = sys.env.get(LauncherProtocol.ENV_LAUNCHER_STOP_IF_SHUTDOWN).map(_.toBoolean)
         if (port != None && secret != None) {
    -      val s = new Socket(InetAddress.getLoopbackAddress(), port.get)
    -      connection = new BackendConnection(s)
    -      connection.send(new Hello(secret.get, SPARK_VERSION))
    -      clientThread = LauncherBackend.threadFactory.newThread(connection)
    -      clientThread.start()
    -      _isConnected = true
    +      connect(port.get, secret.get, stopFlag.getOrElse(false))
    +    }
    +  }
    +
    +  def connect(port: Int, secret: String, stopFlag: Boolean): Unit = {
    +    this.stopOnShutdown = stopFlag
    +    val s = new Socket(InetAddress.getLoopbackAddress(), port)
    +    connection = new BackendConnection(s)
    +    connection.send(new Hello(secret, SPARK_VERSION))
    +    clientThread = LauncherBackend.threadFactory.newThread(connection)
    +    clientThread.start()
    +    _isConnected = true
    +    if (stopOnShutdown) {
    +      logDebug("Adding shutdown hook") // force eager creation of logger
    +      var _shutdownHookRef = ShutdownHookManager.addShutdownHook(
    +        ShutdownHookManager.SPARK_CONTEXT_SHUTDOWN_PRIORITY) { () =>
    +        logInfo("Invoking onStopRequest() from shutdown hook")
    +        try {
    +          if (_isConnected) {
    +            onStopRequest()
    +          }
    +        }
    +        catch {
    +          case anotherIOE: IOException =>
    --- End diff --
    
    Why `anotherIOE`? There's no previous exception being handled here.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #75584 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75584/testReport)** for PR 15009 at commit [`0cfd4a7`](https://github.com/apache/spark/commit/0cfd4a7eb540e751a03b9d8e78af4e8f6e3be62c).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100312144
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkApp.scala ---
    @@ -0,0 +1,40 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark
    +
    +/**
    + * A client that SparkSubmit uses to launch spark Application.
    + * This is currently supported only in YARN mode.
    + */
    +private[spark] trait SparkApp {
    +  this: Singleton =>
    +
    +  /**
    +   * The Client should implement this as entry method to provide application,
    +   * spark conf and system configuration.
    +   *
    +   * @param args    - all argouments for SparkApp.
    --- End diff --
    
    spelling arguments


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78379290
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -613,4 +679,6 @@ protected void handleExtraArgs(List<String> extra) {
     
       }
     
    +
    --- End diff --
    
    remove extra lines


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100934407
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkApp.scala ---
    @@ -0,0 +1,40 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark
    +
    +/**
    + * A client that SparkSubmit uses to launch spark Application.
    + * This is currently supported only in YARN mode.
    + */
    +private[spark] trait SparkApp {
    +  this: Singleton =>
    +
    +  /**
    +   * The Client should implement this as entry method to provide application,
    +   * spark conf and system configuration.
    +   *
    +   * @param args    - all arguments for SparkApp.
    +   * @param conf    - Spark Configuration.
    +   * @param envvars - system environment Variables.
    +   */
    +  def sparkMain(
    +    args: Array[String],
    +    conf: scala.collection.immutable.Map[String, String],
    --- End diff --
    
    You don't need the fully qualified name here.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/72167/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #75006 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75006/testReport)** for PR 15009 at commit [`fe5b5d6`](https://github.com/apache/spark/commit/fe5b5d64b56dd55ad4a956619bf41c3492975f89).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100320712
  
    --- Diff: resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -1149,13 +1179,23 @@ private object Client extends Logging {
         // Set an env variable indicating we are running in YARN mode.
         // Note that any env variable with the SPARK_ prefix gets propagated to all (remote) processes
         System.setProperty("SPARK_YARN_MODE", "true")
    +
    +    val threadEnabled: Boolean = conf.get(SparkLauncher.LAUNCHER_INTERNAL_THREAD_ENABLED).
    --- End diff --
    
    wouldn't hurt to have a comment here explaining this and below if for loading the conf.   I think ideally both cases would pass the conf but we can do the other later


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100934667
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -719,7 +719,23 @@ object SparkSubmit extends CommandLineUtils {
           printWarning("Subclasses of scala.App may not work correctly. Use a main() method instead.")
         }
     
    -    val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
    +    val sparkAppMainMethodArr = mainClass.getMethods().filter{_.getName() == "sparkMain"}
    +    val isSparkApp = sparkAppMainMethodArr.length > 0
    +
    +    val childSparkConf = sysProps.filter{ p => p._1.startsWith("spark.")}.toMap
    +    // If running sparkApp or in thread mode, the System properties should not be cluttered.
    +    // This helps keep clean isolation between multiple Spark Apps launched in different threads.
    +    if (!isSparkApp || !threadEnabled) {
    --- End diff --
    
    should be `&&`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100318547
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/package-info.java ---
    @@ -49,6 +49,38 @@
      * </pre>
      *
      * <p>
    + * Currently, for currently while launching spark application with
    + * {@link org.apache.spark.launcher.SparkLauncher#startApplication(
    + * org.apache.spark.launcher.SparkAppHandle.Listener...)}, there are two options available
    + * for YARN manager in cluster deploy mode:
    + *  - to launch Spark Application as a Thread inside current JVM using
    + *    the {@link org.apache.spark.launcher.SparkLauncher#launchAsThread(boolean)}
    + *  - to request application be killed if launcher process exits using
    + *    the {@link org.apache.spark.launcher.SparkLauncher#stopIfLauncherShutdown()}.
    + * </p>
    + *
    + * <pre>
    + * {@code
    + *   import org.apache.spark.launcher.SparkAppHandle;
    + *   import org.apache.spark.launcher.SparkLauncher;`
    + *
    + *   public class MyLauncher {
    + *     public static void main(String[] args) throws Exception {
    + *       SparkAppHandle handle = new SparkLauncher()
    + *         .setAppResource("/my/app.jar")
    + *         .setMainClass("my.spark.app.Main")
    + *         .setMaster("yarn")
    --- End diff --
    
    we should explicilty set setDeployMode to cluster here.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r82064261
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -59,20 +59,36 @@ import org.apache.spark.util.Utils
     private[spark] class Client(
         val args: ClientArguments,
         val hadoopConf: Configuration,
    -    val sparkConf: SparkConf)
    +    val sparkConf: SparkConf,
    +    val sysEnvironmentInput: Map[String, String])
       extends Logging {
     
       import Client._
       import YarnSparkHadoopUtil._
     
    +  def this(clientArgs: ClientArguments, spConf: SparkConf, sysenvironment: Map[String, String]) =
    +    this(clientArgs, SparkHadoopUtil.get.newConfiguration(spConf), spConf, sysenvironment)
    +
    +  def this(clientArgs: ClientArguments, hadoopConf: Configuration, spConf: SparkConf) =
    +    this(clientArgs, hadoopConf, spConf, Map() ++ sys.env)
    +
       def this(clientArgs: ClientArguments, spConf: SparkConf) =
    -    this(clientArgs, SparkHadoopUtil.get.newConfiguration(spConf), spConf)
    +    this(clientArgs, spConf, Map() ++  sys.env)
    +
    +  private val sysEnvironment: scala.collection.immutable.Map[scala.Predef.String,
    +   scala.Predef.String] = collection.immutable.Map() ++ sysEnvironmentInput
    --- End diff --
    
    change scala.Predef.String to just be String


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #67132 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/67132/consoleFull)** for PR 15009 at commit [`58c6bac`](https://github.com/apache/spark/commit/58c6bac485d77853c912cd220e34173b5e945d1d).
     * This patch **fails PySpark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84788125
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/ChildProcAppHandle.java ---
    @@ -103,67 +46,22 @@ public synchronized void kill() {
           try {
             childProc.exitValue();
           } catch (IllegalThreadStateException e) {
    -        // Child is still alive. Try to use Java 8's "destroyForcibly()" if available,
    --- End diff --
    
    Why is this being removed? This is not supposed to be a "clean kill", and `destroyForcibly` works in certain cases where the child JVM is deadlocked and doesn't respond to `destroy()` (which just sends a SIGTERM).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r108788153
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/package-info.java ---
    @@ -49,6 +51,35 @@
      * </pre>
      *
      * <p>
    + * Here is example of launching application in thread mode for YARN cluster mode
    + * with the auto shutdown option enabled. Showing use case of both
    + * {@link org.apache.spark.launcher.SparkLauncher#autoShutdown()} and
    + * {@link org.apache.spark.launcher.SparkLauncher#launchAsThread(boolean)} methods
    + * </p>
    + *
    + * <pre>
    + * {@code
    + *   import org.apache.spark.launcher.SparkAppHandle;
    + *   import org.apache.spark.launcher.SparkLauncher;`
    --- End diff --
    
    stray backtick at the end


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    @vanzin I added `waitFor` method to ChildSparkHandle allowing it to wait for launched process or thread. Now the test waits for thread to finish.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78379144
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -538,6 +539,71 @@ public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) thr
         return handle;
       }
     
    +  private String getAppName() throws IOException {
    +    String appName = builder.getEffectiveConfig().get(CHILD_PROCESS_LOGGER_NAME);
    +    if (appName == null) {
    +      if (builder.appName != null) {
    +        appName = builder.appName;
    +      } else if (builder.mainClass != null) {
    +        int dot = builder.mainClass.lastIndexOf(".");
    +        if (dot >= 0 && dot < builder.mainClass.length() - 1) {
    +          appName = builder.mainClass.substring(dot + 1, builder.mainClass.length());
    +        } else {
    +          appName = builder.mainClass;
    +        }
    +      } else if (builder.appResource != null) {
    +        appName = new File(builder.appResource).getName();
    +      } else {
    +        appName = String.valueOf(COUNTER.incrementAndGet());
    +      }
    +    }
    +    return appName;
    +  }
    +
    +  /**
    +   * Starts a Spark application.
    +   * <p>
    +   * This method returns a handle that provides information about the running application and can
    +   * be used to do basic interaction with it.
    +   * <p>
    +   * The returned handle assumes that the application will instantiate a single SparkContext
    +   * during its lifetime. Once that context reports a final state (one that indicates the
    +   * SparkContext has stopped), the handle will not perform new state transitions, so anything
    +   * that happens after that cannot be monitored. The underlying application is launched as
    +   * a Thread, {@link SparkAppHandle#kill()} can still be used to kill the spark application.
    +   * <p>
    +   * @since 2.1.0
    +   * @param listeners Listeners to add to the handle before the app is launched.
    +   * @return A handle for the launched application.
    +   */
    +  public SparkAppHandle startApplicationInProcess(SparkAppHandle.Listener... listeners) throws IOException {
    +
    +    ChildThreadAppHandle handle = LauncherServer.newAppThreadHandle();
    +    for (SparkAppHandle.Listener l : listeners) {
    +      handle.addListener(l);
    +    }
    +
    +    String appName = getAppName();
    +    setConf(LAUNCHER_INTERNAL_PORT,String.valueOf(LauncherServer.getServerInstance().getPort()));
    +    setConf(CHILD_PROCESS_LAUNCHER_INTERNAL_SECRET, handle.getSecret());
    +    setConf(CHILD_PROCESS_LAUNCHER_STOP_FLAG, String.valueOf(stopIfInterrupted));
    +    try {
    +      //trying to see if method is available in the classpath.
    +      Method main = SparkSubmitRunner.getSparkSubmitMain();
    --- End diff --
    
    javadoc should mention this relies on the sparksubmit main function being there and if not what does it return.
    it doesn't rely on the entire spark install being there just the core libraries?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106230108
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -17,35 +17,60 @@
     
     package org.apache.spark.launcher
     
    +import java.io.IOException
     import java.net.{InetAddress, Socket}
     
     import org.apache.spark.SPARK_VERSION
    +import org.apache.spark.internal.Logging
     import org.apache.spark.launcher.LauncherProtocol._
    -import org.apache.spark.util.{ThreadUtils, Utils}
    +import org.apache.spark.util.{ShutdownHookManager, ThreadUtils, Utils}
     
     /**
      * A class that can be used to talk to a launcher server. Users should extend this class to
      * provide implementation for the abstract methods.
      *
      * See `LauncherServer` for an explanation of how launcher communication works.
      */
    -private[spark] abstract class LauncherBackend {
    +private[spark] abstract class LauncherBackend extends Logging {
     
       private var clientThread: Thread = _
       private var connection: BackendConnection = _
       private var lastState: SparkAppHandle.State = _
    +  private var stopOnShutdown: Boolean = false
       @volatile private var _isConnected = false
     
       def connect(): Unit = {
         val port = sys.env.get(LauncherProtocol.ENV_LAUNCHER_PORT).map(_.toInt)
         val secret = sys.env.get(LauncherProtocol.ENV_LAUNCHER_SECRET)
    +    val stopFlag = sys.env.get(LauncherProtocol.ENV_LAUNCHER_STOP_IF_SHUTDOWN).map(_.toBoolean)
         if (port != None && secret != None) {
    -      val s = new Socket(InetAddress.getLoopbackAddress(), port.get)
    -      connection = new BackendConnection(s)
    -      connection.send(new Hello(secret.get, SPARK_VERSION))
    -      clientThread = LauncherBackend.threadFactory.newThread(connection)
    -      clientThread.start()
    -      _isConnected = true
    +      connect(port.get, secret.get, stopFlag.getOrElse(false))
    +    }
    +  }
    +
    +  def connect(port: Int, secret: String, stopFlag: Boolean): Unit = {
    +    this.stopOnShutdown = stopFlag
    +    val s = new Socket(InetAddress.getLoopbackAddress(), port)
    +    connection = new BackendConnection(s)
    +    connection.send(new Hello(secret, SPARK_VERSION))
    +    clientThread = LauncherBackend.threadFactory.newThread(connection)
    +    clientThread.start()
    +    _isConnected = true
    +    if (stopOnShutdown) {
    +      logDebug("Adding shutdown hook") // force eager creation of logger
    +      var _shutdownHookRef = ShutdownHookManager.addShutdownHook(
    +        ShutdownHookManager.SPARK_CONTEXT_SHUTDOWN_PRIORITY) { () =>
    +        logInfo("Invoking onStopRequest() from shutdown hook")
    +        try {
    +          if (_isConnected) {
    +            onStopRequest()
    +          }
    +        }
    +        catch {
    --- End diff --
    
    nit: move to previous line


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78377198
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -71,6 +104,9 @@ private[spark] abstract class LauncherBackend {
         if (connection != null && lastState != state) {
           connection.send(new SetState(state))
           lastState = state
    +      if (!_isConnected && stopFlag) {
    --- End diff --
    
    do we still need this if its being done in close() now?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r122050475
  
    --- Diff: core/src/test/java/org/apache/spark/launcher/SparkLauncherSuite.java ---
    @@ -183,12 +185,38 @@ public void testChildProcLauncher() throws Exception {
         assertEquals(0, app.waitFor());
       }
     
    +  @Test
    +  public void testThreadLauncher() throws Exception {
    +    // This test is failed on Windows due to the failure of initiating executors
    +    // by the path length limitation. See SPARK-18718.
    +    assumeTrue(!Utils.isWindows());
    +
    +    launcher = new SparkLauncher();
    +    launcher
    +      .setMaster("local")
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS,
    +        "-Dfoo=bar -Dtest.appender=childproc")
    +      .setConf(SparkLauncher.DRIVER_EXTRA_CLASSPATH, System.getProperty("java.class.path"))
    +      .setMainClass(SparkLauncherTestApp.class.getName())
    +      .launchAsThread(true)
    +      .addAppArgs("thread");
    +    final SparkAppHandle app = launcher.startApplication();
    +    sleep(3000);
    +    AbstractSparkAppHandle handle = (AbstractSparkAppHandle)app;
    +    handle.waitFor();
    --- End diff --
    
    In this unit test the main application is Simple application. There is no spark application running in background to track status, so no way to use `handle.getState`. All I am checking is for launched thread/process is complete.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106234552
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -528,13 +579,42 @@ public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) thr
         pb.environment().put(LauncherProtocol.ENV_LAUNCHER_PORT,
           String.valueOf(LauncherServer.getServerInstance().getPort()));
         pb.environment().put(LauncherProtocol.ENV_LAUNCHER_SECRET, handle.getSecret());
    +    pb.environment().put(LauncherProtocol.ENV_LAUNCHER_STOP_IF_SHUTDOWN, String.valueOf(stopOnShutdown));
         try {
           handle.setChildProc(pb.start(), loggerName);
         } catch (IOException ioe) {
           handle.kill();
           throw ioe;
         }
    +    return handle;
    +  }
    +
    +  private SparkAppHandle startApplicationAsThread(SparkAppHandle.Listener... listeners) throws IOException {
    +    ChildThreadAppHandle handle = LauncherServer.newAppThreadHandle();
    +    for (SparkAppHandle.Listener l : listeners) {
    +      handle.addListener(l);
    +    }
     
    +    String appName = getAppName();
    +    setConf(LAUNCHER_INTERNAL_PORT, String.valueOf(LauncherServer.getServerInstance().getPort()));
    +    setConf(LAUNCHER_INTERNAL_CHILD_PROCESS_SECRET, handle.getSecret());
    +    setConf(LAUNCHER_INTERNAL_STOP_ON_SHUTDOWN, String.valueOf(stopOnShutdown));
    +    try {
    +      // It is important that SparkSubmit class is available in the classpath.
    +      // Trying to see if method is available in the classpath else throws Exception.
    +      Method main = SparkSubmitRunner.getSparkSubmitMain();
    +      Thread submitJobThread = new Thread(new SparkSubmitRunner(main, builder.buildSparkSubmitArgs()));
    +      submitJobThread.setName(appName);
    +      submitJobThread.setDaemon(true);
    +      handle.setChildThread(submitJobThread);
    +      submitJobThread.start();
    +    } catch (ClassNotFoundException cnfe) {
    +      throw new IOException("Please make sure the spark jar containing SparkSubmit is in the classpath.",
    +          cnfe);
    +    } catch (NoSuchMethodException nsme) {
    +      throw new IOException("Please make sure the spark jar containing SparkSubmit version is correct.",
    --- End diff --
    
    nit: line > 100 chars
    
    You can run `dev/lint-java` and I think it will point these out.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106235524
  
    --- Diff: resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -46,32 +46,49 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration
     import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException
     import org.apache.hadoop.yarn.util.Records
     
    -import org.apache.spark.{SecurityManager, SparkConf, SparkException}
    +import org.apache.spark.{SecurityManager, SparkApp, SparkConf, SparkException}
     import org.apache.spark.deploy.SparkHadoopUtil
     import org.apache.spark.deploy.yarn.config._
     import org.apache.spark.deploy.yarn.security.ConfigurableCredentialManager
     import org.apache.spark.internal.Logging
     import org.apache.spark.internal.config._
    -import org.apache.spark.launcher.{LauncherBackend, SparkAppHandle, YarnCommandBuilderUtils}
    +import org.apache.spark.launcher.{LauncherBackend, SparkAppHandle, SparkLauncher, YarnCommandBuilderUtils}
     import org.apache.spark.util.{CallerContext, Utils}
     
    +
     private[spark] class Client(
         val args: ClientArguments,
         val hadoopConf: Configuration,
    -    val sparkConf: SparkConf)
    +    val sparkConf: SparkConf,
    +    val sysEnvironment: scala.collection.immutable.Map[String, String])
       extends Logging {
     
       import Client._
       import YarnSparkHadoopUtil._
     
    +  def this(
    +    clientArgs: ClientArguments,
    --- End diff --
    
    nit: arguments need an extra level of indent.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    I kinda have up waiting for feedback to be addressed here. I'm fixing some things in the launcher library and will work on SPARK-11035 next, replacing part of this PR.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #67219 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/67219/consoleFull)** for PR 15009 at commit [`25c3258`](https://github.com/apache/spark/commit/25c3258d9d1c67b308d44578045dcd3ab9706c2d).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r113085569
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkAppHandle.java ---
    @@ -95,7 +95,8 @@ public boolean isFinal() {
       void kill();
     
       /**
    -   * Disconnects the handle from the application, without stopping it. After this method is called,
    +   * Disconnects the handle from the application. If using {@link SparkLauncher#autoShutdown()}
    --- End diff --
    
    That's because the method is `autoShutdown(boolean)` and not `autoShutdown()`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #68300 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/68300/consoleFull)** for PR 15009 at commit [`c207b30`](https://github.com/apache/spark/commit/c207b309329b6b9b45dc4ffac6fada8befe973b9).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #76288 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76288/testReport)** for PR 15009 at commit [`3f060b6`](https://github.com/apache/spark/commit/3f060b66f32f5d8b3dc3c8cb8de63a4afd51384d).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100939127
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -488,11 +547,22 @@ public Process launch() throws IOException {
        * In all cases, the logger name will start with "org.apache.spark.launcher.app", to fit more
        * easily into the configuration of commonly-used logging systems.
        *
    +   * If the applications are launched as a thread, the {@link SparkLauncher#redirectError} and
    --- End diff --
    
    "...is launched as a thread, ..."
    
    Actually, better to rephrase the whole thing:
    
    "If the application is launched in a thread, the log redirection methods are not supported, and the parent process's output and log configuration will be used."
    
    Since these are public methods and thus show up in public documentation published on the website, please generate the javadocs and make sure there are no warnings / errors and that all the links work.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r101095913
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -71,6 +100,9 @@ private[spark] abstract class LauncherBackend {
         if (connection != null && lastState != state) {
           connection.send(new SetState(state))
           lastState = state
    +      if (!_isConnected && stopOnShutdown) {
    --- End diff --
    
    on the other issue of disconnect() I would think that if we just document that behavior its fine.
    
    I hadn't noticed before that the disconnect java docs state "Disconnects the handle from the application, without stopping it."


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #75314 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75314/testReport)** for PR 15009 at commit [`ee3f24a`](https://github.com/apache/spark/commit/ee3f24adaa00e9323707c6ad64f3a4eb2d4f571e).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by markhamstra <gi...@git.apache.org>.
Github user markhamstra commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100950587
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -719,7 +719,23 @@ object SparkSubmit extends CommandLineUtils {
           printWarning("Subclasses of scala.App may not work correctly. Use a main() method instead.")
         }
     
    -    val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
    +    val sparkAppMainMethodArr = mainClass.getMethods().filter{_.getName() == "sparkMain"}
    --- End diff --
    
    And `getName` shouldn't be a mutator, so no parens.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #76456 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76456/testReport)** for PR 15009 at commit [`f1b49d8`](https://github.com/apache/spark/commit/f1b49d8b7946edc484c6f20e6ed4ee26b7721e11).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84791881
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -1186,9 +1209,13 @@ private[spark] class Client(
     
     }
     
    -private object Client extends Logging {
    +private object Client extends SparkApp with Logging {
     
       def main(argStrings: Array[String]) {
    --- End diff --
    
    Do we even need this method anymore?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r122064689
  
    --- Diff: core/src/test/java/org/apache/spark/launcher/SparkLauncherSuite.java ---
    @@ -183,12 +185,38 @@ public void testChildProcLauncher() throws Exception {
         assertEquals(0, app.waitFor());
       }
     
    +  @Test
    +  public void testThreadLauncher() throws Exception {
    +    // This test is failed on Windows due to the failure of initiating executors
    +    // by the path length limitation. See SPARK-18718.
    +    assumeTrue(!Utils.isWindows());
    +
    +    launcher = new SparkLauncher();
    +    launcher
    +      .setMaster("local")
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS,
    +        "-Dfoo=bar -Dtest.appender=childproc")
    +      .setConf(SparkLauncher.DRIVER_EXTRA_CLASSPATH, System.getProperty("java.class.path"))
    +      .setMainClass(SparkLauncherTestApp.class.getName())
    +      .launchAsThread(true)
    +      .addAppArgs("thread");
    +    final SparkAppHandle app = launcher.startApplication();
    +    sleep(3000);
    +    AbstractSparkAppHandle handle = (AbstractSparkAppHandle)app;
    +    handle.waitFor();
    --- End diff --
    
    Seems like there is a bug somewhere; if the app finishes without reporting state (either in child process or thread mode), the handle should change its state to some form of error (e.g. `LOST`). Anyway that's unrelated to your changes, but please file a separate bug.
    
    You can still check that the state is not `FAILED`, right? Because if the child application throws an exception in thread mode, the handle should at least be updated to the failed state. (That would be a nice candidate for a new unit test, too.)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443] Stop Spark Application if launcher ...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78005596
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -29,26 +31,63 @@ import org.apache.spark.util.{ThreadUtils, Utils}
      *
      * See `LauncherServer` for an explanation of how launcher communication works.
      */
    -private[spark] abstract class LauncherBackend {
    +private[spark] abstract class LauncherBackend extends Logging {
     
       private var clientThread: Thread = _
       private var connection: BackendConnection = _
       private var lastState: SparkAppHandle.State = _
    +  private var stopFlag: Boolean = false
       @volatile private var _isConnected = false
     
       def connect(): Unit = {
         val port = sys.env.get(LauncherProtocol.ENV_LAUNCHER_PORT).map(_.toInt)
         val secret = sys.env.get(LauncherProtocol.ENV_LAUNCHER_SECRET)
    +    val stopFlag = sys.env.get(LauncherProtocol.ENV_LAUNCHER_STOP_FLAG).map(_.toBoolean)
         if (port != None && secret != None) {
    -      val s = new Socket(InetAddress.getLoopbackAddress(), port.get)
    +      if(stopFlag != None) {
    +        connect(port.get, secret.get, stopFlag.get)
    +      } else {
    +        connect(port.get, secret.get)
    +      }
    +    }
    +  }
    +
    +  def connect(port: Int, secret: String): Unit = {
    +    if (port != None && secret != None) {
    +      val s = new Socket(InetAddress.getLoopbackAddress(), port)
           connection = new BackendConnection(s)
    -      connection.send(new Hello(secret.get, SPARK_VERSION))
    +      connection.send(new Hello(secret, SPARK_VERSION))
           clientThread = LauncherBackend.threadFactory.newThread(connection)
           clientThread.start()
           _isConnected = true
    +      if(stopFlag) {
    --- End diff --
    
    space after if before (


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443] Stop Spark Application if launcher goes do...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    made a few comments but haven't made it all the way through yet, hopefully later this afternoon


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r104674280
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -78,9 +78,9 @@
     
       public static final String LAUNCHER_INTERNAL_CHILD_PROCESS_SECRET = "spark.launcher.internal.secret";
     
    -  public static final String LAUNCHER_INTERNAL_STOP_IF_SHUTDOWN = "spark.launcher.internal.stop.if.shutdown";
    +  public static final String LAUNCHER_INTERNAL_STOP_ON_SHUTDOWN = "spark.launcher.internal.stop.on.shutdown";
     
    -  public static final String LAUNCHER_INTERNAL_THREAD_ENABLED = "spark.launcher.internal.thread.enabled";
    +  public static final String LAUNCHER_INTERNAL_USE_THREAD = "spark.launcher.internal.use.thread";
    --- End diff --
    
    I dont' think we need these at all anymore


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r81980741
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -676,10 +678,22 @@ object SparkSubmit {
           addJarToClasspath(jar, loader)
         }
     
    -    for ((key, value) <- sysProps) {
    -      System.setProperty(key, value)
    +    val threadEnabled = sysProps.getOrElse("spark.launcher.internal.launcher.thread.enabled",
    +       "false").toBoolean
    +    if (!threadEnabled) {
    +      for ((key, value) <- sysProps) {
    +        System.setProperty(key, value)
    +      }
    +    } else {
    +      for ( (key, value) <- sys.props ++ sys.env) {
    +        if (!sysProps.contains(key)) {
    +          sysProps.put(key, value)
    +        }
    +      }
    +
         }
     
    +
    --- End diff --
    
    remove extra newline


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Jenkins, test this please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84782803
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkApp.scala ---
    @@ -0,0 +1,29 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark
    +
    +/**
    + * A client that SparkSubmit uses to launch spark Application.
    + * This is currently supported only in YARN mode.
    + */
    +trait SparkApp {
    +  this: Singleton =>
    +
    +  def sparkMain(args: Array[String], conf: scala.collection.mutable.Map[String, String]): Unit
    --- End diff --
    
    Can you add a scaladoc comment to this method, and explicitly explain the arguments?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    @vanzin , Please review and suggest if you have any further changes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r108785772
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -719,7 +719,23 @@ object SparkSubmit extends CommandLineUtils {
           printWarning("Subclasses of scala.App may not work correctly. Use a main() method instead.")
         }
     
    -    val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
    +    val sparkAppMainMethodArr = mainClass.getMethods().filter{_.getName() == "sparkMain"}
    --- End diff --
    
    You haven't addressed this.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #67132 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/67132/consoleFull)** for PR 15009 at commit [`58c6bac`](https://github.com/apache/spark/commit/58c6bac485d77853c912cd220e34173b5e945d1d).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r101061331
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -685,9 +686,8 @@ object SparkSubmit extends CommandLineUtils {
           addJarToClasspath(jar, loader)
         }
     
    -    for ((key, value) <- sysProps) {
    -      System.setProperty(key, value)
    -    }
    +    val threadEnabled = sysProps.getOrElse(SparkLauncher.LAUNCHER_INTERNAL_THREAD_ENABLED,
    --- End diff --
    
    I would move this down to closer to where its used.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r101092206
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -71,6 +100,9 @@ private[spark] abstract class LauncherBackend {
         if (connection != null && lastState != state) {
           connection.send(new SetState(state))
           lastState = state
    +      if (!_isConnected && stopOnShutdown) {
    --- End diff --
    
    why do we need this check at all here vs just relying on the close() call?  _isConnected only becomes false after calling that which should do the fireStopRequest(), am I missing a case?  If it wasn't connected at all on startup the connection != null case wouldn't pass


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100938212
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -73,6 +74,14 @@
       /** Logger name to use when launching a child process. */
       public static final String CHILD_PROCESS_LOGGER_NAME = "spark.launcher.childProcLoggerName";
     
    +  public static final String LAUNCHER_INTERNAL_PORT = "spark.launcher.internal.port";
    +
    +  public static final String LAUNCHER_INTERNAL_CHILD_PROCESS_SECRET = "spark.launcher.internal.secret";
    +
    +  public static final String LAUNCHER_INTERNAL_STOP_IF_SHUTDOWN = "spark.launcher.internal.stop.if.shutdown";
    +
    +  public static final String LAUNCHER_INTERNAL_THREAD_ENABLED = "spark.launcher.internal.thread.enabled";
    --- End diff --
    
    Not a fan of the name. How about `LAUNCHER_INTERNAL_USE_THREAD`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #75516 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75516/testReport)** for PR 15009 at commit [`7323200`](https://github.com/apache/spark/commit/7323200e4e70ab9b8fbbe8b69b1fbe8ac9c24512).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84178923
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkSubmitRunner.java ---
    @@ -0,0 +1,59 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.lang.reflect.InvocationTargetException;
    +import java.lang.reflect.Method;
    +import java.util.List;
    +
    +class SparkSubmitRunner implements Runnable {
    +  private Method main;
    +  private final List<String> args;
    +
    +  SparkSubmitRunner(Method main, List<String> args) {
    +    this.main = main;
    +    this.args = args;
    +  }
    +  /**
    +   *  Trying to see if method is available in the classpath.
    +   */
    +  protected static Method getSparkSubmitMain() throws ClassNotFoundException, NoSuchMethodException {
    +      Class<?> cls = Class.forName("org.apache.spark.deploy.SparkSubmit");
    +      return cls.getDeclaredMethod("main", String[].class);
    +  }
    +
    +  @Override
    +  public void run() {
    +    try {
    +      if(main == null) {
    +        main = getSparkSubmitMain();
    +      }
    +      Object argsObj = args.toArray(new String[args.size()]);
    +      main.invoke(null, argsObj);
    +    } catch (IllegalAccessException illAcEx) {
    --- End diff --
    
    This is to simply enable early fail is `SparkSubmit` is not in classpath, instead of launched `SparkSubmitRunner` thread finding the classpath issue.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r104743802
  
    --- Diff: resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala ---
    @@ -174,6 +174,11 @@ private[spark] class ApplicationMaster(
           sys.props.remove(e.key)
         }
     
    +    // Clean up the spark launcher configuration so it doesn't show up in the Web UI for security.
    +    Seq("spark.launcher.internal.secret", "spark.launcher.internal.port").foreach { e =>
    --- End diff --
    
    use LAUNCHER_CONFIGs here


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #76691 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76691/testReport)** for PR 15009 at commit [`2996fb1`](https://github.com/apache/spark/commit/2996fb1960914bd63ec7eda0a99b53f26a3d1c22).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r114852019
  
    --- Diff: core/src/test/java/org/apache/spark/launcher/SparkLauncherSuite.java ---
    @@ -183,6 +183,26 @@ public void testChildProcLauncher() throws Exception {
         assertEquals(0, app.waitFor());
       }
     
    +  @Test
    +  public void testThreadLauncher() throws Exception {
    +    // This test is failed on Windows due to the failure of initiating executors
    +    // by the path length limitation. See SPARK-18718.
    +    assumeTrue(!Utils.isWindows());
    +
    +    launcher = new SparkLauncher();
    +    launcher
    +      .setMaster("local")
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS,
    +        "-Dfoo=bar -Dtest.appender=childproc")
    +      .setConf(SparkLauncher.DRIVER_EXTRA_CLASSPATH, System.getProperty("java.class.path"))
    +      .setMainClass(SparkLauncherTestApp.class.getName())
    +      .launchAsThread(true)
    +      .addAppArgs("proc");
    +    final SparkAppHandle app = launcher.startApplication();
    +    assertEquals(false, app.getState().isFinal());
    --- End diff --
    
    Do you plan to address this? This test is not enough.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106049046
  
    --- Diff: resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnClusterSuite.scala ---
    @@ -226,6 +243,44 @@ class YarnClusterSuite extends BaseYarnClusterSuite {
         }
       }
     
    +  test("monitor app using launcher library for proc with auto shutdown") {
    +    val env = new JHashMap[String, String]()
    +    env.put("YARN_CONF_DIR", hadoopConfDir.getAbsolutePath())
    +
    +    val propsFile = createConfFile()
    +    val handle = new SparkLauncher(env)
    +      .setSparkHome(sys.props("spark.test.home"))
    +      .setConf("spark.ui.enabled", "false")
    +      .setPropertiesFile(propsFile)
    +      .setMaster("yarn")
    +      .setDeployMode("cluster")
    +      .autoShutdown()
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setMainClass(mainClassName(YarnLauncherTestApp.getClass))
    +      .startApplication()
    +
    +    try {
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.RUNNING)
    +      }
    +
    +      handle.getAppId() should not be (null)
    +      handle.getAppId() should startWith ("application_")
    +      handle.disconnect()
    +
    +      var applicationId = ConverterUtils.toApplicationId(handle.getAppId)
    --- End diff --
    
    both of these can be vals instead of vars since never changed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r114172852
  
    --- Diff: resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/BaseYarnClusterSuite.scala ---
    @@ -66,6 +66,7 @@ abstract class BaseYarnClusterSuite
     
       def newYarnConfig(): YarnConfiguration
     
    +
    --- End diff --
    
    no need for this new line.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #66392 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/66392/consoleFull)** for PR 15009 at commit [`a3250ac`](https://github.com/apache/spark/commit/a3250acf96640568633a6b9270e1461b454aa313).
     * This patch **fails PySpark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r114173131
  
    --- Diff: resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnClusterSuite.scala ---
    @@ -201,6 +192,69 @@ class YarnClusterSuite extends BaseYarnClusterSuite {
         finalState should be (SparkAppHandle.State.FAILED)
       }
     
    +  test("monitor app running in thread using launcher library") {
    +    var handle : SparkAppHandle = null
    +    try {
    +      handle = launchSparkAppWithConf(true, false, "cluster")
    +      handle.stop()
    +
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.KILLED)
    +      }
    +    } finally {
    +      handle.kill()
    +    }
    +  }
    +
    +  test("monitor app using launcher library for proc with auto shutdown") {
    +    var handle : SparkAppHandle = null
    +    try {
    +      handle = launchSparkAppWithConf(false, true, "cluster")
    +      handle.disconnect()
    +      val applicationId = ConverterUtils.toApplicationId(handle.getAppId)
    +      val yarnClient: YarnClient = getYarnClient
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.LOST)
    +        var status = yarnClient.getApplicationReport(applicationId).getFinalApplicationStatus()
    +        status should be (FinalApplicationStatus.KILLED)
    +      }
    +    } finally {
    +      handle.kill()
    +    }
    +  }
    +
    +  test("monitor app using launcher library for thread with auto shutdown") {
    +    var handle = launchSparkAppWithConf(true, true, "cluster")
    +    try {
    +      handle.disconnect()
    +      val applicationId = ConverterUtils.toApplicationId(handle.getAppId)
    +      val yarnClient: YarnClient = getYarnClient
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.LOST)
    +        var status = yarnClient.getApplicationReport(applicationId).getFinalApplicationStatus
    +        status should be (FinalApplicationStatus.KILLED)
    +      }
    +    } finally {
    +      handle.kill()
    +    }
    +  }
    +
    +  test("monitor app using launcher library for thread without auto shutdown") {
    +    var handle = launchSparkAppWithConf(true, false, "cluster")
    --- End diff --
    
    `val`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78379457
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkSubmitRunner.java ---
    @@ -0,0 +1,59 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.lang.reflect.InvocationTargetException;
    +import java.lang.reflect.Method;
    +import java.util.List;
    +
    +class SparkSubmitRunner implements Runnable {
    +  private Method main;
    +  private final List<String> args;
    +
    +  SparkSubmitRunner(Method main, List<String> args) {
    +    this.main = main;
    +    this.args = args;
    +  }
    +  /**
    --- End diff --
    
    add newline above javadoc


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    @vanzin @tgravescs,
    I removed `envvars` argument from SparkApp and all unwanted code along with it.
    It still provides autoShutdown in both Thread mode and process mode for yarn cluster mode Spark jobs. I tested all test scenarios mentioned at the top.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #74498 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74498/testReport)** for PR 15009 at commit [`a3d18b4`](https://github.com/apache/spark/commit/a3d18b4119f9a3aa4c018b5cc49bc0093e5008da).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100318015
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/package-info.java ---
    @@ -49,6 +49,38 @@
      * </pre>
      *
      * <p>
    + * Currently, for currently while launching spark application with
    --- End diff --
    
    have 2 currently in here, remove one


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #72475 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/72475/testReport)** for PR 15009 at commit [`4357107`](https://github.com/apache/spark/commit/43571078cd2912edb7dde07b318609b457769a39).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443] Stop Spark Application if launcher goes do...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Jenkins, test this please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #75056 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75056/testReport)** for PR 15009 at commit [`677edf7`](https://github.com/apache/spark/commit/677edf7f091beab92e1ca42d24a20ad4c5254002).
     * This patch **fails to build**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    @vanzin, 
    - I refactored unit tests
    - Changed LAUNCHER_INTERNAL* variable access to package private
    - Fixed some of the nits.
    
    About passing sys.env, we want to capture set of sys.env variables while launching the new SparkApp. In thread mode, the launching user code could change the sys.env variables after launching application. For instance even pollute env while launching another Spark app.  We made a lot of code changes to ensure this.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/74498/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78189182
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/ChildThreadAppHandle.java ---
    @@ -0,0 +1,54 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.util.logging.Logger;
    +
    +public class ChildThreadAppHandle extends AbstractSparkAppHandle {
    +  private static final Logger LOG = Logger.getLogger(ChildThreadAppHandle.class.getName());
    +  private Thread childThread;
    +
    +  public ChildThreadAppHandle(String secret, LauncherServer server) {
    +    super(server, secret);
    +  }
    +
    +  @Override
    +  public synchronized void  kill() {
    +    if (!disposed) {
    +      disconnect();
    +    }
    +    if (childThread!= null) {
    +      try {
    +        childThread.join(3000);
    +      } catch (IllegalThreadStateException | InterruptedException e) {
    +        try {
    +          childThread.interrupt();
    +        } catch (Exception inner) {
    +          LOG.info("Failed to stop Thread: "+ inner.getMessage());
    +        }
    +      } finally {
    +        childThread = null;
    +      }
    +    }
    +
    --- End diff --
    
    remove extra new line


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106234437
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -528,13 +579,42 @@ public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) thr
         pb.environment().put(LauncherProtocol.ENV_LAUNCHER_PORT,
           String.valueOf(LauncherServer.getServerInstance().getPort()));
         pb.environment().put(LauncherProtocol.ENV_LAUNCHER_SECRET, handle.getSecret());
    +    pb.environment().put(LauncherProtocol.ENV_LAUNCHER_STOP_IF_SHUTDOWN, String.valueOf(stopOnShutdown));
         try {
           handle.setChildProc(pb.start(), loggerName);
         } catch (IOException ioe) {
           handle.kill();
           throw ioe;
         }
    +    return handle;
    +  }
    +
    +  private SparkAppHandle startApplicationAsThread(SparkAppHandle.Listener... listeners) throws IOException {
    +    ChildThreadAppHandle handle = LauncherServer.newAppThreadHandle();
    +    for (SparkAppHandle.Listener l : listeners) {
    +      handle.addListener(l);
    +    }
     
    +    String appName = getAppName();
    +    setConf(LAUNCHER_INTERNAL_PORT, String.valueOf(LauncherServer.getServerInstance().getPort()));
    +    setConf(LAUNCHER_INTERNAL_CHILD_PROCESS_SECRET, handle.getSecret());
    +    setConf(LAUNCHER_INTERNAL_STOP_ON_SHUTDOWN, String.valueOf(stopOnShutdown));
    +    try {
    +      // It is important that SparkSubmit class is available in the classpath.
    +      // Trying to see if method is available in the classpath else throws Exception.
    +      Method main = SparkSubmitRunner.getSparkSubmitMain();
    +      Thread submitJobThread = new Thread(new SparkSubmitRunner(main, builder.buildSparkSubmitArgs()));
    +      submitJobThread.setName(appName);
    +      submitJobThread.setDaemon(true);
    +      handle.setChildThread(submitJobThread);
    +      submitJobThread.start();
    +    } catch (ClassNotFoundException cnfe) {
    +      throw new IOException("Please make sure the spark jar containing SparkSubmit is in the classpath.",
    --- End diff --
    
    nit: line > 100 chars


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Jenkins, test this please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78186862
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/ChildThreadAppHandle.java ---
    @@ -0,0 +1,54 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.util.logging.Logger;
    +
    +public class ChildThreadAppHandle extends AbstractSparkAppHandle {
    +  private static final Logger LOG = Logger.getLogger(ChildThreadAppHandle.class.getName());
    +  private Thread childThread;
    +
    +  public ChildThreadAppHandle(String secret, LauncherServer server) {
    +    super(server, secret);
    +  }
    +
    +  @Override
    +  public synchronized void  kill() {
    +    if (!disposed) {
    +      disconnect();
    +    }
    +    if (childThread!= null) {
    --- End diff --
    
    space before !=


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    @kishorvpatil  please fix documentation


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    +1


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100939063
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -479,7 +538,7 @@ public Process launch() throws IOException {
        * that happens after that cannot be monitored. If the underlying application is launched as
        * a child process, {@link SparkAppHandle#kill()} can still be used to kill the child process.
        * <p>
    -   * Currently, all applications are launched as child processes. The child's stdout and stderr
    +   * If the applications are launched as child processes. The child's stdout and stderr
    --- End diff --
    
    "...is launched as a child process, the child's..."


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106234262
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -528,13 +579,42 @@ public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) thr
         pb.environment().put(LauncherProtocol.ENV_LAUNCHER_PORT,
           String.valueOf(LauncherServer.getServerInstance().getPort()));
         pb.environment().put(LauncherProtocol.ENV_LAUNCHER_SECRET, handle.getSecret());
    +    pb.environment().put(LauncherProtocol.ENV_LAUNCHER_STOP_IF_SHUTDOWN, String.valueOf(stopOnShutdown));
    --- End diff --
    
    nit: line > 100 chars


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #78060 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/78060/testReport)** for PR 15009 at commit [`81fd297`](https://github.com/apache/spark/commit/81fd2974c3b6d7c11112021ae7ca5b8e4c6ee069).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/78060/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Jenkins, test this please



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r78386962
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -73,6 +74,21 @@
       /** Logger name to use when launching a child process. */
       public static final String CHILD_PROCESS_LOGGER_NAME = "spark.launcher.childProcLoggerName";
     
    +  /** Launcher Server Port to use when launching a child process. */
    +  public static final String LAUNCHER_INTERNAL_PORT = "spark.launcher.internal.port";
    +
    +  /** Launcher Server sets this when launching a child process. */
    +  public static final String CHILD_PROCESS_LAUNCHER_INTERNAL_SECRET = "spark.launcher.internal.secret";
    +
    +  /** Stop Flag if interrupted Launcher Server goes away. */
    --- End diff --
    
    actually to be more generic since different backends can handle differently maybe we say it sends the stop request


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r87463913
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -719,7 +721,27 @@ object SparkSubmit {
           printWarning("Subclasses of scala.App may not work correctly. Use a main() method instead.")
         }
     
    -    val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
    +    val isSparkApp = mainClass.getMethods().filter(_.getName() == "sparkMain").length > 0
    --- End diff --
    
    Can you use `classOf[SparkApp].isAssignableFrom(mainClass)` here? Or that doesn't work?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84785459
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -710,7 +723,11 @@ object SparkSubmit {
           printWarning("Subclasses of scala.App may not work correctly. Use a main() method instead.")
         }
     
    -    val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
    +    val mainMethod = if (threadEnabled ) {
    +      mainClass.getMethods().filter(i => i.getName() == "sparkMain")(0)
    +    } else {
    +      mainClass.getMethod("main", new Array[String](0).getClass)
    --- End diff --
    
    not your fault, but `classOf[Array[String]]`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100936310
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -71,6 +100,9 @@ private[spark] abstract class LauncherBackend {
         if (connection != null && lastState != state) {
           connection.send(new SetState(state))
           lastState = state
    +      if (!_isConnected && stopOnShutdown) {
    --- End diff --
    
    What happens with code like this:
    
    ```
    val handle = new SparkLauncher().blahBlahBlah().launchAsThread(true).startApplication()
    // do something, like wait for app to be running
    handle.disconnect()
    ```
    
    `_isConnected` will be false, and in that situation you do not want any call to `close()` here to shut down the running app, since that's not what the user asked for.
    



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84791332
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -56,23 +56,38 @@ import org.apache.spark.internal.config._
     import org.apache.spark.launcher.{LauncherBackend, SparkAppHandle, YarnCommandBuilderUtils}
     import org.apache.spark.util.Utils
     
    +
     private[spark] class Client(
         val args: ClientArguments,
         val hadoopConf: Configuration,
    -    val sparkConf: SparkConf)
    +    val sparkConf: SparkConf,
    +    val sysEnvironmentInput: Map[String, String])
       extends Logging {
     
       import Client._
       import YarnSparkHadoopUtil._
     
    +  def this(clientArgs: ClientArguments, spConf: SparkConf, sysEnv: Map[String, String]) =
    +    this(clientArgs, SparkHadoopUtil.get.newConfiguration(spConf), spConf, sysEnv)
    +
    +  def this(clientArgs: ClientArguments, hadoopConf: Configuration, spConf: SparkConf) =
    +    this(clientArgs, hadoopConf, spConf, Map() ++ sys.env)
    +
       def this(clientArgs: ClientArguments, spConf: SparkConf) =
    -    this(clientArgs, SparkHadoopUtil.get.newConfiguration(spConf), spConf)
    +    this(clientArgs, spConf, Map() ++ sys.env)
    +
    +  private val sysEnvironment: scala.collection.immutable.Map[scala.Predef.String,
    +   scala.Predef.String] = collection.immutable.Map() ++ sysEnvironmentInput
     
       private val yarnClient = YarnClient.createYarnClient
       private val yarnConf = new YarnConfiguration(hadoopConf)
     
       private val isClusterMode = sparkConf.get("spark.submit.deployMode", "client") == "cluster"
     
    +  private val launcherServerPort : Int = sparkConf.get("spark.launcher.internal.port", "0").toInt
    --- End diff --
    
    I think it might be worth it to have constants for these to avoid copy & pasting the name. See how `PYSPARK_DRIVER_PYTHON` is handled in `SparkLauncher` and  `core/src/main/scala/org/apache/spark/internal/config/package.scala` (and the unit test in `SparkLauncherSuite.java`).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100937832
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/LauncherServer.java ---
    @@ -157,9 +176,15 @@ public void run() {
        * Creates a new app handle. The handle will wait for an incoming connection for a configurable
        * amount of time, and if one doesn't arrive, it will transition to an error state.
        */
    -  ChildProcAppHandle newAppHandle(String secret) {
    -    ChildProcAppHandle handle = new ChildProcAppHandle(secret, this);
    -    ChildProcAppHandle existing = pending.putIfAbsent(secret, handle);
    +  AbstractSparkAppHandle newAppHandle(String secret, boolean isThreadHandle) {
    +
    --- End diff --
    
    nit: remove this empty line


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100937560
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/LauncherConnection.java ---
    @@ -106,5 +106,4 @@ public void close() throws IOException {
           }
         }
       }
    -
    --- End diff --
    
    nit: no need to change this file.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84788429
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/ChildThreadAppHandle.java ---
    @@ -0,0 +1,53 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.util.logging.Logger;
    +
    +public class ChildThreadAppHandle extends AbstractSparkAppHandle {
    +  private static final Logger LOG = Logger.getLogger(ChildThreadAppHandle.class.getName());
    +  private Thread childThread;
    --- End diff --
    
    nit: blank line between static and non-static.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/72723/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #74129 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74129/testReport)** for PR 15009 at commit [`99d8c29`](https://github.com/apache/spark/commit/99d8c29d2c337e84588e8b4951c404565838153b).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `abstract class AbstractSparkAppHandle implements SparkAppHandle `


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #74306 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74306/testReport)** for PR 15009 at commit [`b66243d`](https://github.com/apache/spark/commit/b66243dd0644b6c80cece4a9995f9fe256d6cb21).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r87465891
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -17,38 +17,67 @@
     
     package org.apache.spark.launcher
     
    +import java.io.IOException
     import java.net.{InetAddress, Socket}
     
     import org.apache.spark.SPARK_VERSION
    +import org.apache.spark.internal.Logging
     import org.apache.spark.launcher.LauncherProtocol._
    -import org.apache.spark.util.{ThreadUtils, Utils}
    +import org.apache.spark.util.{ShutdownHookManager, ThreadUtils, Utils}
     
     /**
      * A class that can be used to talk to a launcher server. Users should extend this class to
      * provide implementation for the abstract methods.
      *
      * See `LauncherServer` for an explanation of how launcher communication works.
      */
    -private[spark] abstract class LauncherBackend {
    +private[spark] abstract class LauncherBackend extends Logging {
     
       private var clientThread: Thread = _
       private var connection: BackendConnection = _
       private var lastState: SparkAppHandle.State = _
    +  private var stopOnShutdown: Boolean = false
       @volatile private var _isConnected = false
     
       def connect(): Unit = {
         val port = sys.env.get(LauncherProtocol.ENV_LAUNCHER_PORT).map(_.toInt)
         val secret = sys.env.get(LauncherProtocol.ENV_LAUNCHER_SECRET)
    +    val stopFlag = sys.env.get(LauncherProtocol.ENV_LAUNCHER_STOP_FLAG).map(_.toBoolean)
         if (port != None && secret != None) {
    -      val s = new Socket(InetAddress.getLoopbackAddress(), port.get)
    -      connection = new BackendConnection(s)
    -      connection.send(new Hello(secret.get, SPARK_VERSION))
    -      clientThread = LauncherBackend.threadFactory.newThread(connection)
    -      clientThread.start()
    -      _isConnected = true
    +      connect(port.get, secret.get, stopFlag.getOrElse(false))
         }
       }
     
    +  def connect(port: Int, secret: String): Unit = {
    +    val s = new Socket(InetAddress.getLoopbackAddress(), port)
    +    connection = new BackendConnection(s)
    +    connection.send(new Hello(secret, SPARK_VERSION))
    +    clientThread = LauncherBackend.threadFactory.newThread(connection)
    +    clientThread.start()
    +    _isConnected = true
    +    if (stopOnShutdown) {
    +      logDebug("Adding shutdown hook") // force eager creation of logger
    +      var _shutdownHookRef = ShutdownHookManager.addShutdownHook(
    +        ShutdownHookManager.SPARK_CONTEXT_SHUTDOWN_PRIORITY) { () =>
    +        logInfo("Invoking onStopRequest() from shutdown hook")
    +        try {
    +          if (_isConnected && stopOnShutdown) {
    +            onStopRequest()
    +          }
    +        }
    +        catch {
    +          case anotherIOE: IOException =>
    +            logError("Error while running LauncherBackend shutdownHook...", anotherIOE)
    +        }
    +      }
    +    }
    +  }
    +
    +  def connect(port: Int, secret: String, stopFlag: Boolean): Unit = {
    --- End diff --
    
    You haven't addressed my previous feedback here: https://github.com/apache/spark/pull/15009#discussion_r84786490


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #68286 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/68286/consoleFull)** for PR 15009 at commit [`64a21b3`](https://github.com/apache/spark/commit/64a21b3cc15bc1887e3d40d839bbeb1e105378c3).
     * This patch passes all tests.
     * This patch **does not merge cleanly**.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r105260515
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -719,7 +716,24 @@ object SparkSubmit extends CommandLineUtils {
           printWarning("Subclasses of scala.App may not work correctly. Use a main() method instead.")
         }
     
    -    val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
    +    val sparkAppMainMethodArr = mainClass.getMethods().filter(_.getName() == "sparkMain")
    +    val isSparkApp = sparkAppMainMethodArr.length > 0
    +
    +    val childSparkConf = sysProps.filter( p => p._1.startsWith("spark.")).toMap
    +
    +    // If running sparkApp or in thread mode, the System properties should not be cluttered.
    --- End diff --
    
    Also perhaps reword this a bit If running a SparkApp we can explicitly pass in the confs separately.  If we aren't running a SparkApp they get passed via the system properties.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75006/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/78058/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #78064 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/78064/testReport)** for PR 15009 at commit [`10513ec`](https://github.com/apache/spark/commit/10513ec4a1cee2de26104945dc2eae54efeed9d2).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r83277627
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---
    @@ -710,7 +724,12 @@ object SparkSubmit {
           printWarning("Subclasses of scala.App may not work correctly. Use a main() method instead.")
         }
     
    -    val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
    +    val mainMethod =
    +    if (threadEnabled ) {
    --- End diff --
    
    ...and indent this line. Or:
    
    ```
    val mainMethod = if (threadEnabled) {
      ...
    } else {
      ...
    }
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r81985259
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -1322,7 +1373,9 @@ private object Client extends Logging {
           conf: Configuration,
           sparkConf: SparkConf,
           env: HashMap[String, String],
    -      extraClassPath: Option[String] = None): Unit = {
    +      extraClassPath: Option[String] = None,
    +      providedEnv: scala.collection.immutable.Map[scala.Predef.String, scala.Predef.String]
    --- End diff --
    
    shorten scala.Prefdef.String to String


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106231404
  
    --- Diff: core/src/test/java/org/apache/spark/launcher/SparkLauncherSuite.java ---
    @@ -175,6 +175,37 @@ public void testChildProcLauncher() throws Exception {
           .setConf(SparkLauncher.DRIVER_EXTRA_CLASSPATH, System.getProperty("java.class.path"))
           .addSparkArg(opts.CLASS, "ShouldBeOverriddenBelow")
           .setMainClass(SparkLauncherTestApp.class.getName())
    +      .autoShutdown()
    +      .addAppArgs("proc");
    +    final Process app = launcher.launch();
    +
    +    new OutputRedirector(app.getInputStream(), TF);
    +    new OutputRedirector(app.getErrorStream(), TF);
    +    assertEquals(0, app.waitFor());
    +  }
    +
    +  @Test
    +  public void testThreadLauncher() throws Exception {
    +    // This test is failed on Windows due to the failure of initiating executors
    +    // by the path length limitation. See SPARK-18718.
    +    assumeTrue(!Utils.isWindows());
    +
    +    SparkSubmitOptionParser opts = new SparkSubmitOptionParser();
    +    Map<String, String> env = new HashMap<>();
    +    env.put("SPARK_PRINT_LAUNCH_COMMAND", "1");
    +
    +    launcher
    +      .setMaster("local")
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .addSparkArg(opts.CONF,
    +        String.format("%s=-Dfoo=ShouldBeOverriddenBelow", SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS))
    +      .setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS,
    +        "-Dfoo=bar -Dtest.appender=childproc")
    +      .setConf(SparkLauncher.DRIVER_EXTRA_CLASSPATH, System.getProperty("java.class.path"))
    +      .addSparkArg(opts.CLASS, "ShouldBeOverriddenBelow")
    --- End diff --
    
    You don't need this, already tested. Which means you can get rid of the `opts` variable.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/76691/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r82065162
  
    --- Diff: yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -59,20 +59,36 @@ import org.apache.spark.util.Utils
     private[spark] class Client(
         val args: ClientArguments,
         val hadoopConf: Configuration,
    -    val sparkConf: SparkConf)
    +    val sparkConf: SparkConf,
    +    val sysEnvironmentInput: Map[String, String])
       extends Logging {
     
       import Client._
       import YarnSparkHadoopUtil._
     
    +  def this(clientArgs: ClientArguments, spConf: SparkConf, sysenvironment: Map[String, String]) =
    +    this(clientArgs, SparkHadoopUtil.get.newConfiguration(spConf), spConf, sysenvironment)
    +
    +  def this(clientArgs: ClientArguments, hadoopConf: Configuration, spConf: SparkConf) =
    +    this(clientArgs, hadoopConf, spConf, Map() ++ sys.env)
    --- End diff --
    
    sys.env is already a Map, why do we need to Map() ++ ?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/74185/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r114173083
  
    --- Diff: resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnClusterSuite.scala ---
    @@ -201,6 +192,69 @@ class YarnClusterSuite extends BaseYarnClusterSuite {
         finalState should be (SparkAppHandle.State.FAILED)
       }
     
    +  test("monitor app running in thread using launcher library") {
    +    var handle : SparkAppHandle = null
    +    try {
    +      handle = launchSparkAppWithConf(true, false, "cluster")
    +      handle.stop()
    +
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.KILLED)
    +      }
    +    } finally {
    +      handle.kill()
    +    }
    +  }
    +
    +  test("monitor app using launcher library for proc with auto shutdown") {
    +    var handle : SparkAppHandle = null
    +    try {
    +      handle = launchSparkAppWithConf(false, true, "cluster")
    --- End diff --
    
    And here.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #74185 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74185/testReport)** for PR 15009 at commit [`b098ecd`](https://github.com/apache/spark/commit/b098ecd6e21b60ae3db13adc81d02522c2fa9391).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r100938862
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -107,6 +121,30 @@ public static void setConfig(String name, String value) {
         launcherConfig.put(name, value);
       }
     
    +  /**
    +   * Specifies that Spark Application be stopped if current process goes away.
    +   * It tries stop/kill Spark Application if {@link LauncherServer} goes away.
    +   *
    +   * @since 2.2.0
    +   * @return This launcher.
    +   */
    +  public SparkLauncher stopIfLauncherShutdown() {
    --- End diff --
    
    Same here; `stopOnShutdown` more closely matches the behavior, since the behavior is not based on the launcher, but the current app shutting down.
    
    Also, does this work at all for child processes? I don't think so. So the javadocs should at least say that.
    
    Following from my previous comments, I'm not even sure this option is necessary. When would you not want this when using child threads? The user can call `disconnect()` if he doesn't want the child app to fate-share with the launcher. That would simplify the API.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #74032 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74032/testReport)** for PR 15009 at commit [`82df055`](https://github.com/apache/spark/commit/82df055699b6d4010108e1bd41cb276e65657a00).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r108788237
  
    --- Diff: resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala ---
    @@ -55,17 +55,28 @@ import org.apache.spark.internal.config._
     import org.apache.spark.launcher.{LauncherBackend, SparkAppHandle, YarnCommandBuilderUtils}
     import org.apache.spark.util.{CallerContext, Utils}
     
    +
    --- End diff --
    
    nit: don't add this empty line


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/76274/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106049395
  
    --- Diff: resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnClusterSuite.scala ---
    @@ -252,20 +307,55 @@ class YarnClusterSuite extends BaseYarnClusterSuite {
           handle.getAppId() should startWith ("application_")
           handle.disconnect()
     
    +      var applicationId = ConverterUtils.toApplicationId(handle.getAppId)
    +      var yarnClient: YarnClient = getYarnClient
           eventually(timeout(30 seconds), interval(100 millis)) {
             handle.getState() should be (SparkAppHandle.State.LOST)
    +        var status = yarnClient.getApplicationReport(applicationId).getFinalApplicationStatus
    +        status should be (FinalApplicationStatus.KILLED)
           }
    +
         } finally {
           handle.kill()
         }
       }
     
    -  test("timeout to get SparkContext in cluster mode triggers failure") {
    -    val timeout = 2000
    -    val finalState = runSpark(false, mainClassName(SparkContextTimeoutApp.getClass),
    -      appArgs = Seq((timeout * 4).toString),
    -      extraConf = Map(AM_MAX_WAIT_TIME.key -> timeout.toString))
    -    finalState should be (SparkAppHandle.State.FAILED)
    +  test("monitor app using launcher library for thread without auto shutdown") {
    +    val env = new JHashMap[String, String]()
    +    env.put("YARN_CONF_DIR", hadoopConfDir.getAbsolutePath())
    +
    +    val propsFile = createConfFile()
    +    val handle = new SparkLauncher(env)
    +      .setSparkHome(sys.props("spark.test.home"))
    +      .setConf("spark.ui.enabled", "false")
    +      .setPropertiesFile(propsFile)
    +      .setMaster("yarn")
    +      .setDeployMode("cluster")
    +      .launchAsThread(true)
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setMainClass(mainClassName(YarnLauncherTestApp.getClass))
    +      .startApplication()
    +
    +    try {
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.RUNNING)
    +      }
    +
    +      handle.getAppId() should not be (null)
    +      handle.getAppId() should startWith ("application_")
    +      handle.disconnect()
    +
    +      var applicationId = ConverterUtils.toApplicationId(handle.getAppId)
    +      var yarnClient: YarnClient = getYarnClient
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.LOST)
    +        var status = yarnClient.getApplicationReport(applicationId).getYarnApplicationState
    +        status should not be (YarnApplicationState.KILLED)
    --- End diff --
    
    thi sis without auto shutdown so why is this killed ,it should still be running.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r101094707
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -107,6 +121,30 @@ public static void setConfig(String name, String value) {
         launcherConfig.put(name, value);
       }
     
    +  /**
    +   * Specifies that Spark Application be stopped if current process goes away.
    +   * It tries stop/kill Spark Application if {@link LauncherServer} goes away.
    +   *
    +   * @since 2.2.0
    +   * @return This launcher.
    +   */
    +  public SparkLauncher stopIfLauncherShutdown() {
    --- End diff --
    
    BTW, one thing you can do here is to change this to something like `autoShutdown`, which just means that the app will try to shut itself down if the parent process disconnects from the app. (So it's not just restricted to "shutdown", since a "disconnect" would also trigger it.)
    
    Then you can document in "disconnect()" that this option affects its behavior. Since this behavior is opt-in, it should be ok.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #74032 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74032/testReport)** for PR 15009 at commit [`82df055`](https://github.com/apache/spark/commit/82df055699b6d4010108e1bd41cb276e65657a00).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75584/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r105273069
  
    --- Diff: resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnClusterSuite.scala ---
    @@ -193,6 +193,74 @@ class YarnClusterSuite extends BaseYarnClusterSuite {
         }
       }
     
    +  test("monitor app using launcher library for thread") {
    +    val env = new JHashMap[String, String]()
    +    env.put("YARN_CONF_DIR", hadoopConfDir.getAbsolutePath())
    +
    +    val propsFile = createConfFile()
    +    val handle = new SparkLauncher(env)
    +      .setSparkHome(sys.props("spark.test.home"))
    +      .setConf("spark.ui.enabled", "false")
    +      .setPropertiesFile(propsFile)
    +      .setMaster("yarn")
    +      .setDeployMode("cluster")
    +      .launchAsThread(true)
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setMainClass(mainClassName(YarnLauncherTestApp.getClass))
    +      .startApplication()
    +
    +    try {
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.RUNNING)
    +      }
    +
    +      handle.getAppId() should not be (null)
    +      handle.getAppId() should startWith ("application_")
    +      handle.stop()
    +
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.KILLED)
    +      }
    +    } finally {
    +      handle.kill()
    +    }
    +  }
    +
    +  test("monitor app using launcher library for thread with auto shutdown") {
    +    val env = new JHashMap[String, String]()
    +    env.put("YARN_CONF_DIR", hadoopConfDir.getAbsolutePath())
    +
    +    val propsFile = createConfFile()
    +    val handle = new SparkLauncher(env)
    +      .setSparkHome(sys.props("spark.test.home"))
    +      .setConf("spark.ui.enabled", "false")
    +      .setPropertiesFile(propsFile)
    +      .setMaster("yarn")
    +      .setDeployMode("cluster")
    +      .launchAsThread(true)
    +      .autoShutdown()
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setMainClass(mainClassName(YarnLauncherTestApp.getClass))
    +      .startApplication()
    +
    +    try {
    +      eventually(timeout(30 seconds), interval(100 millis)) {
    +        handle.getState() should be (SparkAppHandle.State.RUNNING)
    +      }
    +
    +      handle.getAppId() should not be (null)
    +      handle.getAppId() should startWith ("application_")
    +      handle.disconnect()
    +
    --- End diff --
    
    remove extra newline


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r106235308
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/package-info.java ---
    @@ -49,6 +51,35 @@
      * </pre>
      *
      * <p>
    + * Here is example of launching application in thread mode for yarn cluster mode
    + * with the stop if launcher shutdown option enabled. Showing use case of both
    + * {@link org.apache.spark.launcher.SparkLauncher#stopOnShutdown} and
    --- End diff --
    
    Method is now called "autoShutdown".


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r84785866
  
    --- Diff: core/src/main/scala/org/apache/spark/launcher/LauncherBackend.scala ---
    @@ -17,38 +17,71 @@
     
     package org.apache.spark.launcher
     
    +import java.io.IOException
     import java.net.{InetAddress, Socket}
     
     import org.apache.spark.SPARK_VERSION
    +import org.apache.spark.internal.Logging
     import org.apache.spark.launcher.LauncherProtocol._
    -import org.apache.spark.util.{ThreadUtils, Utils}
    +import org.apache.spark.util.{ShutdownHookManager, ThreadUtils, Utils}
     
     /**
      * A class that can be used to talk to a launcher server. Users should extend this class to
      * provide implementation for the abstract methods.
      *
      * See `LauncherServer` for an explanation of how launcher communication works.
      */
    -private[spark] abstract class LauncherBackend {
    +private[spark] abstract class LauncherBackend extends Logging {
     
       private var clientThread: Thread = _
       private var connection: BackendConnection = _
       private var lastState: SparkAppHandle.State = _
    +  private var stopFlag: Boolean = false
    --- End diff --
    
    nit: type is not necessary. Also, not a big fan of the name of this variable, it should be more descriptive. Like `stopOnShutdown`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by tgravescs <gi...@git.apache.org>.
Github user tgravescs commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r101085524
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkSubmitRunner.java ---
    @@ -0,0 +1,65 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.launcher;
    +
    +import java.lang.reflect.InvocationTargetException;
    +import java.lang.reflect.Method;
    +import java.util.List;
    +
    +/**
    + * This class used to by {@link SparkLauncher#startApplicationAsThread(SparkAppHandle.Listener...)}
    + * <p>
    + * This class to start Spark applications programmatically as a Thread. This uses reflection and relies
    + * on the SparkSubmit main class being in the classpath.
    + * </p>
    + */
    +class SparkSubmitRunner implements Runnable {
    +  private Method main;
    +  private final List<String> args;
    +
    +  SparkSubmitRunner(Method main, List<String> args) {
    +    this.main = main;
    +    this.args = args;
    +  }
    +
    +  /**
    +   * It is important that spark-submit class is available in the classpath.
    --- End diff --
    
    probably just remove this line since line below says same thing


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r114172337
  
    --- Diff: launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
    @@ -459,6 +500,8 @@ public SparkLauncher redirectToLog(String loggerName) {
        * @return A process handle for the Spark app.
        */
       public Process launch() throws IOException {
    +    checkArgument(launchAsThread == false,
    +        "Use StartApplication method to launch application in a Thread");
    --- End diff --
    
    `startApplication` and `thread`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #76456 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76456/testReport)** for PR 15009 at commit [`f1b49d8`](https://github.com/apache/spark/commit/f1b49d8b7946edc484c6f20e6ed4ee26b7721e11).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #76691 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76691/testReport)** for PR 15009 at commit [`2996fb1`](https://github.com/apache/spark/commit/2996fb1960914bd63ec7eda0a99b53f26a3d1c22).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by kishorvpatil <gi...@git.apache.org>.
Github user kishorvpatil commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r122049171
  
    --- Diff: core/src/test/java/org/apache/spark/launcher/SparkLauncherSuite.java ---
    @@ -183,12 +185,38 @@ public void testChildProcLauncher() throws Exception {
         assertEquals(0, app.waitFor());
       }
     
    +  @Test
    +  public void testThreadLauncher() throws Exception {
    +    // This test is failed on Windows due to the failure of initiating executors
    +    // by the path length limitation. See SPARK-18718.
    +    assumeTrue(!Utils.isWindows());
    +
    +    launcher = new SparkLauncher();
    +    launcher
    +      .setMaster("local")
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS,
    +        "-Dfoo=bar -Dtest.appender=childproc")
    +      .setConf(SparkLauncher.DRIVER_EXTRA_CLASSPATH, System.getProperty("java.class.path"))
    +      .setMainClass(SparkLauncherTestApp.class.getName())
    +      .launchAsThread(true)
    +      .addAppArgs("thread");
    +    final SparkAppHandle app = launcher.startApplication();
    +    sleep(3000);
    +    AbstractSparkAppHandle handle = (AbstractSparkAppHandle)app;
    --- End diff --
    
    `waitFor` is a package private now. This method is added for unit test in `AbstractSparkAppHandle` not part of the interface `SparkAppHandle`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #78058 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/78058/testReport)** for PR 15009 at commit [`81fd297`](https://github.com/apache/spark/commit/81fd2974c3b6d7c11112021ae7ca5b8e4c6ee069).
     * This patch **fails RAT tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #76229 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/76229/testReport)** for PR 15009 at commit [`04e56fc`](https://github.com/apache/spark/commit/04e56fcd2cc62b4e651b1016300a9ca5704248c2).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #65395 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/65395/consoleFull)** for PR 15009 at commit [`57defa9`](https://github.com/apache/spark/commit/57defa950532c04420c6ae39ac680cdfa1bcaf13).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #15009: [SPARK-17443][SPARK-11035] Stop Spark Application...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15009#discussion_r119739122
  
    --- Diff: core/src/test/java/org/apache/spark/launcher/SparkLauncherSuite.java ---
    @@ -183,12 +185,38 @@ public void testChildProcLauncher() throws Exception {
         assertEquals(0, app.waitFor());
       }
     
    +  @Test
    +  public void testThreadLauncher() throws Exception {
    +    // This test is failed on Windows due to the failure of initiating executors
    +    // by the path length limitation. See SPARK-18718.
    +    assumeTrue(!Utils.isWindows());
    +
    +    launcher = new SparkLauncher();
    +    launcher
    +      .setMaster("local")
    +      .setAppResource(SparkLauncher.NO_RESOURCE)
    +      .setConf(SparkLauncher.DRIVER_EXTRA_JAVA_OPTIONS,
    +        "-Dfoo=bar -Dtest.appender=childproc")
    +      .setConf(SparkLauncher.DRIVER_EXTRA_CLASSPATH, System.getProperty("java.class.path"))
    +      .setMainClass(SparkLauncherTestApp.class.getName())
    +      .launchAsThread(true)
    +      .addAppArgs("thread");
    +    final SparkAppHandle app = launcher.startApplication();
    +    sleep(3000);
    +    AbstractSparkAppHandle handle = (AbstractSparkAppHandle)app;
    +    handle.waitFor();
    +  }
    +
       public static class SparkLauncherTestApp {
     
         public static void main(String[] args) throws Exception {
           assertEquals(1, args.length);
    -      assertEquals("proc", args[0]);
    -      assertEquals("bar", System.getProperty("foo"));
    +      if("proc".equalsIgnoreCase(args[0])) {
    --- End diff --
    
    missing space after `if`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #74579 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/74579/testReport)** for PR 15009 at commit [`c17f15f`](https://github.com/apache/spark/commit/c17f15f3994ba0cba4be63519f33ce4429adf489).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    retest this please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/76752/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #15009: [SPARK-17443][SPARK-11035] Stop Spark Application if lau...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/15009
  
    **[Test build #72723 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/72723/testReport)** for PR 15009 at commit [`cc2c0be`](https://github.com/apache/spark/commit/cc2c0be9aab069b827fc6d46fb8201a1902c87ba).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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