Search in sources :

Example 1 with GarbageCollectionFunction

use of org.apache.geode.management.internal.cli.functions.GarbageCollectionFunction in project geode by apache.

the class MiscellaneousCommands method executeAndBuildResult.

Result executeAndBuildResult(TabularResultData resultTable, Set<DistributedMember> dsMembers) {
    try {
        List<?> resultList = null;
        Function garbageCollectionFunction = new GarbageCollectionFunction();
        resultList = (List<?>) CliUtil.executeFunction(garbageCollectionFunction, null, dsMembers).getResult();
        for (int i = 0; i < resultList.size(); i++) {
            Object object = resultList.get(i);
            if (object instanceof Exception) {
                LogWrapper.getInstance().fine("Exception in GC " + ((Throwable) object).getMessage(), ((Throwable) object));
                continue;
            } else if (object instanceof Throwable) {
                LogWrapper.getInstance().fine("Exception in GC " + ((Throwable) object).getMessage(), ((Throwable) object));
                continue;
            }
            if (object != null) {
                if (object instanceof String) {
                    // unexpected exception string - cache may be closed or something
                    return ResultBuilder.createUserErrorResult((String) object);
                } else {
                    Map<String, String> resultMap = (Map<String, String>) object;
                    toTabularResultData(resultTable, (String) resultMap.get("MemberId"), (String) resultMap.get("HeapSizeBeforeGC"), (String) resultMap.get("HeapSizeAfterGC"), (String) resultMap.get("TimeSpentInGC"));
                }
            } else {
                LogWrapper.getInstance().fine("ResultMap was null ");
            }
        }
    } catch (Exception e) {
        String stack = CliUtil.stackTraceAsString(e);
        LogWrapper.getInstance().info("GC exception is " + stack);
        return ResultBuilder.createGemFireErrorResult(e.getMessage() + ": " + stack);
    }
    return ResultBuilder.buildResult(resultTable);
}
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) GarbageCollectionFunction(org.apache.geode.management.internal.cli.functions.GarbageCollectionFunction) Map(java.util.Map) HashMap(java.util.HashMap) ConverterHint(org.apache.geode.management.cli.ConverterHint) TimeoutException(java.util.concurrent.TimeoutException) CommandResultException(org.apache.geode.management.internal.cli.result.CommandResultException) ResultDataException(org.apache.geode.management.internal.cli.result.ResultDataException) FunctionException(org.apache.geode.cache.execute.FunctionException) DataFormatException(java.util.zip.DataFormatException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 DataFormatException (java.util.zip.DataFormatException)1 Function (org.apache.geode.cache.execute.Function)1 FunctionException (org.apache.geode.cache.execute.FunctionException)1 ConverterHint (org.apache.geode.management.cli.ConverterHint)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 CommandResultException (org.apache.geode.management.internal.cli.result.CommandResultException)1 ResultDataException (org.apache.geode.management.internal.cli.result.ResultDataException)1