Search in sources :

Example 1 with ShutdownRun

use of org.apache.hyracks.control.common.shutdown.ShutdownRun in project asterixdb by apache.

the class ClusterShutdownWork method doRun.

@Override
public void doRun() {
    try {
        if (ccs.getShutdownRun() != null) {
            throw new IPCException("Shutdown already in progress");
        }
        INodeManager nodeManager = ccs.getNodeManager();
        Collection<String> nodeIds = nodeManager.getAllNodeIds();
        /**
             * set up our listener for the node ACKs
             */
        final ShutdownRun shutdownStatus = new ShutdownRun(nodeIds);
        // set up the CC to listen for it
        ccs.setShutdownRun(shutdownStatus);
        /**
             * Shutdown all the nodes...
             */
        nodeManager.apply(this::shutdownNode);
        ccs.getExecutor().execute(new Runnable() {

            @Override
            public void run() {
                try {
                    /*
                         * wait for all our acks
                         */
                    LOGGER.info("Waiting for NCs to shutdown...");
                    boolean cleanShutdown = shutdownStatus.waitForCompletion();
                    if (!cleanShutdown) {
                        /*
                             * best effort - just exit, user will have to kill misbehaving NCs
                             */
                        LOGGER.severe("Clean shutdown of NCs timed out- giving up; unresponsive nodes: " + shutdownStatus.getRemainingNodes());
                    }
                    callback.setValue(cleanShutdown);
                    ccs.stop(terminateNCService);
                    LOGGER.info("JVM Exiting.. Bye!");
                    Runtime rt = Runtime.getRuntime();
                    rt.exit(cleanShutdown ? 0 : 1);
                } catch (Exception e) {
                    callback.setException(e);
                }
            }
        });
    } catch (Exception e) {
        callback.setException(e);
    }
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) ShutdownRun(org.apache.hyracks.control.common.shutdown.ShutdownRun) IPCException(org.apache.hyracks.ipc.exceptions.IPCException) IPCException(org.apache.hyracks.ipc.exceptions.IPCException)

Example 2 with ShutdownRun

use of org.apache.hyracks.control.common.shutdown.ShutdownRun in project asterixdb by apache.

the class NotifyShutdownWork method doRun.

@Override
public void doRun() {
    // Triggered remotely by a NC to notify that the NC is shutting down.
    ShutdownRun sRun = ccs.getShutdownRun();
    LOGGER.info("Received shutdown acknowledgement from NC ID:" + nodeId);
    sRun.notifyShutdown(nodeId);
}
Also used : ShutdownRun(org.apache.hyracks.control.common.shutdown.ShutdownRun)

Aggregations

ShutdownRun (org.apache.hyracks.control.common.shutdown.ShutdownRun)2 INodeManager (org.apache.hyracks.control.cc.cluster.INodeManager)1 IPCException (org.apache.hyracks.ipc.exceptions.IPCException)1