mirror of
https://github.com/apache/rocketmq-dashboard.git
synced 2026-02-21 04:45:41 +08:00
Support dashboard v4-v5 switch And query for v5 topic (#198)
* Support dashboard v4-v5 switch And query for v5 topic * Modify tag name --------- Co-authored-by: yuanziwei <yuanziwei@xiaomi.com>
This commit is contained in:
@@ -56,6 +56,12 @@ public class TopicController {
|
||||
return topicService.fetchAllTopicList(skipSysProcess, skipRetryAndDlq);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/list.queryTopicType", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object listTopicType() {
|
||||
return topicService.examineAllTopicType();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/stats.query", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object stats(@RequestParam String topic) {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.rocketmq.dashboard.model.request;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TopicTypeList {
|
||||
private List<String> topicNameList;
|
||||
private List<String> messageTypeList;
|
||||
|
||||
public List<String> getTopicNameList() {
|
||||
return topicNameList;
|
||||
}
|
||||
|
||||
public void setTopicNameList(List<String> topicNameList) {
|
||||
this.topicNameList = topicNameList;
|
||||
}
|
||||
|
||||
public List<String> getMessageTypeList() {
|
||||
return messageTypeList;
|
||||
}
|
||||
|
||||
public void setMessageTypeList(List<String> messageTypeList) {
|
||||
this.messageTypeList = messageTypeList;
|
||||
}
|
||||
|
||||
public TopicTypeList(List<String> topicNameList, List<String> messageTypeList) {
|
||||
this.topicNameList = topicNameList;
|
||||
this.messageTypeList = messageTypeList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.rocketmq.dashboard.model.request;
|
||||
|
||||
public class TopicTypeMeta {
|
||||
private String topicName;
|
||||
private String messageType;
|
||||
|
||||
public String getTopicName() {
|
||||
return topicName;
|
||||
}
|
||||
|
||||
public void setTopicName(String topicName) {
|
||||
this.topicName = topicName;
|
||||
}
|
||||
|
||||
public String getMessageType() {
|
||||
return messageType;
|
||||
}
|
||||
|
||||
public void setMessageType(String messageType) {
|
||||
this.messageType = messageType;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ package org.apache.rocketmq.dashboard.service;
|
||||
|
||||
import org.apache.rocketmq.client.producer.SendResult;
|
||||
import org.apache.rocketmq.common.TopicConfig;
|
||||
import org.apache.rocketmq.dashboard.model.request.TopicTypeList;
|
||||
import org.apache.rocketmq.remoting.protocol.admin.TopicStatsTable;
|
||||
import org.apache.rocketmq.remoting.protocol.body.GroupList;
|
||||
import org.apache.rocketmq.remoting.protocol.body.TopicList;
|
||||
@@ -31,6 +32,8 @@ import java.util.List;
|
||||
public interface TopicService {
|
||||
TopicList fetchAllTopicList(boolean skipSysProcess, boolean skipRetryAndDlq);
|
||||
|
||||
TopicTypeList examineAllTopicType();
|
||||
|
||||
TopicStatsTable stats(String topic);
|
||||
|
||||
TopicRouteData route(String topic);
|
||||
|
||||
@@ -40,6 +40,8 @@ import org.apache.rocketmq.common.topic.TopicValidator;
|
||||
import org.apache.rocketmq.dashboard.config.RMQConfigure;
|
||||
import org.apache.rocketmq.dashboard.model.request.SendTopicMessageRequest;
|
||||
import org.apache.rocketmq.dashboard.model.request.TopicConfigInfo;
|
||||
import org.apache.rocketmq.dashboard.model.request.TopicTypeList;
|
||||
import org.apache.rocketmq.dashboard.model.request.TopicTypeMeta;
|
||||
import org.apache.rocketmq.dashboard.service.AbstractCommonService;
|
||||
import org.apache.rocketmq.dashboard.service.TopicService;
|
||||
import org.apache.rocketmq.remoting.RPCHook;
|
||||
@@ -54,7 +56,9 @@ import org.joor.Reflect;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -99,6 +103,41 @@ public class TopicServiceImpl extends AbstractCommonService implements TopicServ
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TopicTypeList examineAllTopicType() {
|
||||
ArrayList<TopicTypeMeta> topicTypes = new ArrayList<>();
|
||||
ArrayList<String> names = new ArrayList<>();
|
||||
ArrayList<String> messageTypes = new ArrayList<>();
|
||||
TopicList topicList = fetchAllTopicList(false, false);
|
||||
checkTopicType(topicList, topicTypes);
|
||||
topicTypes.sort((t1, t2) -> t1.getTopicName().compareTo(t2.getTopicName()));
|
||||
for (TopicTypeMeta topicTypeMeta : topicTypes) {
|
||||
names.add(topicTypeMeta.getTopicName());
|
||||
messageTypes.add(topicTypeMeta.getMessageType());
|
||||
}
|
||||
return new TopicTypeList(names, messageTypes);
|
||||
}
|
||||
|
||||
private void checkTopicType(TopicList topicList, ArrayList<TopicTypeMeta> topicTypes) {
|
||||
for (String topicName : topicList.getTopicList()) {
|
||||
TopicTypeMeta topicType = new TopicTypeMeta();
|
||||
topicType.setTopicName(topicName);
|
||||
if (topicName.startsWith("%R")) {
|
||||
topicType.setMessageType("RETRY");
|
||||
} else if (topicName.startsWith("%D")) {
|
||||
topicType.setMessageType("DELAY");
|
||||
} else if (topicName.startsWith("%S")) {
|
||||
topicType.setMessageType("SYSTEM");
|
||||
} else {
|
||||
List<TopicConfigInfo> topicConfigInfos = examineTopicConfig(topicName);
|
||||
if (!CollectionUtils.isEmpty(topicConfigInfos)) {
|
||||
topicType.setMessageType(topicConfigInfos.get(0).getMessageType());
|
||||
}
|
||||
}
|
||||
topicTypes.add(topicType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TopicStatsTable stats(String topic) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user