From 80d12dd82f2378ccb94980f8dbed1043d6f56a0b Mon Sep 17 00:00:00 2001 From: huzongtang Date: Tue, 1 Jan 2019 00:06:37 +0800 Subject: [PATCH] [ISSUE#525]add a switch variable(traceTopicEnable) for making msg trace worked which is decided by users and rename enableAcl flag variable to keep naming specification,such as clusterTopicEnable. --- .../acl/plain/PlainPermissionLoader.java | 1 - .../rocketmq/broker/BrokerController.java | 2 +- .../broker/topic/TopicConfigManager.java | 14 ++++++---- .../apache/rocketmq/common/BrokerConfig.java | 28 ++++++++++++------- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java index 14b25253..1b826933 100644 --- a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java +++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java @@ -119,7 +119,6 @@ public class PlainPermissionLoader { && (StandardWatchEventKinds.ENTRY_MODIFY.equals(event.kind()) || StandardWatchEventKinds.ENTRY_CREATE.equals(event.kind()))) { log.info("{} make a difference change is : {}", watchFileName, event.toString()); - //TODO do a retain //Clearing the info, may result in a non-available time PlainPermissionLoader.this.clearPermissionInfo(); initialize(); diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java index 73ed7eb4..c3431ca4 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java @@ -492,7 +492,7 @@ public class BrokerController { } private void initialAcl() { - if (!this.brokerConfig.isEnableAcl()) { + if (!this.brokerConfig.isAclEnable()) { log.info("The broker dose not enable acl"); return; } diff --git a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java index 6a97c1c7..ed353da4 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java @@ -125,12 +125,14 @@ public class TopicConfigManager extends ConfigManager { this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig); } { - String topic = this.brokerController.getBrokerConfig().getMsgTraceTopicName(); - TopicConfig topicConfig = new TopicConfig(topic); - this.systemTopicList.add(topic); - topicConfig.setReadQueueNums(1); - topicConfig.setWriteQueueNums(1); - this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig); + if (this.brokerController.getBrokerConfig().isTraceTopicEnable()) { + String topic = this.brokerController.getBrokerConfig().getMsgTraceTopicName(); + TopicConfig topicConfig = new TopicConfig(topic); + this.systemTopicList.add(topic); + topicConfig.setReadQueueNums(1); + topicConfig.setWriteQueueNums(1); + this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig); + } } } diff --git a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java index f9d403ec..1c3f37d0 100644 --- a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java +++ b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java @@ -53,6 +53,8 @@ public class BrokerConfig { private String messageStorePlugIn = ""; @ImportantField private String msgTraceTopicName = MixAll.RMQ_SYS_TRACE_TOPIC; + @ImportantField + private boolean traceTopicEnable = false; /** * thread numbers for send message thread pool, since spin lock will be used by default since 4.0.x, the default * value is 1. @@ -176,8 +178,7 @@ public class BrokerConfig { * Acl feature switch */ @ImportantField - private boolean enableAcl = false; - + private boolean aclEnable = false; public static String localHostName() { try { @@ -717,14 +718,6 @@ public class BrokerConfig { this.transactionCheckInterval = transactionCheckInterval; } - public boolean isEnableAcl() { - return enableAcl; - } - - public void setEnableAcl(boolean isAclPlug) { - this.enableAcl = isAclPlug; - } - public int getEndTransactionThreadPoolNums() { return endTransactionThreadPoolNums; } @@ -756,5 +749,20 @@ public class BrokerConfig { public void setMsgTraceTopicName(String msgTraceTopicName) { this.msgTraceTopicName = msgTraceTopicName; } + + public boolean isTraceTopicEnable() { + return traceTopicEnable; + } + + public void setTraceTopicEnable(boolean traceTopicEnable) { + this.traceTopicEnable = traceTopicEnable; + } + public boolean isAclEnable() { + return aclEnable; + } + + public void setAclEnable(boolean aclEnable) { + this.aclEnable = aclEnable; + } } -- GitLab