Search in sources :

Example 6 with MemberResult

use of org.apache.geode.management.internal.cli.domain.MemberResult in project geode by apache.

the class DurableClientCommands method buildTableResultForQueueSize.

private Result buildTableResultForQueueSize(List<SubscriptionQueueSizeResult> results, String queueSizeColumnName) {
    Result result = null;
    boolean failure = true;
    Map<String, List<String>> failureMap = new HashMap<String, List<String>>();
    Map<String, Long> memberQueueSizeTable = new TreeMap<String, Long>();
    /***
     * Aggregate the results from the members
     */
    for (SubscriptionQueueSizeResult memberResult : results) {
        if (memberResult.isSuccessful()) {
            failure = false;
            memberResult.getSubscriptionQueueSize();
            memberQueueSizeTable.put(memberResult.getMemberNameOrId(), memberResult.getSubscriptionQueueSize());
        } else {
            groupByMessage(memberResult.getErrorMessage(), memberResult.getMemberNameOrId(), failureMap);
        }
    }
    if (!failure) {
        TabularResultData table = ResultBuilder.createTabularResultData();
        Set<String> members = memberQueueSizeTable.keySet();
        for (String member : members) {
            long queueSize = memberQueueSizeTable.get(member);
            table.accumulate(CliStrings.COUNT_DURABLE_CQ_EVENTS__MEMBER, member);
            table.accumulate(queueSizeColumnName, queueSize);
        }
        result = ResultBuilder.buildResult(table);
    } else {
        ErrorResultData erd = ResultBuilder.createErrorResultData();
        buildErrorResult(erd, failureMap);
        result = ResultBuilder.buildResult(erd);
    }
    return result;
}
Also used : TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) 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) LinkedList(java.util.LinkedList) List(java.util.List) ErrorResultData(org.apache.geode.management.internal.cli.result.ErrorResultData) SubscriptionQueueSizeResult(org.apache.geode.management.internal.cli.domain.SubscriptionQueueSizeResult)

Example 7 with MemberResult

use of org.apache.geode.management.internal.cli.domain.MemberResult in project geode by apache.

the class DurableClientCommands method closeDurableClient.

@CliCommand(value = CliStrings.CLOSE_DURABLE_CLIENTS, help = CliStrings.CLOSE_DURABLE_CLIENTS__HELP)
@CliMetaData(shellOnly = false)
@ResourceOperation(resource = Resource.DATA, operation = Operation.MANAGE)
public Result closeDurableClient(@CliOption(key = CliStrings.CLOSE_DURABLE_CLIENTS__CLIENT__ID, mandatory = true, help = CliStrings.CLOSE_DURABLE_CLIENTS__CLIENT__ID__HELP) final String durableClientId, @CliOption(key = CliStrings.CLOSE_DURABLE_CLIENTS__MEMBER, mandatory = false, help = CliStrings.CLOSE_DURABLE_CLIENTS__MEMBER__HELP, optionContext = ConverterHint.MEMBERIDNAME) final String[] memberNameOrId, @CliOption(key = CliStrings.CLOSE_DURABLE_CLIENTS__GROUP, mandatory = false, help = CliStrings.COUNT_DURABLE_CQ_EVENTS__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);
        }
        final ResultCollector<?, ?> rc = CliUtil.executeFunction(new CloseDurableClientFunction(), durableClientId, targetMembers);
        final List<MemberResult> results = (List<MemberResult>) rc.getResult();
        String failureHeader = CliStrings.format(CliStrings.CLOSE_DURABLE_CLIENTS__FAILURE__HEADER, durableClientId);
        String successHeader = CliStrings.format(CliStrings.CLOSE_DURABLE_CLIENTS__SUCCESS, durableClientId);
        result = buildResult(results, successHeader, failureHeader);
    } catch (Exception e) {
        result = ResultBuilder.createGemFireErrorResult(e.getMessage());
    }
    return result;
}
Also used : MemberResult(org.apache.geode.management.internal.cli.domain.MemberResult) DistributedMember(org.apache.geode.distributed.DistributedMember) LinkedList(java.util.LinkedList) List(java.util.List) CloseDurableClientFunction(org.apache.geode.management.internal.cli.functions.CloseDurableClientFunction) 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

MemberResult (org.apache.geode.management.internal.cli.domain.MemberResult)7 LinkedList (java.util.LinkedList)5 List (java.util.List)5 Result (org.apache.geode.management.cli.Result)5 DurableCqNamesResult (org.apache.geode.management.internal.cli.domain.DurableCqNamesResult)5 SubscriptionQueueSizeResult (org.apache.geode.management.internal.cli.domain.SubscriptionQueueSizeResult)5 HashMap (java.util.HashMap)3 DistributedMember (org.apache.geode.distributed.DistributedMember)3 CliMetaData (org.apache.geode.management.cli.CliMetaData)3 CommandResultException (org.apache.geode.management.internal.cli.result.CommandResultException)3 ResourceOperation (org.apache.geode.management.internal.security.ResourceOperation)3 CliCommand (org.springframework.shell.core.annotation.CliCommand)3 TreeMap (java.util.TreeMap)2 Cache (org.apache.geode.cache.Cache)2 CacheClientNotifier (org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier)2 CacheClientProxy (org.apache.geode.internal.cache.tier.sockets.CacheClientProxy)2 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)2 CloseDurableClientFunction (org.apache.geode.management.internal.cli.functions.CloseDurableClientFunction)1 CloseDurableCqFunction (org.apache.geode.management.internal.cli.functions.CloseDurableCqFunction)1 ListDurableCqNamesFunction (org.apache.geode.management.internal.cli.functions.ListDurableCqNamesFunction)1