From 1a80c5ba57b4bf5b56a63a00018fefcbf2d26536 Mon Sep 17 00:00:00 2001 From: dongeforever Date: Sat, 29 Dec 2018 12:03:40 +0800 Subject: [PATCH] Trivial pilishment for acl and msg_trace --- .../acl/plain/PlainPermissionLoader.java | 2 +- .../plain/RemoteAddressStrategyFactory.java | 2 +- .../broker/processor/AdminBrokerProcessor.java | 8 -------- .../broker/topic/TopicConfigManager.java | 18 ++++++------------ .../client/consumer/DefaultMQPushConsumer.java | 4 ---- .../client/producer/DefaultMQProducer.java | 3 --- .../apache/rocketmq/common/BrokerConfig.java | 10 ---------- .../org/apache/rocketmq/common/MixAll.java | 3 +-- .../rocketmq/common/constant/LoggerName.java | 1 - .../rocketmq/common/BrokerConfigTest.java | 3 --- .../conf/2m-noslave/broker-a.properties | 1 - .../conf/2m-noslave/broker-b.properties | 1 - .../conf/2m-noslave/broker-trace.properties | 1 - distribution/conf/broker.conf | 2 -- .../apache/rocketmq/srvutil/ServerUtil.java | 4 ++-- .../apache/rocketmq/test/base/BaseConf.java | 1 - .../rocketmq/tools/command/MQAdminStartup.java | 4 ++-- 17 files changed, 13 insertions(+), 55 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 9c36ecf7..7f0e67a5 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 @@ -43,7 +43,7 @@ import org.apache.rocketmq.logging.InternalLoggerFactory; public class PlainPermissionLoader { - private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.ACL_PLUG_LOGGER_NAME); + private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME); private static final String DEFAULT_PLAIN_ACL_FILE = "/conf/plain_acl.yml"; diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java index 10b47345..4f1dc055 100644 --- a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java +++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java @@ -27,7 +27,7 @@ import org.apache.rocketmq.logging.InternalLoggerFactory; public class RemoteAddressStrategyFactory { - private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.ACL_PLUG_LOGGER_NAME); + private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME); public static final NullRemoteAddressStrategy NULL_NET_ADDRESS_STRATEGY = new NullRemoteAddressStrategy(); diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java index 9771ec9a..73fe4394 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java @@ -228,14 +228,6 @@ public class AdminBrokerProcessor implements NettyRequestProcessor { return response; } - if (this.brokerController.getBrokerConfig().isAutoTraceBrokerEnable()) { - String errorMsg = "the topic[" + requestHeader.getTopic() + "] is user self defined topic and this node is trace broker!"; - log.warn(errorMsg); - response.setCode(ResponseCode.SYSTEM_ERROR); - response.setRemark(errorMsg); - return response; - } - try { response.setCode(ResponseCode.SUCCESS); response.setOpaque(request.getOpaque()); 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 f1ae2612..6a97c1c7 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,14 +125,12 @@ public class TopicConfigManager extends ConfigManager { this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig); } { - if (this.brokerController.getBrokerConfig().isAutoTraceBrokerEnable()) { - 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); - } + 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); } } @@ -164,10 +162,6 @@ public class TopicConfigManager extends ConfigManager { if (topicConfig != null) return topicConfig; - if (this.brokerController.getBrokerConfig().isAutoTraceBrokerEnable()) { - return topicConfig; - } - TopicConfig defaultTopicConfig = this.topicConfigTable.get(defaultTopic); if (defaultTopicConfig != null) { if (defaultTopic.equals(MixAll.AUTO_CREATE_TOPIC_KEY_TOPIC)) { diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java index edb8cb5a..d13a16a2 100644 --- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java +++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java @@ -758,8 +758,4 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume public TraceDispatcher getTraceDispatcher() { return traceDispatcher; } - - public void setTraceDispatcher(TraceDispatcher traceDispatcher) { - this.traceDispatcher = traceDispatcher; - } } diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java b/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java index 23cb53ca..adfac3cd 100644 --- a/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java +++ b/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java @@ -850,7 +850,4 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer { return traceDispatcher; } - public void setTraceDispatcher(TraceDispatcher traceDispatcher) { - this.traceDispatcher = traceDispatcher; - } } 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 eb1a684d..f9d403ec 100644 --- a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java +++ b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java @@ -52,8 +52,6 @@ public class BrokerConfig { private boolean autoCreateSubscriptionGroup = true; private String messageStorePlugIn = ""; @ImportantField - private boolean autoTraceBrokerEnable = false; - @ImportantField private String msgTraceTopicName = MixAll.RMQ_SYS_TRACE_TOPIC; /** * thread numbers for send message thread pool, since spin lock will be used by default since 4.0.x, the default @@ -751,14 +749,6 @@ public class BrokerConfig { this.waitTimeMillsInTransactionQueue = waitTimeMillsInTransactionQueue; } - public boolean isAutoTraceBrokerEnable() { - return autoTraceBrokerEnable; - } - - public void setAutoTraceBrokerEnable(boolean autoTraceBrokerEnable) { - this.autoTraceBrokerEnable = autoTraceBrokerEnable; - } - public String getMsgTraceTopicName() { return msgTraceTopicName; } diff --git a/common/src/main/java/org/apache/rocketmq/common/MixAll.java b/common/src/main/java/org/apache/rocketmq/common/MixAll.java index 5fdb0120..d39e6338 100644 --- a/common/src/main/java/org/apache/rocketmq/common/MixAll.java +++ b/common/src/main/java/org/apache/rocketmq/common/MixAll.java @@ -82,8 +82,7 @@ public class MixAll { public static final long CURRENT_JVM_PID = getPID(); public static final String RETRY_GROUP_TOPIC_PREFIX = "%RETRY%"; - public static final String TRACE_BROKER_NAME_SUFFIX = "trace"; - + public static final String DLQ_GROUP_TOPIC_PREFIX = "%DLQ%"; public static final String SYSTEM_TOPIC_PREFIX = "rmq_sys_"; public static final String UNIQUE_MSG_QUERY_FLAG = "_UNIQUE_KEY_QUERY"; diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java b/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java index a463a4ed..fe0ae9f1 100644 --- a/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java +++ b/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java @@ -37,5 +37,4 @@ public class LoggerName { public static final String PROTECTION_LOGGER_NAME = "RocketmqProtection"; public static final String WATER_MARK_LOGGER_NAME = "RocketmqWaterMark"; public static final String FILTER_LOGGER_NAME = "RocketmqFilter"; - public static final String ACL_PLUG_LOGGER_NAME = "RocketmqAclPlug"; } diff --git a/common/src/test/java/org/apache/rocketmq/common/BrokerConfigTest.java b/common/src/test/java/org/apache/rocketmq/common/BrokerConfigTest.java index 7e197522..aa8bcfa7 100644 --- a/common/src/test/java/org/apache/rocketmq/common/BrokerConfigTest.java +++ b/common/src/test/java/org/apache/rocketmq/common/BrokerConfigTest.java @@ -33,7 +33,6 @@ public class BrokerConfigTest { BrokerConfig brokerConfig = new BrokerConfig(); brokerConfig.setNamesrvAddr("127.0.0.1:9876"); brokerConfig.setAutoCreateTopicEnable(false); - brokerConfig.setAutoTraceBrokerEnable(true); brokerConfig.setBrokerName("broker-a"); brokerConfig.setBrokerId(0); brokerConfig.setBrokerClusterName("DefaultCluster"); @@ -44,7 +43,5 @@ public class BrokerConfigTest { assertThat(brokerConfig.getBrokerId()).isEqualTo(0); assertThat(brokerConfig.getBrokerName()).isEqualTo("broker-a"); assertThat(brokerConfig.isAutoCreateTopicEnable()).isEqualTo(false); - assertThat(brokerConfig.isAutoTraceBrokerEnable()).isEqualTo(true); - } } \ No newline at end of file diff --git a/distribution/conf/2m-noslave/broker-a.properties b/distribution/conf/2m-noslave/broker-a.properties index cd051cdc..b704b54c 100644 --- a/distribution/conf/2m-noslave/broker-a.properties +++ b/distribution/conf/2m-noslave/broker-a.properties @@ -19,4 +19,3 @@ deleteWhen=04 fileReservedTime=48 brokerRole=ASYNC_MASTER flushDiskType=ASYNC_FLUSH -autoTraceBrokerEnable=false \ No newline at end of file diff --git a/distribution/conf/2m-noslave/broker-b.properties b/distribution/conf/2m-noslave/broker-b.properties index da00cd41..130671a7 100644 --- a/distribution/conf/2m-noslave/broker-b.properties +++ b/distribution/conf/2m-noslave/broker-b.properties @@ -19,4 +19,3 @@ deleteWhen=04 fileReservedTime=48 brokerRole=ASYNC_MASTER flushDiskType=ASYNC_FLUSH -autoTraceBrokerEnable=false \ No newline at end of file diff --git a/distribution/conf/2m-noslave/broker-trace.properties b/distribution/conf/2m-noslave/broker-trace.properties index a4898aae..9dd57a73 100644 --- a/distribution/conf/2m-noslave/broker-trace.properties +++ b/distribution/conf/2m-noslave/broker-trace.properties @@ -21,4 +21,3 @@ deleteWhen=04 fileReservedTime=48 brokerRole=ASYNC_MASTER flushDiskType=ASYNC_FLUSH -autoTraceBrokerEnable=true \ No newline at end of file diff --git a/distribution/conf/broker.conf b/distribution/conf/broker.conf index 97039573..0c0b28b7 100644 --- a/distribution/conf/broker.conf +++ b/distribution/conf/broker.conf @@ -20,5 +20,3 @@ deleteWhen = 04 fileReservedTime = 48 brokerRole = ASYNC_MASTER flushDiskType = ASYNC_FLUSH -enableAcl=true -namesrvAddr=127.0.0.1:9876 diff --git a/srvutil/src/main/java/org/apache/rocketmq/srvutil/ServerUtil.java b/srvutil/src/main/java/org/apache/rocketmq/srvutil/ServerUtil.java index ea8047a2..066d36ce 100644 --- a/srvutil/src/main/java/org/apache/rocketmq/srvutil/ServerUtil.java +++ b/srvutil/src/main/java/org/apache/rocketmq/srvutil/ServerUtil.java @@ -35,8 +35,8 @@ public class ServerUtil { new Option("n", "namesrvAddr", true, "Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876"); opt.setRequired(false); - options.addOption(opt); - + options.addOption(opt); + return options; } diff --git a/test/src/test/java/org/apache/rocketmq/test/base/BaseConf.java b/test/src/test/java/org/apache/rocketmq/test/base/BaseConf.java index a05a55a0..780bd475 100644 --- a/test/src/test/java/org/apache/rocketmq/test/base/BaseConf.java +++ b/test/src/test/java/org/apache/rocketmq/test/base/BaseConf.java @@ -24,7 +24,6 @@ import org.apache.log4j.Logger; import org.apache.rocketmq.broker.BrokerController; import org.apache.rocketmq.common.MQVersion; import org.apache.rocketmq.namesrv.NamesrvController; -import org.apache.rocketmq.remoting.netty.TlsSystemConfig; import org.apache.rocketmq.remoting.protocol.RemotingCommand; import org.apache.rocketmq.test.client.rmq.RMQAsyncSendProducer; import org.apache.rocketmq.test.client.rmq.RMQNormalConsumer; diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java index 065e4175..989f8d77 100644 --- a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java +++ b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java @@ -132,7 +132,7 @@ public class MQAdminStartup { System.setProperty(MixAll.NAMESRV_ADDR_PROPERTY, namesrvAddr); } - cmd.execute(commandLine, options, getAclRPCHook(commandLine)); + cmd.execute(commandLine, options, getAclRPCHook()); } else { System.out.printf("The sub command %s not exist.%n", args[0]); } @@ -246,7 +246,7 @@ public class MQAdminStartup { subCommandList.add(command); } - public static RPCHook getAclRPCHook(CommandLine commandLine) { + public static RPCHook getAclRPCHook() { String fileHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV)); String fileName = "/conf/tools.yml"; JSONObject yamlDataObject = AclUtils.getYamlDataObject(fileHome + fileName , -- GitLab