Merge remote-tracking branch 'upstream/develop' into feature_support_grpc_core

# Conflicts:
#	address/pom.xml
#	api/pom.xml
#	auth/pom.xml
#	client/pom.xml
#	cmdb/pom.xml
#	common/pom.xml
#	config/pom.xml
#	consistency/pom.xml
#	console/pom.xml
#	core/pom.xml
#	distribution/pom.xml
#	example/pom.xml
#	istio/pom.xml
#	naming/pom.xml
#	pom.xml
#	sys/pom.xml
#	test/pom.xml
This commit is contained in:
KomachiSion 2021-01-18 10:32:57 +08:00
commit fd06b5a7b6
23 changed files with 98 additions and 64 deletions

View File

@ -19,7 +19,7 @@
<parent>
<artifactId>nacos-all</artifactId>
<groupId>com.alibaba.nacos</groupId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -19,7 +19,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -21,7 +21,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -19,7 +19,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -21,7 +21,7 @@
<parent>
<artifactId>nacos-all</artifactId>
<groupId>com.alibaba.nacos</groupId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -21,7 +21,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -670,6 +670,7 @@ public class ConfigController {
if (StringUtils.isNotBlank(ci.getAppName())) {
ci4save.setAppName(ci.getAppName());
}
ci4save.setDesc(ci.getDesc());
configInfoList4Clone.add(ci4save);
}

View File

@ -130,25 +130,23 @@ public class ConfigServletInner {
final String requestIp = RequestUtil.getRemoteIp(request);
boolean isBeta = false;
if (lockResult > 0) {
// LockResult > 0 means cacheItem is not null and other thread can`t delete this cacheItem
FileInputStream fis = null;
try {
String md5 = Constants.NULL;
long lastModified = 0L;
CacheItem cacheItem = ConfigCacheService.getContentCache(groupKey);
if (cacheItem != null) {
if (cacheItem.isBeta()) {
if (cacheItem.getIps4Beta().contains(clientIp)) {
isBeta = true;
}
}
final String configType =
(null != cacheItem.getType()) ? cacheItem.getType() : FileTypeEnum.TEXT.getFileType();
response.setHeader("Config-Type", configType);
FileTypeEnum fileTypeEnum = FileTypeEnum.getFileTypeEnumByFileExtensionOrFileType(configType);
String contentTypeHeader = fileTypeEnum.getContentType();
response.setHeader(HttpHeaderConsts.CONTENT_TYPE, contentTypeHeader);
if (cacheItem.isBeta() && cacheItem.getIps4Beta().contains(clientIp)) {
isBeta = true;
}
final String configType =
(null != cacheItem.getType()) ? cacheItem.getType() : FileTypeEnum.TEXT.getFileType();
response.setHeader("Config-Type", configType);
FileTypeEnum fileTypeEnum = FileTypeEnum.getFileTypeEnumByFileExtensionOrFileType(configType);
String contentTypeHeader = fileTypeEnum.getContentType();
response.setHeader(HttpHeaderConsts.CONTENT_TYPE, contentTypeHeader);
File file = null;
ConfigInfoBase configInfoBase = null;
PrintWriter out = null;
@ -164,13 +162,11 @@ public class ConfigServletInner {
} else {
if (StringUtils.isBlank(tag)) {
if (isUseTag(cacheItem, autoTag)) {
if (cacheItem != null) {
if (cacheItem.tagMd5 != null) {
md5 = cacheItem.tagMd5.get(autoTag);
}
if (cacheItem.tagLastModifiedTs != null) {
lastModified = cacheItem.tagLastModifiedTs.get(autoTag);
}
if (cacheItem.tagMd5 != null) {
md5 = cacheItem.tagMd5.get(autoTag);
}
if (cacheItem.tagLastModifiedTs != null) {
lastModified = cacheItem.tagLastModifiedTs.get(autoTag);
}
if (PropertyUtil.isDirectRead()) {
configInfoBase = persistService.findConfigInfo4Tag(dataId, group, tenant, autoTag);
@ -204,15 +200,13 @@ public class ConfigServletInner {
}
}
} else {
if (cacheItem != null) {
if (cacheItem.tagMd5 != null) {
md5 = cacheItem.tagMd5.get(tag);
}
if (cacheItem.tagLastModifiedTs != null) {
Long lm = cacheItem.tagLastModifiedTs.get(tag);
if (lm != null) {
lastModified = lm;
}
if (cacheItem.tagMd5 != null) {
md5 = cacheItem.tagMd5.get(tag);
}
if (cacheItem.tagLastModifiedTs != null) {
Long lm = cacheItem.tagLastModifiedTs.get(tag);
if (lm != null) {
lastModified = lm;
}
}
if (PropertyUtil.isDirectRead()) {
@ -303,7 +297,12 @@ public class ConfigServletInner {
private static void releaseConfigReadLock(String groupKey) {
ConfigCacheService.releaseReadLock(groupKey);
}
/**
* Try to add read lock.
* @param groupKey groupKey string value.
* @return 0 - No data and failed. Positive number - lock succeeded. Negative number - lock failed
*/
private static int tryConfigReadLock(String groupKey) {
// Lock failed by default.

View File

@ -630,11 +630,11 @@ public class ConfigCacheService {
}
/**
* Try to add read lock. If it successed, then it can call {@link #releaseWriteLock(String)}.And it won't call if
* Try to add read lock. If it succeeded, then it can call {@link #releaseWriteLock(String)}.And it won't call if
* failed.
*
* @param groupKey groupKey string value.
* @return 0 - No data and failed. Positive number 0 - Success. Negative number - lock failed
* @return 0 - No data and failed. Positive number - lock succeeded. Negative number - lock failed
*/
public static int tryReadLock(String groupKey) {
CacheItem groupItem = CACHE.get(groupKey);
@ -658,7 +658,7 @@ public class ConfigCacheService {
}
/**
* Try to add write lock. If it successed, then it can call {@link #releaseWriteLock(String)}.And it won't call if
* Try to add write lock. If it succeeded, then it can call {@link #releaseWriteLock(String)}.And it won't call if
* failed.
*
* @param groupKey groupKey string value.

View File

@ -2351,6 +2351,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
configAdvanceInfo = new HashMap<>(16);
}
configAdvanceInfo.put("type", type);
configAdvanceInfo.put("desc", configInfo.getDesc());
try {
addConfigInfo(srcIp, srcUser, configInfo2Save, time, configAdvanceInfo, notify, callFinally);
succCount++;

View File

@ -2599,6 +2599,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
configAdvanceInfo = new HashMap<>(16);
}
configAdvanceInfo.put("type", type);
configAdvanceInfo.put("desc", configInfo.getDesc());
try {
addConfigInfo(srcIp, srcUser, configInfo2Save, time, configAdvanceInfo, notify);
succCount++;

View File

@ -87,7 +87,7 @@
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<relativePath>../pom.xml</relativePath>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<properties>

View File

@ -21,7 +21,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<artifactId>nacos-console</artifactId>
<packaging>jar</packaging>

View File

@ -21,7 +21,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -21,7 +21,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -21,7 +21,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -19,7 +19,7 @@
<parent>
<artifactId>nacos-all</artifactId>
<groupId>com.alibaba.nacos</groupId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -21,7 +21,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -21,6 +21,7 @@ import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.utils.NamingUtils;
import com.alibaba.nacos.common.utils.IPUtil;
import com.alibaba.nacos.common.utils.JacksonUtils;
import com.alibaba.nacos.common.utils.Objects;
import com.alibaba.nacos.core.cluster.Member;
import com.alibaba.nacos.core.cluster.ServerMemberManager;
import com.alibaba.nacos.naming.consistency.ConsistencyService;
@ -578,7 +579,7 @@ public class ServiceManager implements RecordListener<Service> {
}
/**
* locate consistency's datum by all or instances provided.
* Locate consistency's datum by all or instances provided.
*
* @param namespaceId namespace
* @param serviceName serviceName
@ -616,16 +617,15 @@ public class ServiceManager implements RecordListener<Service> {
return locatedInstance;
}
private Instance locateInstance(List<Instance> instances, Instance instance) {
int target = 0;
while (target >= 0) {
target = instances.indexOf(instance);
if (target >= 0) {
Instance result = instances.get(target);
if (result.getClusterName().equals(instance.getClusterName())) {
return result;
}
instances.remove(target);
private Instance locateInstance(List<Instance> sources, Instance target) {
if (CollectionUtils.isEmpty(sources)) {
return null;
}
for (Instance element : sources) {
//also need clusterName equals, the same instance maybe exist in two cluster.
if (Objects.equals(element, target) && Objects.equals(element.getClusterName(), target.getClusterName())) {
return element;
}
}
return null;
@ -876,11 +876,12 @@ public class ServiceManager implements RecordListener<Service> {
}
}
}
serviceMap.get(service.getNamespaceId()).put(service.getName(), service);
serviceMap.get(service.getNamespaceId()).putIfAbsent(service.getName(), service);
}
private void putServiceAndInit(Service service) throws NacosException {
putService(service);
service = getService(service.getNamespaceId(), service.getName());
service.init();
consistencyService
.listen(KeyBuilder.buildInstanceListKey(service.getNamespaceId(), service.getName(), true), service);
@ -961,7 +962,8 @@ public class ServiceManager implements RecordListener<Service> {
List<Instance> instances = service.allIPs();
for (Instance instance : instances) {
if (IPUtil.containsPort(containedInstance)) {
if (StringUtils.equals(instance.getIp() + IPUtil.IP_PORT_SPLITER + instance.getPort(), containedInstance)) {
if (StringUtils.equals(instance.getIp() + IPUtil.IP_PORT_SPLITER + instance.getPort(),
containedInstance)) {
contained = true;
break;
}

34
pom.xml
View File

@ -22,7 +22,7 @@
<inceptionYear>2018</inceptionYear>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
<packaging>pom</packaging>
<name>Alibaba NACOS ${project.version}</name>
@ -36,7 +36,7 @@
<url>git@github.com:alibaba/nacos.git</url>
<connection>scm:git@github.com:alibaba/nacos.git</connection>
<developerConnection>scm:git@github.com:alibaba/nacos.git</developerConnection>
<tag>nacos-all-2.0.0-1-SNAPSHOT</tag>
<tag>nacos-all-${revision}</tag>
</scm>
<mailingLists>
@ -88,6 +88,7 @@
</issueManagement>
<properties>
<revision>2.0.0-1-SNAPSHOT</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Compiler settings properties -->
@ -121,6 +122,7 @@
<maven-failsafe-plugin.version>2.19.1</maven-failsafe-plugin.version>
<maven-assembly-plugin.version>3.0.0</maven-assembly-plugin.version>
<maven-checkstyle-plugin.version>3.1.1</maven-checkstyle-plugin.version>
<maven-flatten-version>1.1.0</maven-flatten-version>
<!-- dependency version related to plugin -->
<extra-enforcer-rules.version>1.0-beta-4</extra-enforcer-rules.version>
<p3c-pmd.version>1.3.0</p3c-pmd.version>
@ -426,6 +428,34 @@
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${maven-flatten-version}</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
<pomElements>
<dependencies>expand</dependencies>
</pomElements>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -21,7 +21,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -20,7 +20,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>2.0.0-1-SNAPSHOT</version>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>