1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

Merge pull request #327 from xiaolongzuo/1.x

Fix code format error and polish java doc.
This commit is contained in:
xiaojing 2019-01-30 10:52:03 +08:00 committed by GitHub
commit 6b0510bae8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 25 deletions

View File

@ -49,6 +49,7 @@ public class AcmEndpointAutoConfiguration {
} }
@Bean @Bean
@ConditionalOnMissingBean
public AcmHealthIndicator acmHealthIndicator(AcmProperties acmProperties, public AcmHealthIndicator acmHealthIndicator(AcmProperties acmProperties,
AcmPropertySourceRepository acmPropertySourceRepository) { AcmPropertySourceRepository acmPropertySourceRepository) {
return new AcmHealthIndicator(acmProperties, acmPropertySourceRepository); return new AcmHealthIndicator(acmProperties, acmPropertySourceRepository);

View File

@ -42,84 +42,94 @@ import com.alibaba.cloud.context.ans.AnsConfiguration;
public class AnsProperties implements AnsConfiguration { public class AnsProperties implements AnsConfiguration {
/** /**
* 服务端模式默认为LOCAL * Server side modethe default is LOCAL.
*/ */
private AliCloudServerMode serverMode = AliCloudServerMode.LOCAL; private AliCloudServerMode serverMode = AliCloudServerMode.LOCAL;
/** /**
* 服务端列表 * Server list.
*/ */
private String serverList = "127.0.0.1"; private String serverList = "127.0.0.1";
/** /**
* 服务端列表 * Server port.
*/ */
private String serverPort = "8080"; private String serverPort = "8080";
/** /**
* 注册的服务名默认从 spring.cloud.alicloud.ans.doms 中获取当没有配置时使用 spring.application.name * Service namesdefault value is ${spring.cloud.alicloud.ans.doms}. When not
* configured, use ${spring.application.name}.
*/ */
@Value("${spring.cloud.alicloud.ans.client-domains:${spring.application.name:}}") @Value("${spring.cloud.alicloud.ans.client-domains:${spring.application.name:}}")
private String clientDomains; private String clientDomains;
/** /**
* 注册服务的权重从配置 spring.cloud.alicloud.ans.weight 中获取默认为 1 * The weight of the registration service, obtained from the configuration
* ${spring.cloud.alicloud.ans.weight}, the default is 1.
*/ */
private float clientWeight = 1; private float clientWeight = 1;
/** /**
* 当存在多个doms需要对应不同的 weight 通过 spring.cloud.alicloud.ans.weight.dom1=weight1 的方式配置 * When there are multiple doms and need to correspond to different weights, configure
* them by spring.cloud.alicloud.ans.weight.dom1=weight1.
*/ */
private Map<String, Float> clientWeights = new HashMap<String, Float>(); private Map<String, Float> clientWeights = new HashMap<String, Float>();
/** /**
* 注册服务的 token spring.cloud.alicloud.ans.token 中获取 * The token of the registration service, obtained from
* ${spring.cloud.alicloud.ans.token}.
*/ */
private String clientToken; private String clientToken;
/** /**
* 当存在多个doms需要对应不同的token时通过 spring.cloud.alicloud.ans.tokens.dom1=token1 的方式配置 * When there are multiple doms and need to correspond to different tokens, configure
* them by spring.cloud.alicloud.ans.tokens.dom1=token1.
*/ */
private Map<String, String> clientTokens = new HashMap<String, String>(); private Map<String, String> clientTokens = new HashMap<String, String>();
/** /**
* 配置注册到哪个集群 spring.cloud.alicloud.ans.cluster 中获取默认为 DEFAULT * Configure which cluster to register with, obtained from
* ${spring.cloud.alicloud.ans.cluster}, defaults to DEFAULT.
*/ */
private String clientCluster = "DEFAULT"; private String clientCluster = "DEFAULT";
/** /**
* metadata 实现 serviceInstance 接口所需的字段 ans 目前尚不支持此字段配置了也没用 * Temporarily not supported, reserved fields.
*/ */
private Map<String, String> clientMetadata = new HashMap<>(); private Map<String, String> clientMetadata = new HashMap<>();
/** /**
* 默认打开注册可以通过 spring.cloud.alicloud.ans.register-enabled=false 的配置来关闭注册 * Registration is turned on by default, and registration can be turned off by the
* configuration of spring.cloud.alicloud.ans.register-enabled=false.
*/ */
private boolean registerEnabled = true; private boolean registerEnabled = true;
/** /**
* 想要发布的服务的ip spring.cloud.alicloud.ans.client-ip 中获取 * The ip of the service you want to publish, obtained from
* ${spring.cloud.alicloud.ans.client-ip}.
*/ */
private String clientIp; private String clientIp;
/** /**
* 想要发布的服务的ip从哪一块网卡中获取 * Configure which NIC the ip of the service you want to publish is obtained from.
*/ */
private String clientInterfaceName; private String clientInterfaceName;
/** /**
* 想要发布的服务的端口 spring.cloud.alicloud.ans.port 中获取 * The port of the service you want to publish.
*/ */
private int clientPort = -1; private int clientPort = -1;
/** /**
* 租户下的环境隔离配置相同租户的相同环境下的服务才能互相发现 * The environment isolation configuration under the tenant, the services in the same
* environment of the same tenant can discover each other.
*/ */
@Value("${spring.cloud.alicloud.ans.env:${env.id:DEFAULT}}") @Value("${spring.cloud.alicloud.ans.env:${env.id:DEFAULT}}")
private String env; private String env;
/** /**
* 是否注册成 https 的形式通过 spring.cloud.alicloud.ans.secure 来配置默认为false * Whether to register as https, configured by ${spring.cloud.alicloud.ans.secure},
* default is false.
*/ */
private boolean secure = false; private boolean secure = false;
@ -131,11 +141,10 @@ public class AnsProperties implements AnsConfiguration {
@PostConstruct @PostConstruct
public void init() throws SocketException { public void init() throws SocketException {
// 增加注册类型标记为 spring cloud 应用 // Marked as spring cloud application
tags.put("ANS_SERVICE_TYPE", "SPRING_CLOUD"); tags.put("ANS_SERVICE_TYPE", "SPRING_CLOUD");
if (StringUtils.isEmpty(clientIp)) { if (StringUtils.isEmpty(clientIp)) {
// 如果没有指定注册的ip对应的网卡名则通过遍历网卡去获取
if (StringUtils.isEmpty(clientInterfaceName)) { if (StringUtils.isEmpty(clientInterfaceName)) {
clientIp = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); clientIp = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
} }

View File

@ -27,12 +27,13 @@ public class NacosParameterInitListener
EdasChangeOrderConfiguration edasChangeOrderConfiguration = EdasChangeOrderConfigurationFactory EdasChangeOrderConfiguration edasChangeOrderConfiguration = EdasChangeOrderConfigurationFactory
.getEdasChangeOrderConfiguration(); .getEdasChangeOrderConfiguration();
log.info("Initialize Nacos Parameter from edas change order,is edas managed {}.",
edasChangeOrderConfiguration.isEdasManaged());
if (!edasChangeOrderConfiguration.isEdasManaged()) { if (!edasChangeOrderConfiguration.isEdasManaged()) {
return; return;
} }
log.info("Initialize Nacos Parameter from edas change order,is edas managed {}.",
edasChangeOrderConfiguration.isEdasManaged());
// initialize nacos configuration // initialize nacos configuration
System.getProperties().setProperty("spring.cloud.nacos.config.server-addr", ""); System.getProperties().setProperty("spring.cloud.nacos.config.server-addr", "");
System.getProperties().setProperty("spring.cloud.nacos.config.endpoint", System.getProperties().setProperty("spring.cloud.nacos.config.endpoint",

View File

@ -39,7 +39,7 @@ public class OssStorageProtocolResolver
public static final String PROTOCOL = "oss://"; public static final String PROTOCOL = "oss://";
private static final Logger logger = LoggerFactory private static final Logger log = LoggerFactory
.getLogger(OssStorageProtocolResolver.class); .getLogger(OssStorageProtocolResolver.class);
private ConfigurableListableBeanFactory beanFactory; private ConfigurableListableBeanFactory beanFactory;
@ -49,8 +49,9 @@ public class OssStorageProtocolResolver
private OSS getOSS() { private OSS getOSS() {
if (this.oss == null) { if (this.oss == null) {
if (this.beanFactory.getBeansOfType(OSS.class).size() > 1) { if (this.beanFactory.getBeansOfType(OSS.class).size() > 1) {
logger.warn( log.warn(
"There are multiple OSS instances, consider marking one of them as @Primary to resolve oss protocol."); "There are multiple OSS instances, consider marking one of them as @Primary to resolve oss "
+ "protocol.");
} }
this.oss = this.beanFactory.getBean(OSS.class); this.oss = this.beanFactory.getBean(OSS.class);
} }
@ -71,7 +72,7 @@ public class OssStorageProtocolResolver
((DefaultResourceLoader) resourceLoader).addProtocolResolver(this); ((DefaultResourceLoader) resourceLoader).addProtocolResolver(this);
} }
else { else {
logger.warn("The provided delegate resource loader is not an implementation " log.warn("The provided delegate resource loader is not an implementation "
+ "of DefaultResourceLoader. Custom Protocol using oss:// prefix will not be enabled."); + "of DefaultResourceLoader. Custom Protocol using oss:// prefix will not be enabled.");
} }
} }