Skip to content

Commit

Permalink
Fix #961
Browse files Browse the repository at this point in the history
  • Loading branch information
nkorange committed Mar 26, 2019
1 parent a745423 commit e2a7206
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ public String update(HttpServletRequest request) throws Exception {

cluster.setHealthChecker(abstractHealthChecker);
cluster.setMetadata(UtilsAndCommons.parseMetadata(metadata));

cluster.init();
service.getClusterMap().put(clusterName, cluster);

service.setLastModifiedMillis(System.currentTimeMillis());
service.recalculateChecksum();
service.validate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public class Cluster extends com.alibaba.nacos.api.naming.pojo.Cluster implement
@JSONField(serialize = false)
private Service service;

@JSONField(serialize = false)
private volatile boolean inited = false;

private Map<String, String> metadata = new ConcurrentHashMap<>();

public Cluster() {
Expand Down Expand Up @@ -87,8 +90,12 @@ public List<Instance> allIPs(boolean ephemeral) {
}

public void init() {
if (inited) {
return;
}
checkTask = new HealthCheckTask(this);
HealthCheckReactor.scheduleCheck(checkTask);
inited = true;
}

public void destroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ public List<Instance> updateIpAddresses(Service service, String action, boolean
if (!service.getClusterMap().containsKey(instance.getClusterName())) {
Cluster cluster = new Cluster(instance.getClusterName());
cluster.setService(service);
cluster.init();
service.getClusterMap().put(instance.getClusterName(), cluster);
Loggers.SRV_LOG.warn("cluster: {} not found, ip: {}, will create new cluster with default configuration.",
instance.getClusterName(), instance.toJSON());
Expand Down

0 comments on commit e2a7206

Please sign in to comment.