From daf1b9df79aea5614d740cc46e6d7dd95ce038c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E4=B8=8D=E6=9C=8D?= Date: Mon, 27 Sep 2021 09:07:59 +0800 Subject: [PATCH] [ISSUE #503] NOT_CONSUME_YET not righht in RocketMQ Console (#3091) --- .../org/apache/rocketmq/common/RemotingUtilTest.java | 12 ++++++++++++ .../rocketmq/remoting/common/RemotingUtil.java | 4 ++++ .../rocketmq/tools/admin/DefaultMQAdminExtImpl.java | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java b/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java index 58668963..19346e6b 100644 --- a/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java +++ b/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java @@ -28,4 +28,16 @@ public class RemotingUtilTest { assertThat(localAddress).isNotNull(); assertThat(localAddress.length()).isGreaterThan(0); } + + @Test + public void testConvert2IpStringWithIp() { + String result = RemotingUtil.convert2IpString("127.0.0.1:9876"); + assertThat(result).isEqualTo("127.0.0.1:9876"); + } + + @Test + public void testConvert2IpStringWithHost() { + String result = RemotingUtil.convert2IpString("localhost:9876"); + assertThat(result).isEqualTo("127.0.0.1:9876"); + } } diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java index d936c3bf..3914314f 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java @@ -165,6 +165,10 @@ public class RemotingUtil { return sb.toString(); } + public static String convert2IpString(final String addr) { + return socketAddress2String(string2SocketAddress(addr)); + } + private static boolean isBridge(NetworkInterface networkInterface) { try { if (isLinuxPlatform()) { diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java index 55cca540..d0e65ba7 100644 --- a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java +++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java @@ -888,7 +888,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner { if (mq.getTopic().equals(msg.getTopic()) && mq.getQueueId() == msg.getQueueId()) { BrokerData brokerData = ci.getBrokerAddrTable().get(mq.getBrokerName()); if (brokerData != null) { - String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID); + String addr = RemotingUtil.convert2IpString(brokerData.getBrokerAddrs().get(MixAll.MASTER_ID)); if (RemotingUtil.socketAddress2String(msg.getStoreHost()).equals(addr)) { if (next.getValue().getConsumerOffset() > msg.getQueueOffset()) { return true; -- GitLab