diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java index d9529783..1a456488 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java @@ -188,6 +188,12 @@ public class ParamFlowRuleController { if (entity.getParamIdx() == null || entity.getParamIdx() < 0) { return Result.ofFail(-1, "paramIdx should be valid"); } + if (entity.getDurationInSec() <= 0) { + return Result.ofFail(-1, "durationInSec should be valid"); + } + if (entity.getControlBehavior() < 0) { + return Result.ofFail(-1, "controlBehavior should be valid"); + } return null; } diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AbstractRuleEntity.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AbstractRuleEntity.java index 1f5eaa23..6f60647d 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AbstractRuleEntity.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AbstractRuleEntity.java @@ -18,6 +18,7 @@ package com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; import java.util.Date; import com.alibaba.csp.sentinel.slots.block.AbstractRule; +import com.alibaba.csp.sentinel.slots.block.Rule; /** * @author Eric Zhao @@ -103,4 +104,9 @@ public abstract class AbstractRuleEntity implements Rule this.gmtModified = gmtModified; return this; } + + @Override + public T toRule() { + return rule; + } } diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AuthorityRuleEntity.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AuthorityRuleEntity.java index 2a77d32f..92496201 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AuthorityRuleEntity.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AuthorityRuleEntity.java @@ -15,7 +15,6 @@ */ package com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; -import com.alibaba.csp.sentinel.slots.block.Rule; import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule; import com.alibaba.csp.sentinel.util.AssertUtil; @@ -56,9 +55,4 @@ public class AuthorityRuleEntity extends AbstractRuleEntity { public int getStrategy() { return rule.getStrategy(); } - - @Override - public Rule toRule() { - return rule; - } } diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java index e2bbb03b..5ffb1fe1 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java @@ -17,7 +17,6 @@ package com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; import java.util.List; -import com.alibaba.csp.sentinel.slots.block.Rule; import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowClusterConfig; import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowItem; import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRule; @@ -76,6 +75,26 @@ public class ParamFlowRuleEntity extends AbstractRuleEntity { return rule.getParamFlowItemList(); } + @JsonIgnore + public int getControlBehavior() { + return rule.getControlBehavior(); + } + + @JsonIgnore + public int getMaxQueueingTimeMs() { + return rule.getMaxQueueingTimeMs(); + } + + @JsonIgnore + public int getBurstCount() { + return rule.getBurstCount(); + } + + @JsonIgnore + public long getDurationInSec() { + return rule.getDurationInSec(); + } + @JsonIgnore public boolean isClusterMode() { return rule.isClusterMode(); @@ -85,9 +104,4 @@ public class ParamFlowRuleEntity extends AbstractRuleEntity { public ParamFlowClusterConfig getClusterConfig() { return rule.getClusterConfig(); } - - @Override - public Rule toRule() { - return rule; - } } diff --git a/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/identity.js b/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/identity.js index 33a4ec07..1deecc83 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/identity.js +++ b/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/identity.js @@ -322,6 +322,15 @@ app.controller('IdentityCtl', ['$scope', '$stateParams', 'IdentityService', paramFlowItemList: [], count: 0, limitApp: 'default', + controlBehavior: 0, + durationInSec: 1, + burstCount: 0, + maxQueueingTimeMs: 0, + clusterMode: false, + clusterConfig: { + thresholdType: 0, + fallbackToLocalWhenFail: true, + } } }; diff --git a/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/param_flow.js b/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/param_flow.js index 03a2054f..65d868a8 100644 --- a/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/param_flow.js +++ b/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/param_flow.js @@ -130,6 +130,9 @@ angular.module('sentinelDashboardApp').controller('ParamFlowController', ['$scop $scope.editRule = function (rule) { $scope.currentRule = angular.copy(rule); + if ($scope.currentRule.rule && $scope.currentRule.rule.durationInSec === undefined) { + $scope.currentRule.rule.durationInSec = 1; + } $scope.paramFlowRuleDialog = { title: '编辑热点规则', type: 'edit', @@ -157,9 +160,14 @@ angular.module('sentinelDashboardApp').controller('ParamFlowController', ['$scop paramFlowItemList: [], count: 0, limitApp: 'default', + controlBehavior: 0, + durationInSec: 1, + burstCount: 0, + maxQueueingTimeMs: 0, clusterMode: false, clusterConfig: { - thresholdType: 0 + thresholdType: 0, + fallbackToLocalWhenFail: true, } } }; @@ -167,6 +175,7 @@ angular.module('sentinelDashboardApp').controller('ParamFlowController', ['$scop title: '新增热点规则', type: 'add', confirmBtnText: '新增', + supportAdvanced: true, showAdvanceButton: true, }; paramFlowRuleDialog = ngDialog.open({ diff --git a/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/flow-rule-dialog.html b/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/flow-rule-dialog.html index a010a251..f832ce3e 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/flow-rule-dialog.html +++ b/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/flow-rule-dialog.html @@ -15,9 +15,9 @@
- +
-
@@ -72,9 +72,9 @@
-  如果 Token Server 不可用是否退化到单机限流
diff --git a/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/param-flow-rule-dialog.html b/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/param-flow-rule-dialog.html index eae5d08a..02f00b08 100644 --- a/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/param-flow-rule-dialog.html +++ b/sentinel-dashboard/src/main/webapp/resources/app/views/dialog/param-flow-rule-dialog.html @@ -27,9 +27,16 @@
-
+
+ +
+ + +
@@ -61,6 +68,16 @@
+
+ +
+
+ +  若选择,则 Token Server 不可用时将退化到单机限流 +
+
+