You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by zh...@apache.org on 2022/01/08 14:06:40 UTC
[rocketmq-dashboard] branch master updated: [ISSUE #62]Uses the YML format instead of the Properties format. (#63)
This is an automated email from the ASF dual-hosted git repository.
zhangjidi2016 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new e281b74 [ISSUE #62]Uses the YML format instead of the Properties format. (#63)
e281b74 is described below
commit e281b74456809c1bed37f0e6cd7ae7b0d2f5351a
Author: zhangjidi2016 <10...@qq.com>
AuthorDate: Sat Jan 8 22:05:21 2022 +0800
[ISSUE #62]Uses the YML format instead of the Properties format. (#63)
* [ISSUE #62]Uses the YML format instead of the Properties format.
* retrigger ci
* Solve the apache-rat check
Co-authored-by: zhangjidi <zh...@cmss.chinamobile.com>
---
pom.xml | 6 +++
.../rocketmq/dashboard/config/RMQConfigure.java | 18 +++----
.../dashboard/service/impl/OpsServiceImpl.java | 3 +-
src/main/resources/application.properties | 55 -------------------
src/main/resources/application.yml | 63 ++++++++++++++++++++++
.../dashboard/config/RMQConfigureTest.java | 3 ++
.../dashboard/controller/BaseControllerTest.java | 3 +-
.../dashboard/controller/OpsControllerTest.java | 3 +-
8 files changed, 84 insertions(+), 70 deletions(-)
diff --git a/pom.xml b/pom.xml
index e318d92..78fa7b7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -103,6 +103,7 @@
<easyexcel.version>2.2.10</easyexcel.version>
<asm.version>4.2</asm.version>
<junit.version>4.12</junit.version>
+ <snakeyaml.version>1.30</snakeyaml.version>
</properties>
<dependencies>
@@ -264,6 +265,11 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>${snakeyaml.version}</version>
+ </dependency>
</dependencies>
<build>
diff --git a/src/main/java/org/apache/rocketmq/dashboard/config/RMQConfigure.java b/src/main/java/org/apache/rocketmq/dashboard/config/RMQConfigure.java
index d9149ef..991a2d8 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/config/RMQConfigure.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/config/RMQConfigure.java
@@ -16,7 +16,8 @@
*/
package org.apache.rocketmq.dashboard.config;
-import com.google.common.base.Splitter;
+import java.util.ArrayList;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.common.MixAll;
import org.slf4j.Logger;
@@ -59,7 +60,7 @@ public class RMQConfigure {
private Long timeoutMillis;
- private String namesrvAddrs;
+ private List<String> namesrvAddrs = new ArrayList<>();
public String getAccessKey() {
return accessKey;
@@ -81,17 +82,14 @@ public class RMQConfigure {
return namesrvAddr;
}
- public String getNamesrvAddrs() {
+ public List<String> getNamesrvAddrs() {
return namesrvAddrs;
}
- public void setNamesrvAddrs(String namesrvAddrs) {
- if (StringUtils.isNotBlank(namesrvAddrs)) {
- this.namesrvAddrs = namesrvAddrs;
- List<String> nameSrvAddrList = Splitter.on("@").splitToList(this.namesrvAddrs);
- if (!nameSrvAddrList.isEmpty()) {
- this.setNamesrvAddr(nameSrvAddrList.get(0));
- }
+ public void setNamesrvAddrs(List<String> namesrvAddrs) {
+ this.namesrvAddrs = namesrvAddrs;
+ if (CollectionUtils.isNotEmpty(namesrvAddrs)) {
+ this.setNamesrvAddr(namesrvAddrs.get(0));
}
}
diff --git a/src/main/java/org/apache/rocketmq/dashboard/service/impl/OpsServiceImpl.java b/src/main/java/org/apache/rocketmq/dashboard/service/impl/OpsServiceImpl.java
index 1b92ac1..cb882f7 100644
--- a/src/main/java/org/apache/rocketmq/dashboard/service/impl/OpsServiceImpl.java
+++ b/src/main/java/org/apache/rocketmq/dashboard/service/impl/OpsServiceImpl.java
@@ -16,7 +16,6 @@
*/
package org.apache.rocketmq.dashboard.service.impl;
-import com.google.common.base.Splitter;
import com.google.common.collect.Maps;
import java.util.List;
import java.util.Map;
@@ -47,7 +46,7 @@ public class OpsServiceImpl extends AbstractCommonService implements OpsService
public Map<String, Object> homePageInfo() {
Map<String, Object> homePageInfoMap = Maps.newHashMap();
homePageInfoMap.put("currentNamesrv", configure.getNamesrvAddr());
- homePageInfoMap.put("namesvrAddrList", Splitter.on("@").splitToList(configure.getNamesrvAddrs()));
+ homePageInfoMap.put("namesvrAddrList", configure.getNamesrvAddrs());
homePageInfoMap.put("useVIPChannel", Boolean.valueOf(configure.getIsVIPChannel()));
homePageInfoMap.put("useTLS", configure.isUseTLS());
return homePageInfoMap;
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
deleted file mode 100644
index b0a6be0..0000000
--- a/src/main/resources/application.properties
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-server.address=0.0.0.0
-server.port=8080
-
-### SSL setting
-#server.ssl.key-store=classpath:rmqcngkeystore.jks
-#server.ssl.key-store-password=rocketmq
-#server.ssl.keyStoreType=PKCS12
-#server.ssl.keyAlias=rmqcngkey
-
-#spring.application.index=true
-spring.application.name=rocketmq-dashboard
-spring.http.encoding.charset=UTF-8
-spring.http.encoding.enabled=true
-spring.http.encoding.force=true
-logging.level.root=INFO
-logging.config=classpath:logback.xml
-#if this value is empty,use env value rocketmq.config.namesrvAddr NAMESRV_ADDR | now, default localhost:9876
-#use @ to distinct the namesrv of different clusters
-rocketmq.config.namesrvAddrs=
-#if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default true
-rocketmq.config.isVIPChannel=
-#timeout for mqadminExt, default 5000ms
-rocketmq.config.timeoutMillis=
-#rocketmq-console's data path:dashboard/monitor
-rocketmq.config.dataPath=/tmp/rocketmq-console/data
-#set it false if you don't want use dashboard.default true
-rocketmq.config.enableDashBoardCollect=true
-#set the message track trace topic if you don't want use the default one
-rocketmq.config.msgTrackTopicName=
-rocketmq.config.ticketKey=ticket
-
-#Must create userInfo file: ${rocketmq.config.dataPath}/users.properties if the login is required
-rocketmq.config.loginRequired=false
-
-#set the accessKey and secretKey if you used acl
-#rocketmq.config.accessKey=
-#rocketmq.config.secretKey=
-rocketmq.config.useTLS=false
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
new file mode 100644
index 0000000..4a6a207
--- /dev/null
+++ b/src/main/resources/application.yml
@@ -0,0 +1,63 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+server:
+ port: 8080
+ servlet:
+ encoding:
+ charset: UTF-8
+ enabled: true
+ force: true
+## SSL setting
+# ssl:
+# key-store: classpath:rmqcngkeystore.jks
+# key-store-password: rocketmq
+# key-store-type: PKCS12
+# key-alias: rmqcngkey
+
+spring:
+ application:
+ name: rocketmq-dashboard
+
+logging:
+ config: classpath:logback.xml
+
+rocketmq:
+ config:
+ # if this value is empty,use env value rocketmq.config.namesrvAddr NAMESRV_ADDR | now, default localhost:9876
+ # configure multiple namesrv addresses to manage multiple different clusters
+ namesrvAddrs:
+ - 127.0.0.1:9876
+ - 127.0.0.2:9876
+ # if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default true
+ isVIPChannel:
+ # timeout for mqadminExt, default 5000ms
+ timeoutMillis:
+ # rocketmq-console's data path:dashboard/monitor
+ dataPath: /tmp/rocketmq-console/data
+ # set it false if you don't want use dashboard.default true
+ enableDashBoardCollect: true
+ # set the message track trace topic if you don't want use the default one
+ msgTrackTopicName:
+ ticketKey: ticket
+ # must create userInfo file: ${rocketmq.config.dataPath}/users.properties if the login is required
+ loginRequired: false
+ useTLS: false
+ # set the accessKey and secretKey if you used acl
+ accessKey: # if version > 4.4.0
+ secretKey: # if version > 4.4.0
+
diff --git a/src/test/java/org/apache/rocketmq/dashboard/config/RMQConfigureTest.java b/src/test/java/org/apache/rocketmq/dashboard/config/RMQConfigureTest.java
index e63caf3..0f7cad7 100644
--- a/src/test/java/org/apache/rocketmq/dashboard/config/RMQConfigureTest.java
+++ b/src/test/java/org/apache/rocketmq/dashboard/config/RMQConfigureTest.java
@@ -17,6 +17,7 @@
package org.apache.rocketmq.dashboard.config;
+import com.google.common.collect.Lists;
import java.io.File;
import org.junit.Assert;
import org.junit.Test;
@@ -39,6 +40,7 @@ public class RMQConfigureTest {
rmqConfigure.setLoginRequired(true);
rmqConfigure.setNamesrvAddr("127.0.0.1:9876");
rmqConfigure.setTimeoutMillis(3000L);
+ rmqConfigure.setNamesrvAddrs(Lists.asList("127.0.0.1:9876", new String[] {"127.0.0.2:9876"}));
}
@Test
@@ -54,6 +56,7 @@ public class RMQConfigureTest {
Assert.assertTrue(rmqConfigure.isEnableDashBoardCollect());
Assert.assertTrue(rmqConfigure.isLoginRequired());
Assert.assertEquals(rmqConfigure.getNamesrvAddr(), "127.0.0.1:9876");
+ Assert.assertEquals(rmqConfigure.getNamesrvAddrs().size(), 2);
Assert.assertEquals(rmqConfigure.getTimeoutMillis().longValue(), 3000L);
ErrorPageRegistrar registrar = rmqConfigure.errorPageRegistrar();
registrar.registerErrorPages(new ErrorPageRegistry() {
diff --git a/src/test/java/org/apache/rocketmq/dashboard/controller/BaseControllerTest.java b/src/test/java/org/apache/rocketmq/dashboard/controller/BaseControllerTest.java
index 1061a3c..c3b89ae 100644
--- a/src/test/java/org/apache/rocketmq/dashboard/controller/BaseControllerTest.java
+++ b/src/test/java/org/apache/rocketmq/dashboard/controller/BaseControllerTest.java
@@ -17,6 +17,7 @@
package org.apache.rocketmq.dashboard.controller;
+import com.google.common.collect.Lists;
import org.apache.rocketmq.dashboard.BaseTest;
import org.apache.rocketmq.dashboard.config.RMQConfigure;
import org.apache.rocketmq.dashboard.support.GlobalExceptionHandler;
@@ -62,7 +63,7 @@ public abstract class BaseControllerTest extends BaseTest {
when(configure.getAccessKey()).thenReturn("12345678");
when(configure.getSecretKey()).thenReturn("rocketmq");
when(configure.getNamesrvAddr()).thenReturn("127.0.0.1:9876");
- when(configure.getNamesrvAddrs()).thenReturn("127.0.0.1:9876");
+ when(configure.getNamesrvAddrs()).thenReturn(Lists.asList("127.0.0.1:9876", new String[] {"127.0.0.2:9876"}));
when(configure.isACLEnabled()).thenReturn(true);
when(configure.isUseTLS()).thenReturn(false);
}
diff --git a/src/test/java/org/apache/rocketmq/dashboard/controller/OpsControllerTest.java b/src/test/java/org/apache/rocketmq/dashboard/controller/OpsControllerTest.java
index f864755..ce3ce0e 100644
--- a/src/test/java/org/apache/rocketmq/dashboard/controller/OpsControllerTest.java
+++ b/src/test/java/org/apache/rocketmq/dashboard/controller/OpsControllerTest.java
@@ -64,7 +64,7 @@ public class OpsControllerTest extends BaseControllerTest {
.andExpect(jsonPath("$.data").isMap())
.andExpect(jsonPath("$.data.useVIPChannel").value(false))
.andExpect(jsonPath("$.data.namesvrAddrList").isArray())
- .andExpect(jsonPath("$.data.namesvrAddrList", hasSize(1)))
+ .andExpect(jsonPath("$.data.namesvrAddrList", hasSize(2)))
.andExpect(jsonPath("$.data.namesvrAddrList[0]").value("127.0.0.1:9876"));
}
@@ -96,7 +96,6 @@ public class OpsControllerTest extends BaseControllerTest {
.andExpect(jsonPath("$.data").value(true));
}
-
@Test
public void testUpdateUseTLS() throws Exception {
final String url = "/ops/updateUseTLS.do";