mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
修改代码风格为eclipse风格
This commit is contained in:
parent
156404554e
commit
03a64885d4
@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.alibaba.sentinel;
|
package org.springframework.cloud.alibaba.sentinel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiaojing
|
* @author xiaojing
|
||||||
* @author hengyunabc
|
* @author hengyunabc
|
||||||
@ -30,245 +30,245 @@ import java.util.List;
|
|||||||
@ConfigurationProperties(prefix = SentinelConstants.PROPERTY_PREFIX)
|
@ConfigurationProperties(prefix = SentinelConstants.PROPERTY_PREFIX)
|
||||||
public class SentinelProperties {
|
public class SentinelProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否提前初始化心跳连接
|
||||||
|
*/
|
||||||
|
private boolean eager = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否提前初始化心跳连接
|
* Enable sentinel auto configure, the default value is true
|
||||||
*/
|
*/
|
||||||
private boolean eager = false;
|
private boolean enabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable sentinel auto configure, the default value is true
|
* 字符编码集
|
||||||
*/
|
*/
|
||||||
private boolean enabled = true;
|
private String charset = "UTF-8";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符编码集
|
* 通信相关配置
|
||||||
*/
|
*/
|
||||||
private String charset = "UTF-8";
|
@NestedConfigurationProperty
|
||||||
|
private Transport transport = new Transport();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通信相关配置
|
* 监控数据相关配置
|
||||||
*/
|
*/
|
||||||
@NestedConfigurationProperty
|
@NestedConfigurationProperty
|
||||||
private Transport transport = new Transport();
|
private Metric metric = new Metric();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监控数据相关配置
|
* web 相关配置
|
||||||
*/
|
*/
|
||||||
@NestedConfigurationProperty
|
@NestedConfigurationProperty
|
||||||
private Metric metric = new Metric();
|
private Servlet servlet = new Servlet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web 相关配置
|
* 限流相关
|
||||||
*/
|
*/
|
||||||
@NestedConfigurationProperty
|
@NestedConfigurationProperty
|
||||||
private Servlet servlet = new Servlet();
|
private Filter filter = new Filter();
|
||||||
|
|
||||||
/**
|
@NestedConfigurationProperty
|
||||||
* 限流相关
|
private Flow flow = new Flow();
|
||||||
*/
|
|
||||||
@NestedConfigurationProperty
|
|
||||||
private Filter filter = new Filter();
|
|
||||||
|
|
||||||
@NestedConfigurationProperty
|
public boolean isEager() {
|
||||||
private Flow flow = new Flow();
|
return eager;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEager() {
|
public void setEager(boolean eager) {
|
||||||
return eager;
|
this.eager = eager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEager(boolean eager) {
|
public Flow getFlow() {
|
||||||
this.eager = eager;
|
return flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Flow getFlow() {
|
public void setFlow(Flow flow) {
|
||||||
return flow;
|
this.flow = flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlow(Flow flow) {
|
public String getCharset() {
|
||||||
this.flow = flow;
|
return charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCharset() {
|
public void setCharset(String charset) {
|
||||||
return charset;
|
this.charset = charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCharset(String charset) {
|
public Transport getTransport() {
|
||||||
this.charset = charset;
|
return transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Transport getTransport() {
|
public void setTransport(Transport transport) {
|
||||||
return transport;
|
this.transport = transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTransport(Transport transport) {
|
public Metric getMetric() {
|
||||||
this.transport = transport;
|
return metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Metric getMetric() {
|
public void setMetric(Metric metric) {
|
||||||
return metric;
|
this.metric = metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMetric(Metric metric) {
|
public Servlet getServlet() {
|
||||||
this.metric = metric;
|
return servlet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Servlet getServlet() {
|
public void setServlet(Servlet servlet) {
|
||||||
return servlet;
|
this.servlet = servlet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServlet(Servlet servlet) {
|
public boolean isEnabled() {
|
||||||
this.servlet = servlet;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public void setEnabled(boolean enabled) {
|
||||||
return enabled;
|
this.enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
public Filter getFilter() {
|
||||||
this.enabled = enabled;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Filter getFilter() {
|
public void setFilter(Filter filter) {
|
||||||
return filter;
|
this.filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilter(Filter filter) {
|
public static class Flow {
|
||||||
this.filter = filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Flow {
|
/**
|
||||||
|
* 限流冷启动因子
|
||||||
|
*/
|
||||||
|
private String coldFactor = "3";
|
||||||
|
|
||||||
/**
|
public String getColdFactor() {
|
||||||
* 限流冷启动因子
|
return coldFactor;
|
||||||
*/
|
}
|
||||||
private String coldFactor = "3";
|
|
||||||
|
|
||||||
public String getColdFactor() {
|
public void setColdFactor(String coldFactor) {
|
||||||
return coldFactor;
|
this.coldFactor = coldFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColdFactor(String coldFactor) {
|
}
|
||||||
this.coldFactor = coldFactor;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
public static class Servlet {
|
||||||
|
|
||||||
public static class Servlet {
|
/**
|
||||||
|
* url 限流后的处理页面
|
||||||
|
*/
|
||||||
|
private String blockPage;
|
||||||
|
|
||||||
/**
|
public String getBlockPage() {
|
||||||
* url 限流后的处理页面
|
return blockPage;
|
||||||
*/
|
}
|
||||||
private String blockPage;
|
|
||||||
|
|
||||||
public String getBlockPage() {
|
public void setBlockPage(String blockPage) {
|
||||||
return blockPage;
|
this.blockPage = blockPage;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setBlockPage(String blockPage) {
|
public static class Metric {
|
||||||
this.blockPage = blockPage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Metric {
|
/**
|
||||||
|
* 监控数据写磁盘时单个文件的大小
|
||||||
|
*/
|
||||||
|
private String fileSingleSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监控数据写磁盘时单个文件的大小
|
* 监控数据在磁盘上的总数量
|
||||||
*/
|
*/
|
||||||
private String fileSingleSize;
|
private String fileTotalCount;
|
||||||
|
|
||||||
/**
|
public String getFileSingleSize() {
|
||||||
* 监控数据在磁盘上的总数量
|
return fileSingleSize;
|
||||||
*/
|
}
|
||||||
private String fileTotalCount;
|
|
||||||
|
|
||||||
public String getFileSingleSize() {
|
public void setFileSingleSize(String fileSingleSize) {
|
||||||
return fileSingleSize;
|
this.fileSingleSize = fileSingleSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileSingleSize(String fileSingleSize) {
|
public String getFileTotalCount() {
|
||||||
this.fileSingleSize = fileSingleSize;
|
return fileTotalCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileTotalCount() {
|
public void setFileTotalCount(String fileTotalCount) {
|
||||||
return fileTotalCount;
|
this.fileTotalCount = fileTotalCount;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setFileTotalCount(String fileTotalCount) {
|
public static class Transport {
|
||||||
this.fileTotalCount = fileTotalCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Transport {
|
/**
|
||||||
|
* sentinel api port,default value is 8721
|
||||||
|
*/
|
||||||
|
private String port = "8721";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sentinel api port,default value is 8721
|
* Sentinel dashboard address, won't try to connect dashboard when address is
|
||||||
*/
|
* empty
|
||||||
private String port = "8721";
|
*/
|
||||||
|
private String dashboard = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sentinel dashboard address, won't try to connect dashboard when address is empty
|
* 客户端和DashBord心跳发送时间
|
||||||
*/
|
*/
|
||||||
private String dashboard = "";
|
private String heartbeatIntervalMs;
|
||||||
|
|
||||||
/**
|
public String getHeartbeatIntervalMs() {
|
||||||
* 客户端和DashBord心跳发送时间
|
return heartbeatIntervalMs;
|
||||||
*/
|
}
|
||||||
private String heartbeatIntervalMs;
|
|
||||||
|
|
||||||
public String getHeartbeatIntervalMs() {
|
public void setHeartbeatIntervalMs(String heartbeatIntervalMs) {
|
||||||
return heartbeatIntervalMs;
|
this.heartbeatIntervalMs = heartbeatIntervalMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHeartbeatIntervalMs(String heartbeatIntervalMs) {
|
public String getPort() {
|
||||||
this.heartbeatIntervalMs = heartbeatIntervalMs;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPort() {
|
public void setPort(String port) {
|
||||||
return port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPort(String port) {
|
public String getDashboard() {
|
||||||
this.port = port;
|
return dashboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDashboard() {
|
public void setDashboard(String dashboard) {
|
||||||
return dashboard;
|
this.dashboard = dashboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDashboard(String dashboard) {
|
}
|
||||||
this.dashboard = dashboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
public static class Filter {
|
||||||
|
|
||||||
public static class Filter {
|
/**
|
||||||
|
* Sentinel filter chain order.
|
||||||
|
*/
|
||||||
|
private int order = Ordered.HIGHEST_PRECEDENCE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sentinel filter chain order.
|
* URL pattern for sentinel filter,default is /*
|
||||||
*/
|
*/
|
||||||
private int order = Ordered.HIGHEST_PRECEDENCE;
|
private List<String> urlPatterns;
|
||||||
|
|
||||||
/**
|
public int getOrder() {
|
||||||
* URL pattern for sentinel filter,default is /*
|
return this.order;
|
||||||
*/
|
}
|
||||||
private List<String> urlPatterns;
|
|
||||||
|
|
||||||
public int getOrder() {
|
public void setOrder(int order) {
|
||||||
return this.order;
|
this.order = order;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrder(int order) {
|
public List<String> getUrlPatterns() {
|
||||||
this.order = order;
|
return urlPatterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getUrlPatterns() {
|
public void setUrlPatterns(List<String> urlPatterns) {
|
||||||
return urlPatterns;
|
this.urlPatterns = urlPatterns;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void setUrlPatterns(List<String> urlPatterns) {
|
|
||||||
this.urlPatterns = urlPatterns;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,11 @@
|
|||||||
|
|
||||||
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;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -27,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
|
||||||
@ -40,38 +42,38 @@ import java.util.List;
|
|||||||
@EnableConfigurationProperties(SentinelProperties.class)
|
@EnableConfigurationProperties(SentinelProperties.class)
|
||||||
public class SentinelWebAutoConfiguration {
|
public class SentinelWebAutoConfiguration {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory
|
private static final Logger logger = LoggerFactory
|
||||||
.getLogger(SentinelWebAutoConfiguration.class);
|
.getLogger(SentinelWebAutoConfiguration.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SentinelProperties properties;
|
private SentinelProperties properties;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public FilterRegistrationBean servletRequestListener() {
|
public FilterRegistrationBean servletRequestListener() {
|
||||||
FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>();
|
FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>();
|
||||||
|
|
||||||
SentinelProperties.Filter filterConfig = properties.getFilter();
|
SentinelProperties.Filter filterConfig = properties.getFilter();
|
||||||
|
|
||||||
if (null == filterConfig) {
|
if (null == filterConfig) {
|
||||||
filterConfig = new SentinelProperties.Filter();
|
filterConfig = new SentinelProperties.Filter();
|
||||||
properties.setFilter(filterConfig);
|
properties.setFilter(filterConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterConfig.getUrlPatterns() == null
|
if (filterConfig.getUrlPatterns() == null
|
||||||
|| filterConfig.getUrlPatterns().isEmpty()) {
|
|| filterConfig.getUrlPatterns().isEmpty()) {
|
||||||
List<String> defaultPatterns = new ArrayList<>();
|
List<String> defaultPatterns = new ArrayList<>();
|
||||||
defaultPatterns.add("/*");
|
defaultPatterns.add("/*");
|
||||||
filterConfig.setUrlPatterns(defaultPatterns);
|
filterConfig.setUrlPatterns(defaultPatterns);
|
||||||
}
|
}
|
||||||
|
|
||||||
registration.addUrlPatterns(filterConfig.getUrlPatterns().toArray(new String[0]));
|
registration.addUrlPatterns(filterConfig.getUrlPatterns().toArray(new String[0]));
|
||||||
Filter filter = new CommonFilter();
|
Filter filter = new CommonFilter();
|
||||||
registration.setFilter(filter);
|
registration.setFilter(filter);
|
||||||
registration.setOrder(filterConfig.getOrder());
|
registration.setOrder(filterConfig.getOrder());
|
||||||
logger.info("[Sentinel Starter] register Sentinel with urlPatterns: {}.",
|
logger.info("[Sentinel Starter] register Sentinel with urlPatterns: {}.",
|
||||||
filterConfig.getUrlPatterns());
|
filterConfig.getUrlPatterns());
|
||||||
return registration;
|
return registration;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -16,17 +16,10 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.alibaba.sentinel.custom;
|
package org.springframework.cloud.alibaba.sentinel.custom;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.Env;
|
import java.util.Optional;
|
||||||
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlBlockHandler;
|
|
||||||
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlCleaner;
|
import javax.annotation.PostConstruct;
|
||||||
import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager;
|
|
||||||
import com.alibaba.csp.sentinel.adapter.servlet.config.WebServletConfig;
|
|
||||||
import com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect;
|
|
||||||
import com.alibaba.csp.sentinel.config.SentinelConfig;
|
|
||||||
import com.alibaba.csp.sentinel.init.InitExecutor;
|
|
||||||
import com.alibaba.csp.sentinel.node.NodeBuilder;
|
|
||||||
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
|
||||||
import com.alibaba.csp.sentinel.util.AppNameUtil;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
@ -39,8 +32,17 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import com.alibaba.csp.sentinel.Env;
|
||||||
import java.util.Optional;
|
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlBlockHandler;
|
||||||
|
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlCleaner;
|
||||||
|
import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager;
|
||||||
|
import com.alibaba.csp.sentinel.adapter.servlet.config.WebServletConfig;
|
||||||
|
import com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect;
|
||||||
|
import com.alibaba.csp.sentinel.config.SentinelConfig;
|
||||||
|
import com.alibaba.csp.sentinel.init.InitExecutor;
|
||||||
|
import com.alibaba.csp.sentinel.node.NodeBuilder;
|
||||||
|
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
||||||
|
import com.alibaba.csp.sentinel.util.AppNameUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiaojing
|
* @author xiaojing
|
||||||
@ -51,79 +53,94 @@ import java.util.Optional;
|
|||||||
@EnableConfigurationProperties(SentinelProperties.class)
|
@EnableConfigurationProperties(SentinelProperties.class)
|
||||||
public class SentinelAutoConfiguration {
|
public class SentinelAutoConfiguration {
|
||||||
|
|
||||||
@Value("${project.name:${spring.application.name:}}")
|
@Value("${project.name:${spring.application.name:}}")
|
||||||
private String projectName;
|
private String projectName;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SentinelProperties properties;
|
private SentinelProperties properties;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Optional<UrlCleaner> urlCleanerOptional;
|
private Optional<UrlCleaner> urlCleanerOptional;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Optional<UrlBlockHandler> urlBlockHandlerOptional;
|
private Optional<UrlBlockHandler> urlBlockHandlerOptional;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void init() {
|
private void init() {
|
||||||
|
|
||||||
if (StringUtils.isEmpty(System.getProperty(AppNameUtil.APP_NAME))) {
|
if (StringUtils.isEmpty(System.getProperty(AppNameUtil.APP_NAME))) {
|
||||||
System.setProperty(AppNameUtil.APP_NAME, projectName);
|
System.setProperty(AppNameUtil.APP_NAME, projectName);
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(System.getProperty(TransportConfig.SERVER_PORT)) && StringUtils.hasText(properties.getTransport().getPort())) {
|
if (StringUtils.isEmpty(System.getProperty(TransportConfig.SERVER_PORT))
|
||||||
System.setProperty(TransportConfig.SERVER_PORT, properties.getTransport().getPort());
|
&& StringUtils.hasText(properties.getTransport().getPort())) {
|
||||||
}
|
System.setProperty(TransportConfig.SERVER_PORT,
|
||||||
if (StringUtils.isEmpty(System.getProperty(TransportConfig.CONSOLE_SERVER)) && StringUtils.hasText(properties.getTransport().getDashboard())) {
|
properties.getTransport().getPort());
|
||||||
System.setProperty(TransportConfig.CONSOLE_SERVER, properties.getTransport().getDashboard());
|
}
|
||||||
}
|
if (StringUtils.isEmpty(System.getProperty(TransportConfig.CONSOLE_SERVER))
|
||||||
if (StringUtils.isEmpty(System.getProperty(TransportConfig.HEARTBEAT_INTERVAL_MS)) && StringUtils.hasText(properties.getTransport().getHeartbeatIntervalMs())) {
|
&& StringUtils.hasText(properties.getTransport().getDashboard())) {
|
||||||
System.setProperty(TransportConfig.HEARTBEAT_INTERVAL_MS, properties.getTransport().getHeartbeatIntervalMs());
|
System.setProperty(TransportConfig.CONSOLE_SERVER,
|
||||||
}
|
properties.getTransport().getDashboard());
|
||||||
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.CHARSET)) && StringUtils.hasText(properties.getCharset())) {
|
}
|
||||||
System.setProperty(SentinelConfig.CHARSET, properties.getCharset());
|
if (StringUtils.isEmpty(System.getProperty(TransportConfig.HEARTBEAT_INTERVAL_MS))
|
||||||
}
|
&& StringUtils
|
||||||
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.SINGLE_METRIC_FILE_SIZE)) && StringUtils.hasText(properties.getMetric().getFileSingleSize())) {
|
.hasText(properties.getTransport().getHeartbeatIntervalMs())) {
|
||||||
System.setProperty(SentinelConfig.SINGLE_METRIC_FILE_SIZE, properties.getMetric().getFileSingleSize());
|
System.setProperty(TransportConfig.HEARTBEAT_INTERVAL_MS,
|
||||||
}
|
properties.getTransport().getHeartbeatIntervalMs());
|
||||||
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.TOTAL_METRIC_FILE_COUNT)) && StringUtils.hasText(properties.getMetric().getFileTotalCount())) {
|
}
|
||||||
System.setProperty(SentinelConfig.TOTAL_METRIC_FILE_COUNT, properties.getMetric().getFileTotalCount());
|
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.CHARSET))
|
||||||
}
|
&& StringUtils.hasText(properties.getCharset())) {
|
||||||
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.COLD_FACTOR)) && StringUtils.hasText(properties.getFlow().getColdFactor())) {
|
System.setProperty(SentinelConfig.CHARSET, properties.getCharset());
|
||||||
System.setProperty(SentinelConfig.COLD_FACTOR, properties.getFlow().getColdFactor());
|
}
|
||||||
}
|
if (StringUtils
|
||||||
|
.isEmpty(System.getProperty(SentinelConfig.SINGLE_METRIC_FILE_SIZE))
|
||||||
|
&& StringUtils.hasText(properties.getMetric().getFileSingleSize())) {
|
||||||
|
System.setProperty(SentinelConfig.SINGLE_METRIC_FILE_SIZE,
|
||||||
|
properties.getMetric().getFileSingleSize());
|
||||||
|
}
|
||||||
|
if (StringUtils
|
||||||
|
.isEmpty(System.getProperty(SentinelConfig.TOTAL_METRIC_FILE_COUNT))
|
||||||
|
&& StringUtils.hasText(properties.getMetric().getFileTotalCount())) {
|
||||||
|
System.setProperty(SentinelConfig.TOTAL_METRIC_FILE_COUNT,
|
||||||
|
properties.getMetric().getFileTotalCount());
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.COLD_FACTOR))
|
||||||
|
&& StringUtils.hasText(properties.getFlow().getColdFactor())) {
|
||||||
|
System.setProperty(SentinelConfig.COLD_FACTOR,
|
||||||
|
properties.getFlow().getColdFactor());
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.hasText(properties.getServlet().getBlockPage())) {
|
if (StringUtils.hasText(properties.getServlet().getBlockPage())) {
|
||||||
WebServletConfig.setBlockPage(properties.getServlet().getBlockPage());
|
WebServletConfig.setBlockPage(properties.getServlet().getBlockPage());
|
||||||
}
|
}
|
||||||
urlBlockHandlerOptional.ifPresent(WebCallbackManager::setUrlBlockHandler);
|
urlBlockHandlerOptional.ifPresent(WebCallbackManager::setUrlBlockHandler);
|
||||||
urlCleanerOptional.ifPresent(WebCallbackManager::setUrlCleaner);
|
urlCleanerOptional.ifPresent(WebCallbackManager::setUrlCleaner);
|
||||||
|
|
||||||
InitExecutor.doInit();
|
InitExecutor.doInit();
|
||||||
|
|
||||||
// earlier initialize
|
// earlier initialize
|
||||||
if (properties.isEager()) {
|
if (properties.isEager()) {
|
||||||
NodeBuilder nodeBuilder = Env.nodeBuilder;
|
NodeBuilder nodeBuilder = Env.nodeBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public SentinelResourceAspect sentinelResourceAspect() {
|
public SentinelResourceAspect sentinelResourceAspect() {
|
||||||
return new SentinelResourceAspect();
|
return new SentinelResourceAspect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
@ConditionalOnClass(name = "org.springframework.web.client.RestTemplate")
|
||||||
|
public SentinelBeanPostProcessor sentinelBeanPostProcessor() {
|
||||||
|
return new SentinelBeanPostProcessor();
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
@ConditionalOnClass(name = "org.springframework.web.client.RestTemplate")
|
public SentinelDataSourcePostProcessor sentinelDataSourcePostProcessor() {
|
||||||
public SentinelBeanPostProcessor sentinelBeanPostProcessor() {
|
return new SentinelDataSourcePostProcessor();
|
||||||
return new SentinelBeanPostProcessor();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
public SentinelDataSourcePostProcessor sentinelDataSourcePostProcessor() {
|
|
||||||
return new SentinelDataSourcePostProcessor();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user