Search in sources :

Example 1 with CloseDurableCqFunction

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

the class DurableClientCommands method closeDurableCqs.

@CliCommand(value = CliStrings.CLOSE_DURABLE_CQS, help = CliStrings.CLOSE_DURABLE_CQS__HELP)
@CliMetaData(shellOnly = false)
@ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
public Result closeDurableCqs(@CliOption(key = CliStrings.CLOSE_DURABLE_CQS__DURABLE__CLIENT__ID, mandatory = true, help = CliStrings.CLOSE_DURABLE_CQS__DURABLE__CLIENT__ID__HELP) final String durableClientId, @CliOption(key = CliStrings.CLOSE_DURABLE_CQS__NAME, mandatory = true, help = CliStrings.CLOSE_DURABLE_CQS__NAME__HELP) final String cqName, @CliOption(key = CliStrings.CLOSE_DURABLE_CQS__MEMBER, mandatory = false, help = CliStrings.CLOSE_DURABLE_CQS__MEMBER__HELP, optionContext = ConverterHint.MEMBERIDNAME) final String[] memberNameOrId, @CliOption(key = CliStrings.CLOSE_DURABLE_CQS__GROUP, mandatory = false, help = CliStrings.CLOSE_DURABLE_CQS__GROUP__HELP, optionContext = ConverterHint.MEMBERGROUP) final String[] group) {
    Result result = null;
    try {
        Set<DistributedMember> targetMembers = CliUtil.findMembers(group, memberNameOrId);
        if (targetMembers.isEmpty()) {
            return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
        }
        String[] params = new String[2];
        params[0] = durableClientId;
        params[1] = cqName;
        final ResultCollector<?, ?> rc = CliUtil.executeFunction(new CloseDurableCqFunction(), params, targetMembers);
        final List<MemberResult> results = (List<MemberResult>) rc.getResult();
        String failureHeader = CliStrings.format(CliStrings.CLOSE_DURABLE_CQS__FAILURE__HEADER, cqName, durableClientId);
        String successHeader = CliStrings.format(CliStrings.CLOSE_DURABLE_CQS__SUCCESS, cqName, durableClientId);
        result = buildResult(results, successHeader, failureHeader);
    } catch (Exception e) {
        result = ResultBuilder.createGemFireErrorResult(e.getMessage());
    }
    return result;
}
Also used : CloseDurableCqFunction(org.apache.geode.management.internal.cli.functions.CloseDurableCqFunction) MemberResult(org.apache.geode.management.internal.cli.domain.MemberResult) DistributedMember(org.apache.geode.distributed.DistributedMember) LinkedList(java.util.LinkedList) List(java.util.List) CommandResultException(org.apache.geode.management.internal.cli.result.CommandResultException) SubscriptionQueueSizeResult(org.apache.geode.management.internal.cli.domain.SubscriptionQueueSizeResult) DurableCqNamesResult(org.apache.geode.management.internal.cli.domain.DurableCqNamesResult) Result(org.apache.geode.management.cli.Result) MemberResult(org.apache.geode.management.internal.cli.domain.MemberResult) CliCommand(org.springframework.shell.core.annotation.CliCommand) CliMetaData(org.apache.geode.management.cli.CliMetaData) ResourceOperation(org.apache.geode.management.internal.security.ResourceOperation)

Aggregations

LinkedList (java.util.LinkedList)1 List (java.util.List)1 DistributedMember (org.apache.geode.distributed.DistributedMember)1 CliMetaData (org.apache.geode.management.cli.CliMetaData)1 Result (org.apache.geode.management.cli.Result)1 DurableCqNamesResult (org.apache.geode.management.internal.cli.domain.DurableCqNamesResult)1 MemberResult (org.apache.geode.management.internal.cli.domain.MemberResult)1 SubscriptionQueueSizeResult (org.apache.geode.management.internal.cli.domain.SubscriptionQueueSizeResult)1 CloseDurableCqFunction (org.apache.geode.management.internal.cli.functions.CloseDurableCqFunction)1 CommandResultException (org.apache.geode.management.internal.cli.result.CommandResultException)1 ResourceOperation (org.apache.geode.management.internal.security.ResourceOperation)1 CliCommand (org.springframework.shell.core.annotation.CliCommand)1