use of org.apache.geode.management.internal.cli.functions.GatewaySenderDestroyFunctionArgs in project geode by apache.
the class WanCommands method destroyGatewaySender.
@CliCommand(value = CliStrings.DESTROY_GATEWAYSENDER, help = CliStrings.DESTROY_GATEWAYSENDER__HELP)
@CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
@ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
public Result destroyGatewaySender(@CliOption(key = CliStrings.DESTROY_GATEWAYSENDER__GROUP, optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.DESTROY_GATEWAYSENDER__GROUP__HELP) String[] onGroups, @CliOption(key = CliStrings.DESTROY_GATEWAYSENDER__MEMBER, optionContext = ConverterHint.MEMBERIDNAME, unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, help = CliStrings.DESTROY_GATEWAYSENDER__MEMBER__HELP) String[] onMember, @CliOption(key = CliStrings.DESTROY_GATEWAYSENDER__ID, mandatory = true, optionContext = ConverterHint.GATEWAY_SENDER_ID, help = CliStrings.DESTROY_GATEWAYSENDER__ID__HELP) String id) {
Result result = null;
try {
GatewaySenderDestroyFunctionArgs gatewaySenderDestroyFunctionArgs = new GatewaySenderDestroyFunctionArgs(id);
Set<DistributedMember> membersToDestroyGatewaySenderOn = CliUtil.findMembers(onGroups, onMember);
if (membersToDestroyGatewaySenderOn.isEmpty()) {
return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
}
ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(GatewaySenderDestroyFunction.INSTANCE, gatewaySenderDestroyFunctionArgs, membersToDestroyGatewaySenderOn);
@SuppressWarnings("unchecked") List<CliFunctionResult> gatewaySenderDestroyResults = (List<CliFunctionResult>) resultCollector.getResult();
TabularResultData tabularResultData = ResultBuilder.createTabularResultData();
final String errorPrefix = "ERROR: ";
for (CliFunctionResult gatewaySenderDestroyResult : gatewaySenderDestroyResults) {
boolean success = gatewaySenderDestroyResult.isSuccessful();
tabularResultData.accumulate("Member", gatewaySenderDestroyResult.getMemberIdOrName());
tabularResultData.accumulate("Status", (success ? "" : errorPrefix) + gatewaySenderDestroyResult.getMessage());
}
result = ResultBuilder.buildResult(tabularResultData);
} catch (IllegalArgumentException e) {
LogWrapper.getInstance().info(e.getMessage());
result = ResultBuilder.createUserErrorResult(e.getMessage());
}
return result;
}
Aggregations