use of org.apache.geode.management.internal.cli.functions.ShutDownFunction in project geode by apache.
the class MiscellaneousCommands method shutdownNode.
public void shutdownNode(final long timeout, final Set<DistributedMember> includeMembers) throws TimeoutException, InterruptedException, ExecutionException {
ExecutorService exec = Executors.newSingleThreadExecutor();
try {
final Function shutDownFunction = new ShutDownFunction();
logger.info("Gfsh executing shutdown on members " + includeMembers);
Callable<String> shutdownNodes = new Callable<String>() {
@Override
public String call() {
try {
Execution execution = FunctionService.onMembers(includeMembers);
execution.execute(shutDownFunction);
} catch (FunctionException functionEx) {
// Expected Exception as the function is shutting down the target members and the result
// collector will get member departed exception
}
return "SUCCESS";
}
};
Future<String> result = exec.submit(shutdownNodes);
result.get(timeout, TimeUnit.MILLISECONDS);
} catch (TimeoutException te) {
logger.error("TimeoutException in shutting down members." + includeMembers);
throw te;
} catch (InterruptedException e) {
logger.error("InterruptedException in shutting down members." + includeMembers);
throw e;
} catch (ExecutionException e) {
logger.error("ExecutionException in shutting down members." + includeMembers);
throw e;
} finally {
exec.shutdownNow();
}
}
Aggregations