use of org.apache.geode.management.internal.cli.functions.ListAsyncEventQueuesFunction in project geode by apache.
the class QueueCommands method listAsyncEventQueues.
@CliCommand(value = CliStrings.LIST_ASYNC_EVENT_QUEUES, help = CliStrings.LIST_ASYNC_EVENT_QUEUES__HELP)
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public Result listAsyncEventQueues() {
try {
TabularResultData tabularData = ResultBuilder.createTabularResultData();
boolean accumulatedData = false;
Set<DistributedMember> targetMembers = CliUtil.findMembers(null, null);
if (targetMembers.isEmpty()) {
return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
}
ResultCollector<?, ?> rc = CliUtil.executeFunction(new ListAsyncEventQueuesFunction(), new Object[] {}, targetMembers);
List<CliFunctionResult> results = CliFunctionResult.cleanResults((List<?>) rc.getResult());
for (CliFunctionResult result : results) {
if (result.getThrowable() != null) {
tabularData.accumulate("Member", result.getMemberIdOrName());
tabularData.accumulate("Result", "ERROR: " + result.getThrowable().getClass().getName() + ": " + result.getThrowable().getMessage());
accumulatedData = true;
tabularData.setStatus(Status.ERROR);
} else {
AsyncEventQueueDetails[] details = (AsyncEventQueueDetails[]) result.getSerializables();
for (int i = 0; i < details.length; i++) {
tabularData.accumulate("Member", result.getMemberIdOrName());
tabularData.accumulate("ID", details[i].getId());
tabularData.accumulate("Batch Size", details[i].getBatchSize());
tabularData.accumulate("Persistent", details[i].isPersistent());
tabularData.accumulate("Disk Store", details[i].getDiskStoreName());
tabularData.accumulate("Max Memory", details[i].getMaxQueueMemory());
Properties listenerProperties = details[i].getListenerProperties();
if (listenerProperties == null || listenerProperties.size() == 0) {
tabularData.accumulate("Listener", details[i].getListener());
} else {
StringBuilder propsStringBuilder = new StringBuilder();
propsStringBuilder.append('(');
boolean firstProperty = true;
for (Map.Entry<Object, Object> property : listenerProperties.entrySet()) {
if (!firstProperty) {
propsStringBuilder.append(',');
} else {
firstProperty = false;
}
propsStringBuilder.append(property.getKey()).append('=').append(property.getValue());
}
propsStringBuilder.append(')');
tabularData.accumulate("Listener", details[i].getListener() + propsStringBuilder.toString());
}
accumulatedData = true;
}
}
}
if (!accumulatedData) {
return ResultBuilder.createInfoResult(CliStrings.LIST_ASYNC_EVENT_QUEUES__NO_QUEUES_FOUND_MESSAGE);
}
return ResultBuilder.buildResult(tabularData);
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
throw e;
} catch (Throwable th) {
SystemFailure.checkFailure();
return ResultBuilder.createGemFireErrorResult(CliStrings.format(CliStrings.LIST_ASYNC_EVENT_QUEUES__ERROR_WHILE_LISTING_REASON_0, new Object[] { th.getMessage() }));
}
}
Aggregations