Example usage for org.apache.spark.launcher SparkAppHandle stop

List of usage examples for org.apache.spark.launcher SparkAppHandle stop

Introduction

In this page you can find the example usage for org.apache.spark.launcher SparkAppHandle stop.

Prototype

void stop();

Source Link

Document

Asks the application to stop.

Usage

From source file:org.apache.hive.spark.client.SparkLauncherSparkClient.java

License:Apache License

@VisibleForTesting
static Future<Void> createSparkLauncherFuture(CountDownLatch shutdownLatch, SparkAppHandle sparkAppHandle,
        RpcServer rpcServer, String clientId) {
    // Monitor the countdown latch
    Callable<Void> runnable = () -> {
        try {//from ww w.  ja v a  2 s  . com
            shutdownLatch.await();
        } catch (InterruptedException e) {
            rpcServer.cancelClient(clientId, "Spark app launcher interrupted");
            sparkAppHandle.stop();
        }
        return null;
    };

    FutureTask<Void> futureTask = new FutureTask<>(runnable);

    Thread driverThread = new Thread(futureTask);
    driverThread.setDaemon(true);
    driverThread.setName("SparkLauncherMonitor");
    driverThread.start();

    return futureTask;
}