ShadowySpirits commented on code in PR #5956:
URL: https://github.com/apache/rocketmq/pull/5956#discussion_r1092804436
##########
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java:
##########
@@ -418,35 +418,20 @@ public ConsumeStats examineConsumeStats(
@Override
public ConsumeStats examineConsumeStats(String consumerGroup,
String topic) throws RemotingException, MQClientException,
InterruptedException, MQBrokerException {
- TopicRouteData topicRouteData = null;
- List<String> routeTopics = new ArrayList<>();
- routeTopics.add(MixAll.getRetryTopic(consumerGroup));
- if (topic != null) {
- routeTopics.add(topic);
- routeTopics.add(KeyBuilder.buildPopRetryTopic(topic,
consumerGroup));
- }
- for (int i = 0; i < routeTopics.size(); i++) {
- try {
- topicRouteData =
this.examineTopicRouteInfo(routeTopics.get(i));
- if (topicRouteData != null) {
- break;
- }
- } catch (Throwable e) {
- if (i == routeTopics.size() - 1) {
- throw e;
- }
- }
- }
ConsumeStats result = new ConsumeStats();
-
- for (BrokerData bd : topicRouteData.getBrokerDatas()) {
- String addr = bd.selectBrokerAddr();
- if (addr != null) {
- ConsumeStats consumeStats =
this.mqClientInstance.getMQClientAPIImpl().getConsumeStats(addr, consumerGroup,
topic, timeoutMillis * 3);
- result.getOffsetTable().putAll(consumeStats.getOffsetTable());
- double value = result.getConsumeTps() +
consumeStats.getConsumeTps();
- result.setConsumeTps(value);
+ for (BrokerData brokerData :
this.examineBrokerClusterInfo().getBrokerAddrTable().values()) {
Review Comment:
> IMO, old code also scan all clusters, because consumers send heartbeat and
create retry topics on all brokers. Do you have any suggestions for improvement
here?
That's not exactly. If we only have one cluster, these two ways do not have
differences. But in production practice, there are many broker clusters
registered to the same nameserver cluster. So that your modification will
access unnecessary clusters.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]