Skip to content

Commit

Permalink
本次提交是为了解决alibaba#905 上面 dashboard 无法正常显示system rule 的cpu部分配置规则信息的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Crazy10552 committed Jul 16, 2019
1 parent 7dd20dd commit 7718a5d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package com.alibaba.csp.sentinel.dashboard.datasource.entity.rule;

import java.util.Date;

import com.alibaba.csp.sentinel.slots.system.SystemRule;

import java.util.Date;

/**
* @author leyou
*/
Expand All @@ -33,6 +33,7 @@ public class SystemRuleEntity implements RuleEntity {
private Long avgRt;
private Long maxThread;
private Double qps;
private Double avgCpu;

private Date gmtCreate;
private Date gmtModified;
Expand All @@ -43,6 +44,7 @@ public static SystemRuleEntity fromSystemRule(String app, String ip, Integer por
entity.setIp(ip);
entity.setPort(port);
entity.setAvgLoad(rule.getHighestSystemLoad());
entity.setAvgCpu(rule.getHighestCpuUsage());
entity.setAvgRt(rule.getAvgRt());
entity.setMaxThread(rule.getMaxThread());
entity.setQps(rule.getQps());
Expand Down Expand Up @@ -118,6 +120,14 @@ public void setQps(Double qps) {
this.qps = qps;
}

public Double getAvgCpu() {
return avgCpu;
}

public void setAvgCpu(Double avgCpu) {
this.avgCpu = avgCpu;
}

@Override
public Date getGmtCreate() {
return gmtCreate;
Expand All @@ -142,6 +152,7 @@ public SystemRule toRule() {
rule.setAvgRt(avgRt);
rule.setMaxThread(maxThread);
rule.setQps(qps);
rule.setHighestCpuUsage(avgCpu);
return rule;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo
rule.grade = 2;
} else if (rule.qps >= 0) {
rule.grade = 3;
}else if (rule.avgCpu >= 0) {
rule.grade = 4;
}
});
$scope.rulesPageConfig.totalCount = $scope.rules.length;
Expand Down Expand Up @@ -119,6 +121,9 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo
} else if (rule.qps != -1) {
ruleTypeDesc = 'QPS';
ruleTypeCount = rule.qps;
}else if (rule.avgCpu != -1) {
ruleTypeDesc = 'CPU';
ruleTypeCount = rule.avgCpu;
}

$scope.confirmDialog = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ app.service('SystemService', ['$http', function ($http) {
param.maxThread = rule.maxThread;
} else if (rule.grade == 3) {// qps
param.qps = rule.qps;
}else if (rule.grade == 4) {// cpu
param.avgCpu = rule.avgCpu;
}

return $http({
Expand All @@ -49,6 +51,8 @@ app.service('SystemService', ['$http', function ($http) {
param.maxThread = rule.maxThread;
} else if (rule.grade == 3) {// qps
param.qps = rule.qps;
}else if (rule.grade == 4) {// cpu
param.avgCpu = rule.avgCpu;
}
return $http({
url: '/system/save.json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@
<span ng-if="rule.avgRt >= 0">RT</span>
<span ng-if="rule.maxThread >= 0">线程数</span>
<span ng-if="rule.qps >= 0">QPS</span>
<span ng-if="rule.avgCpu >= 0">CPU</span>
</td>
<td style="word-wrap:break-word;word-break:break-all;">
<span ng-if="rule.avgLoad >= 0">{{rule.avgLoad}}</span>
<span ng-if="rule.avgRt >= 0">{{rule.avgRt}}</span>
<span ng-if="rule.maxThread >= 0">{{rule.maxThread}}</span>
<span ng-if="rule.qps >= 0">{{rule.qps}}</span>
<span ng-if="rule.avgCpu >= 0">{{rule.avgCpu}}</span>
</td>
<td>
<button class="btn btn-xs btn-default" type="button" ng-click="editRule(rule)" style="font-size: 12px; height:25px;">编辑</button>
Expand Down

0 comments on commit 7718a5d

Please sign in to comment.