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

sync to edgware before graduation

This commit is contained in:
fangjian0423
2019-07-28 19:42:32 +08:00
parent f19c83a7a9
commit e0c0a9f1c3
21 changed files with 252 additions and 151 deletions

View File

@@ -155,6 +155,21 @@ public class NacosDiscoveryProperties {
*/
private String secretKey;
/**
* Heart beat interval. Time unit: second.
*/
private Integer heartBeatInterval;
/**
* Heart beat timeout. Time unit: second.
*/
private Integer heartBeatTimeout;
/**
* Ip delete timeout. Time unit: second.
*/
private Integer ipDeleteTimeout;
@Autowired
private InetUtils inetUtils;
@@ -339,6 +354,30 @@ public class NacosDiscoveryProperties {
this.secretKey = secretKey;
}
public Integer getHeartBeatInterval() {
return heartBeatInterval;
}
public void setHeartBeatInterval(Integer heartBeatInterval) {
this.heartBeatInterval = heartBeatInterval;
}
public Integer getHeartBeatTimeout() {
return heartBeatTimeout;
}
public void setHeartBeatTimeout(Integer heartBeatTimeout) {
this.heartBeatTimeout = heartBeatTimeout;
}
public Integer getIpDeleteTimeout() {
return ipDeleteTimeout;
}
public void setIpDeleteTimeout(Integer ipDeleteTimeout) {
this.ipDeleteTimeout = ipDeleteTimeout;
}
public String getNamingLoadCacheAtStart() {
return namingLoadCacheAtStart;
}

View File

@@ -31,6 +31,7 @@ import org.springframework.util.StringUtils;
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
/**
* @author xiaojing
@@ -53,11 +54,10 @@ public class NacosRegistration implements Registration, ServiceInstance {
@PostConstruct
public void init() {
Map<String, String> metadata = nacosDiscoveryProperties.getMetadata();
Environment env = context.getEnvironment();
Integer managementPort = ManagementServerPortUtils.getPort(context);
if (null != managementPort) {
Map<String, String> metadata = nacosDiscoveryProperties.getMetadata();
metadata.put(MANAGEMENT_PORT, managementPort.toString());
String contextPath = env.getProperty("management.context-path");
String address = env.getProperty("management.address");
@@ -68,6 +68,19 @@ public class NacosRegistration implements Registration, ServiceInstance {
metadata.put(MANAGEMENT_ADDRESS, address);
}
}
if (null != nacosDiscoveryProperties.getHeartBeatInterval()) {
metadata.put(PreservedMetadataKeys.HEART_BEAT_INTERVAL,
nacosDiscoveryProperties.getHeartBeatInterval().toString());
}
if (null != nacosDiscoveryProperties.getHeartBeatTimeout()) {
metadata.put(PreservedMetadataKeys.HEART_BEAT_TIMEOUT,
nacosDiscoveryProperties.getHeartBeatTimeout().toString());
}
if (null != nacosDiscoveryProperties.getIpDeleteTimeout()) {
metadata.put(PreservedMetadataKeys.IP_DELETE_TIMEOUT,
nacosDiscoveryProperties.getIpDeleteTimeout().toString());
}
}
@Override