Fix QPS mode of system rule: use passQps instead of successQps and support batchCount (#2455)
This commit is contained in:
parent
d4ea89e978
commit
3e9f42efce
|
|
@ -287,7 +287,7 @@ public final class SystemRuleManager {
|
|||
* @param resourceWrapper the resource.
|
||||
* @throws BlockException when any system rule's threshold is exceeded.
|
||||
*/
|
||||
public static void checkSystem(ResourceWrapper resourceWrapper) throws BlockException {
|
||||
public static void checkSystem(ResourceWrapper resourceWrapper, int count) throws BlockException {
|
||||
if (resourceWrapper == null) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -302,8 +302,8 @@ public final class SystemRuleManager {
|
|||
}
|
||||
|
||||
// total qps
|
||||
double currentQps = Constants.ENTRY_NODE == null ? 0.0 : Constants.ENTRY_NODE.successQps();
|
||||
if (currentQps > qps) {
|
||||
double currentQps = Constants.ENTRY_NODE == null ? 0.0 : Constants.ENTRY_NODE.passQps();
|
||||
if (currentQps + count > qps) {
|
||||
throw new SystemBlockException(resourceWrapper.getName(), "qps");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class SystemSlot extends AbstractLinkedProcessorSlot<DefaultNode> {
|
|||
@Override
|
||||
public void entry(Context context, ResourceWrapper resourceWrapper, DefaultNode node, int count,
|
||||
boolean prioritized, Object... args) throws Throwable {
|
||||
SystemRuleManager.checkSystem(resourceWrapper);
|
||||
SystemRuleManager.checkSystem(resourceWrapper, count);
|
||||
fireEntry(context, resourceWrapper, node, count, prioritized, args);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,8 @@ public class SystemRuleManagerTest {
|
|||
|
||||
boolean blocked = false;
|
||||
try {
|
||||
SystemRuleManager.checkSystem(new StringResourceWrapper("testCheckMaxCpuUsageNotBBR", EntryType.IN));
|
||||
StringResourceWrapper resourceWrapper = new StringResourceWrapper("testCheckMaxCpuUsageNotBBR", EntryType.IN);
|
||||
SystemRuleManager.checkSystem(resourceWrapper, 1);
|
||||
} catch (BlockException ex) {
|
||||
blocked = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue