diff --git a/api/pom.xml b/api/pom.xml
index 02b263a32..64273fc7b 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -16,7 +16,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0
+ 1.0.1
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 96c906452..680864962 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 @@ package com.alibaba.nacos.api;
*/
public class PropertyKeyConst {
+ public final static String IS_USE_CLOUD_NAMESPACE_PARSING = "isUseCloudNamespaceParsing";
+
public final static String IS_USE_ENDPOINT_PARSING_RULE = "isUseEndpointParsingRule";
public final static String ENDPOINT = "endpoint";
@@ -50,6 +52,9 @@ public class PropertyKeyConst {
public final static String NAMING_POLLING_THREAD_COUNT = "namingPollingThreadCount";
+ /**
+ * Get the key value of some variable value from the system property
+ */
public static class SystemEnv {
public static final String ALIBABA_ALIWARE_ENDPOINT_PORT = "ALIBABA_ALIWARE_ENDPOINT_PORT";
@@ -58,4 +63,5 @@ public class PropertyKeyConst {
public static final String ALIBABA_ALIWARE_ENDPOINT_URL = "ALIBABA_ALIWARE_ENDPOINT_URL";
}
+
}
diff --git a/api/src/main/java/com/alibaba/nacos/api/SystemPropertyKeyConst.java b/api/src/main/java/com/alibaba/nacos/api/SystemPropertyKeyConst.java
index 4b41e6c8a..580a241b0 100644
--- a/api/src/main/java/com/alibaba/nacos/api/SystemPropertyKeyConst.java
+++ b/api/src/main/java/com/alibaba/nacos/api/SystemPropertyKeyConst.java
@@ -16,6 +16,9 @@
package com.alibaba.nacos.api;
/**
+ *
+ * Support for reading the value of the specified variable from the -D parameter
+ *
* Properties that are preferred to which in {@link PropertyKeyConst}
*
* @author pbting
@@ -27,5 +30,23 @@ public interface SystemPropertyKeyConst {
String NAMING_WEB_CONTEXT = "nacos.naming.web.context";
- String NACOS_NAMING_REQUEST_MODULE = "nacos.naming.request.module";
+ /**
+ * In the cloud (Alibaba Cloud or other cloud vendors) environment,
+ * whether to enable namespace resolution in the cloud environment.
+ *
+ * The default is on.
+ *
+ */
+ String IS_USE_CLOUD_NAMESPACE_PARSING = "nacos.use.cloud.namespace.parsing";
+
+ /**
+ * In the cloud environment, if the process level requires a globally uniform namespace,
+ * it can be specified with the -D parameter.
+ */
+ String ANS_NAMESPACE = "ans.namespace";
+
+ /**
+ * It is also supported by the -D parameter.
+ */
+ String IS_USE_ENDPOINT_PARSING_RULE = "nacos.use.endpoint.parsing.rule";
}
diff --git a/api/src/main/java/com/alibaba/nacos/api/common/Constants.java b/api/src/main/java/com/alibaba/nacos/api/common/Constants.java
index 3ec47eda8..aac7c929f 100644
--- a/api/src/main/java/com/alibaba/nacos/api/common/Constants.java
+++ b/api/src/main/java/com/alibaba/nacos/api/common/Constants.java
@@ -105,9 +105,9 @@ public class Constants {
public static final float DEFAULT_PROTECT_THRESHOLD = 0.0F;
- public static final String LINE_SEPARATOR = Character.toString((char)1);
+ public static final String LINE_SEPARATOR = Character.toString((char) 1);
- public static final String WORD_SEPARATOR = Character.toString((char)2);
+ public static final String WORD_SEPARATOR = Character.toString((char) 2);
public static final String LONGPOLLING_LINE_SEPARATOR = "\r\n";
@@ -125,6 +125,8 @@ public class Constants {
public static final String DEFAULT_NAMESPACE_ID = "public";
+ public static final boolean DEFAULT_USE_CLOUD_NAMESPACE_PARSING = true;
+
public static final int WRITE_REDIRECT_CODE = 307;
public static final String SERVICE_INFO_SPLITER = "@@";
diff --git a/client/pom.xml b/client/pom.xml
index b251c5b54..2e3fcac5d 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -16,7 +16,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0
+ 1.0.1
../pom.xml
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 9569b9570..371d6f776 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
@@ -16,6 +16,7 @@
package com.alibaba.nacos.client.config;
import com.alibaba.nacos.api.PropertyKeyConst;
+import com.alibaba.nacos.api.SystemPropertyKeyConst;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
@@ -31,10 +32,10 @@ import com.alibaba.nacos.client.config.impl.HttpSimpleClient.HttpResult;
import com.alibaba.nacos.client.config.impl.LocalConfigInfoProcessor;
import com.alibaba.nacos.client.config.utils.ContentUtils;
import com.alibaba.nacos.client.config.utils.ParamUtils;
-import com.alibaba.nacos.client.config.utils.TenantUtil;
import com.alibaba.nacos.client.utils.LogUtils;
import com.alibaba.nacos.client.utils.StringUtils;
import com.alibaba.nacos.client.utils.TemplateUtils;
+import com.alibaba.nacos.client.utils.TenantUtil;
import org.slf4j.Logger;
import java.io.IOException;
@@ -87,20 +88,27 @@ public class NacosConfigService implements ConfigService {
private void initNamespace(Properties properties) {
String namespaceTmp = null;
- namespaceTmp = TemplateUtils.stringBlankAndThenExecute(namespaceTmp, new Callable() {
- @Override
- public String call() {
- return TenantUtil.getUserTenant();
- }
- });
+ String isUseCloudNamespaceParsing =
+ properties.getProperty(PropertyKeyConst.IS_USE_CLOUD_NAMESPACE_PARSING,
+ System.getProperty(SystemPropertyKeyConst.IS_USE_CLOUD_NAMESPACE_PARSING,
+ String.valueOf(Constants.DEFAULT_USE_CLOUD_NAMESPACE_PARSING)));
- namespaceTmp = TemplateUtils.stringBlankAndThenExecute(namespaceTmp, new Callable() {
- @Override
- public String call() {
- String namespace = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_NAMESPACE);
- return StringUtils.isNotBlank(namespace) ? namespace : EMPTY;
- }
- });
+ if (Boolean.valueOf(isUseCloudNamespaceParsing)) {
+ namespaceTmp = TemplateUtils.stringBlankAndThenExecute(namespaceTmp, new Callable() {
+ @Override
+ public String call() {
+ return TenantUtil.getUserTenantForAcm();
+ }
+ });
+
+ namespaceTmp = TemplateUtils.stringBlankAndThenExecute(namespaceTmp, new Callable() {
+ @Override
+ public String call() {
+ String namespace = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_NAMESPACE);
+ return StringUtils.isNotBlank(namespace) ? namespace : EMPTY;
+ }
+ });
+ }
if (StringUtils.isBlank(namespaceTmp)) {
namespaceTmp = properties.getProperty(PropertyKeyConst.NAMESPACE);
diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/CacheData.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/CacheData.java
index dd80c9c79..47c1d262d 100644
--- a/client/src/main/java/com/alibaba/nacos/client/config/impl/CacheData.java
+++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/CacheData.java
@@ -22,8 +22,8 @@ import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.client.config.filter.impl.ConfigFilterChainManager;
import com.alibaba.nacos.client.config.filter.impl.ConfigResponse;
import com.alibaba.nacos.client.config.utils.MD5;
-import com.alibaba.nacos.client.config.utils.TenantUtil;
import com.alibaba.nacos.client.utils.LogUtils;
+import com.alibaba.nacos.client.utils.TenantUtil;
import org.slf4j.Logger;
import java.util.ArrayList;
@@ -145,7 +145,7 @@ public class CacheData {
if (this == obj) {
return true;
}
- CacheData other = (CacheData)obj;
+ CacheData other = (CacheData) obj;
return dataId.equals(other.dataId) && group.equals(other.group);
}
@@ -172,7 +172,7 @@ public class CacheData {
ClassLoader appClassLoader = listener.getClass().getClassLoader();
try {
if (listener instanceof AbstractSharedListener) {
- AbstractSharedListener adapter = (AbstractSharedListener)listener;
+ AbstractSharedListener adapter = (AbstractSharedListener) listener;
adapter.fillContext(dataId, group);
LOGGER.info("[{}] [notify-context] dataId={}, group={}, md5={}", name, dataId, group, md5);
}
@@ -236,7 +236,7 @@ public class CacheData {
this.configFilterChainManager = configFilterChainManager;
this.dataId = dataId;
this.group = group;
- this.tenant = TenantUtil.getUserTenant();
+ this.tenant = TenantUtil.getUserTenantForAcm();
listeners = new CopyOnWriteArrayList();
this.isInitializing = true;
this.content = loadCacheContentFromDiskLocal(name, dataId, group, tenant);
@@ -298,7 +298,7 @@ class ManagerListenerWrap {
if (obj == this) {
return true;
}
- ManagerListenerWrap other = (ManagerListenerWrap)obj;
+ ManagerListenerWrap other = (ManagerListenerWrap) obj;
return listener.equals(other.listener);
}
diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java
index 7490404f6..cb881d677 100644
--- a/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java
+++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/ClientWorker.java
@@ -24,29 +24,19 @@ import com.alibaba.nacos.client.config.http.HttpAgent;
import com.alibaba.nacos.client.config.impl.HttpSimpleClient.HttpResult;
import com.alibaba.nacos.client.config.utils.ContentUtils;
import com.alibaba.nacos.client.config.utils.MD5;
-import com.alibaba.nacos.client.config.utils.TenantUtil;
import com.alibaba.nacos.client.monitor.MetricsMonitor;
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.TenantUtil;
import org.slf4j.Logger;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
+import java.util.*;
+import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference;
import static com.alibaba.nacos.api.common.Constants.LINE_SEPARATOR;
@@ -143,7 +133,7 @@ public class ClientWorker {
//reset so that server not hang this check
cache.setInitializing(true);
} else {
- int taskId = cacheMap.get().size() / (int)ParamUtil.getPerTaskConfigSize();
+ int taskId = cacheMap.get().size() / (int) ParamUtil.getPerTaskConfigSize();
cache.setTaskId(taskId);
}
@@ -189,7 +179,7 @@ public class ClientWorker {
}
public CacheData getCache(String dataId, String group) {
- return getCache(dataId, group, TenantUtil.getUserTenant());
+ return getCache(dataId, group, TenantUtil.getUserTenantForAcm());
}
public CacheData getCache(String dataId, String group, String tenant) {
@@ -299,9 +289,9 @@ public class ClientWorker {
// 分任务
int listenerSize = cacheMap.get().size();
// 向上取整为批数
- int longingTaskCount = (int)Math.ceil(listenerSize / ParamUtil.getPerTaskConfigSize());
+ int longingTaskCount = (int) Math.ceil(listenerSize / ParamUtil.getPerTaskConfigSize());
if (longingTaskCount > currentLongingTaskCount) {
- for (int i = (int)currentLongingTaskCount; i < longingTaskCount; i++) {
+ for (int i = (int) currentLongingTaskCount; i < longingTaskCount; i++) {
// 要判断任务是否在执行 这块需要好好想想。 任务列表现在是无序的。变化过程可能有问题
executorService.execute(new LongPollingRunnable(i));
}
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 06a3ee065..a8ef929b0 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
@@ -16,6 +16,7 @@
package com.alibaba.nacos.client.config.impl;
import com.alibaba.nacos.api.PropertyKeyConst;
+import com.alibaba.nacos.api.SystemPropertyKeyConst;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.client.config.impl.EventDispatcher.ServerlistChangeEvent;
import com.alibaba.nacos.client.config.impl.HttpSimpleClient.HttpResult;
@@ -180,7 +181,13 @@ public class ServerListManager {
}
String endpointTmp = properties.getProperty(PropertyKeyConst.ENDPOINT);
- if (Boolean.valueOf(properties.getProperty(PropertyKeyConst.IS_USE_ENDPOINT_PARSING_RULE, ParamUtil.USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE))) {
+
+ // Whether to enable domain name resolution rules
+ String isUseEndpointRuleParsing =
+ properties.getProperty(PropertyKeyConst.IS_USE_ENDPOINT_PARSING_RULE,
+ System.getProperty(SystemPropertyKeyConst.IS_USE_ENDPOINT_PARSING_RULE,
+ String.valueOf(ParamUtil.USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE)));
+ if (Boolean.valueOf(isUseEndpointRuleParsing)) {
String endpointUrl = ParamUtil.parsingEndpointRule(endpointTmp);
if (StringUtils.isNotBlank(endpointUrl)) {
serverAddrsStr = "";
@@ -352,7 +359,7 @@ public class ServerListManager {
}
/**
- * 不同环境的名称
+ * The name of the different environment
*/
private String name;
private String namespace = "";
@@ -362,7 +369,7 @@ public class ServerListManager {
static public final String FIXED_NAME = "fixed";
private int initServerlistRetryTimes = 5;
/**
- * 和其他server的连接超时和socket超时
+ * Connection timeout and socket timeout with other servers
*/
static final int TIMEOUT = 5000;
@@ -384,7 +391,7 @@ public class ServerListManager {
}
/**
- * 对地址列表排序,同机房优先。
+ * Sort the address list, with the same room priority.
*/
class ServerAddressIterator implements Iterator {
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java
index a13638d2e..15b4ae14f 100644
--- a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java
+++ b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java
@@ -60,7 +60,7 @@ public class NacosNamingMaintainService implements NamingMaintainService {
}
private void init(Properties properties) {
- namespace = InitUtils.initNamespace(properties);
+ namespace = InitUtils.initNamespaceForNaming(properties);
initServerAddr(properties);
InitUtils.initWebRootContext();
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 b7d5207f8..8e5e0d2d3 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
@@ -79,7 +79,7 @@ public class NacosNamingService implements NamingService {
}
private void init(Properties properties) {
- namespace = InitUtils.initNamespace(properties);
+ namespace = InitUtils.initNamespaceForNaming(properties);
initServerAddr(properties);
InitUtils.initWebRootContext();
initCacheDir();
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/backups/FailoverReactor.java b/client/src/main/java/com/alibaba/nacos/client/naming/backups/FailoverReactor.java
index 9e9044e15..88b0ff30c 100644
--- a/client/src/main/java/com/alibaba/nacos/client/naming/backups/FailoverReactor.java
+++ b/client/src/main/java/com/alibaba/nacos/client/naming/backups/FailoverReactor.java
@@ -21,8 +21,8 @@ import com.alibaba.nacos.client.naming.cache.ConcurrentDiskUtil;
import com.alibaba.nacos.client.naming.cache.DiskCache;
import com.alibaba.nacos.client.naming.core.HostReactor;
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.StringUtils;
import java.io.BufferedReader;
import java.io.File;
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java b/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java
index b183a790b..2e7cad6c9 100644
--- a/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java
+++ b/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java
@@ -20,7 +20,7 @@ import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
-import com.alibaba.nacos.client.naming.utils.StringUtils;
+import com.alibaba.nacos.client.utils.StringUtils;
import java.io.BufferedReader;
import java.io.File;
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/core/HostReactor.java b/client/src/main/java/com/alibaba/nacos/client/naming/core/HostReactor.java
index ba5a7a256..444093de2 100644
--- a/client/src/main/java/com/alibaba/nacos/client/naming/core/HostReactor.java
+++ b/client/src/main/java/com/alibaba/nacos/client/naming/core/HostReactor.java
@@ -23,8 +23,8 @@ import com.alibaba.nacos.client.monitor.MetricsMonitor;
import com.alibaba.nacos.client.naming.backups.FailoverReactor;
import com.alibaba.nacos.client.naming.cache.DiskCache;
import com.alibaba.nacos.client.naming.net.NamingProxy;
-import com.alibaba.nacos.client.naming.utils.StringUtils;
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
+import com.alibaba.nacos.client.utils.StringUtils;
import java.util.*;
import java.util.concurrent.*;
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/core/PushReceiver.java b/client/src/main/java/com/alibaba/nacos/client/naming/core/PushReceiver.java
index a698402b1..cbb53d924 100644
--- a/client/src/main/java/com/alibaba/nacos/client/naming/core/PushReceiver.java
+++ b/client/src/main/java/com/alibaba/nacos/client/naming/core/PushReceiver.java
@@ -17,7 +17,7 @@ package com.alibaba.nacos.client.naming.core;
import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.client.naming.utils.IoUtils;
-import com.alibaba.nacos.client.naming.utils.StringUtils;
+import com.alibaba.nacos.client.utils.StringUtils;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/net/HttpClient.java b/client/src/main/java/com/alibaba/nacos/client/naming/net/HttpClient.java
index d05bd236d..3259d53c9 100644
--- a/client/src/main/java/com/alibaba/nacos/client/naming/net/HttpClient.java
+++ b/client/src/main/java/com/alibaba/nacos/client/naming/net/HttpClient.java
@@ -17,7 +17,7 @@ package com.alibaba.nacos.client.naming.net;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.client.naming.utils.IoUtils;
-import com.alibaba.nacos.client.naming.utils.StringUtils;
+import com.alibaba.nacos.client.utils.StringUtils;
import com.google.common.net.HttpHeaders;
import java.io.IOException;
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java
index 6b27abdeb..4a7716f4f 100644
--- a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java
+++ b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java
@@ -32,6 +32,7 @@ import com.alibaba.nacos.client.config.impl.SpasAdapter;
import com.alibaba.nacos.client.monitor.MetricsMonitor;
import com.alibaba.nacos.client.naming.beat.BeatInfo;
import com.alibaba.nacos.client.naming.utils.*;
+import com.alibaba.nacos.client.utils.StringUtils;
import com.alibaba.nacos.client.utils.TemplateUtils;
import com.alibaba.nacos.common.util.HttpMethod;
import com.alibaba.nacos.common.util.UuidUtils;
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/utils/InitUtils.java b/client/src/main/java/com/alibaba/nacos/client/naming/utils/InitUtils.java
index d8435b6bd..6920f1b72 100644
--- a/client/src/main/java/com/alibaba/nacos/client/naming/utils/InitUtils.java
+++ b/client/src/main/java/com/alibaba/nacos/client/naming/utils/InitUtils.java
@@ -18,24 +18,56 @@ package com.alibaba.nacos.client.naming.utils;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.SystemPropertyKeyConst;
-import com.alibaba.nacos.client.identify.CredentialService;
-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 com.alibaba.nacos.api.common.Constants;
+import com.alibaba.nacos.client.utils.*;
import java.util.Properties;
import java.util.concurrent.Callable;
/**
* @author liaochuntao
+ * @author deshao
*/
public class InitUtils {
- public static final String initNamespace(Properties properties) {
+ /**
+ * Add a difference to the name naming. This method simply initializes the namespace for Naming.
+ * Config initialization is not the same, so it cannot be reused directly.
+ *
+ * @param properties
+ * @return
+ */
+ public static final String initNamespaceForNaming(Properties properties) {
String tmpNamespace = null;
+
+ String isUseCloudNamespaceParsing =
+ properties.getProperty(PropertyKeyConst.IS_USE_CLOUD_NAMESPACE_PARSING,
+ System.getProperty(SystemPropertyKeyConst.IS_USE_CLOUD_NAMESPACE_PARSING,
+ String.valueOf(Constants.DEFAULT_USE_CLOUD_NAMESPACE_PARSING)));
+
+ if (Boolean.valueOf(isUseCloudNamespaceParsing)) {
+
+ tmpNamespace = TenantUtil.getUserTenantForAns();
+ tmpNamespace = TemplateUtils.stringEmptyAndThenExecute(tmpNamespace, new Callable() {
+ @Override
+ public String call() {
+ String namespace = System.getProperty(SystemPropertyKeyConst.ANS_NAMESPACE);
+ LogUtils.NAMING_LOGGER.info("initializer namespace from System Property :" + namespace);
+ return namespace;
+ }
+ });
+
+ tmpNamespace = TemplateUtils.stringEmptyAndThenExecute(tmpNamespace, new Callable() {
+ @Override
+ public String call() {
+ String namespace = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_NAMESPACE);
+ LogUtils.NAMING_LOGGER.info("initializer namespace from System Environment :" + namespace);
+ return namespace;
+ }
+ });
+ }
+
tmpNamespace = TemplateUtils.stringEmptyAndThenExecute(tmpNamespace, new Callable() {
@Override
public String call() {
@@ -45,26 +77,7 @@ public class InitUtils {
}
});
-
- tmpNamespace = TemplateUtils.stringEmptyAndThenExecute(tmpNamespace, new Callable() {
- @Override
- public String call() {
- String namespace = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_NAMESPACE);
- LogUtils.NAMING_LOGGER.info("initializer namespace from System Environment :" + namespace);
- return namespace;
- }
- });
-
- tmpNamespace = TemplateUtils.stringEmptyAndThenExecute(tmpNamespace, new Callable() {
- @Override
- public String call() {
- String namespace = CredentialService.getInstance().getCredential().getTenantId();
- LogUtils.NAMING_LOGGER.info("initializer namespace from Credential Module " + namespace);
- return namespace;
- }
- });
-
- if (com.alibaba.nacos.client.utils.StringUtils.isEmpty(tmpNamespace) && properties != null) {
+ if (StringUtils.isEmpty(tmpNamespace) && properties != null) {
tmpNamespace = properties.getProperty(PropertyKeyConst.NAMESPACE);
}
@@ -97,13 +110,18 @@ public class InitUtils {
return "";
}
- // 是否开启域名解析规则
- boolean isUseEndpointParsingRule = Boolean.valueOf(properties.getProperty(PropertyKeyConst.IS_USE_ENDPOINT_PARSING_RULE, ParamUtil.USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE));
+ // Whether to enable domain name resolution rules
+ String isUseEndpointRuleParsing =
+ properties.getProperty(PropertyKeyConst.IS_USE_ENDPOINT_PARSING_RULE,
+ System.getProperty(SystemPropertyKeyConst.IS_USE_ENDPOINT_PARSING_RULE,
+ String.valueOf(ParamUtil.USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE)));
+
+ boolean isUseEndpointParsingRule = Boolean.valueOf(isUseEndpointRuleParsing);
String endpointUrl;
if (isUseEndpointParsingRule) {
- // 获取设置的域名信息
+ // Get the set domain name information
endpointUrl = ParamUtil.parsingEndpointRule(properties.getProperty(PropertyKeyConst.ENDPOINT));
- if (com.alibaba.nacos.client.utils.StringUtils.isNotBlank(endpointUrl)) {
+ if (com.alibaba.nacos.client.utils.StringUtils.isBlank(endpointUrl)) {
return "";
}
} else {
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/utils/IoUtils.java b/client/src/main/java/com/alibaba/nacos/client/naming/utils/IoUtils.java
index f0b4a01c1..f447e637b 100644
--- a/client/src/main/java/com/alibaba/nacos/client/naming/utils/IoUtils.java
+++ b/client/src/main/java/com/alibaba/nacos/client/naming/utils/IoUtils.java
@@ -16,6 +16,8 @@
package com.alibaba.nacos.client.naming.utils;
+import com.alibaba.nacos.client.utils.StringUtils;
+
import java.io.*;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/utils/NetUtils.java b/client/src/main/java/com/alibaba/nacos/client/naming/utils/NetUtils.java
index ddc449e8b..e192e577c 100644
--- a/client/src/main/java/com/alibaba/nacos/client/naming/utils/NetUtils.java
+++ b/client/src/main/java/com/alibaba/nacos/client/naming/utils/NetUtils.java
@@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.client.naming.utils;
+import com.alibaba.nacos.client.utils.StringUtils;
+
import java.net.InetAddress;
import java.net.UnknownHostException;
diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/utils/StringUtils.java b/client/src/main/java/com/alibaba/nacos/client/naming/utils/StringUtils.java
deleted file mode 100644
index b174cb5c6..000000000
--- a/client/src/main/java/com/alibaba/nacos/client/naming/utils/StringUtils.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 1999-2018 Alibaba Group Holding Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.alibaba.nacos.client.naming.utils;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Collection;
-import java.util.Locale;
-
-/**
- * @author nkorange
- */
-public class StringUtils {
- public static boolean isEmpty(String str) {
- return str == null || str.length() == 0;
- }
-
- public static final String EMPTY = "";
-
- public static boolean equals(String str1, String str2) {
- return str1 == null ? str2 == null : str1.equals(str2);
- }
-
- 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();
- }
-
- public static boolean isNotEmpty(String str) {
- return !isEmpty(str);
- }
-
- public static String escapeJavaScript(String str) {
- return escapeJavaStyleString(str, true, true);
- }
-
- private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes, boolean escapeForwardSlash) {
- if (str == null) {
- return null;
- }
- try {
- StringWriter writer = new StringWriter(str.length() * 2);
- escapeJavaStyleString(writer, str, escapeSingleQuotes, escapeForwardSlash);
- return writer.toString();
- } catch (IOException ioe) {
- // this should never ever happen while writing to a StringWriter
- return null;
- }
- }
-
- private static String hex(char ch) {
- return Integer.toHexString(ch).toUpperCase(Locale.ENGLISH);
- }
-
- private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote,
- boolean escapeForwardSlash) throws IOException {
- if (out == null) {
- throw new IllegalArgumentException("The Writer must not be null");
- }
- if (str == null) {
- return;
- }
- int sz;
- sz = str.length();
- for (int i = 0; i < sz; i++) {
- char ch = str.charAt(i);
-
- // handle unicode
- if (ch > 0xfff) {
- out.write("\\u" + hex(ch));
- } else if (ch > 0xff) {
- out.write("\\u0" + hex(ch));
- } else if (ch > 0x7f) {
- out.write("\\u00" + hex(ch));
- } else if (ch < 32) {
- switch (ch) {
- case '\b':
- out.write('\\');
- out.write('b');
- break;
- case '\n':
- out.write('\\');
- out.write('n');
- break;
- case '\t':
- out.write('\\');
- out.write('t');
- break;
- case '\f':
- out.write('\\');
- out.write('f');
- break;
- case '\r':
- out.write('\\');
- out.write('r');
- break;
- default:
- if (ch > 0xf) {
- out.write("\\u00" + hex(ch));
- } else {
- out.write("\\u000" + hex(ch));
- }
- break;
- }
- } else {
- switch (ch) {
- case '\'':
- if (escapeSingleQuote) {
- out.write('\\');
- }
- out.write('\'');
- break;
- case '"':
- out.write('\\');
- out.write('"');
- break;
- case '\\':
- out.write('\\');
- out.write('\\');
- break;
- case '/':
- if (escapeForwardSlash) {
- out.write('\\');
- }
- out.write('/');
- break;
- default:
- out.write(ch);
- break;
- }
- }
- }
- }
-
-}
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 c5e81671f..9145fa662 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
@@ -33,7 +33,7 @@ public class ParamUtil {
private final static Logger LOGGER = LogUtils.logger(ParamUtil.class);
- public final static String USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE = "true";
+ public final static boolean USE_ENDPOINT_PARSING_RULE_DEFAULT_VALUE = true;
private static final Pattern PATTERN = Pattern.compile("\\$\\{[^}]+\\}");
private static String defaultContextPath = "nacos";
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 6dd226a9e..2fc915ad1 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,7 +15,11 @@
*/
package com.alibaba.nacos.client.utils;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
import java.util.Collection;
+import java.util.Locale;
/**
* string util
@@ -26,6 +30,8 @@ public class StringUtils {
public static final int INDEX_NOT_FOUND = -1;
+ public static final String EMPTY = "";
+
public static boolean isBlank(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
@@ -92,4 +98,106 @@ public class StringUtils {
return stringBuilder.toString();
}
+
+ public static String escapeJavaScript(String str) {
+ return escapeJavaStyleString(str, true, true);
+ }
+
+ private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes, boolean escapeForwardSlash) {
+ if (str == null) {
+ return null;
+ }
+ try {
+ StringWriter writer = new StringWriter(str.length() * 2);
+ escapeJavaStyleString(writer, str, escapeSingleQuotes, escapeForwardSlash);
+ return writer.toString();
+ } catch (IOException ioe) {
+ // this should never ever happen while writing to a StringWriter
+ return null;
+ }
+ }
+
+ private static String hex(char ch) {
+ return Integer.toHexString(ch).toUpperCase(Locale.ENGLISH);
+ }
+
+ private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote,
+ boolean escapeForwardSlash) throws IOException {
+ if (out == null) {
+ throw new IllegalArgumentException("The Writer must not be null");
+ }
+ if (str == null) {
+ return;
+ }
+ int sz;
+ sz = str.length();
+ for (int i = 0; i < sz; i++) {
+ char ch = str.charAt(i);
+
+ // handle unicode
+ if (ch > 0xfff) {
+ out.write("\\u" + hex(ch));
+ } else if (ch > 0xff) {
+ out.write("\\u0" + hex(ch));
+ } else if (ch > 0x7f) {
+ out.write("\\u00" + hex(ch));
+ } else if (ch < 32) {
+ switch (ch) {
+ case '\b':
+ out.write('\\');
+ out.write('b');
+ break;
+ case '\n':
+ out.write('\\');
+ out.write('n');
+ break;
+ case '\t':
+ out.write('\\');
+ out.write('t');
+ break;
+ case '\f':
+ out.write('\\');
+ out.write('f');
+ break;
+ case '\r':
+ out.write('\\');
+ out.write('r');
+ break;
+ default:
+ if (ch > 0xf) {
+ out.write("\\u00" + hex(ch));
+ } else {
+ out.write("\\u000" + hex(ch));
+ }
+ break;
+ }
+ } else {
+ switch (ch) {
+ case '\'':
+ if (escapeSingleQuote) {
+ out.write('\\');
+ }
+ out.write('\'');
+ break;
+ case '"':
+ out.write('\\');
+ out.write('"');
+ break;
+ case '\\':
+ out.write('\\');
+ out.write('\\');
+ break;
+ case '/':
+ if (escapeForwardSlash) {
+ out.write('\\');
+ }
+ out.write('/');
+ break;
+ default:
+ out.write(ch);
+ break;
+ }
+ }
+ }
+ }
}
diff --git a/client/src/main/java/com/alibaba/nacos/client/config/utils/TenantUtil.java b/client/src/main/java/com/alibaba/nacos/client/utils/TenantUtil.java
similarity index 50%
rename from client/src/main/java/com/alibaba/nacos/client/config/utils/TenantUtil.java
rename to client/src/main/java/com/alibaba/nacos/client/utils/TenantUtil.java
index b27b4324c..721ad72fe 100644
--- a/client/src/main/java/com/alibaba/nacos/client/config/utils/TenantUtil.java
+++ b/client/src/main/java/com/alibaba/nacos/client/utils/TenantUtil.java
@@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.alibaba.nacos.client.config.utils;
-
-import com.alibaba.nacos.client.utils.StringUtils;
+package com.alibaba.nacos.client.utils;
/**
* Tenant Util
@@ -24,20 +22,42 @@ import com.alibaba.nacos.client.utils.StringUtils;
*/
public class TenantUtil {
- private static String userTenant = "";
+ private static String userTenant;
static {
userTenant = System.getProperty("tenant.id", "");
+ }
+
+ /**
+ * Adapt the way ACM gets tenant on the cloud.
+ *
+ * Note the difference between getting and getting ANS.
+ * Since the processing logic on the server side is different, the default value returns differently.
+ *
+ *
+ * @return
+ */
+ public static String getUserTenantForAcm() {
+ String tmp = userTenant;
+
if (StringUtils.isBlank(userTenant)) {
- userTenant = System.getProperty("acm.namespace", "");
+ tmp = System.getProperty("acm.namespace", "");
}
+
+ return tmp;
}
- public static String getUserTenant() {
- return userTenant;
- }
+ /**
+ * Adapt the way ANS gets tenant on the cloud.
+ *
+ * @return
+ */
+ public static String getUserTenantForAns() {
+ String tmp = userTenant;
- public static void setUserTenant(String userTenant) {
- TenantUtil.userTenant = userTenant;
+ if (StringUtils.isBlank(userTenant)) {
+ tmp = System.getProperty("ans.namespace");
+ }
+ return tmp;
}
}
diff --git a/cmdb/pom.xml b/cmdb/pom.xml
index 4106a3d54..7c6a4520e 100644
--- a/cmdb/pom.xml
+++ b/cmdb/pom.xml
@@ -18,7 +18,7 @@
nacos-all
com.alibaba.nacos
- 1.0.0
+ 1.0.1
../pom.xml
4.0.0
diff --git a/common/pom.xml b/common/pom.xml
index ab79babed..01880dd71 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0
+ 1.0.1
../pom.xml
4.0.0
diff --git a/config/pom.xml b/config/pom.xml
index 70382328b..abaee2dee 100644
--- a/config/pom.xml
+++ b/config/pom.xml
@@ -17,7 +17,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0
+ 1.0.1
4.0.0
diff --git a/console/pom.xml b/console/pom.xml
index 84dccd280..34d2f61e4 100644
--- a/console/pom.xml
+++ b/console/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0
+ 1.0.1
nacos-console
diff --git a/core/pom.xml b/core/pom.xml
index 4717bcb23..82b4362fc 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0
+ 1.0.1
../pom.xml
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 504f2cf57..b5a95a68e 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0
+ 1.0.1
../pom.xml
diff --git a/example/pom.xml b/example/pom.xml
index 31d131558..a3680fe8d 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0
+ 1.0.1
../pom.xml
diff --git a/naming/pom.xml b/naming/pom.xml
index 16e2ef257..d999ba33f 100644
--- a/naming/pom.xml
+++ b/naming/pom.xml
@@ -18,7 +18,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0
+ 1.0.1
../pom.xml
diff --git a/pom.xml b/pom.xml
index 1d19f9261..4058e3a65 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
2018
com.alibaba.nacos
nacos-all
- 1.0.0
+ 1.0.1
pom
Alibaba NACOS ${project.version}
@@ -36,7 +36,7 @@
git@github.com:alibaba/nacos.git
scm:git@github.com:alibaba/nacos.git
scm:git@github.com:alibaba/nacos.git
- nacos-all-1.0.0
+ nacos-all-1.0.1
@@ -378,18 +378,6 @@
-
-
-
- sona
- https://oss.sonatype.org/content/repositories/snapshots
-
-
- sona
- https://oss.sonatype.org/service/local/staging/deploy/maven2
-
-
-
it-test
@@ -738,5 +726,6 @@
+
diff --git a/test/pom.xml b/test/pom.xml
index 8086fd987..391ee7eef 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -17,7 +17,7 @@
com.alibaba.nacos
nacos-all
- 1.0.0
+ 1.0.1
../pom.xml
4.0.0