Search in sources :

Example 1 with QueueStatInfo

use of org.apache.rocketmq.console.model.QueueStatInfo in project rocketmq-externals by apache.

the class ConsumerServiceImpl method queryConsumeStatsList.

@Override
@MultiMQAdminCmdMethod
public List<TopicConsumerInfo> queryConsumeStatsList(final String topic, String groupName) {
    ConsumeStats consumeStats = null;
    try {
        consumeStats = mqAdminExt.examineConsumeStats(groupName, topic);
    } catch (Exception e) {
        throw propagate(e);
    }
    List<MessageQueue> mqList = Lists.newArrayList(Iterables.filter(consumeStats.getOffsetTable().keySet(), new Predicate<MessageQueue>() {

        @Override
        public boolean apply(MessageQueue o) {
            return StringUtils.isBlank(topic) || o.getTopic().equals(topic);
        }
    }));
    Collections.sort(mqList);
    List<TopicConsumerInfo> topicConsumerInfoList = Lists.newArrayList();
    TopicConsumerInfo nowTopicConsumerInfo = null;
    Map<MessageQueue, String> messageQueueClientMap = getClientConnection(groupName);
    for (MessageQueue mq : mqList) {
        if (nowTopicConsumerInfo == null || (!StringUtils.equals(mq.getTopic(), nowTopicConsumerInfo.getTopic()))) {
            nowTopicConsumerInfo = new TopicConsumerInfo(mq.getTopic());
            topicConsumerInfoList.add(nowTopicConsumerInfo);
        }
        QueueStatInfo queueStatInfo = QueueStatInfo.fromOffsetTableEntry(mq, consumeStats.getOffsetTable().get(mq));
        queueStatInfo.setClientInfo(messageQueueClientMap.get(mq));
        nowTopicConsumerInfo.appendQueueStatInfo(queueStatInfo);
    }
    return topicConsumerInfoList;
}
Also used : QueueStatInfo(org.apache.rocketmq.console.model.QueueStatInfo) MessageQueue(org.apache.rocketmq.common.message.MessageQueue) ConsumeStats(org.apache.rocketmq.common.admin.ConsumeStats) TopicConsumerInfo(org.apache.rocketmq.console.model.TopicConsumerInfo) MQClientException(org.apache.rocketmq.client.exception.MQClientException) Predicate(com.google.common.base.Predicate) MultiMQAdminCmdMethod(org.apache.rocketmq.console.aspect.admin.annotation.MultiMQAdminCmdMethod)

Aggregations

Predicate (com.google.common.base.Predicate)1 MQClientException (org.apache.rocketmq.client.exception.MQClientException)1 ConsumeStats (org.apache.rocketmq.common.admin.ConsumeStats)1 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)1 MultiMQAdminCmdMethod (org.apache.rocketmq.console.aspect.admin.annotation.MultiMQAdminCmdMethod)1 QueueStatInfo (org.apache.rocketmq.console.model.QueueStatInfo)1 TopicConsumerInfo (org.apache.rocketmq.console.model.TopicConsumerInfo)1