You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by ji...@apache.org on 2023/01/12 02:49:14 UTC

[rocketmq] branch develop updated: [ISSUE #5708] Fix NamesrvStartup can't print config when use -p command (#5709)

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 7c128a5f0 [ISSUE #5708] Fix NamesrvStartup can't print config when use -p command (#5709)
7c128a5f0 is described below

commit 7c128a5f0a2c9585ce8a16a221049baa6a7bcc0c
Author: mxsm <lj...@gmail.com>
AuthorDate: Thu Jan 12 10:49:06 2023 +0800

    [ISSUE #5708] Fix NamesrvStartup can't print config when use -p command (#5709)
---
 .../apache/rocketmq/common/constant/LoggerName.java   |  1 +
 .../org/apache/rocketmq/namesrv/NamesrvStartup.java   | 19 +++++++++----------
 style/rmq_checkstyle.xml                              |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

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 7d05a046e..9797fddff 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
@@ -19,6 +19,7 @@ package org.apache.rocketmq.common.constant;
 public class LoggerName {
     public static final String FILTERSRV_LOGGER_NAME = "RocketmqFiltersrv";
     public static final String NAMESRV_LOGGER_NAME = "RocketmqNamesrv";
+    public static final String NAMESRV_CONSOLE_LOGGER_NAME = "RocketmqNamesrvConsole";
     public static final String CONTROLLER_LOGGER_NAME = "RocketmqController";
     public static final String NAMESRV_WATER_MARK_LOGGER_NAME = "RocketmqNamesrvWaterMark";
     public static final String BROKER_LOGGER_NAME = "RocketmqBroker";
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
index 3f5fbb85e..deb7c75d1 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
@@ -42,7 +42,8 @@ import org.apache.rocketmq.srvutil.ShutdownHookThread;
 
 public class NamesrvStartup {
 
-    private static Logger log;
+    private final static Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
+    private final static Logger logConsole = LoggerFactory.getLogger(LoggerName.NAMESRV_CONSOLE_LOGGER_NAME);
     private static Properties properties = null;
     private static NamesrvConfig namesrvConfig = null;
     private static NettyServerConfig nettyServerConfig = null;
@@ -113,23 +114,21 @@ public class NamesrvStartup {
             }
         }
 
+        MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), namesrvConfig);
         if (commandLine.hasOption('p')) {
-            MixAll.printObjectProperties(null, namesrvConfig);
-            MixAll.printObjectProperties(null, nettyServerConfig);
-            MixAll.printObjectProperties(null, nettyClientConfig);
-            MixAll.printObjectProperties(null, controllerConfig);
+            MixAll.printObjectProperties(logConsole, namesrvConfig);
+            MixAll.printObjectProperties(logConsole, nettyServerConfig);
+            MixAll.printObjectProperties(logConsole, nettyClientConfig);
+            if (namesrvConfig.isEnableControllerInNamesrv()) {
+                MixAll.printObjectProperties(logConsole, controllerConfig);
+            }
             System.exit(0);
         }
 
-        MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), namesrvConfig);
-
         if (null == namesrvConfig.getRocketmqHome()) {
             System.out.printf("Please set the %s variable in your environment to match the location of the RocketMQ installation%n", MixAll.ROCKETMQ_HOME_ENV);
             System.exit(-2);
         }
-
-        log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
-
         MixAll.printObjectProperties(log, namesrvConfig);
         MixAll.printObjectProperties(log, nettyServerConfig);
 
diff --git a/style/rmq_checkstyle.xml b/style/rmq_checkstyle.xml
index 16078710e..0fb549b70 100644
--- a/style/rmq_checkstyle.xml
+++ b/style/rmq_checkstyle.xml
@@ -101,7 +101,7 @@
         <!--Checks that long constants are defined with an upper ell-->
         <module name="UpperEll"/>
         <module name="ConstantName">
-            <property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)|(^log$)"/>
+            <property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)|(^log[a-zA-Z0-9]*$)"/>
         </module>
         <!--Checks that local, non-final variable names conform to producerGroup format specified by the format property-->
         <module name="LocalVariableName"/>