Skip to content

Commit

Permalink
Merge commit '06304f583c27034337c16babfb99bbf004b78191' into zen5
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyuguang committed Jul 12, 2019
2 parents 7d0aebc + 06304f5 commit 31e81e0
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 121 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ It is super easy to get started with your first project.

You can download the package from the [latest stable release](https://github.com/alibaba/nacos/releases).

Take release nacos-server-0.9.0.zip for example.
Take release nacos-server-1.0.0.zip for example.
```
unzip nacos-server-0.9.0.zip
unzip nacos-server-1.0.0.zip
cd nacos/bin
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public String update(HttpServletRequest request) throws Exception {
if (StringUtils.isBlank(healthyString)) {
throw new IllegalArgumentException("Param 'healthy' is required.");
}

valid = BooleanUtils.toBoolean(healthyString);

Service service = serviceManager.getService(namespaceId, serviceName);
Expand All @@ -108,7 +108,7 @@ public String update(HttpServletRequest request) throws Exception {
Loggers.EVT_LOG.info((valid ? "[IP-ENABLED]" : "[IP-DISABLED]") + " ips: "
+ instance.getIp() + ":" + instance.getPort() + "@" + instance.getClusterName()
+ ", service: " + serviceName + ", msg: update thought HealthController api");
pushService.serviceChanged(namespaceId, service.getName());
pushService.serviceChanged(service);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public void updateIPs(Collection<Instance> instances, boolean ephemeral) {
}

setLastModifiedMillis(System.currentTimeMillis());
getPushService().serviceChanged(namespaceId, getName());
getPushService().serviceChanged(this);
StringBuilder stringBuilder = new StringBuilder();

for (Instance instance : allIPs()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public void updatedHealthStatus(String namespaceId, String serviceName, String s
}
}

pushService.serviceChanged(service.getNamespaceId(), service.getName());
pushService.serviceChanged(service);
StringBuilder stringBuilder = new StringBuilder();
List<Instance> allIps = service.allIPs();
for (Instance instance : allIps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
import com.alibaba.nacos.naming.boot.RunningConfig;
import com.alibaba.nacos.naming.boot.SpringContext;
import com.alibaba.nacos.naming.core.DistroMapper;
Expand All @@ -28,13 +26,9 @@
import com.alibaba.nacos.naming.push.PushService;
import com.ning.http.client.AsyncCompletionHandler;
import com.ning.http.client.Response;
import org.springframework.util.StringUtils;

import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;

import static com.alibaba.nacos.naming.misc.UtilsAndCommons.NUMBER_PATTERN;


/**
Expand Down Expand Up @@ -87,7 +81,7 @@ public void run() {
Loggers.EVT_LOG.info("{POS} {IP-DISABLED} valid: {}:{}@{}@{}, region: {}, msg: client timeout after {}, last beat: {}",
instance.getIp(), instance.getPort(), instance.getClusterName(), service.getName(),
UtilsAndCommons.LOCALHOST_SITE, instance.getInstanceHeartBeatTimeOut(), instance.getLastBeat());
getPushService().serviceChanged(service.getNamespaceId(), service.getName());
getPushService().serviceChanged(service);
}
}
}
Expand All @@ -99,6 +93,11 @@ public void run() {

// then remove obsolete instances:
for (Instance instance : instances) {

if (instance.isMarked()) {
continue;
}

if (System.currentTimeMillis() - instance.getLastBeat() > instance.getIpDeleteTimeout()) {
// delete instance
Loggers.SRV_LOG.info("[AUTO-DELETE-IP] service: {}, ip: {}", service.getName(), JSON.toJSONString(instance));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void run() {
instance.setHealthy(true);
Loggers.EVT_LOG.info("service: {} {POS} {IP-ENABLED} valid: {}:{}@{}, region: {}, msg: client beat ok",
cluster.getService().getName(), ip, port, cluster.getName(), UtilsAndCommons.LOCALHOST_SITE);
getPushService().serviceChanged(service.getNamespaceId(), this.service.getName());
getPushService().serviceChanged(service);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,10 @@ public void checkOK(Instance ip, HealthCheckTask task, String msg) {
ip.setHealthy(true);
ip.setMockValid(true);

Service vDom = cluster.getService();
vDom.setLastModifiedMillis(System.currentTimeMillis());

pushService.serviceChanged(vDom.getNamespaceId(), vDom.getName());
addResult(new HealthCheckResult(vDom.getName(), ip));
Service service = cluster.getService();
service.setLastModifiedMillis(System.currentTimeMillis());
pushService.serviceChanged(service);
addResult(new HealthCheckResult(service.getName(), ip));

Loggers.EVT_LOG.info("serviceName: {} {POS} {IP-ENABLED} valid: {}:{}@{}, region: {}, msg: {}",
cluster.getService().getName(), ip.getIp(), ip.getPort(), cluster.getName(), UtilsAndCommons.LOCALHOST_SITE, msg);
Expand Down Expand Up @@ -180,11 +179,11 @@ public void checkFail(Instance ip, HealthCheckTask task, String msg) {
ip.setHealthy(false);
ip.setMockValid(false);

Service vDom = cluster.getService();
vDom.setLastModifiedMillis(System.currentTimeMillis());
addResult(new HealthCheckResult(vDom.getName(), ip));
Service service = cluster.getService();
service.setLastModifiedMillis(System.currentTimeMillis());
addResult(new HealthCheckResult(service.getName(), ip));

pushService.serviceChanged(vDom.getNamespaceId(), vDom.getName());
pushService.serviceChanged(service);

Loggers.EVT_LOG.info("serviceName: {} {POS} {IP-DISABLED} invalid: {}:{}@{}, region: {}, msg: {}",
cluster.getService().getName(), ip.getIp(), ip.getPort(), cluster.getName(), UtilsAndCommons.LOCALHOST_SITE, msg);
Expand Down Expand Up @@ -215,11 +214,11 @@ public void checkFailNow(Instance ip, HealthCheckTask task, String msg) {
ip.setHealthy(false);
ip.setMockValid(false);

Service vDom = cluster.getService();
vDom.setLastModifiedMillis(System.currentTimeMillis());
Service service = cluster.getService();
service.setLastModifiedMillis(System.currentTimeMillis());

pushService.serviceChanged(vDom.getNamespaceId(), vDom.getName());
addResult(new HealthCheckResult(vDom.getName(), ip));
pushService.serviceChanged(service);
addResult(new HealthCheckResult(service.getName(), ip));

Loggers.EVT_LOG.info("serviceName: {} {POS} {IP-DISABLED} invalid-now: {}:{}@{}, region: {}, msg: {}",
cluster.getService().getName(), ip.getIp(), ip.getPort(), cluster.getName(), UtilsAndCommons.LOCALHOST_SITE, msg);
Expand Down
Loading

0 comments on commit 31e81e0

Please sign in to comment.