Skip to content

Commit e7cb315

Browse files
1294566108yuanziwei
andauthored
Support FIFO-Type SubGroup Add、Update and Query For V5 (#204)
* Support dashboard v4-v5 switch And query for v5 topic * Modify tag name * Support subGroup FIFO Type Query and Update --------- Co-authored-by: yuanziwei <[email protected]>
1 parent 21dc2ac commit e7cb315

File tree

5 files changed

+159
-8
lines changed

5 files changed

+159
-8
lines changed

src/main/java/org/apache/rocketmq/dashboard/model/GroupConsumeInfo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class GroupConsumeInfo implements Comparable<GroupConsumeInfo> {
2727
private MessageModel messageModel;
2828
private int consumeTps;
2929
private long diffTotal = -1;
30+
private String subGroupType = "NORMAL";
31+
3032

3133
public String getGroup() {
3234
return group;
@@ -91,4 +93,12 @@ public String getVersion() {
9193
public void setVersion(String version) {
9294
this.version = version;
9395
}
96+
97+
public String getSubGroupType() {
98+
return subGroupType;
99+
}
100+
101+
public void setSubGroupType(String subGroupType) {
102+
this.subGroupType = subGroupType;
103+
}
94104
}

src/main/java/org/apache/rocketmq/dashboard/service/impl/ConsumerServiceImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ public GroupConsumeInfo queryGroup(String consumerGroup) {
177177
}
178178

179179
ConsumerConnection consumerConnection = null;
180+
boolean isFifoType = examineSubscriptionGroupConfig(consumerGroup)
181+
.stream().map(ConsumerConfigInfo::getSubscriptionGroupConfig)
182+
.allMatch(SubscriptionGroupConfig::isConsumeMessageOrderly);
183+
180184
try {
181185
consumerConnection = mqAdminExt.examineConsumerConnectionInfo(consumerGroup);
182186
}
@@ -185,6 +189,13 @@ public GroupConsumeInfo queryGroup(String consumerGroup) {
185189
}
186190

187191
groupConsumeInfo.setGroup(consumerGroup);
192+
if (SYSTEM_GROUP_SET.contains(consumerGroup)) {
193+
groupConsumeInfo.setSubGroupType("SYSTEM");
194+
} else if (isFifoType) {
195+
groupConsumeInfo.setSubGroupType("FIFO");
196+
} else {
197+
groupConsumeInfo.setSubGroupType("NORMAL");
198+
}
188199

189200
if (consumeStats != null) {
190201
groupConsumeInfo.setConsumeTps((int)consumeStats.getConsumeTps());

src/main/resources/static/src/consumer.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
4545
$scope.writeOperationEnabled = $scope.userRole == null ? true : ($scope.userRole == 1 ? true : false);
4646
$scope.filterNormal = true;
4747
$scope.filterSystem = false;
48+
$scope.filterFIFO = false;
4849

4950
$scope.doSort = function () {// todo how to change this fe's code ? (it's dirty)
5051
if ($scope.sortKey == 'diffTotal') {
@@ -75,7 +76,10 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
7576

7677
$http({
7778
method: "GET",
78-
url: "consumer/groupList.query"
79+
url: "consumer/groupList.query",
80+
params: {
81+
skipSysGroup: false,
82+
}
7983
}).success(function (resp) {
8084
if (resp.status == 0) {
8185
$scope.allConsumerGrouopList = resp.data;
@@ -135,16 +139,28 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
135139
$scope.filterList(1);
136140
});
137141

138-
$scope.filterByType = function (str) {
142+
$scope.$watch('filterFIFO', function () {
143+
$scope.filterList(1);
144+
});
145+
146+
$scope.filterByType = function (str, type,version) {
139147
if ($scope.filterSystem) {
140-
if (str.startsWith("%S")) {
148+
if (type === "SYSTEM") {
141149
return true
142150
}
143151
}
144152
if ($scope.filterNormal) {
145-
if (str.startsWith("%") == false) {
153+
if (type === "NORMAL") {
146154
return true
147155
}
156+
if(!version && type === "FIFO"){
157+
return true;
158+
}
159+
}
160+
if ($scope.filterFIFO) {
161+
if (type === "FIFO") {
162+
return true;
163+
}
148164
}
149165
return false;
150166
};
@@ -154,7 +170,7 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
154170
var canShowList = [];
155171
$scope.allConsumerGrouopList.forEach(function (element) {
156172
console.log(element)
157-
if ($scope.filterByType(element.group)) {
173+
if ($scope.filterByType(element.group, element.subGroupType, $scope.rmqVersion)) {
158174
if (element.group.toLowerCase().indexOf(lowExceptStr) != -1) {
159175
canShowList.push(element);
160176
}
@@ -189,6 +205,7 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
189205
subscriptionGroupConfig: {
190206
groupName: "",
191207
consumeEnable: true,
208+
consumeMessageOrderly: false,
192209
consumeFromMinEnable: true,
193210
consumeBroadcastEnable: true,
194211
retryQueueNums: 1,
@@ -211,7 +228,7 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
211228
// Refresh topic list
212229
$scope.refreshConsumerData();
213230
},
214-
template: 'consumerModifyDialog',
231+
template: $scope.rmqVersion ? 'consumerModifyDialogForV5' : 'consumerModifyDialog',
215232
controller: 'consumerModifyDialogController',
216233
data: {
217234
consumerRequestList: request,

src/main/resources/static/src/controller.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
* limitations under the License.
1616
*/
1717
app.controller('AppCtrl', ['$scope','$window','$translate','$http','Notification', function ($scope,$window,$translate, $http, Notification) {
18-
$scope.rmqVersion = localStorage.getItem("isV5") === "true" ? true : false;
18+
$scope.rmqVersion = localStorage.getItem("isV5");
1919

2020
$scope.changeTranslate = function(langKey){
2121
$translate.use(langKey);
2222
}
2323

2424
$scope.changeRMQVersion = function (version) {
2525
$scope.rmqVersion = version === 5;
26-
localStorage.setItem("isV5", $scope.rmqVersion);
26+
var v = version === 5;
27+
localStorage.setItem("isV5", v);
2728
}
2829

2930
$scope.logout = function(){

src/main/resources/static/view/pages/consumer.html

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
</div>
2727
<md-checkbox aria-label="Checkbox" ng-model="filterNormal" class="md-primary">{{'NORMAL' | translate}}
2828
</md-checkbox>
29+
<md-checkbox aria-label="Checkbox" ng-show="rmqVersion" ng-model="filterFIFO" class="md-primary">{{'FIFO' | translate}}
30+
</md-checkbox>
2931
<md-checkbox aria-label="Checkbox" ng-model="filterSystem" class="md-primary">{{'SYSTEM' | translate}}
3032
</md-checkbox>
3133
<button class="btn btn-raised btn-sm btn-primary" type="button" ng-show="{{writeOperationEnabled}}"
@@ -320,6 +322,116 @@ <h4 class="modal-title">{{'SUBSCRIPTION_CHANGE'|translate}}</h4>
320322
</div>
321323
</script>
322324

325+
<script type="text/ng-template" id="consumerModifyDialogForV5">
326+
<div>
327+
<div>
328+
<div class="modal-header">
329+
<h4 class="modal-title">{{'SUBSCRIPTION_CHANGE'|translate}}</h4>
330+
</div>
331+
<div class="modal-body " ng-repeat="item in ngDialogData.consumerRequestList">
332+
<form id="addAppForm1" name="addAppForm" class="form-horizontal" novalidate>
333+
<div class="form-group" ng-hide="ngDialogData.bIsUpdate">
334+
<label class="control-label col-sm-3">clusterName:</label>
335+
<div class="col-sm-9">
336+
<select name="mySelectClusterNameList" multiple chosen
337+
ng-model="item.clusterNameList"
338+
ng-options="clusterNameItem for clusterNameItem in ngDialogData.allClusterNameList">
339+
<option value=""></option>
340+
</select>
341+
</div>
342+
</div>
343+
<div class="form-group">
344+
<label class="control-label col-sm-3">brokerName:</label>
345+
<div class="col-sm-9">
346+
<select name="mySelectBrokerNameList" multiple chosen
347+
ng-disabled="ngDialogData.bIsUpdate"
348+
ng-model="item.brokerNameList"
349+
ng-options="brokerNameItem for brokerNameItem in ngDialogData.allBrokerNameList">
350+
<option value=""></option>
351+
</select>
352+
</div>
353+
</div>
354+
<div class="form-group">
355+
<label class="control-label col-sm-3">groupName:</label>
356+
<div class="col-sm-9">
357+
<input class="form-control" ng-model="item.subscriptionGroupConfig.groupName" type="text"
358+
ng-disabled="ngDialogData.bIsUpdate" required/>
359+
<span class="text-danger" ng-show="addAppForm.name.$error.required">编号不能为空.</span>
360+
</div>
361+
</div>
362+
<div class="form-group">
363+
<label class="control-label col-sm-3">consumeEnable:</label>
364+
<div class="col-sm-9">
365+
<md-switch class="md-primary" ng-disabled="{{!ngDialogData.writeOperationEnabled}}" md-no-ink
366+
aria-label="Switch No Ink" ng-model="item.subscriptionGroupConfig.consumeEnable">
367+
</md-switch>
368+
</div>
369+
</div>
370+
<div class="form-group">
371+
<label class="control-label col-sm-3">consumeOrderlyEnable:</label>
372+
<div class="col-sm-9">
373+
<md-switch class="md-primary custom-md-switch" eng-disabled="{{!ngDialogData.writeOperationEnabled}}" md-no-ink
374+
aria-label="Switch No Ink" ng-model="item.subscriptionGroupConfig.consumeMessageOrderly">
375+
</md-switch>
376+
<span style="font-size: 12px;">[Pay Attention: FIFO ConsumerGroup Need Open 'consumeOrderlyEnable' Option]</span>
377+
</div>
378+
379+
</div>
380+
<div class="form-group">
381+
<label class="control-label col-sm-3">consumeBroadcastEnable:</label>
382+
<div class="col-sm-9">
383+
<md-switch class="md-primary" ng-disabled="{{!ngDialogData.writeOperationEnabled}}" md-no-ink
384+
aria-label="Switch No Ink"
385+
ng-model="item.subscriptionGroupConfig.consumeBroadcastEnable">
386+
</md-switch>
387+
</div>
388+
</div>
389+
<div class="form-group">
390+
<label class="control-label col-sm-3">retryQueueNums:</label>
391+
<div class="col-sm-9">
392+
<input class="form-control" ng-model="item.subscriptionGroupConfig.retryQueueNums"
393+
type="text" ng-disabled="{{!ngDialogData.writeOperationEnabled}}"
394+
required/>
395+
<span class="text-danger" ng-show="addAppForm.name.$error.required">编号不能为空.</span>
396+
</div>
397+
</div>
398+
<div class="form-group">
399+
<label class="control-label col-sm-3">brokerId:</label>
400+
<div class="col-sm-9">
401+
<input class="form-control" ng-model="item.subscriptionGroupConfig.brokerId" type="text"
402+
ng-disabled="{{!ngDialogData.writeOperationEnabled}}" required/>
403+
<span class="text-danger" ng-show="addAppForm.name.$error.required">编号不能为空.</span>
404+
</div>
405+
</div>
406+
<div class="form-group">
407+
<label class="control-label col-sm-3">whichBrokerWhenConsumeSlowly:</label>
408+
<div class="col-sm-9">
409+
<input class="form-control"
410+
ng-model="item.subscriptionGroupConfig.whichBrokerWhenConsumeSlowly" type="text"
411+
ng-disabled="{{!ngDialogData.writeOperationEnabled}}" required/>
412+
<span class="text-danger" ng-show="addAppForm.name.$error.required">编号不能为空.</span>
413+
</div>
414+
</div>
415+
</form>
416+
<div class="modal-footer">
417+
<div class="ngdialog-buttons">
418+
<button type="button" class="ngdialog-button ngdialog-button-primary"
419+
ng-disabled="addAppForm.$invalid"
420+
ng-show="{{ngDialogData.writeOperationEnabled}}"
421+
ng-click="postConsumerRequest(item)">{{ 'COMMIT' | translate }}
422+
</button>
423+
<button type="button" class="ngdialog-button ngdialog-button-secondary"
424+
ng-click="closeThisDialog('Cancel')">{{ 'CLOSE' | translate }}
425+
</button>
426+
</div>
427+
</div>
428+
</div>
429+
</div>
430+
</div>
431+
432+
</div>
433+
</script>
434+
323435
<!--consumer monitor config-->
324436
<script type="text/ng-template" id="consumerMonitorDialog">
325437
<div class="modal-header">

0 commit comments

Comments
 (0)