diff --git a/api/pom.xml b/api/pom.xml
index 6c6560a59..5bb255ec9 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -16,7 +16,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
4.0.0
diff --git a/client/pom.xml b/client/pom.xml
index ac2038af6..97707da92 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -16,7 +16,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
../pom.xml
diff --git a/cmdb/pom.xml b/cmdb/pom.xml
index 9a554b7d5..7c62fd0be 100644
--- a/cmdb/pom.xml
+++ b/cmdb/pom.xml
@@ -18,7 +18,7 @@
nacos-all
com.alibaba.nacos
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
../pom.xml
4.0.0
diff --git a/common/pom.xml b/common/pom.xml
index b651942f3..dcb043448 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
../pom.xml
4.0.0
diff --git a/config/pom.xml b/config/pom.xml
index 94c3f6112..ee4f6557c 100644
--- a/config/pom.xml
+++ b/config/pom.xml
@@ -17,7 +17,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
4.0.0
diff --git a/console/pom.xml b/console/pom.xml
index f9622740b..a91260678 100644
--- a/console/pom.xml
+++ b/console/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
nacos-console
diff --git a/core/pom.xml b/core/pom.xml
index d83e2c3e3..849d652b3 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
../pom.xml
diff --git a/distribution/pom.xml b/distribution/pom.xml
index bb7262064..53a5adaed 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
../pom.xml
diff --git a/example/pom.xml b/example/pom.xml
index 8520fecd3..5002dda3a 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
../pom.xml
diff --git a/naming/pom.xml b/naming/pom.xml
index 147adc31d..0f55ba330 100644
--- a/naming/pom.xml
+++ b/naming/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
../pom.xml
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/distro/DistroConsistencyServiceImpl.java b/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/distro/DistroConsistencyServiceImpl.java
index 88e332834..d6cfbe0bf 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/distro/DistroConsistencyServiceImpl.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/consistency/ephemeral/distro/DistroConsistencyServiceImpl.java
@@ -102,6 +102,8 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
private volatile Map> listeners = new ConcurrentHashMap<>();
+ private volatile Map syncChecksumTasks = new ConcurrentHashMap<>(16);
+
@PostConstruct
public void init() throws Exception {
GlobalExecutor.submit(new Runnable() {
@@ -190,6 +192,14 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
public void onReceiveChecksums(Map checksumMap, String server) {
+ if (syncChecksumTasks.containsKey(server)) {
+ // Already in process of this server:
+ Loggers.EPHEMERAL.warn("sync checksum task already in process with {}", server);
+ return;
+ }
+
+ syncChecksumTasks.put(server, "1");
+
List toUpdateKeys = new ArrayList<>();
List toRemoveKeys = new ArrayList<>();
for (Map.Entry entry : checksumMap.entrySet()) {
@@ -234,6 +244,8 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
Loggers.EPHEMERAL.error("get data from " + server + " failed!", e);
}
+ // Remove this 'in process' flag:
+ syncChecksumTasks.remove(server);
}
public boolean syncAllDataFromRemote(Server server) {
@@ -261,6 +273,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
// pretty sure the service not exist:
if (ServerMode.AP.name().equals(switchDomain.getServerMode())) {
// create empty service
+ Loggers.EPHEMERAL.info("creating service {}", entry.getKey());
Service service = new Service();
String serviceName = KeyBuilder.getServiceName(entry.getKey());
String namespaceId = KeyBuilder.getNamespace(entry.getKey());
@@ -277,19 +290,24 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
}
for (Map.Entry> entry : datumMap.entrySet()) {
- dataStore.put(entry.getKey(), entry.getValue());
if (!listeners.containsKey(entry.getKey())) {
- Loggers.EPHEMERAL.warn("listener not found: {}", entry.getKey());
+ // Should not happen:
+ Loggers.EPHEMERAL.warn("listener of {} not found.", entry.getKey());
continue;
}
- for (RecordListener listener : listeners.get(entry.getKey())) {
- try {
+
+ try {
+ for (RecordListener listener : listeners.get(entry.getKey())) {
listener.onChange(entry.getKey(), entry.getValue().value);
- } catch (Exception e) {
- Loggers.EPHEMERAL.error("notify " + listener + ", key: " + entry.getKey() + " failed.", e);
}
+ } catch (Exception e) {
+ Loggers.EPHEMERAL.error("[NACOS-DISTRO] error while execute listener of key: {}", entry.getKey(), e);
+ continue;
}
+
+ // Update data store if listener executed successfully:
+ dataStore.put(entry.getKey(), entry.getValue());
}
}
}
@@ -384,7 +402,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
continue;
}
} catch (Throwable e) {
- Loggers.EPHEMERAL.error("[NACOS-DISTRO] error while notifying listener of key: {} {}", datumKey, e);
+ Loggers.EPHEMERAL.error("[NACOS-DISTRO] error while notifying listener of key: {}", datumKey, e);
}
}
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java
index 2504a2767..6fb7ea93f 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/DistroController.java
@@ -15,6 +15,7 @@
*/
package com.alibaba.nacos.naming.controllers;
+import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.nacos.core.utils.WebUtils;
import com.alibaba.nacos.naming.cluster.ServerMode;
@@ -106,7 +107,9 @@ public class DistroController {
@RequestMapping(value = "/datum", method = RequestMethod.GET)
public void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
- String keys = WebUtils.required(request, "keys");
+
+ String entity = IOUtils.toString(request.getInputStream(), "UTF-8");
+ String keys = JSON.parseObject(entity).getString("keys");
String keySplitter = ",";
Map datumMap = new HashMap<>(64);
for (String key : keys.split(keySplitter)) {
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
index 2aa1498b7..e0a905482 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/core/Service.java
@@ -18,8 +18,8 @@ package com.alibaba.nacos.naming.core;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.nacos.naming.boot.SpringContext;
-import com.alibaba.nacos.naming.consistency.RecordListener;
import com.alibaba.nacos.naming.consistency.KeyBuilder;
+import com.alibaba.nacos.naming.consistency.RecordListener;
import com.alibaba.nacos.naming.healthcheck.ClientBeatCheckTask;
import com.alibaba.nacos.naming.healthcheck.ClientBeatProcessor;
import com.alibaba.nacos.naming.healthcheck.HealthCheckReactor;
@@ -156,14 +156,19 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
Loggers.SRV_LOG.info("[NACOS-RAFT] datum is changed, key: {}, value: {}", key, value);
- for (Instance ip : value.getInstanceList()) {
+ for (Instance instance : value.getInstanceList()) {
- if (ip.getWeight() > 10000.0D) {
- ip.setWeight(10000.0D);
+ if (instance == null) {
+ // Reject this abnormal instance list:
+ throw new RuntimeException("got null instance " + key);
}
- if (ip.getWeight() < 0.01D && ip.getWeight() > 0.0D) {
- ip.setWeight(0.01D);
+ if (instance.getWeight() > 10000.0D) {
+ instance.setWeight(10000.0D);
+ }
+
+ if (instance.getWeight() < 0.01D && instance.getWeight() > 0.0D) {
+ instance.setWeight(0.01D);
}
}
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java
index a054ca084..d259c80ba 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java
@@ -79,6 +79,8 @@ public class ServiceManager implements RecordListener {
@Autowired
private PushService pushService;
+ private final Object putServiceLock = new Object();
+
@PostConstruct
public void init() {
@@ -330,6 +332,7 @@ public class ServiceManager implements RecordListener {
public void createEmptyService(String namespaceId, String serviceName) throws NacosException {
Service service = getService(namespaceId, serviceName);
if (service == null) {
+ Loggers.SRV_LOG.info("creating empty service {}:{}", namespaceId, serviceName);
service = new Service();
service.setName(serviceName);
service.setNamespaceId(namespaceId);
@@ -521,7 +524,11 @@ public class ServiceManager implements RecordListener {
public void putService(Service service) {
if (!serviceMap.containsKey(service.getNamespaceId())) {
- serviceMap.put(service.getNamespaceId(), new ConcurrentHashMap<>(16));
+ synchronized (putServiceLock) {
+ if (!serviceMap.containsKey(service.getNamespaceId())) {
+ serviceMap.put(service.getNamespaceId(), new ConcurrentHashMap<>(16));
+ }
+ }
}
serviceMap.get(service.getNamespaceId()).put(service.getName(), service);
}
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/HttpClient.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/HttpClient.java
index dc54484b2..a6d54d18a 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/misc/HttpClient.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/HttpClient.java
@@ -27,6 +27,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.http.*;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.ContentType;
@@ -41,6 +43,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
+import java.net.URI;
import java.net.URL;
import java.net.URLEncoder;
import java.util.*;
@@ -313,6 +316,35 @@ public class HttpClient {
}
}
+ public static HttpResult httpGetLarge(String url, Map headers, String content) {
+
+ try {
+ HttpClientBuilder builder = HttpClients.custom();
+ builder.setUserAgent(UtilsAndCommons.SERVER_VERSION);
+ builder.setConnectionTimeToLive(500, TimeUnit.MILLISECONDS);
+
+ CloseableHttpClient httpClient = builder.build();
+ HttpGetWithEntity httpGetWithEntity = new HttpGetWithEntity();
+ httpGetWithEntity.setURI(new URI(url));
+
+ for (Map.Entry entry : headers.entrySet()) {
+ httpGetWithEntity.setHeader(entry.getKey(), entry.getValue());
+ }
+
+ httpGetWithEntity.setEntity(new StringEntity(content, ContentType.create("application/json", "UTF-8")));
+ HttpResponse response = httpClient.execute(httpGetWithEntity);
+ HttpEntity entity = response.getEntity();
+
+ HeaderElement[] headerElements = entity.getContentType().getElements();
+ String charset = headerElements[0].getParameterByName("charset").getValue();
+
+ return new HttpResult(response.getStatusLine().getStatusCode(),
+ IOUtils.toString(entity.getContent(), charset), Collections.emptyMap());
+ } catch (Exception e) {
+ return new HttpResult(500, e.toString(), Collections.emptyMap());
+ }
+ }
+
public static HttpResult httpPostLarge(String url, Map headers, String content) {
try {
HttpClientBuilder builder = HttpClients.custom();
@@ -442,4 +474,14 @@ public class HttpClient {
return respHeaders.get(name);
}
}
+
+ public static class HttpGetWithEntity extends HttpEntityEnclosingRequestBase {
+
+ public final static String METHOD_NAME = "GET";
+
+ @Override
+ public String getMethod() {
+ return METHOD_NAME;
+ }
+ }
}
diff --git a/naming/src/main/java/com/alibaba/nacos/naming/misc/NamingProxy.java b/naming/src/main/java/com/alibaba/nacos/naming/misc/NamingProxy.java
index 9903967a2..bf3220f7e 100644
--- a/naming/src/main/java/com/alibaba/nacos/naming/misc/NamingProxy.java
+++ b/naming/src/main/java/com/alibaba/nacos/naming/misc/NamingProxy.java
@@ -79,8 +79,8 @@ public class NamingProxy {
Map params = new HashMap<>(8);
params.put("keys", StringUtils.join(keys, ","));
- HttpClient.HttpResult result = HttpClient.httpGet("http://" + server + RunningConfig.getContextPath()
- + UtilsAndCommons.NACOS_NAMING_CONTEXT + DATA_GET_URL, new ArrayList<>(), params);
+ HttpClient.HttpResult result = HttpClient.httpGetLarge("http://" + server + RunningConfig.getContextPath()
+ + UtilsAndCommons.NACOS_NAMING_CONTEXT + DATA_GET_URL, new HashMap<>(8), JSON.toJSONString(params));
if (HttpURLConnection.HTTP_OK == result.code) {
return result.content.getBytes();
diff --git a/pom.xml b/pom.xml
index 0f8624d7f..4d3bb6774 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
2018
com.alibaba.nacos
nacos-all
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
pom
Alibaba NACOS ${project.version}
diff --git a/test/pom.xml b/test/pom.xml
index 81e5dcd88..f3f17fba7 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -17,7 +17,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC1
+ 1.0.0-SNAPSHOT
../pom.xml
4.0.0