Release v2.2.0-beta3
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
<groupId>com.fizzgate</groupId>
|
||||
<artifactId>fizz-bootstrap</artifactId>
|
||||
<version>2.2.0-beta2</version>
|
||||
<version>2.2.0-beta3</version>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>fizz-gateway-community</artifactId>
|
||||
<groupId>com.fizzgate</groupId>
|
||||
<version>2.2.0-beta2</version>
|
||||
<version>2.2.0-beta3</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>fizz-gateway-community</artifactId>
|
||||
<groupId>com.fizzgate</groupId>
|
||||
<version>2.2.0-beta2</version>
|
||||
<version>2.2.0-beta3</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -137,14 +137,31 @@ public class FlowStatSchedConfig extends SchedConfig {
|
||||
String app = null, pi = null, node = ResourceRateLimitConfig.NODE, service = null, path = null;
|
||||
int type = ResourceRateLimitConfig.Type.NODE, id = 0;
|
||||
ResourceRateLimitConfig c = resourceRateLimitConfigService.getResourceRateLimitConfig(resource);
|
||||
if (c == null) {
|
||||
|
||||
if (c == null) { // _global, service, app, ip, ip+service
|
||||
node = ResourceRateLimitConfig.getNode(resource);
|
||||
if (node != null && node.equals(ResourceRateLimitConfig.NODE)) {
|
||||
} else {
|
||||
service = ResourceRateLimitConfig.getService(resource);
|
||||
if (service != null) {
|
||||
app = ResourceRateLimitConfig.getApp(resource);
|
||||
pi = ResourceRateLimitConfig.getIp(resource);
|
||||
if (service == null) {
|
||||
if (app == null) {
|
||||
type = ResourceRateLimitConfig.Type.IP;
|
||||
} else {
|
||||
ResourceRateLimitConfig appConfig = resourceRateLimitConfigService.getResourceRateLimitConfig(ResourceRateLimitConfig.APP_DEFAULT_RESOURCE);
|
||||
if (appConfig != null && appConfig.isEnable()) {
|
||||
type = ResourceRateLimitConfig.Type.APP_DEFAULT;
|
||||
} else {
|
||||
type = ResourceRateLimitConfig.Type.APP;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pi == null) {
|
||||
type = ResourceRateLimitConfig.Type.SERVICE_DEFAULT;
|
||||
} else {
|
||||
app = ResourceRateLimitConfig.getApp(resource);
|
||||
if (app != null) {
|
||||
type = ResourceRateLimitConfig.Type.APP_DEFAULT;
|
||||
type = ResourceRateLimitConfig.Type.IP;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -203,6 +203,7 @@ public class FlowControlFilter extends FizzWebFilter {
|
||||
ResourceConfig rc = null;
|
||||
ResourceRateLimitConfig rateLimitConfig = resourceRateLimitConfigService.getResourceRateLimitConfig(resource);
|
||||
if (rateLimitConfig != null && rateLimitConfig.isEnable()) {
|
||||
something4appAndIp(resourceConfigs, rateLimitConfig);
|
||||
rc = new ResourceConfig(resource, rateLimitConfig.concurrents, rateLimitConfig.qps);
|
||||
resourceConfigs.add(rc);
|
||||
} else {
|
||||
@@ -231,4 +232,53 @@ public class FlowControlFilter extends FizzWebFilter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void something4appAndIp(List<ResourceConfig> resourceConfigs, ResourceRateLimitConfig rateLimitConfig) {
|
||||
int sz = resourceConfigs.size();
|
||||
String prev = null, prevPrev = null;
|
||||
if (sz > 1) {
|
||||
prev = resourceConfigs.get(sz - 1).getResourceId();
|
||||
prevPrev = resourceConfigs.get(sz - 2).getResourceId();
|
||||
|
||||
if (rateLimitConfig.type == ResourceRateLimitConfig.Type.APP) {
|
||||
String app = ResourceRateLimitConfig.getApp(prev);
|
||||
if (app == null) {
|
||||
something4(resourceConfigs, rateLimitConfig.app, null, null);
|
||||
} else {
|
||||
String service = ResourceRateLimitConfig.getService(prev);
|
||||
if (service == null) {
|
||||
} else {
|
||||
app = ResourceRateLimitConfig.getApp(prevPrev);
|
||||
if (app == null) {
|
||||
something4(resourceConfigs, rateLimitConfig.app, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (rateLimitConfig.type == ResourceRateLimitConfig.Type.IP) {
|
||||
|
||||
String ip = ResourceRateLimitConfig.getIp(prev);
|
||||
if (ip == null) {
|
||||
something4(resourceConfigs, null, rateLimitConfig.ip, null);
|
||||
something4(resourceConfigs, null, rateLimitConfig.ip, rateLimitConfig.service);
|
||||
} else {
|
||||
String service = ResourceRateLimitConfig.getService(prev);
|
||||
if (service == null) {
|
||||
something4(resourceConfigs, null, rateLimitConfig.ip, rateLimitConfig.service);
|
||||
} else {
|
||||
ip = ResourceRateLimitConfig.getIp(prevPrev);
|
||||
if (ip == null) {
|
||||
something4(resourceConfigs, null, rateLimitConfig.ip, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void something4(List<ResourceConfig> resourceConfigs, String app, String ip, String service) {
|
||||
String r = ResourceRateLimitConfig.buildResourceId(app, ip, null, service, null);
|
||||
ResourceConfig rc = new ResourceConfig(r, 0, 0);
|
||||
resourceConfigs.add(rc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>fizz-gateway-community</artifactId>
|
||||
<groupId>com.fizzgate</groupId>
|
||||
<version>2.2.0-beta2</version>
|
||||
<version>2.2.0-beta3</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>fizz-gateway-community</artifactId>
|
||||
<groupId>com.fizzgate</groupId>
|
||||
<version>2.2.0-beta2</version>
|
||||
<version>2.2.0-beta3</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
Reference in New Issue
Block a user