ISSUE #271 Separate System Topics from Normal topic list

This commit is contained in:
walking98
2019-05-09 18:58:45 +08:00
parent 20c969b11d
commit c7c0d95a47
5 changed files with 53 additions and 6 deletions

View File

@@ -20,10 +20,9 @@ package org.apache.rocketmq.console.service.impl;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
@@ -55,7 +54,20 @@ public class TopicServiceImpl extends AbstractCommonService implements TopicServ
@Override
public TopicList fetchAllTopicList() {
try {
return mqAdminExt.fetchAllTopicList();
TopicList sysTopics = getSystemTopicList();
TopicList allTopics = mqAdminExt.fetchAllTopicList();
Set<String> topics = new HashSet<>();
for (String topic: allTopics.getTopicList()) {
if (sysTopics.getTopicList().contains(topic)) {
topics.add(String.format("%s%s", "%SYS%", topic));
} else {
topics.add(topic);
}
}
allTopics.getTopicList().clear();
allTopics.getTopicList().addAll(topics);
return allTopics;
}
catch (Exception e) {
throw Throwables.propagate(e);
@@ -189,6 +201,24 @@ public class TopicServiceImpl extends AbstractCommonService implements TopicServ
return true;
}
private TopicList getSystemTopicList() {
DefaultMQProducer producer = new DefaultMQProducer(MixAll.SELF_TEST_PRODUCER_GROUP);
producer.setInstanceName(String.valueOf(System.currentTimeMillis()));
producer.setNamesrvAddr(rMQConfigure.getNamesrvAddr());
try {
producer.start();
return producer.getDefaultMQProducerImpl().getmQClientFactory().getMQClientAPIImpl().getSystemTopicList(20000L);
}
catch (Exception e) {
throw Throwables.propagate(e);
}
finally {
producer.shutdown();
}
}
@Override
public SendResult sendTopicMessageRequest(SendTopicMessageRequest sendTopicMessageRequest) {
DefaultMQProducer producer = new DefaultMQProducer(MixAll.SELF_TEST_PRODUCER_GROUP);

View File

@@ -83,5 +83,6 @@ var en = {
"USER_NAME":"Username",
"PASSWORD":"Password",
"NO_DATA":"Don't have ",
"SYSTEM":"SYSTEM",
"WELCOME":"Hi, welcome using RocketMQ Console"
}

View File

@@ -83,5 +83,6 @@ var zh = {
"USER_NAME":"用户名",
"PASSWORD":"密码",
"NO_DATA":"不存在 ",
"SYSTEM":"系统",
"WELCOME":"您好欢迎使用RocketMQ控制台"
}

View File

@@ -33,6 +33,7 @@ module.controller('topicController', ['$scope', 'ngDialog', '$http','Notificatio
$scope.filterNormal = true
$scope.filterRetry = false
$scope.filterDLQ = false
$scope.filterSystem = false
$scope.allTopicList = [];
$scope.topicShowList = [];
@@ -68,6 +69,9 @@ module.controller('topicController', ['$scope', 'ngDialog', '$http','Notificatio
$scope.$watch('filterDLQ', function() {
$scope.filterList(1);
});
$scope.$watch('filterSystem', function() {
$scope.filterList(1);
});
$scope.filterList = function (currentPage) {
var lowExceptStr = $scope.filterStr.toLowerCase();
var canShowList = [];
@@ -97,6 +101,11 @@ module.controller('topicController', ['$scope', 'ngDialog', '$http','Notificatio
return true
}
}
if($scope.filterSystem){
if(str.startsWith("%S")){
return true
}
}
if($scope.filterNormal){
if(str.startsWith("%") == false){
return true

View File

@@ -28,6 +28,8 @@
</md-checkbox>
<md-checkbox aria-label="Checkbox" ng-model="filterDLQ" class="md-primary">{{'DLQ' | translate}}
</md-checkbox>
<md-checkbox aria-label="Checkbox" ng-model="filterSystem" class="md-primary">{{'SYSTEM' | translate}}
</md-checkbox>
<button class="btn btn-raised btn-sm btn-primary" type="button" ng-click="openAddDialog()">{{'ADD' |
translate}}/ {{'UPDATE' | translate}}
</button>
@@ -46,7 +48,7 @@
</tr>
<tr ng-repeat="topic in topicShowList">
<td class="text-center">{{topic}}</td>
<td class="text-center">
<td class="text-left">
<button class="btn btn-raised btn-sm btn-primary" type="button"
ng-click="statsView(topic)">{{'STATUS' | translate}}
</button>
@@ -58,15 +60,19 @@
ng-click="consumerView(topic)">consumer {{'MANAGE' | translate}}
</button>
<button class="btn btn-raised btn-sm btn-primary" type="button"
ng-show="{{!topic.startsWith('%S')}}"
ng-click="openUpdateDialog(topic)">topic {{'CONFIG' |translate}}
</button>
<button class="btn btn-raised btn-sm btn-primary" type="button"
ng-show="{{!topic.startsWith('%S')}}"
ng-click="openSendTopicMessageDialog(topic)">{{'SEND_MSG' | translate}}
</button>
<button class="btn btn-raised btn-sm btn-danger" type="button"
ng-show="{{!topic.startsWith('%S')}}"
ng-click="openConsumerResetOffsetDialog(topic)">{{'RESET_CUS_OFFSET' | translate}}
</button>
<button class="btn btn-raised btn-sm btn-danger" type="button"
ng-show="{{!topic.startsWith('%S')}}"
ng-confirm-click="Are you sure to delete?"
confirmed-click="deleteTopic(topic)">{{'DELETE' | translate}}
</button>