Skip to content

Commit a450594

Browse files
authored
fix: Add consumer global refresh and fix the problem #290 (#291)
1 parent bbabd1c commit a450594

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

src/main/java/org/apache/rocketmq/dashboard/controller/ConsumerController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public Object refresh(String address,
5858
return consumerService.refreshGroup(address, consumerGroup);
5959
}
6060

61+
@RequestMapping(value = "group.refresh.all")
62+
@ResponseBody
63+
public Object refreshAll(String address) {
64+
return consumerService.refreshAllGroup(address);
65+
}
66+
6167
@RequestMapping(value = "/group.query")
6268
@ResponseBody
6369
public Object groupQuery(@RequestParam String consumerGroup, String address) {

src/main/java/org/apache/rocketmq/dashboard/service/ConsumerService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,6 @@ public interface ConsumerService {
5757
ConsumerRunningInfo getConsumerRunningInfo(String consumerGroup, String clientId, boolean jstack);
5858

5959
Object refreshGroup(String address, String consumerGroup);
60+
61+
Object refreshAllGroup(String address);
6062
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,18 @@ public GroupConsumeInfo refreshGroup(String address, String consumerGroup) {
529529
if (groupConsumeInfo.getGroup().equals(consumerGroup)) {
530530
GroupConsumeInfo updatedInfo = queryGroup(consumerGroup, "");
531531
updatedInfo.setUpdateTime(new Date());
532+
updatedInfo.setGroup(consumerGroup);
532533
cacheConsumeInfoList.set(i, updatedInfo);
533534
return updatedInfo;
534535
}
535536
}
536537
}
537538
throw new RuntimeException("No consumer group information available");
538539
}
540+
541+
@Override
542+
public List<GroupConsumeInfo> refreshAllGroup(String address) {
543+
cacheConsumeInfoList.clear();
544+
return queryGroupList(false, address);
545+
}
539546
}

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
9898
});
9999
}
100100

101-
$scope.refreshConsumerData = function () {
101+
$scope.queryConsumerData = function () {
102102
//Show loader
103103
$('#loaderConsumer').removeClass("hide-myloader");
104104

@@ -123,6 +123,30 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
123123
}
124124
});
125125
};
126+
$scope.refreshConsumerData = function () {
127+
//Show loader
128+
$('#loaderConsumer').removeClass("hide-myloader");
129+
130+
$http({
131+
method: "GET",
132+
url: "consumer/group.refresh.all",
133+
params: {
134+
skipSysGroup: false
135+
}
136+
}).success(function (resp) {
137+
if (resp.status == 0) {
138+
$scope.allConsumerGrouopList = resp.data;
139+
console.log($scope.allConsumerGrouopList);
140+
console.log(JSON.stringify(resp));
141+
$scope.showConsumerGroupList($scope.paginationConf.currentPage, $scope.allConsumerGrouopList.length);
142+
143+
//Hide loader
144+
$('#loaderConsumer').addClass("hide-myloader");
145+
} else {
146+
Notification.error({message: resp.errMsg, delay: 2000});
147+
}
148+
});
149+
};
126150
$scope.monitor = function (consumerGroupName) {
127151
$http({
128152
method: "GET",
@@ -148,12 +172,12 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
148172
$scope.intervalProcess = null;
149173
}
150174
if ($scope.intervalProcessSwitch) {
151-
$scope.intervalProcess = setInterval($scope.refreshConsumerData, 10000);
175+
$scope.intervalProcess = setInterval($scope.queryConsumerData, 10000);
152176
}
153177
});
154178

155179

156-
$scope.refreshConsumerData();
180+
$scope.queryConsumerData();
157181
$scope.filterStr = "";
158182
$scope.$watch('filterStr', function () {
159183
$scope.paginationConf.currentPage = 1;
@@ -255,7 +279,7 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
255279
ngDialog.open({
256280
preCloseCallback: function (value) {
257281
// Refresh topic list
258-
$scope.refreshConsumerData();
282+
$scope.queryConsumerData();
259283
},
260284
template: $scope.rmqVersion ? 'consumerModifyDialogForV5' : 'consumerModifyDialog',
261285
controller: 'consumerModifyDialogController',
@@ -339,7 +363,7 @@ module.controller('consumerController', ['$scope', 'ngDialog', '$http', 'Notific
339363
ngDialog.open({
340364
preCloseCallback: function (value) {
341365
// Refresh topic list
342-
$scope.refreshConsumerData();
366+
$scope.queryConsumerData();
343367
},
344368
template: 'deleteConsumerDialog',
345369
controller: 'deleteConsumerDialogController',

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
<button class="btn btn-raised btn-sm btn-primary" type="button" ng-show="{{writeOperationEnabled}}"
3434
ng-click="openAddDialog()">{{'ADD' | translate}}/ {{'UPDATE' | translate}}
3535
</button>
36+
<button class="btn btn-raised btn-sm btn-primary" type="button" ng-click="refreshConsumerData()">
37+
{{'REFRESH' | translate}}
38+
</button>
3639
<md-switch class="md-primary" md-no-ink aria-label="Switch No Ink" ng-model="intervalProcessSwitch">
3740
{{'AUTO_REFRESH' | translate}}
3841
</md-switch>

0 commit comments

Comments
 (0)