Example usage for org.apache.hadoop.util ExitUtil halt

List of usage examples for org.apache.hadoop.util ExitUtil halt

Introduction

In this page you can find the example usage for org.apache.hadoop.util ExitUtil halt.

Prototype

public static void halt(int status, String message) throws HaltException 

Source Link

Document

Forcibly terminates the currently running Java virtual machine.

Usage

From source file:org.apache.slider.core.main.ServiceLauncher.java

License:Apache License

/**
 * The service has been interrupted -try to shut down the service.
 * Give the service time to do this before the exit operation is called 
 * @param interruptData the interrupted data.
 *//*from  w w  w . j  a  v a 2 s  .co m*/
@Override
public void interrupted(IrqHandler.InterruptData interruptData) {
    String message = "Service interrupted by " + interruptData.toString();
    warn(message);
    if (!signalAlreadyReceived.compareAndSet(false, true)) {
        warn("Repeated interrupt: escalating to a JVM halt");
        // signal already received. On a second request to a hard JVM
        // halt and so bypass any blocking shutdown hooks.
        ExitUtil.halt(EXIT_INTERRUPTED, message);
    }
    int shutdownTimeMillis = SHUTDOWN_TIME_ON_INTERRUPT;
    //start an async shutdown thread with a timeout
    ServiceForcedShutdown forcedShutdown = new ServiceForcedShutdown(shutdownTimeMillis);
    Thread thread = new Thread(forcedShutdown);
    thread.setDaemon(true);
    thread.start();
    //wait for that thread to finish
    try {
        thread.join(shutdownTimeMillis);
    } catch (InterruptedException ignored) {
        //ignored
    }
    if (!forcedShutdown.isServiceStopped()) {
        warn("Service did not shut down in time");
    }
    exit(EXIT_INTERRUPTED, message);
}

From source file:org.apache.slider.server.appmaster.actions.ActionHalt.java

License:Apache License

@Override
public void execute(SliderAppMaster appMaster, QueueAccess queueService, AppState appState) throws Exception {
    ExitUtil.halt(status, text);
}