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