|
|
@ -22,53 +22,119 @@ 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 com.alibaba.csp.sentinel.config.SentinelConfig;
|
|
|
|
|
|
|
|
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author xiaojing
|
|
|
|
* @author xiaojing
|
|
|
|
* @author hengyunabc
|
|
|
|
* @author hengyunabc
|
|
|
|
|
|
|
|
* @author jiashuai.xie
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ConfigurationProperties(prefix = SentinelConstants.PROPERTY_PREFIX)
|
|
|
|
@ConfigurationProperties(prefix = SentinelConstants.PROPERTY_PREFIX)
|
|
|
|
public class SentinelProperties {
|
|
|
|
public class SentinelProperties {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Enable sentinel auto configure, the default value is true
|
|
|
|
* earlier initialize heart-beat when the spring container starts <note> when the
|
|
|
|
|
|
|
|
* transport dependency is on classpath ,the configuration is effective </note>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private boolean eager = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* enable sentinel auto configure, the default value is true
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private boolean enabled = true;
|
|
|
|
private boolean enabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* sentinel api port,default value is 8721
|
|
|
|
* charset when sentinel write or search metric file {@link SentinelConfig#CHARSET}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private String port = "8721";
|
|
|
|
private String charset = "UTF-8";
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Sentinel dashboard address, won't try to connect dashboard when address is empty
|
|
|
|
* transport configuration about dashboard and client
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private String dashboard = "";
|
|
|
|
@NestedConfigurationProperty
|
|
|
|
|
|
|
|
private Transport transport = new Transport();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* metric configuration about resource
|
|
|
|
|
|
|
|
*/
|
|
|
|
@NestedConfigurationProperty
|
|
|
|
@NestedConfigurationProperty
|
|
|
|
private Filter filter;
|
|
|
|
private Metric metric = new Metric();
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isEnabled() {
|
|
|
|
/**
|
|
|
|
return enabled;
|
|
|
|
* web servlet configuration <note> when the application is web ,the configuration is
|
|
|
|
|
|
|
|
* effective </note>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@NestedConfigurationProperty
|
|
|
|
|
|
|
|
private Servlet servlet = new Servlet();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* sentinel filter <note> when the application is web ,the configuration is effective
|
|
|
|
|
|
|
|
* </note>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@NestedConfigurationProperty
|
|
|
|
|
|
|
|
private Filter filter = new Filter();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* flow configuration
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@NestedConfigurationProperty
|
|
|
|
|
|
|
|
private Flow flow = new Flow();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isEager() {
|
|
|
|
|
|
|
|
return eager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setEnabled(boolean enabled) {
|
|
|
|
public void setEager(boolean eager) {
|
|
|
|
this.enabled = enabled;
|
|
|
|
this.eager = eager;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Flow getFlow() {
|
|
|
|
|
|
|
|
return flow;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setFlow(Flow flow) {
|
|
|
|
|
|
|
|
this.flow = flow;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getCharset() {
|
|
|
|
|
|
|
|
return charset;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setCharset(String charset) {
|
|
|
|
|
|
|
|
this.charset = charset;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Transport getTransport() {
|
|
|
|
|
|
|
|
return transport;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setTransport(Transport transport) {
|
|
|
|
|
|
|
|
this.transport = transport;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Metric getMetric() {
|
|
|
|
|
|
|
|
return metric;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setMetric(Metric metric) {
|
|
|
|
|
|
|
|
this.metric = metric;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getPort() {
|
|
|
|
public Servlet getServlet() {
|
|
|
|
return port;
|
|
|
|
return servlet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setPort(String port) {
|
|
|
|
public void setServlet(Servlet servlet) {
|
|
|
|
this.port = port;
|
|
|
|
this.servlet = servlet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getDashboard() {
|
|
|
|
public boolean isEnabled() {
|
|
|
|
return dashboard;
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setDashboard(String dashboard) {
|
|
|
|
public void setEnabled(boolean enabled) {
|
|
|
|
this.dashboard = dashboard;
|
|
|
|
this.enabled = enabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Filter getFilter() {
|
|
|
|
public Filter getFilter() {
|
|
|
@ -79,10 +145,117 @@ public class SentinelProperties {
|
|
|
|
this.filter = filter;
|
|
|
|
this.filter = filter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class Flow {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* the cold factor {@link SentinelConfig#COLD_FACTOR}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String coldFactor = "3";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getColdFactor() {
|
|
|
|
|
|
|
|
return coldFactor;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setColdFactor(String coldFactor) {
|
|
|
|
|
|
|
|
this.coldFactor = coldFactor;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class Servlet {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* The process page when the flow control is triggered
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String blockPage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getBlockPage() {
|
|
|
|
|
|
|
|
return blockPage;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setBlockPage(String blockPage) {
|
|
|
|
|
|
|
|
this.blockPage = blockPage;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class Metric {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* the metric file size {@link SentinelConfig#SINGLE_METRIC_FILE_SIZE}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String fileSingleSize;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* the total metric file count {@link SentinelConfig#TOTAL_METRIC_FILE_COUNT}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String fileTotalCount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getFileSingleSize() {
|
|
|
|
|
|
|
|
return fileSingleSize;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setFileSingleSize(String fileSingleSize) {
|
|
|
|
|
|
|
|
this.fileSingleSize = fileSingleSize;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getFileTotalCount() {
|
|
|
|
|
|
|
|
return fileTotalCount;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setFileTotalCount(String fileTotalCount) {
|
|
|
|
|
|
|
|
this.fileTotalCount = fileTotalCount;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class Transport {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* sentinel api port,default value is 8721 {@link TransportConfig#SERVER_PORT}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String port = "8721";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* sentinel dashboard address, won't try to connect dashboard when address is
|
|
|
|
|
|
|
|
* empty {@link TransportConfig#CONSOLE_SERVER}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String dashboard = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* send heartbeat interval millisecond
|
|
|
|
|
|
|
|
* {@link TransportConfig#HEARTBEAT_INTERVAL_MS}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private String heartbeatIntervalMs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getHeartbeatIntervalMs() {
|
|
|
|
|
|
|
|
return heartbeatIntervalMs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setHeartbeatIntervalMs(String heartbeatIntervalMs) {
|
|
|
|
|
|
|
|
this.heartbeatIntervalMs = heartbeatIntervalMs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getPort() {
|
|
|
|
|
|
|
|
return port;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setPort(String port) {
|
|
|
|
|
|
|
|
this.port = port;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getDashboard() {
|
|
|
|
|
|
|
|
return dashboard;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setDashboard(String dashboard) {
|
|
|
|
|
|
|
|
this.dashboard = dashboard;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class Filter {
|
|
|
|
public static class Filter {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Sentinel filter chain order.
|
|
|
|
* sentinel filter chain order.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private int order = Ordered.HIGHEST_PRECEDENCE;
|
|
|
|
private int order = Ordered.HIGHEST_PRECEDENCE;
|
|
|
|
|
|
|
|
|
|
|
@ -107,4 +280,5 @@ public class SentinelProperties {
|
|
|
|
this.urlPatterns = urlPatterns;
|
|
|
|
this.urlPatterns = urlPatterns;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|