{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/25303965","id":25303965,"diff_hunk":"@@ -0,0 +1,335 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements.  See the NOTICE file distributed with\n+ * this work for additional information regarding copyright ownership.\n+ * The ASF licenses this file to You under the Apache License, Version 2.0\n+ * (the \"License\"); you may not use this file except in compliance with\n+ * the License.  You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.apache.spark.launcher;\n+\n+import java.io.IOException;\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.Collections;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Properties;\n+\n+import static org.apache.spark.launcher.CommandBuilderUtils.*;\n+\n+/**\n+ * Special launcher for handling a CLI invocation of SparkSubmit.\n+ * <p/>\n+ * This launcher extends SparkLauncher to add command line parsing compatible with\n+ * SparkSubmit. It handles setting driver-side options and special parsing needed\n+ * for the different specialClasses.\n+ * <p/>\n+ * This class has also some special features to aid PySparkLauncher.\n+ */\n+class SparkSubmitCommandBuilder extends AbstractCommandBuilder {\n+\n+  /**\n+   * Name of the app resource used to identify the PySpark shell. The command line parser expects\n+   * the resource name to be the very first argument to spark-submit in this case.\n+   *\n+   * NOTE: this cannot be \"pyspark-shell\" since that identifies the PySpark shell to SparkSubmit\n+   * (see java_gateway.py), and can cause this code to enter into an infinite loop.\n+   */\n+  static final String PYSPARK_SHELL = \"pyspark-shell-main\";","path":"launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java","position":49,"original_position":49,"commit_id":"c12d84bdf6b62ac5281833c6ce46ef867e34ce04","original_commit_id":"e2d4d717cee78de21aa9bdb60d524bbfd3aeb5fa","user":{"login":"andrewor14","id":2133137,"avatar_url":"https://avatars.githubusercontent.com/u/2133137?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewor14","html_url":"https://github.com/andrewor14","followers_url":"https://api.github.com/users/andrewor14/followers","following_url":"https://api.github.com/users/andrewor14/following{/other_user}","gists_url":"https://api.github.com/users/andrewor14/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewor14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewor14/subscriptions","organizations_url":"https://api.github.com/users/andrewor14/orgs","repos_url":"https://api.github.com/users/andrewor14/repos","events_url":"https://api.github.com/users/andrewor14/events{/privacy}","received_events_url":"https://api.github.com/users/andrewor14/received_events","type":"User","site_admin":false},"body":"in `bin/pyspark`, why not just run `python` directly as before, instead of launching a JVM to compile the python command and dealing with all the escaping, just for BASH to launch the python command again? Then you won't need this extra `pyspark-shell-main` to avoid an infinite loop. Is there a particular motivation for restructuring the `pyspark` script this way? Does it have something to do with children processes not exiting properly if the parent dies?","created_at":"2015-02-24T23:20:32Z","updated_at":"2015-02-24T23:20:32Z","html_url":"https://github.com/apache/spark/pull/3916#discussion_r25303965","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/3916","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/25303965"},"html":{"href":"https://github.com/apache/spark/pull/3916#discussion_r25303965"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/3916"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/3916","id":26924003,"html_url":"https://github.com/apache/spark/pull/3916","diff_url":"https://github.com/apache/spark/pull/3916.diff","patch_url":"https://github.com/apache/spark/pull/3916.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/3916","number":3916,"state":"open","locked":false,"title":"[SPARK-4924] Add a library for launching Spark jobs programmatically.","user":{"login":"vanzin","id":1694083,"avatar_url":"https://avatars.githubusercontent.com/u/1694083?v=3","gravatar_id":"","url":"https://api.github.com/users/vanzin","html_url":"https://github.com/vanzin","followers_url":"https://api.github.com/users/vanzin/followers","following_url":"https://api.github.com/users/vanzin/following{/other_user}","gists_url":"https://api.github.com/users/vanzin/gists{/gist_id}","starred_url":"https://api.github.com/users/vanzin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanzin/subscriptions","organizations_url":"https://api.github.com/users/vanzin/orgs","repos_url":"https://api.github.com/users/vanzin/repos","events_url":"https://api.github.com/users/vanzin/events{/privacy}","received_events_url":"https://api.github.com/users/vanzin/received_events","type":"User","site_admin":false},"body":"This change encapsulates all the logic involved in launching a Spark job\r\ninto a small Java library that can be easily embedded into other applications.\r\n\r\nThe overall goal of this change is twofold, as described in the bug:\r\n\r\n- Provide a public API for launching Spark processes. This is a common request\r\n  from users and currently there's no good answer for it.\r\n\r\n- Remove a lot of the duplicated code and other coupling that exists in the\r\n  different parts of Spark that deal with launching processes.\r\n\r\nA lot of the duplication was due to different code needed to build an\r\napplication's classpath (and the bootstrapper needed to run the driver in\r\ncertain situations), and also different code needed to parse spark-submit\r\ncommand line options in different contexts. The change centralizes those\r\nas much as possible so that all code paths can rely on the library for\r\nhandling those appropriately.\r\n","created_at":"2015-01-06T22:40:31Z","updated_at":"2015-02-24T23:20:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6cf4b734f82eadb97f2eecae6d26f08fe7c77ec1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/3916/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/3916/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/3916/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/c12d84bdf6b62ac5281833c6ce46ef867e34ce04","head":{"label":"vanzin:SPARK-4924","ref":"SPARK-4924","sha":"c12d84bdf6b62ac5281833c6ce46ef867e34ce04","user":{"login":"vanzin","id":1694083,"avatar_url":"https://avatars.githubusercontent.com/u/1694083?v=3","gravatar_id":"","url":"https://api.github.com/users/vanzin","html_url":"https://github.com/vanzin","followers_url":"https://api.github.com/users/vanzin/followers","following_url":"https://api.github.com/users/vanzin/following{/other_user}","gists_url":"https://api.github.com/users/vanzin/gists{/gist_id}","starred_url":"https://api.github.com/users/vanzin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanzin/subscriptions","organizations_url":"https://api.github.com/users/vanzin/orgs","repos_url":"https://api.github.com/users/vanzin/repos","events_url":"https://api.github.com/users/vanzin/events{/privacy}","received_events_url":"https://api.github.com/users/vanzin/received_events","type":"User","site_admin":false},"repo":{"id":18302272,"name":"spark","full_name":"vanzin/spark","owner":{"login":"vanzin","id":1694083,"avatar_url":"https://avatars.githubusercontent.com/u/1694083?v=3","gravatar_id":"","url":"https://api.github.com/users/vanzin","html_url":"https://github.com/vanzin","followers_url":"https://api.github.com/users/vanzin/followers","following_url":"https://api.github.com/users/vanzin/following{/other_user}","gists_url":"https://api.github.com/users/vanzin/gists{/gist_id}","starred_url":"https://api.github.com/users/vanzin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanzin/subscriptions","organizations_url":"https://api.github.com/users/vanzin/orgs","repos_url":"https://api.github.com/users/vanzin/repos","events_url":"https://api.github.com/users/vanzin/events{/privacy}","received_events_url":"https://api.github.com/users/vanzin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vanzin/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/vanzin/spark","forks_url":"https://api.github.com/repos/vanzin/spark/forks","keys_url":"https://api.github.com/repos/vanzin/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vanzin/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vanzin/spark/teams","hooks_url":"https://api.github.com/repos/vanzin/spark/hooks","issue_events_url":"https://api.github.com/repos/vanzin/spark/issues/events{/number}","events_url":"https://api.github.com/repos/vanzin/spark/events","assignees_url":"https://api.github.com/repos/vanzin/spark/assignees{/user}","branches_url":"https://api.github.com/repos/vanzin/spark/branches{/branch}","tags_url":"https://api.github.com/repos/vanzin/spark/tags","blobs_url":"https://api.github.com/repos/vanzin/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vanzin/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vanzin/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/vanzin/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vanzin/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/vanzin/spark/languages","stargazers_url":"https://api.github.com/repos/vanzin/spark/stargazers","contributors_url":"https://api.github.com/repos/vanzin/spark/contributors","subscribers_url":"https://api.github.com/repos/vanzin/spark/subscribers","subscription_url":"https://api.github.com/repos/vanzin/spark/subscription","commits_url":"https://api.github.com/repos/vanzin/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/vanzin/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/vanzin/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/vanzin/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/vanzin/spark/contents/{+path}","compare_url":"https://api.github.com/repos/vanzin/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vanzin/spark/merges","archive_url":"https://api.github.com/repos/vanzin/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vanzin/spark/downloads","issues_url":"https://api.github.com/repos/vanzin/spark/issues{/number}","pulls_url":"https://api.github.com/repos/vanzin/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/vanzin/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/vanzin/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vanzin/spark/labels{/name}","releases_url":"https://api.github.com/repos/vanzin/spark/releases{/id}","created_at":"2014-03-31T17:49:25Z","updated_at":"2014-06-25T00:58:09Z","pushed_at":"2015-02-24T21:36:35Z","git_url":"git://github.com/vanzin/spark.git","ssh_url":"git@github.com:vanzin/spark.git","clone_url":"https://github.com/vanzin/spark.git","svn_url":"https://github.com/vanzin/spark","homepage":null,"size":90265,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"90095bf3ce9304d09a32ceffaa99069079071b59","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-02-24T23:13:47Z","pushed_at":"2015-02-24T23:13:47Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":1325188,"stargazers_count":2983,"watchers_count":2983,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2591,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":256,"forks":2591,"open_issues":256,"watchers":2983,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/3916"},"html":{"href":"https://github.com/apache/spark/pull/3916"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/3916"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/3916/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/3916/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/3916/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/c12d84bdf6b62ac5281833c6ce46ef867e34ce04"}}}}