Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/1845#discussion_r16397299
--- Diff:
core/src/main/scala/org/apache/spark/deploy/SparkClassLauncher.scala ---
@@ -0,0 +1,116 @@
+/*
+ * 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.deploy
+
+import java.io.File
+
+import scala.collection.JavaConversions._
+
+import org.apache.spark.util.{RedirectThread, Utils}
+
+/**
+ * Wrapper of `bin/spark-class` that prepares the launch environment of
the child JVM properly.
+ * This is currently only used for running Spark submit in client mode.
The goal moving forward
+ * is to use this class for all use cases of `bin/spark-class`.
+ */
+object SparkClassLauncher {
+
+ /**
+ * Launch a Spark class with the given class paths, library paths, java
options and memory.
+ * If we are launching an application through Spark submit in client
mode, we must also
+ * take into account special `spark.driver.*` properties needed to start
the driver JVM.
+ */
+ def main(args: Array[String]): Unit = {
+ if (args.size < 8) {
+ System.err.println(
+ """
+ |Usage: org.apache.spark.deploy.SparkClassLauncher
+ |
+ | [properties file] - path to your Spark properties file
+ | [java runner] - command to launch the child JVM
+ | [java class paths] - class paths to pass to the child JVM
+ | [java library paths] - library paths to pass to the child JVM
+ | [java opts] - java options to pass to the child JVM
+ | [java memory] - memory used to launch the child JVM
+ | [client mode] - whether the child JVM will run the
Spark driver
+ | [main class] - main class to run in the child JVM
+ | <main args> - arguments passed to this main class
+ |
+ |Example:
+ | org.apache.spark.deploy.SparkClassLauncher.SparkClassLauncher
+ | conf/spark-defaults.conf java /classpath1:/classpath2
/librarypath1:/librarypath2
+ | "-XX:-UseParallelGC -Dsome=property" 5g true
org.apache.spark.deploy.SparkSubmit
+ | --master local --class org.apache.spark.examples.SparkPi 10
+ """.stripMargin)
+ System.exit(1)
+ }
+ val propertiesFile = args(0)
+ val javaRunner = args(1)
+ val clClassPaths = args(2)
+ val clLibraryPaths = args(3)
+ val clJavaOpts = Utils.splitCommandString(args(4))
+ val clJavaMemory = args(5)
+ val clientMode = args(6) == "true"
--- End diff --
This is anticipating the future where all usages of `bin/spark-class` are
routed through this class. I was hesitant on removing this because it would
technically break backward compatibility if we decide to add a new flag in the
future, since this is not `private[spark]` or anything. Should I just add a
warning saying this should be called only from `bin/spark-class` instead?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]