mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
upgrade sentinel to 1.6.3 & sync code in finchley
This commit is contained in:
parent
4f56165658
commit
0039974737
@ -18,7 +18,7 @@
|
|||||||
<description>Spring Cloud Alibaba Dependencies</description>
|
<description>Spring Cloud Alibaba Dependencies</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<sentinel.version>1.6.2</sentinel.version>
|
<sentinel.version>1.6.3</sentinel.version>
|
||||||
<oss.version>3.1.0</oss.version>
|
<oss.version>3.1.0</oss.version>
|
||||||
<seata.version>0.7.1</seata.version>
|
<seata.version>0.7.1</seata.version>
|
||||||
<nacos.client.version>1.1.1</nacos.client.version>
|
<nacos.client.version>1.1.1</nacos.client.version>
|
||||||
|
@ -36,6 +36,8 @@ spring:
|
|||||||
scg.fallback:
|
scg.fallback:
|
||||||
mode: redirect
|
mode: redirect
|
||||||
redirect: http://www.taobao.com
|
redirect: http://www.taobao.com
|
||||||
|
scg:
|
||||||
|
order: -100
|
||||||
# response-status: 444
|
# response-status: 444
|
||||||
# response-body: 1234
|
# response-body: 1234
|
||||||
# content-type: text/plain
|
# content-type: text/plain
|
||||||
|
@ -22,6 +22,7 @@ package com.alibaba.cloud.sentinel.gateway;
|
|||||||
public interface ConfigConstants {
|
public interface ConfigConstants {
|
||||||
|
|
||||||
String APP_TYPE_ZUUL_GATEWAY = "12";
|
String APP_TYPE_ZUUL_GATEWAY = "12";
|
||||||
|
String APP_TYPE_SCG_GATEWAY = "11";
|
||||||
|
|
||||||
String ZUUl_PREFIX = "spring.cloud.sentinel.zuul";
|
String ZUUl_PREFIX = "spring.cloud.sentinel.zuul";
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package com.alibaba.cloud.sentinel.gateway.scg;
|
|||||||
|
|
||||||
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 com.alibaba.cloud.sentinel.gateway.ConfigConstants;
|
import com.alibaba.cloud.sentinel.gateway.ConfigConstants;
|
||||||
import com.alibaba.cloud.sentinel.gateway.FallbackProperties;
|
import com.alibaba.cloud.sentinel.gateway.FallbackProperties;
|
||||||
@ -31,6 +32,8 @@ public class SentinelGatewayProperties {
|
|||||||
@NestedConfigurationProperty
|
@NestedConfigurationProperty
|
||||||
private FallbackProperties fallback;
|
private FallbackProperties fallback;
|
||||||
|
|
||||||
|
private Integer order = Ordered.HIGHEST_PRECEDENCE;
|
||||||
|
|
||||||
public FallbackProperties getFallback() {
|
public FallbackProperties getFallback() {
|
||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
@ -40,4 +43,11 @@ public class SentinelGatewayProperties {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getOrder() {
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrder(Integer order) {
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
}
|
}
|
@ -45,7 +45,6 @@ import org.springframework.web.server.ServerWebExchange;
|
|||||||
|
|
||||||
import com.alibaba.cloud.sentinel.gateway.ConfigConstants;
|
import com.alibaba.cloud.sentinel.gateway.ConfigConstants;
|
||||||
import com.alibaba.cloud.sentinel.gateway.FallbackProperties;
|
import com.alibaba.cloud.sentinel.gateway.FallbackProperties;
|
||||||
import com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants;
|
|
||||||
import com.alibaba.csp.sentinel.adapter.gateway.sc.SentinelGatewayFilter;
|
import com.alibaba.csp.sentinel.adapter.gateway.sc.SentinelGatewayFilter;
|
||||||
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.BlockRequestHandler;
|
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.BlockRequestHandler;
|
||||||
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
|
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
|
||||||
@ -94,7 +93,7 @@ public class SentinelSCGAutoConfiguration {
|
|||||||
|
|
||||||
private void initAppType() {
|
private void initAppType() {
|
||||||
System.setProperty(SentinelConfig.APP_TYPE,
|
System.setProperty(SentinelConfig.APP_TYPE,
|
||||||
String.valueOf(SentinelGatewayConstants.APP_TYPE_GATEWAY));
|
String.valueOf(ConfigConstants.APP_TYPE_SCG_GATEWAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFallback() {
|
private void initFallback() {
|
||||||
@ -149,8 +148,10 @@ public class SentinelSCGAutoConfiguration {
|
|||||||
@Order(-1)
|
@Order(-1)
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public SentinelGatewayFilter sentinelGatewayFilter() {
|
public SentinelGatewayFilter sentinelGatewayFilter() {
|
||||||
logger.info("[Sentinel SpringCloudGateway] register SentinelGatewayFilter");
|
logger.info(
|
||||||
return new SentinelGatewayFilter();
|
"[Sentinel SpringCloudGateway] register SentinelGatewayFilter with order: {}",
|
||||||
|
gatewayProperties.getOrder());
|
||||||
|
return new SentinelGatewayFilter(gatewayProperties.getOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,7 @@ public class SentinelAutoConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
public SentinelDataSourceHandler sentinelDataSourceHandler(
|
public SentinelDataSourceHandler sentinelDataSourceHandler(
|
||||||
DefaultListableBeanFactory beanFactory, SentinelProperties sentinelProperties,
|
DefaultListableBeanFactory beanFactory, SentinelProperties sentinelProperties,
|
||||||
Environment env) {
|
Environment env) {
|
||||||
|
@ -25,7 +25,7 @@ import feign.MethodMetadata;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Using static field {@link SentinelContractHolder#metadataMap} to hold
|
* Using static field {@link SentinelContractHolder#METADATA_MAP} to hold
|
||||||
* {@link MethodMetadata} data
|
* {@link MethodMetadata} data
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||||
@ -38,7 +38,7 @@ public class SentinelContractHolder implements Contract {
|
|||||||
* map key is constructed by ClassFullName + configKey. configKey is constructed by
|
* map key is constructed by ClassFullName + configKey. configKey is constructed by
|
||||||
* {@link feign.Feign#configKey}
|
* {@link feign.Feign#configKey}
|
||||||
*/
|
*/
|
||||||
public final static Map<String, MethodMetadata> metadataMap = new HashMap();
|
public final static Map<String, MethodMetadata> METADATA_MAP = new HashMap();
|
||||||
|
|
||||||
public SentinelContractHolder(Contract delegate) {
|
public SentinelContractHolder(Contract delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
@ -47,7 +47,7 @@ public class SentinelContractHolder implements Contract {
|
|||||||
@Override
|
@Override
|
||||||
public List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType) {
|
public List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType) {
|
||||||
List<MethodMetadata> metadatas = delegate.parseAndValidatateMetadata(targetType);
|
List<MethodMetadata> metadatas = delegate.parseAndValidatateMetadata(targetType);
|
||||||
metadatas.forEach(metadata -> metadataMap
|
metadatas.forEach(metadata -> METADATA_MAP
|
||||||
.put(targetType.getName() + metadata.configKey(), metadata));
|
.put(targetType.getName() + metadata.configKey(), metadata));
|
||||||
return metadatas;
|
return metadatas;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ public class SentinelInvocationHandler implements InvocationHandler {
|
|||||||
// only handle by HardCodedTarget
|
// only handle by HardCodedTarget
|
||||||
if (target instanceof Target.HardCodedTarget) {
|
if (target instanceof Target.HardCodedTarget) {
|
||||||
Target.HardCodedTarget hardCodedTarget = (Target.HardCodedTarget) target;
|
Target.HardCodedTarget hardCodedTarget = (Target.HardCodedTarget) target;
|
||||||
MethodMetadata methodMetadata = SentinelContractHolder.metadataMap
|
MethodMetadata methodMetadata = SentinelContractHolder.METADATA_MAP
|
||||||
.get(hardCodedTarget.type().getName()
|
.get(hardCodedTarget.type().getName()
|
||||||
+ Feign.configKey(hardCodedTarget.type(), method));
|
+ Feign.configKey(hardCodedTarget.type(), method));
|
||||||
if (methodMetadata == null) {
|
if (methodMetadata == null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user