mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
Merge pull request #1433 from yuhuangbin/sentinel-1.7.2
Upgrade Sentinel version to 1.7.2
This commit is contained in:
commit
593433502d
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>2.2.1.RELEASE</revision>
|
<revision>2.2.1.RELEASE</revision>
|
||||||
<sentinel.version>1.7.1</sentinel.version>
|
<sentinel.version>1.7.2</sentinel.version>
|
||||||
<oss.version>3.1.0</oss.version>
|
<oss.version>3.1.0</oss.version>
|
||||||
<seata.version>1.1.0</seata.version>
|
<seata.version>1.1.0</seata.version>
|
||||||
<nacos.client.version>1.2.1</nacos.client.version>
|
<nacos.client.version>1.2.1</nacos.client.version>
|
||||||
|
@ -9,6 +9,7 @@ management.health.diskspace.enabled=false
|
|||||||
|
|
||||||
spring.cloud.sentinel.transport.dashboard=localhost:8080
|
spring.cloud.sentinel.transport.dashboard=localhost:8080
|
||||||
spring.cloud.sentinel.eager=true
|
spring.cloud.sentinel.eager=true
|
||||||
|
spring.cloud.sentinel.web-context-unify=true
|
||||||
|
|
||||||
#spring.cloud.sentinel.block-page=/errorPage
|
#spring.cloud.sentinel.block-page=/errorPage
|
||||||
#spring.cloud.sentinel.filter.enabled=false
|
#spring.cloud.sentinel.filter.enabled=false
|
||||||
|
@ -102,6 +102,20 @@ public class SentinelProperties {
|
|||||||
*/
|
*/
|
||||||
private Boolean httpMethodSpecify = false;
|
private Boolean httpMethodSpecify = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify whether unify web context(i.e. use the default context name), and is true
|
||||||
|
* by default.
|
||||||
|
*/
|
||||||
|
private Boolean webContextUnify = true;
|
||||||
|
|
||||||
|
public Boolean getWebContextUnify() {
|
||||||
|
return webContextUnify;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWebContextUnify(Boolean webContextUnify) {
|
||||||
|
this.webContextUnify = webContextUnify;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEager() {
|
public boolean isEager() {
|
||||||
return eager;
|
return eager;
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,7 @@ public class SentinelWebAutoConfiguration implements WebMvcConfigurer {
|
|||||||
public SentinelWebMvcConfig sentinelWebMvcConfig() {
|
public SentinelWebMvcConfig sentinelWebMvcConfig() {
|
||||||
SentinelWebMvcConfig sentinelWebMvcConfig = new SentinelWebMvcConfig();
|
SentinelWebMvcConfig sentinelWebMvcConfig = new SentinelWebMvcConfig();
|
||||||
sentinelWebMvcConfig.setHttpMethodSpecify(properties.getHttpMethodSpecify());
|
sentinelWebMvcConfig.setHttpMethodSpecify(properties.getHttpMethodSpecify());
|
||||||
|
sentinelWebMvcConfig.setWebContextUnify(properties.getWebContextUnify());
|
||||||
|
|
||||||
if (blockExceptionHandlerOptional.isPresent()) {
|
if (blockExceptionHandlerOptional.isPresent()) {
|
||||||
blockExceptionHandlerOptional
|
blockExceptionHandlerOptional
|
||||||
|
@ -61,7 +61,7 @@ public class SentinelEndpoint {
|
|||||||
result.put("metricsFileSize", SentinelConfig.singleMetricFileSize());
|
result.put("metricsFileSize", SentinelConfig.singleMetricFileSize());
|
||||||
result.put("metricsFileCharset", SentinelConfig.charset());
|
result.put("metricsFileCharset", SentinelConfig.charset());
|
||||||
result.put("totalMetricsFileCount", SentinelConfig.totalMetricFileCount());
|
result.put("totalMetricsFileCount", SentinelConfig.totalMetricFileCount());
|
||||||
result.put("consoleServer", TransportConfig.getConsoleServer());
|
result.put("consoleServer", TransportConfig.getConsoleServerList());
|
||||||
result.put("clientIp", TransportConfig.getHeartbeatClientIp());
|
result.put("clientIp", TransportConfig.getHeartbeatClientIp());
|
||||||
result.put("heartbeatIntervalMs", TransportConfig.getHeartbeatIntervalMs());
|
result.put("heartbeatIntervalMs", TransportConfig.getHeartbeatIntervalMs());
|
||||||
result.put("clientPort", TransportConfig.getPort());
|
result.put("clientPort", TransportConfig.getPort());
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package com.alibaba.cloud.sentinel.endpoint;
|
package com.alibaba.cloud.sentinel.endpoint;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.alibaba.cloud.sentinel.SentinelProperties;
|
import com.alibaba.cloud.sentinel.SentinelProperties;
|
||||||
@ -24,13 +25,14 @@ import com.alibaba.csp.sentinel.datasource.AbstractDataSource;
|
|||||||
import com.alibaba.csp.sentinel.heartbeat.HeartbeatSenderProvider;
|
import com.alibaba.csp.sentinel.heartbeat.HeartbeatSenderProvider;
|
||||||
import com.alibaba.csp.sentinel.transport.HeartbeatSender;
|
import com.alibaba.csp.sentinel.transport.HeartbeatSender;
|
||||||
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
||||||
|
import com.alibaba.csp.sentinel.util.function.Tuple2;
|
||||||
|
|
||||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.Health;
|
import org.springframework.boot.actuate.health.Health;
|
||||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||||
import org.springframework.boot.actuate.health.Status;
|
import org.springframework.boot.actuate.health.Status;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link HealthIndicator} for Sentinel, which checks the status of Sentinel Dashboard
|
* A {@link HealthIndicator} for Sentinel, which checks the status of Sentinel Dashboard
|
||||||
@ -82,8 +84,9 @@ public class SentinelHealthIndicator extends AbstractHealthIndicator {
|
|||||||
|
|
||||||
// Check health of Dashboard
|
// Check health of Dashboard
|
||||||
boolean dashboardUp = true;
|
boolean dashboardUp = true;
|
||||||
String consoleServer = TransportConfig.getConsoleServer();
|
List<Tuple2<String, Integer>> consoleServerList = TransportConfig
|
||||||
if (StringUtils.isEmpty(consoleServer)) {
|
.getConsoleServerList();
|
||||||
|
if (CollectionUtils.isEmpty(consoleServerList)) {
|
||||||
// If Dashboard isn't configured, it's OK and mark the status of Dashboard
|
// If Dashboard isn't configured, it's OK and mark the status of Dashboard
|
||||||
// with UNKNOWN.
|
// with UNKNOWN.
|
||||||
detailMap.put("dashboard",
|
detailMap.put("dashboard",
|
||||||
@ -101,8 +104,10 @@ public class SentinelHealthIndicator extends AbstractHealthIndicator {
|
|||||||
else {
|
else {
|
||||||
// If failed to send heartbeat message, means that the Dashboard is DOWN
|
// If failed to send heartbeat message, means that the Dashboard is DOWN
|
||||||
dashboardUp = false;
|
dashboardUp = false;
|
||||||
detailMap.put("dashboard", new Status(Status.DOWN.getCode(),
|
detailMap.put("dashboard",
|
||||||
consoleServer + " can't be connected"));
|
new Status(Status.DOWN.getCode(), String.format(
|
||||||
|
"the dashboard servers [%s] one of them can't be connected",
|
||||||
|
consoleServerList)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,12 @@
|
|||||||
"defaultValue": false,
|
"defaultValue": false,
|
||||||
"description": "earlier initialize heart-beat when the spring container starts when the transport dependency is on classpath, the configuration is effective."
|
"description": "earlier initialize heart-beat when the spring container starts when the transport dependency is on classpath, the configuration is effective."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "spring.cloud.sentinel.web-context-unify",
|
||||||
|
"type": "java.lang.Boolean",
|
||||||
|
"defaultValue": true,
|
||||||
|
"description": "Specify whether unify web context(i.e. use the default context name), and is true by default."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "spring.cloud.sentinel.transport.port",
|
"name": "spring.cloud.sentinel.transport.port",
|
||||||
"type": "java.lang.String",
|
"type": "java.lang.String",
|
||||||
|
@ -33,6 +33,7 @@ import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
|
|||||||
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
|
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
|
||||||
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
|
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
|
||||||
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
||||||
|
import com.alibaba.csp.sentinel.util.function.Tuple2;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -73,7 +74,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
|||||||
"spring.cloud.sentinel.flow.coldFactor=3",
|
"spring.cloud.sentinel.flow.coldFactor=3",
|
||||||
"spring.cloud.sentinel.eager=true",
|
"spring.cloud.sentinel.eager=true",
|
||||||
"spring.cloud.sentinel.log.switchPid=true",
|
"spring.cloud.sentinel.log.switchPid=true",
|
||||||
"spring.cloud.sentinel.transport.dashboard=http://localhost:8080",
|
"spring.cloud.sentinel.transport.dashboard=http://localhost:8080,http://localhost:8081",
|
||||||
"spring.cloud.sentinel.transport.port=9999",
|
"spring.cloud.sentinel.transport.port=9999",
|
||||||
"spring.cloud.sentinel.transport.clientIp=1.1.1.1",
|
"spring.cloud.sentinel.transport.clientIp=1.1.1.1",
|
||||||
"spring.cloud.sentinel.transport.heartbeatIntervalMs=20000" },
|
"spring.cloud.sentinel.transport.heartbeatIntervalMs=20000" },
|
||||||
@ -142,7 +143,9 @@ public class SentinelAutoConfigurationTests {
|
|||||||
Map<String, Object> map = sentinelEndpoint.invoke();
|
Map<String, Object> map = sentinelEndpoint.invoke();
|
||||||
|
|
||||||
assertThat(map.get("logUsePid")).isEqualTo(Boolean.TRUE);
|
assertThat(map.get("logUsePid")).isEqualTo(Boolean.TRUE);
|
||||||
assertThat(map.get("consoleServer")).isEqualTo("http://localhost:8080");
|
assertThat(map.get("consoleServer").toString()).isEqualTo(
|
||||||
|
Arrays.asList(Tuple2.of("localhost", 8080), Tuple2.of("localhost", 8081))
|
||||||
|
.toString());
|
||||||
assertThat(map.get("clientPort")).isEqualTo("9999");
|
assertThat(map.get("clientPort")).isEqualTo("9999");
|
||||||
assertThat(map.get("heartbeatIntervalMs")).isEqualTo(20000L);
|
assertThat(map.get("heartbeatIntervalMs")).isEqualTo(20000L);
|
||||||
assertThat(map.get("clientIp")).isEqualTo("1.1.1.1");
|
assertThat(map.get("clientIp")).isEqualTo("1.1.1.1");
|
||||||
@ -174,7 +177,7 @@ public class SentinelAutoConfigurationTests {
|
|||||||
private void checkSentinelTransport() {
|
private void checkSentinelTransport() {
|
||||||
assertThat(sentinelProperties.getTransport().getPort()).isEqualTo("9999");
|
assertThat(sentinelProperties.getTransport().getPort()).isEqualTo("9999");
|
||||||
assertThat(sentinelProperties.getTransport().getDashboard())
|
assertThat(sentinelProperties.getTransport().getDashboard())
|
||||||
.isEqualTo("http://localhost:8080");
|
.isEqualTo("http://localhost:8080,http://localhost:8081");
|
||||||
assertThat(sentinelProperties.getTransport().getClientIp()).isEqualTo("1.1.1.1");
|
assertThat(sentinelProperties.getTransport().getClientIp()).isEqualTo("1.1.1.1");
|
||||||
assertThat(sentinelProperties.getTransport().getHeartbeatIntervalMs())
|
assertThat(sentinelProperties.getTransport().getHeartbeatIntervalMs())
|
||||||
.isEqualTo("20000");
|
.isEqualTo("20000");
|
||||||
@ -191,7 +194,9 @@ public class SentinelAutoConfigurationTests {
|
|||||||
@Test
|
@Test
|
||||||
public void testSentinelSystemProperties() {
|
public void testSentinelSystemProperties() {
|
||||||
assertThat(LogBase.isLogNameUsePid()).isEqualTo(true);
|
assertThat(LogBase.isLogNameUsePid()).isEqualTo(true);
|
||||||
assertThat(TransportConfig.getConsoleServer()).isEqualTo("http://localhost:8080");
|
assertThat(TransportConfig.getConsoleServerList().toString()).isEqualTo(
|
||||||
|
Arrays.asList(Tuple2.of("localhost", 8080), Tuple2.of("localhost", 8081))
|
||||||
|
.toString());
|
||||||
assertThat(TransportConfig.getPort()).isEqualTo("9999");
|
assertThat(TransportConfig.getPort()).isEqualTo("9999");
|
||||||
assertThat(TransportConfig.getHeartbeatIntervalMs().longValue())
|
assertThat(TransportConfig.getHeartbeatIntervalMs().longValue())
|
||||||
.isEqualTo(20000L);
|
.isEqualTo(20000L);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user