Skip to content

Commit

Permalink
Merge pull request alibaba#823 from nanamikon/issues-821
Browse files Browse the repository at this point in the history
Registering instance should update valid (health)
  • Loading branch information
Fury Zhu authored Feb 27, 2019
2 parents 931a0f4 + 56f91e7 commit 1f7c2f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions naming/src/main/java/com/alibaba/nacos/naming/core/Cluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ public void updateIPs(List<IpAddress> ips) {
if (responsible(ip)) {
// do not update the ip validation status of updated ips
// because the checker has the most precise result

// Only when ip is not marked, don't we update the health status of IP:
if (!ip.isMarked()) {
ip.setValid(oldIP.isValid());
if (((VirtualClusterDomain)dom).getEnableHealthCheck() || ((VirtualClusterDomain)dom).getEnableClientBeat()) {
// Only when ip is not marked, don't we update the health status of IP:
if (!ip.isMarked()) {
ip.setValid(oldIP.isValid());
}
}

} else {
if (ip.isValid() != oldIP.isValid()) {
// ip validation status updated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,15 @@ private IpAddress getIPAddress(HttpServletRequest request) {
cluster = WebUtils.optional(request, "clusterName", UtilsAndCommons.DEFAULT_CLUSTER_NAME);
}
boolean enabled = BooleanUtils.toBoolean(WebUtils.optional(request, "enable", "true"));
boolean valid = BooleanUtils.toBoolean(WebUtils.optional(request, "valid", "true"));

IpAddress ipAddress = new IpAddress();
ipAddress.setPort(Integer.parseInt(port));
ipAddress.setIp(ip);
ipAddress.setWeight(Double.parseDouble(weight));
ipAddress.setClusterName(cluster);
ipAddress.setEnabled(enabled);
ipAddress.setValid(valid);

if (!ipAddress.validate()) {
throw new IllegalArgumentException("malfomed ip config: " + ipAddress);
Expand Down

0 comments on commit 1f7c2f9

Please sign in to comment.