All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.spark.launcher.package-info Maven / Gradle / Ivy

The newest version!
/*
 * 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.
 */

/**
 * Library for launching Spark applications programmatically.
 *
 * 

* There are two ways to start applications with this library: as a child process, using * {@link org.apache.spark.launcher.SparkLauncher}, or in-process, using * {@link org.apache.spark.launcher.InProcessLauncher}. *

* *

* The {@link org.apache.spark.launcher.AbstractLauncher#startApplication( * org.apache.spark.launcher.SparkAppHandle.Listener...)} method can be used to start Spark and * provide a handle to monitor and control the running application: *

* *
 * {@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("local")
 *         .setConf(SparkLauncher.DRIVER_MEMORY, "2g")
 *         .startApplication();
 *       // Use handle API to monitor / control application.
 *     }
 *   }
 * }
 * 
* *

* Launching applications as a child process requires a full Spark installation. The installation * directory can be provided to the launcher explicitly in the launcher's configuration, or by * setting the SPARK_HOME environment variable. *

* *

* Launching applications in-process is only recommended in cluster mode, since Spark cannot run * multiple client-mode applications concurrently in the same process. The in-process launcher * requires the necessary Spark dependencies (such as spark-core and cluster manager-specific * modules) to be present in the caller thread's class loader. *

* *

* It's also possible to launch a raw child process, without the extra monitoring, using the * {@link org.apache.spark.launcher.SparkLauncher#launch()} method: *

* *
 * {@code
 *   import org.apache.spark.launcher.SparkLauncher;
 *
 *   public class MyLauncher {
 *     public static void main(String[] args) throws Exception {
 *       Process spark = new SparkLauncher()
 *         .setAppResource("/my/app.jar")
 *         .setMainClass("my.spark.app.Main")
 *         .setMaster("local")
 *         .setConf(SparkLauncher.DRIVER_MEMORY, "2g")
 *         .launch();
 *       spark.waitFor();
 *     }
 *   }
 * }
 * 
* *

This method requires the calling code to manually manage the child process, including its * output streams (to avoid possible deadlocks). It's recommended that * {@link org.apache.spark.launcher.SparkLauncher#startApplication( * org.apache.spark.launcher.SparkAppHandle.Listener...)} be used instead.

*/ package org.apache.spark.launcher;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy