diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6662a0941fe..5ff3ded6ef4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 1.0.0-RC2(Mar 22, 2019)
+## 1.0.0-RC4(Mar 22, 2019)
* [#923] Nacos 1.0.0 compatible with nacos-client 0.6.2
* [#938] Client beat processor task lost
* [#946] Change default server mode to AP
diff --git a/api/pom.xml b/api/pom.xml
index b8bdcfdf790..af6ff178ef8 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -16,7 +16,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC3
+ 1.0.0
4.0.0
diff --git a/api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java b/api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java
index e22b70948ac..96c90645221 100644
--- a/api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java
+++ b/api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java
@@ -22,6 +22,8 @@
*/
public class PropertyKeyConst {
+ public final static String IS_USE_ENDPOINT_PARSING_RULE = "isUseEndpointParsingRule";
+
public final static String ENDPOINT = "endpoint";
public final static String ENDPOINT_PORT = "endpointPort";
diff --git a/client/pom.xml b/client/pom.xml
index 9bfadceb5a5..b251c5b5400 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -16,7 +16,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC3
+ 1.0.0
../pom.xml
@@ -113,6 +113,7 @@
+
diff --git a/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java b/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java
index aa304a47247..e285207a710 100644
--- a/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java
+++ b/client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java
@@ -82,7 +82,7 @@ public NacosConfigService(Properties properties) throws NacosException {
}
private void initNamespace(Properties properties) {
- String namespaceTmp = properties.getProperty(PropertyKeyConst.NAMESPACE);
+ String namespaceTmp = null;
namespaceTmp = TemplateUtils.stringBlankAndThenExecute(namespaceTmp, new Callable() {
@Override
@@ -98,6 +98,10 @@ public String call() {
return StringUtils.isNotBlank(namespace) ? namespace : "";
}
});
+
+ if (StringUtils.isBlank(namespaceTmp)) {
+ namespaceTmp = properties.getProperty(PropertyKeyConst.NAMESPACE);
+ }
namespace = namespaceTmp;
properties.put(PropertyKeyConst.NAMESPACE, namespace);
}
diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java
index d3b48e24adb..3569ecb94da 100644
--- a/client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java
+++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java
@@ -85,7 +85,9 @@ public ServerListManager(String endpoint) throws NacosException {
public ServerListManager(String endpoint, String namespace) throws NacosException {
isFixed = false;
isStarted = false;
- endpoint = initEndpoint(endpoint);
+ Properties properties = new Properties();
+ properties.setProperty(PropertyKeyConst.ENDPOINT, endpoint);
+ endpoint = initEndpoint(properties);
if (StringUtils.isBlank(endpoint)) {
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, "endpoint is blank");
@@ -108,7 +110,7 @@ public ServerListManager(String endpoint, String namespace) throws NacosExceptio
public ServerListManager(Properties properties) throws NacosException {
isStarted = false;
- String serverAddrsStr = properties.getProperty(PropertyKeyConst.SERVER_ADDR);
+ serverAddrsStr = properties.getProperty(PropertyKeyConst.SERVER_ADDR);
String namespace = properties.getProperty(PropertyKeyConst.NAMESPACE);
initParam(properties);
if (StringUtils.isNotEmpty(serverAddrsStr)) {
@@ -152,7 +154,7 @@ public ServerListManager(Properties properties) throws NacosException {
}
private void initParam(Properties properties) {
- endpoint = initEndpoint(properties.getProperty(PropertyKeyConst.ENDPOINT));
+ endpoint = initEndpoint(properties);
String contentPathTmp = properties.getProperty(PropertyKeyConst.CONTEXT_PATH);
if (!StringUtils.isBlank(contentPathTmp)) {
@@ -164,19 +166,29 @@ private void initParam(Properties properties) {
}
}
- private String initEndpoint(String endpointTmp) {
- String endpointPortTmp = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_PORT);
- if (StringUtils.isNotBlank(endpointPortTmp)) {
- endpointPort = Integer.parseInt(endpointPortTmp);
- }
+ private String initEndpoint(final Properties properties) {
- return TemplateUtils.stringBlankAndThenExecute(endpointTmp, new Callable() {
+ String endpointPortTmp = TemplateUtils.stringEmptyAndThenExecute(System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_PORT), new Callable() {
@Override
public String call() {
- String endpointUrl = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_URL);
- return StringUtils.isNotBlank(endpointUrl) ? endpointUrl : "";
+ return properties.getProperty(PropertyKeyConst.ENDPOINT_PORT);
}
});
+
+ if (StringUtils.isNotBlank(endpointPortTmp)) {
+ endpointPort = Integer.parseInt(endpointPortTmp);
+ }
+
+ String endpointTmp = properties.getProperty(PropertyKeyConst.ENDPOINT);
+ if (Boolean.valueOf(properties.getProperty(PropertyKeyConst.IS_USE_ENDPOINT_PARSING_RULE, ParamUtil.USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE))) {
+ String endpointUrl = ParamUtil.parsingEndpointRule(endpointPortTmp);
+ if (StringUtils.isNotBlank(endpointUrl)) {
+ serverAddrsStr = "";
+ }
+ return endpointUrl;
+ }
+
+ return StringUtils.isNotBlank(endpointTmp) ? endpointTmp : "";
}
public synchronized void start() throws NacosException {
@@ -368,6 +380,7 @@ public String getTenant() {
public String addressServerUrl;
+ private String serverAddrsStr;
}
/**
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java
index 271a44f4ec0..09b6da76e80 100644
--- a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java
+++ b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingService.java
@@ -34,9 +34,10 @@
import com.alibaba.nacos.client.naming.core.HostReactor;
import com.alibaba.nacos.client.naming.net.NamingProxy;
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
-import com.alibaba.nacos.client.naming.utils.StringUtils;
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
import com.alibaba.nacos.client.utils.LogUtils;
+import com.alibaba.nacos.client.utils.ParamUtil;
+import com.alibaba.nacos.client.utils.StringUtils;
import com.alibaba.nacos.client.utils.TemplateUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.math.NumberUtils;
@@ -86,9 +87,7 @@ public NacosNamingService(Properties properties) {
}
private void init(Properties properties) {
-
serverList = properties.getProperty(PropertyKeyConst.SERVER_ADDR);
-
initNamespace(properties);
initEndpoint(properties);
initWebRootContext();
@@ -150,30 +149,35 @@ private void initCacheDir() {
}
}
- private void initEndpoint(Properties properties) {
+ private void initEndpoint(final Properties properties) {
if (properties == null) {
return;
}
-
- String endpointUrl = TemplateUtils.stringEmptyAndThenExecute(properties.getProperty(PropertyKeyConst.ENDPOINT), new Callable() {
- @Override
- public String call() {
- return System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_URL);
+ //这里通过 dubbo/sca 侧来初始化默认传入的是 true
+ boolean isUseEndpointParsingRule = Boolean.valueOf(properties.getProperty(PropertyKeyConst.IS_USE_ENDPOINT_PARSING_RULE, ParamUtil.USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE));
+ String endpointUrl;
+ if (isUseEndpointParsingRule) {
+ endpointUrl = ParamUtil.parsingEndpointRule(properties.getProperty(PropertyKeyConst.ENDPOINT));
+ if (com.alibaba.nacos.client.utils.StringUtils.isNotBlank(endpointUrl)) {
+ serverList = "";
}
- });
+ } else {
+ endpointUrl = properties.getProperty(PropertyKeyConst.ENDPOINT);
+ }
- if (com.alibaba.nacos.client.utils.StringUtils.isBlank(endpointUrl)) {
+ if (StringUtils.isBlank(endpointUrl)) {
return;
}
- String endpointPort = TemplateUtils.stringEmptyAndThenExecute(properties.getProperty(PropertyKeyConst.ENDPOINT_PORT), new Callable() {
+ String endpointPort = TemplateUtils.stringEmptyAndThenExecute(System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_PORT), new Callable() {
@Override
public String call() {
- return System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_PORT);
+ return properties.getProperty(PropertyKeyConst.ENDPOINT_PORT);
}
});
+
endpointPort = TemplateUtils.stringEmptyAndThenExecute(endpointPort, new Callable() {
@Override
public String call() {
@@ -187,10 +191,6 @@ public String call() {
private void initNamespace(Properties properties) {
String tmpNamespace = null;
- if (properties != null) {
- tmpNamespace = properties.getProperty(PropertyKeyConst.NAMESPACE);
- }
-
tmpNamespace = TemplateUtils.stringEmptyAndThenExecute(tmpNamespace, new Callable() {
@Override
public String call() {
@@ -219,6 +219,10 @@ public String call() {
}
});
+ if (StringUtils.isEmpty(tmpNamespace) && properties != null) {
+ tmpNamespace = properties.getProperty(PropertyKeyConst.NAMESPACE);
+ }
+
tmpNamespace = TemplateUtils.stringEmptyAndThenExecute(tmpNamespace, new Callable() {
@Override
public String call() {
diff --git a/client/src/main/java/com/alibaba/nacos/client/utils/ParamUtil.java b/client/src/main/java/com/alibaba/nacos/client/utils/ParamUtil.java
index aa109efbbf3..c736919f3ff 100644
--- a/client/src/main/java/com/alibaba/nacos/client/utils/ParamUtil.java
+++ b/client/src/main/java/com/alibaba/nacos/client/utils/ParamUtil.java
@@ -15,11 +15,14 @@
*/
package com.alibaba.nacos.client.utils;
+import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.client.config.impl.HttpSimpleClient;
import org.slf4j.Logger;
import java.io.InputStream;
import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.regex.Pattern;
/**
* manage param tool
@@ -27,8 +30,12 @@
* @author nacos
*/
public class ParamUtil {
+
private final static Logger LOGGER = LogUtils.logger(ParamUtil.class);
+ public final static String USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE = "false";
+
+ private static final Pattern PATTERN = Pattern.compile("\\$\\{[^}]+\\}");
private static String defaultContextPath = "nacos";
private static String defaultNodesPath = "serverlist";
private static String appKey;
@@ -143,4 +150,46 @@ public static void setDefaultNodesPath(String defaultNodesPath) {
ParamUtil.defaultNodesPath = defaultNodesPath;
}
+
+ public static String parsingEndpointRule(String endpointUrl) {
+ // 配置文件中输入的话,以 ENV 中的优先,
+ if (endpointUrl == null
+ || !PATTERN.matcher(endpointUrl).find()) {
+ // skip retrieve from system property and retrieve directly from system env
+ String endpointUrlSource = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_URL);
+ if (com.alibaba.nacos.client.utils.StringUtils.isNotBlank(endpointUrlSource)) {
+ endpointUrl = endpointUrlSource;
+ }
+
+ return StringUtils.isNotBlank(endpointUrl) ? endpointUrl : "";
+ }
+
+ endpointUrl = endpointUrl.substring(endpointUrl.indexOf("${") + 2,
+ endpointUrl.lastIndexOf("}"));
+ int defStartOf = endpointUrl.indexOf(":");
+ String defaultEndpointUrl = null;
+ if (defStartOf != -1) {
+ defaultEndpointUrl = endpointUrl.substring(defStartOf + 1);
+ endpointUrl = endpointUrl.substring(0, defStartOf);
+ }
+
+ String endpointUrlSource = TemplateUtils.stringBlankAndThenExecute(System.getProperty(endpointUrl,
+ System.getenv(endpointUrl)), new Callable() {
+ @Override
+ public String call() {
+ return System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_URL);
+ }
+ });
+
+
+ if (com.alibaba.nacos.client.utils.StringUtils.isBlank(endpointUrlSource)) {
+ if (com.alibaba.nacos.client.utils.StringUtils.isNotBlank(defaultEndpointUrl)) {
+ endpointUrl = defaultEndpointUrl;
+ }
+ } else {
+ endpointUrl = endpointUrlSource;
+ }
+
+ return StringUtils.isNotBlank(endpointUrl) ? endpointUrl : "";
+ }
}
diff --git a/client/src/main/java/com/alibaba/nacos/client/utils/StringUtils.java b/client/src/main/java/com/alibaba/nacos/client/utils/StringUtils.java
index 0e4e1ec4e97..6dd226a9ef1 100644
--- a/client/src/main/java/com/alibaba/nacos/client/utils/StringUtils.java
+++ b/client/src/main/java/com/alibaba/nacos/client/utils/StringUtils.java
@@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.client.utils;
+import java.util.Collection;
+
/**
* string util
*
@@ -71,4 +73,23 @@ public static String substringBetween(String str, String open, String close) {
}
return null;
}
+
+ public static String join(Collection collection, String separator) {
+ if (collection == null) {
+ return null;
+ }
+
+ StringBuilder stringBuilder = new StringBuilder();
+ Object[] objects = collection.toArray();
+
+ for (int i = 0; i < collection.size() - 1; i++) {
+ stringBuilder.append(objects[i].toString()).append(separator);
+ }
+
+ if (collection.size() > 0) {
+ stringBuilder.append(objects[collection.size() - 1]);
+ }
+
+ return stringBuilder.toString();
+ }
}
diff --git a/cmdb/pom.xml b/cmdb/pom.xml
index b0f933659de..4106a3d5401 100644
--- a/cmdb/pom.xml
+++ b/cmdb/pom.xml
@@ -18,7 +18,7 @@
nacos-all
com.alibaba.nacos
- 1.0.0-RC3
+ 1.0.0
../pom.xml
4.0.0
diff --git a/common/pom.xml b/common/pom.xml
index 1c0aec9f194..ab79babedfd 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC3
+ 1.0.0
../pom.xml
4.0.0
diff --git a/config/pom.xml b/config/pom.xml
index 303e41715d4..70382328b40 100644
--- a/config/pom.xml
+++ b/config/pom.xml
@@ -17,7 +17,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC3
+ 1.0.0
4.0.0
diff --git a/console/pom.xml b/console/pom.xml
index e6fa7fff3cd..da846322c57 100644
--- a/console/pom.xml
+++ b/console/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC3
+ 1.0.0
nacos-console
diff --git a/core/pom.xml b/core/pom.xml
index 84da4aa053a..4717bcb23c2 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC3
+ 1.0.0
../pom.xml
diff --git a/distribution/pom.xml b/distribution/pom.xml
index b282d54e01a..504f2cf5700 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC3
+ 1.0.0
../pom.xml
diff --git a/example/pom.xml b/example/pom.xml
index fb29d5b5256..31d1315585b 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC3
+ 1.0.0
../pom.xml
diff --git a/naming/pom.xml b/naming/pom.xml
index ef719b42c5d..16e2ef257f0 100644
--- a/naming/pom.xml
+++ b/naming/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC3
+ 1.0.0
../pom.xml
diff --git a/pom.xml b/pom.xml
index 000879587a2..46aa6872e69 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
2018
com.alibaba.nacos
nacos-all
- 1.0.0-RC3
+ 1.0.0
pom
Alibaba NACOS ${project.version}
diff --git a/test/pom.xml b/test/pom.xml
index df7eb9a9ac8..8086fd987fa 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -17,7 +17,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0-RC3
+ 1.0.0
../pom.xml
4.0.0