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