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);
}
}
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);
}
Aggregations