Search in sources :

Example 1 with ShutDownFunction

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();
    }
}
Also used : ChangeLogLevelFunction(org.apache.geode.management.internal.cli.functions.ChangeLogLevelFunction) Function(org.apache.geode.cache.execute.Function) NetstatFunction(org.apache.geode.management.internal.cli.functions.NetstatFunction) ShutDownFunction(org.apache.geode.management.internal.cli.functions.ShutDownFunction) GarbageCollectionFunction(org.apache.geode.management.internal.cli.functions.GarbageCollectionFunction) GetStackTracesFunction(org.apache.geode.management.internal.cli.functions.GetStackTracesFunction) Execution(org.apache.geode.cache.execute.Execution) ShutDownFunction(org.apache.geode.management.internal.cli.functions.ShutDownFunction) ExecutorService(java.util.concurrent.ExecutorService) FunctionException(org.apache.geode.cache.execute.FunctionException) ExecutionException(java.util.concurrent.ExecutionException) Callable(java.util.concurrent.Callable) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

Callable (java.util.concurrent.Callable)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 TimeoutException (java.util.concurrent.TimeoutException)1 Execution (org.apache.geode.cache.execute.Execution)1 Function (org.apache.geode.cache.execute.Function)1 FunctionException (org.apache.geode.cache.execute.FunctionException)1 ChangeLogLevelFunction (org.apache.geode.management.internal.cli.functions.ChangeLogLevelFunction)1 GarbageCollectionFunction (org.apache.geode.management.internal.cli.functions.GarbageCollectionFunction)1 GetStackTracesFunction (org.apache.geode.management.internal.cli.functions.GetStackTracesFunction)1 NetstatFunction (org.apache.geode.management.internal.cli.functions.NetstatFunction)1 ShutDownFunction (org.apache.geode.management.internal.cli.functions.ShutDownFunction)1