mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
add switch to instance CommonFilter in SentinelProperties
This commit is contained in:
parent
f126d57cc8
commit
bfcabfd068
@ -272,6 +272,7 @@ Sentinel Endpoint 里暴露的信息非常有用。包括当前应用的所有
|
|||||||
|`spring.cloud.sentinel.transport.client-ip`|客户端IP|
|
|`spring.cloud.sentinel.transport.client-ip`|客户端IP|
|
||||||
|`spring.cloud.sentinel.filter.order`|Servlet Filter的加载顺序。Starter内部会构造这个filter|Integer.MIN_VALUE
|
|`spring.cloud.sentinel.filter.order`|Servlet Filter的加载顺序。Starter内部会构造这个filter|Integer.MIN_VALUE
|
||||||
|`spring.cloud.sentinel.filter.url-patterns`|数据类型是数组。表示Servlet Filter的url pattern集合|/*
|
|`spring.cloud.sentinel.filter.url-patterns`|数据类型是数组。表示Servlet Filter的url pattern集合|/*
|
||||||
|
|`spring.cloud.sentinel.filter.enabled`|Enable to instance CommonFilter|true
|
||||||
|`spring.cloud.sentinel.metric.charset`|metric文件字符集|UTF-8
|
|`spring.cloud.sentinel.metric.charset`|metric文件字符集|UTF-8
|
||||||
|`spring.cloud.sentinel.metric.file-single-size`|Sentinel metric 单个文件的大小|
|
|`spring.cloud.sentinel.metric.file-single-size`|Sentinel metric 单个文件的大小|
|
||||||
|`spring.cloud.sentinel.metric.file-total-count`|Sentinel metric 总文件数量|
|
|`spring.cloud.sentinel.metric.file-total-count`|Sentinel metric 总文件数量|
|
||||||
|
@ -271,6 +271,7 @@ The following table shows all the configurations of Spring Cloud Alibaba Sentine
|
|||||||
|`spring.cloud.sentinel.transport.client-ip`|Client IP|
|
|`spring.cloud.sentinel.transport.client-ip`|Client IP|
|
||||||
|`spring.cloud.sentinel.filter.order`|Loading order of Servlet Filter. The filter will be constructed in the Starter|Integer.MIN_VALUE
|
|`spring.cloud.sentinel.filter.order`|Loading order of Servlet Filter. The filter will be constructed in the Starter|Integer.MIN_VALUE
|
||||||
|`spring.cloud.sentinel.filter.url-patterns`|Data type is array. Refers to the collection of Servlet Filter ULR patterns|/*
|
|`spring.cloud.sentinel.filter.url-patterns`|Data type is array. Refers to the collection of Servlet Filter ULR patterns|/*
|
||||||
|
|`spring.cloud.sentinel.filter.enabled`|Enable to instance CommonFilter|true
|
||||||
|`spring.cloud.sentinel.metric.charset`|metric file character set|UTF-8
|
|`spring.cloud.sentinel.metric.charset`|metric file character set|UTF-8
|
||||||
|`spring.cloud.sentinel.metric.fileSingleSize`|Sentinel metric single file size|
|
|`spring.cloud.sentinel.metric.fileSingleSize`|Sentinel metric single file size|
|
||||||
|`spring.cloud.sentinel.metric.fileTotalCount`|Sentinel metric total file number|
|
|`spring.cloud.sentinel.metric.fileTotalCount`|Sentinel metric total file number|
|
||||||
|
@ -16,17 +16,18 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.alibaba.sentinel;
|
package org.springframework.cloud.alibaba.sentinel;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.config.SentinelConfig;
|
import java.util.List;
|
||||||
import com.alibaba.csp.sentinel.log.LogBase;
|
import java.util.Map;
|
||||||
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.cloud.alibaba.sentinel.datasource.config.DataSourcePropertiesConfiguration;
|
import org.springframework.cloud.alibaba.sentinel.datasource.config.DataSourcePropertiesConfiguration;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.List;
|
import com.alibaba.csp.sentinel.config.SentinelConfig;
|
||||||
import java.util.Map;
|
import com.alibaba.csp.sentinel.log.LogBase;
|
||||||
import java.util.TreeMap;
|
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ConfigurationProperties} for Sentinel.
|
* {@link ConfigurationProperties} for Sentinel.
|
||||||
@ -306,6 +307,12 @@ public class SentinelProperties {
|
|||||||
*/
|
*/
|
||||||
private List<String> urlPatterns;
|
private List<String> urlPatterns;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable to instance
|
||||||
|
* {@link com.alibaba.csp.sentinel.adapter.servlet.CommonFilter}.
|
||||||
|
*/
|
||||||
|
private boolean enabled = true;
|
||||||
|
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return this.order;
|
return this.order;
|
||||||
}
|
}
|
||||||
@ -321,6 +328,14 @@ public class SentinelProperties {
|
|||||||
public void setUrlPatterns(List<String> urlPatterns) {
|
public void setUrlPatterns(List<String> urlPatterns) {
|
||||||
this.urlPatterns = urlPatterns;
|
this.urlPatterns = urlPatterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Log {
|
public static class Log {
|
||||||
|
@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.alibaba.sentinel;
|
package org.springframework.cloud.alibaba.sentinel;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.servlet.Filter;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -28,9 +31,7 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import javax.servlet.Filter;
|
import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiaojing
|
* @author xiaojing
|
||||||
@ -48,7 +49,8 @@ public class SentinelWebAutoConfiguration {
|
|||||||
private SentinelProperties properties;
|
private SentinelProperties properties;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public FilterRegistrationBean servletRequestListener() {
|
@ConditionalOnProperty(name = "spring.cloud.sentinel.filter.enabled", matchIfMissing = true)
|
||||||
|
public FilterRegistrationBean sentinelFilter() {
|
||||||
FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>();
|
FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>();
|
||||||
|
|
||||||
SentinelProperties.Filter filterConfig = properties.getFilter();
|
SentinelProperties.Filter filterConfig = properties.getFilter();
|
||||||
|
@ -39,6 +39,12 @@
|
|||||||
"defaultValue": "Integer.MIN_VALUE",
|
"defaultValue": "Integer.MIN_VALUE",
|
||||||
"description": "sentinel filter chain order, will be set to FilterRegistrationBean."
|
"description": "sentinel filter chain order, will be set to FilterRegistrationBean."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "spring.cloud.sentinel.filter.enabled",
|
||||||
|
"type": "java.lang.Boolean",
|
||||||
|
"defaultValue": true,
|
||||||
|
"description": "Enable to instance com.alibaba.csp.sentinel.adapter.servlet.CommonFilter."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "spring.cloud.sentinel.metric.charset",
|
"name": "spring.cloud.sentinel.metric.charset",
|
||||||
"type": "java.lang.String",
|
"type": "java.lang.String",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user