This is an automated email from the ASF dual-hosted git repository. jinrongtong pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push: new 33a185a901 [ISSUE #9221] Extract some common code in BrokerPathConfigHelper (#9222) 33a185a901 is described below commit 33a185a901c0d53d9e75456e067c3b520c1a0bdc Author: yx9o <yangx_s...@163.com> AuthorDate: Tue Mar 4 15:20:28 2025 +0800 [ISSUE #9221] Extract some common code in BrokerPathConfigHelper (#9222) --- .../rocketmq/broker/BrokerPathConfigHelper.java | 26 +++++++++++++--------- .../broker/BrokerPathConfigHelperTest.java | 24 ++++++++++++++++++-- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java index 0b2f52f32e..1c37774fe0 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java @@ -32,43 +32,47 @@ public class BrokerPathConfigHelper { } public static String getTopicConfigPath(final String rootDir) { - return rootDir + File.separator + "config" + File.separator + "topics.json"; + return getConfigDir(rootDir) + "topics.json"; } public static String getTopicQueueMappingPath(final String rootDir) { - return rootDir + File.separator + "config" + File.separator + "topicQueueMapping.json"; + return getConfigDir(rootDir) + "topicQueueMapping.json"; } public static String getConsumerOffsetPath(final String rootDir) { - return rootDir + File.separator + "config" + File.separator + "consumerOffset.json"; + return getConfigDir(rootDir) + "consumerOffset.json"; } public static String getLmqConsumerOffsetPath(final String rootDir) { - return rootDir + File.separator + "config" + File.separator + "lmqConsumerOffset.json"; + return getConfigDir(rootDir) + "lmqConsumerOffset.json"; } public static String getConsumerOrderInfoPath(final String rootDir) { - return rootDir + File.separator + "config" + File.separator + "consumerOrderInfo.json"; + return getConfigDir(rootDir) + "consumerOrderInfo.json"; } public static String getSubscriptionGroupPath(final String rootDir) { - return rootDir + File.separator + "config" + File.separator + "subscriptionGroup.json"; + return getConfigDir(rootDir) + "subscriptionGroup.json"; } public static String getTimerCheckPath(final String rootDir) { - return rootDir + File.separator + "config" + File.separator + "timercheck"; + return getConfigDir(rootDir) + "timercheck"; } public static String getTimerMetricsPath(final String rootDir) { - return rootDir + File.separator + "config" + File.separator + "timermetrics"; + return getConfigDir(rootDir) + "timermetrics"; } public static String getTransactionMetricsPath(final String rootDir) { - return rootDir + File.separator + "config" + File.separator + "transactionMetrics"; + return getConfigDir(rootDir) + "transactionMetrics"; } public static String getConsumerFilterPath(final String rootDir) { - return rootDir + File.separator + "config" + File.separator + "consumerFilter.json"; + return getConfigDir(rootDir) + "consumerFilter.json"; } public static String getMessageRequestModePath(final String rootDir) { - return rootDir + File.separator + "config" + File.separator + "messageRequestMode.json"; + return getConfigDir(rootDir) + "messageRequestMode.json"; + } + + private static String getConfigDir(final String rootDir) { + return rootDir + File.separator + "config" + File.separator; } } diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerPathConfigHelperTest.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerPathConfigHelperTest.java index 3b26054083..61a0891c9e 100644 --- a/broker/src/test/java/org/apache/rocketmq/broker/BrokerPathConfigHelperTest.java +++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerPathConfigHelperTest.java @@ -25,7 +25,7 @@ import static org.junit.Assert.assertEquals; public class BrokerPathConfigHelperTest { @Test - public void testGetLmqConsumerOffsetPath() { + public void testGetPath() { String lmqConsumerOffsetPath = BrokerPathConfigHelper.getLmqConsumerOffsetPath("/home/admin/store".replace("/", File.separator)); assertEquals("/home/admin/store/config/lmqConsumerOffset.json".replace("/", File.separator), lmqConsumerOffsetPath); @@ -38,5 +38,25 @@ public class BrokerPathConfigHelperTest { String subscriptionGroupPath = BrokerPathConfigHelper.getSubscriptionGroupPath("/home/admin/store".replace("/", File.separator)); assertEquals("/home/admin/store/config/subscriptionGroup.json".replace("/", File.separator), subscriptionGroupPath); + String topicQueueMappingPath = BrokerPathConfigHelper.getTopicQueueMappingPath("/home/admin/store".replace("/", File.separator)); + assertEquals("/home/admin/store/config/topicQueueMapping.json".replace("/", File.separator), topicQueueMappingPath); + + String consumerOrderInfoPath = BrokerPathConfigHelper.getConsumerOrderInfoPath("/home/admin/store".replace("/", File.separator)); + assertEquals("/home/admin/store/config/consumerOrderInfo.json".replace("/", File.separator), consumerOrderInfoPath); + + String timercheckPath = BrokerPathConfigHelper.getTimerCheckPath("/home/admin/store".replace("/", File.separator)); + assertEquals("/home/admin/store/config/timercheck".replace("/", File.separator), timercheckPath); + + String timermetricsPath = BrokerPathConfigHelper.getTimerMetricsPath("/home/admin/store".replace("/", File.separator)); + assertEquals("/home/admin/store/config/timermetrics".replace("/", File.separator), timermetricsPath); + + String transactionMetricsPath = BrokerPathConfigHelper.getTransactionMetricsPath("/home/admin/store".replace("/", File.separator)); + assertEquals("/home/admin/store/config/transactionMetrics".replace("/", File.separator), transactionMetricsPath); + + String consumerFilterPath = BrokerPathConfigHelper.getConsumerFilterPath("/home/admin/store".replace("/", File.separator)); + assertEquals("/home/admin/store/config/consumerFilter.json".replace("/", File.separator), consumerFilterPath); + + String messageRequestModePath = BrokerPathConfigHelper.getMessageRequestModePath("/home/admin/store".replace("/", File.separator)); + assertEquals("/home/admin/store/config/messageRequestMode.json".replace("/", File.separator), messageRequestModePath); } -} \ No newline at end of file +}