当前位置: 首页>>代码示例>>Java>>正文


Java ConsumeStats.setConsumeTps方法代码示例

本文整理汇总了Java中com.alibaba.rocketmq.common.admin.ConsumeStats.setConsumeTps方法的典型用法代码示例。如果您正苦于以下问题:Java ConsumeStats.setConsumeTps方法的具体用法?Java ConsumeStats.setConsumeTps怎么用?Java ConsumeStats.setConsumeTps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.rocketmq.common.admin.ConsumeStats的用法示例。


在下文中一共展示了ConsumeStats.setConsumeTps方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: examineConsumeStats

import com.alibaba.rocketmq.common.admin.ConsumeStats; //导入方法依赖的package包/类
@Override
public ConsumeStats examineConsumeStats(String consumerGroup) throws RemotingException,
        MQClientException, InterruptedException, MQBrokerException {
    String retryTopic = MixAll.getRetryTopic(consumerGroup);
    TopicRouteData topicRouteData = this.examineTopicRouteInfo(retryTopic);
    ConsumeStats result = new ConsumeStats();

    for (BrokerData bd : topicRouteData.getBrokerDatas()) {
        String addr = bd.selectBrokerAddr();
        if (addr != null) {
            // 由于查询时间戳会产生IO操作,可能会耗时较长,所以超时时间设置为15s
            ConsumeStats consumeStats =
                    this.mQClientFactory.getMQClientAPIImpl().getConsumeStats(addr, consumerGroup, 15000);
            result.getOffsetTable().putAll(consumeStats.getOffsetTable());
            long value = result.getConsumeTps() + consumeStats.getConsumeTps();
            result.setConsumeTps(value);
        }
    }

    if (result.getOffsetTable().isEmpty()) {
        throw new MQClientException(
            "Not found the consumer group consume stats, because return offset table is empty, maybe the consumer not consume any message",
            null);
    }

    return result;
}
 
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:28,代码来源:DefaultMQAdminExtImpl.java

示例2: getConsumeStats

import com.alibaba.rocketmq.common.admin.ConsumeStats; //导入方法依赖的package包/类
private RemotingCommand getConsumeStats(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetConsumeStatsRequestHeader requestHeader =
            (GetConsumeStatsRequestHeader) request.decodeCommandCustomHeader(GetConsumeStatsRequestHeader.class);

    ConsumeStats consumeStats = new ConsumeStats();

    Set<String> topics = new HashSet<String>();
    if (UtilAll.isBlank(requestHeader.getTopic())) {
        topics = this.brokerController.getConsumerOffsetManager().whichTopicByConsumer(requestHeader.getConsumerGroup());
    }
    else {
        topics.add(requestHeader.getTopic());
    }

    for (String topic : topics) {
        TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
        if (null == topicConfig) {
            log.warn("consumeStats, topic config not exist, {}", topic);
            continue;
        }
        {
            SubscriptionData findSubscriptionData =
                    this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getConsumerGroup(), topic);
            if (null == findSubscriptionData //
                    && this.brokerController.getConsumerManager().findSubscriptionDataCount(requestHeader.getConsumerGroup()) > 0) {
                log.warn("consumeStats, the consumer group[{}], topic[{}] not exist", requestHeader.getConsumerGroup(), topic);
                continue;
            }
        }

        for (int i = 0; i < topicConfig.getReadQueueNums(); i++) {
            MessageQueue mq = new MessageQueue();
            mq.setTopic(topic);
            mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
            mq.setQueueId(i);

            OffsetWrapper offsetWrapper = new OffsetWrapper();

            long brokerOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
            if (brokerOffset < 0)
                brokerOffset = 0;

            long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(//
                requestHeader.getConsumerGroup(),//
                topic,//
                i);
            if (consumerOffset < 0)
                consumerOffset = 0;

            offsetWrapper.setBrokerOffset(brokerOffset);
            offsetWrapper.setConsumerOffset(consumerOffset);

            long timeOffset = consumerOffset - 1;
            if (timeOffset >= 0) {
                long lastTimestamp = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, timeOffset);
                if (lastTimestamp > 0) {
                    offsetWrapper.setLastTimestamp(lastTimestamp);
                }
            }

            consumeStats.getOffsetTable().put(mq, offsetWrapper);
        }

        double consumeTps = this.brokerController.getBrokerStatsManager().tpsGroupGetNums(requestHeader.getConsumerGroup(), topic);

        consumeTps += consumeStats.getConsumeTps();
        consumeStats.setConsumeTps(consumeTps);
    }

    byte[] body = consumeStats.encode();
    response.setBody(body);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:77,代码来源:AdminBrokerProcessor.java

示例3: getConsumeStats

import com.alibaba.rocketmq.common.admin.ConsumeStats; //导入方法依赖的package包/类
private RemotingCommand getConsumeStats(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetConsumeStatsRequestHeader requestHeader =
            (GetConsumeStatsRequestHeader) request.decodeCommandCustomHeader(GetConsumeStatsRequestHeader.class);

    ConsumeStats consumeStats = new ConsumeStats();

    Set<String> topics = new HashSet<String>();
    if (UtilAll.isBlank(requestHeader.getTopic())) {
        topics = this.brokerController.getConsumerOffsetManager().whichTopicByConsumer(requestHeader.getConsumerGroup());
    } else {
        topics.add(requestHeader.getTopic());
    }

    for (String topic : topics) {
        TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
        if (null == topicConfig) {
            log.warn("consumeStats, topic config not exist, {}", topic);
            continue;
        }
        {
            SubscriptionData findSubscriptionData =
                    this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getConsumerGroup(), topic);
            if (null == findSubscriptionData //
                    && this.brokerController.getConsumerManager().findSubscriptionDataCount(requestHeader.getConsumerGroup()) > 0) {
                log.warn("consumeStats, the consumer group[{}], topic[{}] not exist", requestHeader.getConsumerGroup(), topic);
                continue;
            }
        }

        for (int i = 0; i < topicConfig.getReadQueueNums(); i++) {
            MessageQueue mq = new MessageQueue();
            mq.setTopic(topic);
            mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
            mq.setQueueId(i);

            OffsetWrapper offsetWrapper = new OffsetWrapper();

            long brokerOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
            if (brokerOffset < 0)
                brokerOffset = 0;

            long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(//
                    requestHeader.getConsumerGroup(),//
                    topic,//
                    i);
            if (consumerOffset < 0)
                consumerOffset = 0;

            offsetWrapper.setBrokerOffset(brokerOffset);
            offsetWrapper.setConsumerOffset(consumerOffset);

            long timeOffset = consumerOffset - 1;
            if (timeOffset >= 0) {
                long lastTimestamp = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, timeOffset);
                if (lastTimestamp > 0) {
                    offsetWrapper.setLastTimestamp(lastTimestamp);
                }
            }

            consumeStats.getOffsetTable().put(mq, offsetWrapper);
        }

        double consumeTps = this.brokerController.getBrokerStatsManager().tpsGroupGetNums(requestHeader.getConsumerGroup(), topic);

        consumeTps += consumeStats.getConsumeTps();
        consumeStats.setConsumeTps(consumeTps);
    }

    byte[] body = consumeStats.encode();
    response.setBody(body);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:medusar,项目名称:rocketmq-commet,代码行数:76,代码来源:AdminBrokerProcessor.java

示例4: getConsumeStats

import com.alibaba.rocketmq.common.admin.ConsumeStats; //导入方法依赖的package包/类
private RemotingCommand getConsumeStats(ChannelHandlerContext ctx, RemotingCommand request)
        throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetConsumeStatsRequestHeader requestHeader =
            (GetConsumeStatsRequestHeader) request
                .decodeCommandCustomHeader(GetConsumeStatsRequestHeader.class);

    ConsumeStats consumeStats = new ConsumeStats();

    Set<String> topics =
            this.brokerController.getConsumerOffsetManager().whichTopicByConsumer(
                requestHeader.getConsumerGroup());

    for (String topic : topics) {
        TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
        if (null == topicConfig) {
            log.warn("consumeStats, topic config not exist, {}", topic);
            continue;
        }

        SubscriptionData findSubscriptionData =
                this.brokerController.getConsumerManager().findSubscriptionData(
                    requestHeader.getConsumerGroup(), topic);
        if (null == findSubscriptionData) {
            log.warn("consumeStats, the consumer group[{}], topic[{}] not exist",
                requestHeader.getConsumerGroup(), topic);
            continue;
        }

        for (int i = 0; i < topicConfig.getWriteQueueNums(); i++) {
            MessageQueue mq = new MessageQueue();
            mq.setTopic(topic);
            mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
            mq.setQueueId(i);

            OffsetWrapper offsetWrapper = new OffsetWrapper();

            long brokerOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
            if (brokerOffset < 0)
                brokerOffset = 0;

            long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(//
                requestHeader.getConsumerGroup(),//
                topic,//
                i);
            if (consumerOffset < 0)
                consumerOffset = 0;

            offsetWrapper.setBrokerOffset(brokerOffset);
            offsetWrapper.setConsumerOffset(consumerOffset);

            // 查询消费者最后一条消息对应的时间戳
            long timeOffset = consumerOffset - 1;
            if (timeOffset >= 0) {
                long lastTimestamp =
                        this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i,
                            timeOffset);
                if (lastTimestamp > 0) {
                    offsetWrapper.setLastTimestamp(lastTimestamp);
                }
            }

            consumeStats.getOffsetTable().put(mq, offsetWrapper);
        }

        long consumeTps =
                this.brokerController.getConsumerOffsetManager().computePullTPS(topic,
                    requestHeader.getConsumerGroup());

        consumeTps += consumeStats.getConsumeTps();
        consumeStats.setConsumeTps(consumeTps);
    }

    byte[] body = consumeStats.encode();
    response.setBody(body);
    response.setCode(ResponseCode.SUCCESS);
    response.setRemark(null);
    return response;
}
 
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:80,代码来源:AdminBrokerProcessor.java

示例5: getConsumeStats

import com.alibaba.rocketmq.common.admin.ConsumeStats; //导入方法依赖的package包/类
private RemotingCommand getConsumeStats(ChannelHandlerContext ctx, RemotingCommand request)
        throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetConsumeStatsRequestHeader requestHeader =
            (GetConsumeStatsRequestHeader) request
                .decodeCommandCustomHeader(GetConsumeStatsRequestHeader.class);

    ConsumeStats consumeStats = new ConsumeStats();

    Set<String> topics =
            this.brokerController.getConsumerOffsetManager().whichTopicByConsumer(
                requestHeader.getConsumerGroup());

    for (String topic : topics) {
        TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
        if (null == topicConfig) {
            log.warn("consumeStats, topic config not exist, {}", topic);
            continue;
        }

        SubscriptionData findSubscriptionData =
                this.brokerController.getConsumerManager().findSubscriptionData(
                    requestHeader.getConsumerGroup(), topic);
        if (null == findSubscriptionData) {
            log.warn("consumeStats, the consumer group[{}], topic[{}] not exist",
                requestHeader.getConsumerGroup(), topic);
            continue;
        }

        for (int i = 0; i < topicConfig.getWriteQueueNums(); i++) {
            MessageQueue mq = new MessageQueue();
            mq.setTopic(topic);
            mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
            mq.setQueueId(i);

            OffsetWrapper offsetWrapper = new OffsetWrapper();

            long brokerOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
            if (brokerOffset < 0)
                brokerOffset = 0;

            long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(//
                requestHeader.getConsumerGroup(),//
                topic,//
                i);
            if (consumerOffset < 0)
                consumerOffset = 0;

            offsetWrapper.setBrokerOffset(brokerOffset);
            offsetWrapper.setConsumerOffset(consumerOffset);

            // 查询消费者最后一条消息对应的时间戳
            long timeOffset = consumerOffset - 1;
            if (timeOffset >= 0) {
                long lastTimestamp =
                        this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i,
                            timeOffset);
                if (lastTimestamp > 0) {
                    offsetWrapper.setLastTimestamp(lastTimestamp);
                }
            }

            consumeStats.getOffsetTable().put(mq, offsetWrapper);
        }

        long consumeTps =
                this.brokerController.getConsumerOffsetManager().computePullTPS(topic,
                    requestHeader.getConsumerGroup());

        consumeTps += consumeStats.getConsumeTps();
        consumeStats.setConsumeTps(consumeTps);
    }

    byte[] body = consumeStats.encode();
    response.setBody(body);
    response.setCode(ResponseCode.SUCCESS_VALUE);
    response.setRemark(null);
    return response;
}
 
开发者ID:brucechan0921,项目名称:RocketMQ-3.0.8,代码行数:80,代码来源:AdminBrokerProcessor.java


注:本文中的com.alibaba.rocketmq.common.admin.ConsumeStats.setConsumeTps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。