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

Polish java doc.

This commit is contained in:
xiaolongzuo 2019-01-29 16:10:06 +08:00
parent b3fffdda0e
commit d5d90d9c0a

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 目前尚不支持此字段配置了也没用 * Unsupported.
*/ */
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();
} }