From e92b3a352ad297edc8ac2e8ebbbca49273388e4a Mon Sep 17 00:00:00 2001 From: Crazy10552 Date: Thu, 18 Jul 2019 09:25:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E6=AC=A1=E6=8F=90=E4=BA=A4=E6=98=AF?= =?UTF-8?q?=E4=B8=BA=E4=BA=86=E8=A7=A3=E5=86=B3https://github.com/alibaba/?= =?UTF-8?q?Sentinel/issues/905=20=E4=B8=8A=E9=9D=A2=20dashboard=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E6=98=BE=E7=A4=BAsystem=20?= =?UTF-8?q?rule=20=E7=9A=84cpu=E9=83=A8=E5=88=86=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=A7=84=E5=88=99=E4=BF=A1=E6=81=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SystemController.java | 87 ++++++++++++++++--- .../entity/rule/SystemRuleEntity.java | 39 +++++++-- .../app/scripts/controllers/system.js | 31 ++++--- .../app/scripts/services/systemservice.js | 9 +- .../app/views/dialog/system-rule-dialog.html | 33 +++---- .../webapp/resources/app/views/system.html | 6 +- .../src/main/webapp/resources/dist/js/app.js | 5 +- 7 files changed, 158 insertions(+), 52 deletions(-) diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java index 8e99718bc3..ade1692af0 100755 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java @@ -88,10 +88,33 @@ private int countNotNullAndNotNegative(Number... values) { return notNullCount; } + /** + * @modify + * 目前代码里做了如下几点修改: + * 1】修改属性名称avgLoad 修改为highestSystemLoad + * 2】修改属性名称avgCpu 修改为highestCpuUsage + * 3】调用countNotNullAndNotNegative非空校验方法里增加参数highestCpuUsage, + * 4】修改notNullCount部分判断错误提示语,因为目前countNotNullAndNotNegative里针对=0的情况也做了限制 + * 5】对于highestSystemLoad、highestCpuUsage增加>1 的这个判断 + * @author tianyang5@yeah.net + * @time 2019年7月17日 18:30:32 + * @modify + * + * @param request + * @param app + * @param ip + * @param port + * @param highestSystemLoad + * @param highestCpuUsage + * @param avgRt + * @param maxThread + * @param qps + * @return + */ @ResponseBody @RequestMapping("/new.json") Result add(HttpServletRequest request, - String app, String ip, Integer port, Double avgLoad, Long avgRt, Long maxThread, Double qps) { + String app, String ip, Integer port, Double highestSystemLoad,Double highestCpuUsage, Long avgRt, Long maxThread, Double qps) { AuthUser authUser = authService.getAuthUser(request); authUser.authTarget(app, PrivilegeType.WRITE_RULE); if (StringUtil.isBlank(app)) { @@ -103,21 +126,32 @@ Result add(HttpServletRequest request, if (port == null) { return Result.ofFail(-1, "port can't be null"); } - int notNullCount = countNotNullAndNotNegative(avgLoad, avgRt, maxThread, qps); + + int notNullCount = countNotNullAndNotNegative(highestSystemLoad, avgRt, maxThread, qps,highestCpuUsage); if (notNullCount != 1) { - return Result.ofFail(-1, "only one of [avgLoad, avgRt, maxThread, qps] " - + "value must be set >= 0, but " + notNullCount + " values get"); + return Result.ofFail(-1, "only one of [highestSystemLoad, avgRt, maxThread, qps,highestCpuUsage] " + + "value must be set > 0, but " + notNullCount + " values get"); + } + if ( null!=highestCpuUsage && 1 < highestCpuUsage ) { + return Result.ofFail(-1, "highestCpuUsage must <= 1"); } SystemRuleEntity entity = new SystemRuleEntity(); entity.setApp(app.trim()); entity.setIp(ip.trim()); entity.setPort(port); // -1 is a fake value - if (avgLoad != null) { - entity.setAvgLoad(avgLoad); + if ( null != highestSystemLoad ) { + entity.setHighestSystemLoad(highestSystemLoad); + } else { + entity.setHighestSystemLoad(-1D); + } + + if ( null != highestCpuUsage ) { + entity.setHighestCpuUsage(highestCpuUsage); } else { - entity.setAvgLoad(-1D); + entity.setHighestCpuUsage(-1D); } + if (avgRt != null) { entity.setAvgRt(avgRt); } else { @@ -148,10 +182,30 @@ Result add(HttpServletRequest request, return Result.ofSuccess(entity); } + /** + * @modify + * 目前代码里做了如下几点修改: + * 1】修改属性名称avgLoad 修改为highestSystemLoad + * 2】修改属性名称avgCpu 修改为highestCpuUsage + * 1】对于highestSystemLoad、highestCpuUsage增加>1 的这个判断,调整原先<0的判断,调整为<=0 等于0的这种规则设置了也没有意义 + * @author tianyang5@yeah.net + * @time 2019年7月17日 18:30:32 + * @modify + * + * @param request + * @param id + * @param app + * @param highestSystemLoad + * @param highestCpuUsage + * @param avgRt + * @param maxThread + * @param qps + * @return + */ @ResponseBody @RequestMapping("/save.json") Result updateIfNotNull(HttpServletRequest request, - Long id, String app, Double avgLoad, Long avgRt, Long maxThread, Double qps) { + Long id, String app, Double highestSystemLoad,Double highestCpuUsage, Long avgRt, Long maxThread, Double qps) { AuthUser authUser = authService.getAuthUser(request); if (id == null) { return Result.ofFail(-1, "id can't be null"); @@ -164,11 +218,20 @@ Result updateIfNotNull(HttpServletRequest request, if (StringUtil.isNotBlank(app)) { entity.setApp(app.trim()); } - if (avgLoad != null) { - if (avgLoad < 0) { - return Result.ofFail(-1, "avgLoad must >= 0"); + if (highestSystemLoad != null) { + if (highestSystemLoad <= 0) { + return Result.ofFail(-1, "highestSystemLoad must >= 0"); + } + entity.setHighestSystemLoad(highestSystemLoad); + } + if (highestCpuUsage != null) { + if (highestCpuUsage < 0) { + return Result.ofFail(-1, "highestCpuUsage must >= 0"); + } + if (highestCpuUsage > 1) { + return Result.ofFail(-1, "highestCpuUsage must <= 1"); } - entity.setAvgLoad(avgLoad); + entity.setHighestCpuUsage(highestCpuUsage); } if (avgRt != null) { if (avgRt < 0) { diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java index 08041b0a76..22e3d5781f 100755 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java @@ -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 */ @@ -29,10 +29,21 @@ public class SystemRuleEntity implements RuleEntity { private String app; private String ip; private Integer port; - private Double avgLoad; + /** + * 对应SystemRule 里的属性highestSystemLoad,这里做下调整 + * @author tianyang5@yeah.net + * @time 2019年7月17日 18:30:32 + */ + private Double highestSystemLoad; private Long avgRt; private Long maxThread; private Double qps; + /** + * 对应SystemRule 里的属性highestCpuUsage + * @author tianyang5@yeah.net + * @time 2019年7月17日 18:30:32 + */ + private Double highestCpuUsage; private Date gmtCreate; private Date gmtModified; @@ -42,7 +53,8 @@ public static SystemRuleEntity fromSystemRule(String app, String ip, Integer por entity.setApp(app); entity.setIp(ip); entity.setPort(port); - entity.setAvgLoad(rule.getHighestSystemLoad()); + entity.setHighestSystemLoad(rule.getHighestSystemLoad()); + entity.setHighestCpuUsage(rule.getHighestCpuUsage()); entity.setAvgRt(rule.getAvgRt()); entity.setMaxThread(rule.getMaxThread()); entity.setQps(rule.getQps()); @@ -86,12 +98,12 @@ public void setApp(String app) { this.app = app; } - public Double getAvgLoad() { - return avgLoad; + public Double getHighestSystemLoad() { + return highestSystemLoad; } - public void setAvgLoad(Double avgLoad) { - this.avgLoad = avgLoad; + public void setHighestSystemLoad(Double highestSystemLoad) { + this.highestSystemLoad = highestSystemLoad; } public Long getAvgRt() { @@ -118,6 +130,14 @@ public void setQps(Double qps) { this.qps = qps; } + public Double getHighestCpuUsage() { + return highestCpuUsage; + } + + public void setHighestCpuUsage(Double highestCpuUsage) { + this.highestCpuUsage = highestCpuUsage; + } + @Override public Date getGmtCreate() { return gmtCreate; @@ -138,10 +158,11 @@ public void setGmtModified(Date gmtModified) { @Override public SystemRule toRule() { SystemRule rule = new SystemRule(); - rule.setHighestSystemLoad(avgLoad); + rule.setHighestSystemLoad(highestSystemLoad); rule.setAvgRt(avgRt); rule.setMaxThread(maxThread); rule.setQps(qps); + rule.setHighestCpuUsage(highestCpuUsage); return rule; } } diff --git a/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js b/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js index ff754727e8..ae76bd47ad 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js +++ b/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js @@ -38,7 +38,7 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo $scope.rules = data.data; $.each($scope.rules, function (idx, rule) { // rule.orginEnable = rule.enable; - if (rule.avgLoad >= 0) { + if (rule.highestSystemLoad >= 0) { rule.grade = 0; } else if (rule.avgRt >= 0) { rule.grade = 1; @@ -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.highestCpuUsage >= 0) { + rule.grade = 4; } }); $scope.rulesPageConfig.totalCount = $scope.rules.length; @@ -107,9 +109,9 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo $scope.currentRule = rule; var ruleTypeDesc = ''; var ruleTypeCount = null; - if (rule.avgLoad != -1) { - ruleTypeDesc = 'LOAD'; - ruleTypeCount = rule.avgLoad; + if (rule.highestSystemLoad != -1) { + ruleTypeDesc = '系统LOAD'; + ruleTypeCount = rule.highestSystemLoad; } else if (rule.avgRt != -1) { ruleTypeDesc = 'RT'; ruleTypeCount = rule.avgRt; @@ -119,6 +121,9 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo } else if (rule.qps != -1) { ruleTypeDesc = 'QPS'; ruleTypeCount = rule.qps; + }else if (rule.highestCpuUsage != -1) { + ruleTypeDesc = 'CPU 使用率'; + ruleTypeCount = rule.highestCpuUsage; } $scope.confirmDialog = { @@ -159,8 +164,10 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo if (data.code == 0) { getMachineRules(); confirmDialog.close(); - } else { - alert + } else if(data.msg!=null){ + alert(data.msg); + } else{ + alert('失败!'); } }); }; @@ -170,8 +177,10 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo if (data.code == 0) { getMachineRules(); systemRuleDialog.close(); - } else { - alert('失败!'); + } else if(data.msg!=null){ + alert(data.msg); + }else{ + alert('失败!'); } }); }; @@ -190,8 +199,10 @@ app.controller('SystemCtl', ['$scope', '$stateParams', 'SystemService', 'ngDialo } else { confirmDialog.close(); } - } else { - alert('失败!'); + } else if(data.msg!=null){ + alert(data.msg); + }else{ + alert('失败!'); } }); } diff --git a/sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js b/sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js index a912eb577a..d3ca68ed56 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js +++ b/sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js @@ -21,13 +21,15 @@ app.service('SystemService', ['$http', function ($http) { port: rule.port }; if (rule.grade == 0) {// avgLoad - param.avgLoad = rule.avgLoad; + param.highestSystemLoad = rule.highestSystemLoad; } else if (rule.grade == 1) {// avgRt param.avgRt = rule.avgRt; } else if (rule.grade == 2) {// maxThread param.maxThread = rule.maxThread; } else if (rule.grade == 3) {// qps param.qps = rule.qps; + }else if (rule.grade == 4) {// cpu + param.highestCpuUsage = rule.highestCpuUsage; } return $http({ @@ -42,14 +44,17 @@ app.service('SystemService', ['$http', function ($http) { id: rule.id, }; if (rule.grade == 0) {// avgLoad - param.avgLoad = rule.avgLoad; + param.highestSystemLoad = rule.highestSystemLoad; } else if (rule.grade == 1) {// avgRt param.avgRt = rule.avgRt; } else if (rule.grade == 2) {// maxThread param.maxThread = rule.maxThread; } else if (rule.grade == 3) {// qps param.qps = rule.qps; + }else if (rule.grade == 4) {// cpu + param.highestCpuUsage = rule.highestCpuUsage; } + return $http({ url: '/system/save.json', params: param, diff --git a/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html b/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html index 728909d541..a9fd32b502 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html +++ b/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html @@ -9,40 +9,41 @@
- -  LOAD   + +  系统LOAD    RT    线程数   -  入口 QPS +  入口 QPS + +  CPU 使用率   +
- -  LOAD   + +  系统LOAD    RT    线程数   -  入口 QPS +  入口 QPS + +  CPU 使用率   +
- - - - + + + + +
diff --git a/sentinel-dashboard/src/main/webapp/resources/app/views/system.html b/sentinel-dashboard/src/main/webapp/resources/app/views/system.html index 80fa9b29f0..f522dda29b 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/views/system.html +++ b/sentinel-dashboard/src/main/webapp/resources/app/views/system.html @@ -45,16 +45,18 @@ - LOAD + 系统LOAD RT 线程数 QPS + CPU使用率 - {{rule.avgLoad}} + {{rule.highestSystemLoad}} {{rule.avgRt}} {{rule.maxThread}} {{rule.qps}} + {{rule.highestCpuUsage}} diff --git a/sentinel-dashboard/src/main/webapp/resources/dist/js/app.js b/sentinel-dashboard/src/main/webapp/resources/dist/js/app.js index 7b99240081..3326334ff1 100755 --- a/sentinel-dashboard/src/main/webapp/resources/dist/js/app.js +++ b/sentinel-dashboard/src/main/webapp/resources/dist/js/app.js @@ -1 +1,4 @@ -"use strict";var app;angular.module("sentinelDashboardApp",["oc.lazyLoad","ui.router","ui.bootstrap","angular-loading-bar","ngDialog","ui.bootstrap.datetimepicker","ui-notification","rzTable","angular-clipboard","selectize","angularUtils.directives.dirPagination"]).factory("AuthInterceptor",["$window","$state",function(t,r){return{responseError:function(e){return 401===e.status&&(t.localStorage.removeItem("session_sentinel_admin"),r.go("login")),e},response:function(e){return e},request:function(e){return e},requestError:function(e){return e}}}]).config(["$stateProvider","$urlRouterProvider","$ocLazyLoadProvider","$httpProvider",function(e,t,r,a){a.interceptors.push("AuthInterceptor"),r.config({debug:!1,events:!0}),t.otherwise("/dashboard/home"),e.state("login",{url:"/login",templateUrl:"app/views/login.html",controller:"LoginCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/login.js"]})}]}}).state("dashboard",{url:"/dashboard",templateUrl:"app/views/dashboard/main.html",resolve:{loadMyDirectives:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/directives/header/header.js","app/scripts/directives/sidebar/sidebar.js","app/scripts/directives/sidebar/sidebar-search/sidebar-search.js"]})}]}}).state("dashboard.home",{url:"/home",templateUrl:"app/views/dashboard/home.html",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/main.js"]})}]}}).state("dashboard.flowV1",{templateUrl:"app/views/flow_v1.html",url:"/flow/:app",controller:"FlowControllerV1",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/flow_v1.js"]})}]}}).state("dashboard.flow",{templateUrl:"app/views/flow_v2.html",url:"/v2/flow/:app",controller:"FlowControllerV2",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/flow_v2.js"]})}]}}).state("dashboard.paramFlow",{templateUrl:"app/views/param_flow.html",url:"/paramFlow/:app",controller:"ParamFlowController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/param_flow.js"]})}]}}).state("dashboard.clusterAppAssignManage",{templateUrl:"app/views/cluster_app_assign_manage.html",url:"/cluster/assign_manage/:app",controller:"SentinelClusterAppAssignManageController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/cluster_app_assign_manage.js"]})}]}}).state("dashboard.clusterAppServerList",{templateUrl:"app/views/cluster_app_server_list.html",url:"/cluster/server/:app",controller:"SentinelClusterAppServerListController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/cluster_app_server_list.js"]})}]}}).state("dashboard.clusterAppClientList",{templateUrl:"app/views/cluster_app_client_list.html",url:"/cluster/client/:app",controller:"SentinelClusterAppTokenClientListController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/cluster_app_token_client_list.js"]})}]}}).state("dashboard.clusterSingle",{templateUrl:"app/views/cluster_single_config.html",url:"/cluster/single/:app",controller:"SentinelClusterSingleController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/cluster_single.js"]})}]}}).state("dashboard.authority",{templateUrl:"app/views/authority.html",url:"/authority/:app",controller:"AuthorityRuleController",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/authority.js"]})}]}}).state("dashboard.degrade",{templateUrl:"app/views/degrade.html",url:"/degrade/:app",controller:"DegradeCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/degrade.js"]})}]}}).state("dashboard.system",{templateUrl:"app/views/system.html",url:"/system/:app",controller:"SystemCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/system.js"]})}]}}).state("dashboard.machine",{templateUrl:"app/views/machine.html",url:"/app/:app",controller:"MachineCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/machine.js"]})}]}}).state("dashboard.identity",{templateUrl:"app/views/identity.html",url:"/identity/:app",controller:"IdentityCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/identity.js"]})}]}}).state("dashboard.gatewayIdentity",{templateUrl:"app/views/gateway/identity.html",url:"/gateway/identity/:app",controller:"GatewayIdentityCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/gateway/identity.js"]})}]}}).state("dashboard.metric",{templateUrl:"app/views/metric.html",url:"/metric/:app",controller:"MetricCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/metric.js"]})}]}}).state("dashboard.gatewayApi",{templateUrl:"app/views/gateway/api.html",url:"/gateway/api/:app",controller:"GatewayApiCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/gateway/api.js"]})}]}}).state("dashboard.gatewayFlow",{templateUrl:"app/views/gateway/flow.html",url:"/gateway/flow/:app",controller:"GatewayFlowCtl",resolve:{loadMyFiles:["$ocLazyLoad",function(e){return e.load({name:"sentinelDashboardApp",files:["app/scripts/controllers/gateway/flow.js"]})}]}})}]),(app=angular.module("sentinelDashboardApp")).filter("range",[function(){return function(e,t){if(isNaN(t)||t<=0)return[];e=[];for(var r=1;r<=t;r++)e.push(r);return e}}]),(app=angular.module("sentinelDashboardApp")).service("AuthService",["$http",function(t){this.login=function(e){return t({url:"/auth/login",params:e,method:"POST"})},this.logout=function(){return t({url:"/auth/logout",method:"POST"})}}]),(app=angular.module("sentinelDashboardApp")).service("AppService",["$http",function(e){this.getApps=function(){return e({url:"app/briefinfos.json",method:"GET"})}}]),(app=angular.module("sentinelDashboardApp")).service("FlowServiceV1",["$http",function(a){function t(e){return void 0===e||""===e||isNaN(e)||e<=0}this.queryMachineRules=function(e,t,r){return a({url:"/v1/flow/rules",params:{app:e,ip:t,port:r},method:"GET"})},this.newRule=function(e){e.resource,e.limitApp,e.grade,e.count,e.strategy,e.refResource,e.controlBehavior,e.warmUpPeriodSec,e.maxQueueingTimeMs,e.app,e.ip,e.port;return a({url:"/v1/flow/rule",data:e,method:"POST"})},this.saveRule=function(e){var t={id:e.id,resource:e.resource,limitApp:e.limitApp,grade:e.grade,count:e.count,strategy:e.strategy,refResource:e.refResource,controlBehavior:e.controlBehavior,warmUpPeriodSec:e.warmUpPeriodSec,maxQueueingTimeMs:e.maxQueueingTimeMs};return a({url:"/v1/flow/save.json",params:t,method:"PUT"})},this.deleteRule=function(e){var t={id:e.id,app:e.app};return a({url:"/v1/flow/delete.json",params:t,method:"DELETE"})},this.checkRuleValid=function(e){return void 0===e.resource||""===e.resource?(alert("资源名称不能为空"),!1):void 0===e.count||e.count<0?(alert("限流阈值必须大于等于 0"),!1):void 0===e.strategy||e.strategy<0?(alert("无效的流控模式"),!1):1!=e.strategy&&2!=e.strategy||void 0!==e.refResource&&""!=e.refResource?void 0===e.controlBehavior||e.controlBehavior<0?(alert("无效的流控整形方式"),!1):1==e.controlBehavior&&t(e.warmUpPeriodSec)?(alert("预热时长必须大于 0"),!1):2==e.controlBehavior&&t(e.maxQueueingTimeMs)?(alert("排队超时时间必须大于 0"),!1):!e.clusterMode||void 0!==e.clusterConfig&&void 0!==e.clusterConfig.thresholdType||(alert("集群限流配置不正确"),!1):(alert("请填写关联资源或入口"),!1)}}]),(app=angular.module("sentinelDashboardApp")).service("FlowServiceV2",["$http",function(a){function t(e){return void 0===e||""===e||isNaN(e)||e<=0}this.queryMachineRules=function(e,t,r){return a({url:"/v2/flow/rules",params:{app:e,ip:t,port:r},method:"GET"})},this.newRule=function(e){return a({url:"/v2/flow/rule",data:e,method:"POST"})},this.saveRule=function(e){return a({url:"/v2/flow/rule/"+e.id,data:e,method:"PUT"})},this.deleteRule=function(e){return a({url:"/v2/flow/rule/"+e.id,method:"DELETE"})},this.checkRuleValid=function(e){return void 0===e.resource||""===e.resource?(alert("资源名称不能为空"),!1):void 0===e.count||e.count<0?(alert("限流阈值必须大于等于 0"),!1):void 0===e.strategy||e.strategy<0?(alert("无效的流控模式"),!1):1!=e.strategy&&2!=e.strategy||void 0!==e.refResource&&""!=e.refResource?void 0===e.controlBehavior||e.controlBehavior<0?(alert("无效的流控整形方式"),!1):1==e.controlBehavior&&t(e.warmUpPeriodSec)?(alert("预热时长必须大于 0"),!1):2==e.controlBehavior&&t(e.maxQueueingTimeMs)?(alert("排队超时时间必须大于 0"),!1):!e.clusterMode||void 0!==e.clusterConfig&&void 0!==e.clusterConfig.thresholdType||(alert("集群限流配置不正确"),!1):(alert("请填写关联资源或入口"),!1)}}]),(app=angular.module("sentinelDashboardApp")).service("DegradeService",["$http",function(a){this.queryMachineRules=function(e,t,r){return a({url:"degrade/rules.json",params:{app:e,ip:t,port:r},method:"GET"})},this.newRule=function(e){var t={id:e.id,resource:e.resource,limitApp:e.limitApp,count:e.count,timeWindow:e.timeWindow,grade:e.grade,app:e.app,ip:e.ip,port:e.port};return a({url:"/degrade/new.json",params:t,method:"GET"})},this.saveRule=function(e){var t={id:e.id,resource:e.resource,limitApp:e.limitApp,grade:e.grade,count:e.count,timeWindow:e.timeWindow};return a({url:"/degrade/save.json",params:t,method:"GET"})},this.deleteRule=function(e){var t={id:e.id,app:e.app};return a({url:"/degrade/delete.json",params:t,method:"GET"})},this.checkRuleValid=function(e){return void 0===e.resource||""===e.resource?(alert("资源名称不能为空"),!1):void 0===e.grade||e.grade<0?(alert("未知的降级策略"),!1):void 0===e.count||""===e.count||e.count<0?(alert("降级阈值不能为空或小于 0"),!1):void 0===e.timeWindow||""===e.timeWindow||e.timeWindow<=0?(alert("降级时间窗口必须大于 0"),!1):!(1==e.grade&&1