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>
|
||||
|
||||
<properties>
|
||||
<sentinel.version>1.6.2</sentinel.version>
|
||||
<sentinel.version>1.6.3</sentinel.version>
|
||||
<oss.version>3.1.0</oss.version>
|
||||
<seata.version>0.7.1</seata.version>
|
||||
<nacos.client.version>1.1.1</nacos.client.version>
|
||||
|
@ -36,6 +36,8 @@ spring:
|
||||
scg.fallback:
|
||||
mode: redirect
|
||||
redirect: http://www.taobao.com
|
||||
scg:
|
||||
order: -100
|
||||
# response-status: 444
|
||||
# response-body: 1234
|
||||
# content-type: text/plain
|
||||
|
@ -22,6 +22,7 @@ package com.alibaba.cloud.sentinel.gateway;
|
||||
public interface ConfigConstants {
|
||||
|
||||
String APP_TYPE_ZUUL_GATEWAY = "12";
|
||||
String APP_TYPE_SCG_GATEWAY = "11";
|
||||
|
||||
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.NestedConfigurationProperty;
|
||||
import org.springframework.core.Ordered;
|
||||
|
||||
import com.alibaba.cloud.sentinel.gateway.ConfigConstants;
|
||||
import com.alibaba.cloud.sentinel.gateway.FallbackProperties;
|
||||
@ -31,6 +32,8 @@ public class SentinelGatewayProperties {
|
||||
@NestedConfigurationProperty
|
||||
private FallbackProperties fallback;
|
||||
|
||||
private Integer order = Ordered.HIGHEST_PRECEDENCE;
|
||||
|
||||
public FallbackProperties getFallback() {
|
||||
return fallback;
|
||||
}
|
||||
@ -40,4 +43,11 @@ public class SentinelGatewayProperties {
|
||||
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.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.callback.BlockRequestHandler;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
|
||||
@ -94,7 +93,7 @@ public class SentinelSCGAutoConfiguration {
|
||||
|
||||
private void initAppType() {
|
||||
System.setProperty(SentinelConfig.APP_TYPE,
|
||||
String.valueOf(SentinelGatewayConstants.APP_TYPE_GATEWAY));
|
||||
String.valueOf(ConfigConstants.APP_TYPE_SCG_GATEWAY));
|
||||
}
|
||||
|
||||
private void initFallback() {
|
||||
@ -149,8 +148,10 @@ public class SentinelSCGAutoConfiguration {
|
||||
@Order(-1)
|
||||
@ConditionalOnMissingBean
|
||||
public SentinelGatewayFilter sentinelGatewayFilter() {
|
||||
logger.info("[Sentinel SpringCloudGateway] register SentinelGatewayFilter");
|
||||
return new SentinelGatewayFilter();
|
||||
logger.info(
|
||||
"[Sentinel SpringCloudGateway] register SentinelGatewayFilter with order: {}",
|
||||
gatewayProperties.getOrder());
|
||||
return new SentinelGatewayFilter(gatewayProperties.getOrder());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -152,6 +152,7 @@ public class SentinelAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SentinelDataSourceHandler sentinelDataSourceHandler(
|
||||
DefaultListableBeanFactory beanFactory, SentinelProperties sentinelProperties,
|
||||
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
|
||||
*
|
||||
* @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
|
||||
* {@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) {
|
||||
this.delegate = delegate;
|
||||
@ -47,7 +47,7 @@ public class SentinelContractHolder implements Contract {
|
||||
@Override
|
||||
public List<MethodMetadata> parseAndValidatateMetadata(Class<?> targetType) {
|
||||
List<MethodMetadata> metadatas = delegate.parseAndValidatateMetadata(targetType);
|
||||
metadatas.forEach(metadata -> metadataMap
|
||||
metadatas.forEach(metadata -> METADATA_MAP
|
||||
.put(targetType.getName() + metadata.configKey(), metadata));
|
||||
return metadatas;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class SentinelInvocationHandler implements InvocationHandler {
|
||||
// only handle by HardCodedTarget
|
||||
if (target instanceof Target.HardCodedTarget) {
|
||||
Target.HardCodedTarget hardCodedTarget = (Target.HardCodedTarget) target;
|
||||
MethodMetadata methodMetadata = SentinelContractHolder.metadataMap
|
||||
MethodMetadata methodMetadata = SentinelContractHolder.METADATA_MAP
|
||||
.get(hardCodedTarget.type().getName()
|
||||
+ Feign.configKey(hardCodedTarget.type(), method));
|
||||
if (methodMetadata == null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user