support rejecting all requests by ratelimit
This commit is contained in:
@@ -228,10 +228,10 @@ public class FlowStat {
|
|||||||
for (ResourceConfig resourceConfig : resourceConfigs) {
|
for (ResourceConfig resourceConfig : resourceConfigs) {
|
||||||
long maxCon = resourceConfig.getMaxCon();
|
long maxCon = resourceConfig.getMaxCon();
|
||||||
long maxQPS = resourceConfig.getMaxQPS();
|
long maxQPS = resourceConfig.getMaxQPS();
|
||||||
if (maxCon > 0 || maxQPS > 0) {
|
if (maxCon >= 0 || maxQPS >= 0) {
|
||||||
ResourceStat resourceStat = getResourceStat(resourceConfig.getResourceId());
|
ResourceStat resourceStat = getResourceStat(resourceConfig.getResourceId());
|
||||||
// check concurrent request
|
// check concurrent request
|
||||||
if (maxCon > 0) {
|
if (maxCon >= 0) {
|
||||||
long n = resourceStat.getConcurrentRequests().get();
|
long n = resourceStat.getConcurrentRequests().get();
|
||||||
if (n >= maxCon) {
|
if (n >= maxCon) {
|
||||||
resourceStat.incrBlockRequestToTimeSlot(curTimeSlotId);
|
resourceStat.incrBlockRequestToTimeSlot(curTimeSlotId);
|
||||||
@@ -251,7 +251,7 @@ public class FlowStat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check QPS
|
// check QPS
|
||||||
if (maxQPS > 0) {
|
if (maxQPS >= 0) {
|
||||||
long total = resourceStat.getTimeSlot(curTimeSlotId).getCounter();
|
long total = resourceStat.getTimeSlot(curTimeSlotId).getCounter();
|
||||||
if (total >= maxQPS) {
|
if (total >= maxQPS) {
|
||||||
resourceStat.incrBlockRequestToTimeSlot(curTimeSlotId);
|
resourceStat.incrBlockRequestToTimeSlot(curTimeSlotId);
|
||||||
|
|||||||
Reference in New Issue
Block a user