Release v2.2.0-beta3

This commit is contained in:
hongqiaowei
2021-06-25 16:04:46 +08:00
parent ef8809598a
commit 6cec714a0a
8 changed files with 79 additions and 12 deletions

View File

@@ -12,7 +12,7 @@
<groupId>com.fizzgate</groupId> <groupId>com.fizzgate</groupId>
<artifactId>fizz-bootstrap</artifactId> <artifactId>fizz-bootstrap</artifactId>
<version>2.2.0-beta2</version> <version>2.2.0-beta3</version>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>fizz-gateway-community</artifactId> <artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId> <groupId>com.fizzgate</groupId>
<version>2.2.0-beta2</version> <version>2.2.0-beta3</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>fizz-gateway-community</artifactId> <artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId> <groupId>com.fizzgate</groupId>
<version>2.2.0-beta2</version> <version>2.2.0-beta3</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -137,14 +137,31 @@ public class FlowStatSchedConfig extends SchedConfig {
String app = null, pi = null, node = ResourceRateLimitConfig.NODE, service = null, path = null; String app = null, pi = null, node = ResourceRateLimitConfig.NODE, service = null, path = null;
int type = ResourceRateLimitConfig.Type.NODE, id = 0; int type = ResourceRateLimitConfig.Type.NODE, id = 0;
ResourceRateLimitConfig c = resourceRateLimitConfigService.getResourceRateLimitConfig(resource); ResourceRateLimitConfig c = resourceRateLimitConfigService.getResourceRateLimitConfig(resource);
if (c == null) {
service = ResourceRateLimitConfig.getService(resource); if (c == null) { // _global, service, app, ip, ip+service
if (service != null) { node = ResourceRateLimitConfig.getNode(resource);
type = ResourceRateLimitConfig.Type.SERVICE_DEFAULT; if (node != null && node.equals(ResourceRateLimitConfig.NODE)) {
} else { } else {
service = ResourceRateLimitConfig.getService(resource);
app = ResourceRateLimitConfig.getApp(resource); app = ResourceRateLimitConfig.getApp(resource);
if (app != null) { pi = ResourceRateLimitConfig.getIp(resource);
type = ResourceRateLimitConfig.Type.APP_DEFAULT; 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 {
type = ResourceRateLimitConfig.Type.IP;
}
} }
} }
} else { } else {

View File

@@ -203,6 +203,7 @@ public class FlowControlFilter extends FizzWebFilter {
ResourceConfig rc = null; ResourceConfig rc = null;
ResourceRateLimitConfig rateLimitConfig = resourceRateLimitConfigService.getResourceRateLimitConfig(resource); ResourceRateLimitConfig rateLimitConfig = resourceRateLimitConfigService.getResourceRateLimitConfig(resource);
if (rateLimitConfig != null && rateLimitConfig.isEnable()) { if (rateLimitConfig != null && rateLimitConfig.isEnable()) {
something4appAndIp(resourceConfigs, rateLimitConfig);
rc = new ResourceConfig(resource, rateLimitConfig.concurrents, rateLimitConfig.qps); rc = new ResourceConfig(resource, rateLimitConfig.concurrents, rateLimitConfig.qps);
resourceConfigs.add(rc); resourceConfigs.add(rc);
} else { } 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);
}
} }

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>fizz-gateway-community</artifactId> <artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId> <groupId>com.fizzgate</groupId>
<version>2.2.0-beta2</version> <version>2.2.0-beta3</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>fizz-gateway-community</artifactId> <artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId> <groupId>com.fizzgate</groupId>
<version>2.2.0-beta2</version> <version>2.2.0-beta3</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@@ -31,7 +31,7 @@
<artifactId>fizz-gateway-community</artifactId> <artifactId>fizz-gateway-community</artifactId>
<name>${project.artifactId}</name> <name>${project.artifactId}</name>
<description>fizz gateway community</description> <description>fizz gateway community</description>
<version>2.2.0-beta2</version> <version>2.2.0-beta3</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
<module>fizz-common</module> <module>fizz-common</module>