Merge pull request #326 from xiaolongzuo/master

Polish java doc.
pull/335/head
xiaojing 6 years ago committed by GitHub
commit efa89e6fea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;
/** /**
* domstoken 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();
} }

Loading…
Cancel
Save