Skip to content

Commit

Permalink
同步alibaba develop到自己的develop (#1)
Browse files Browse the repository at this point in the history
* fix: closes alibaba#1569

* fix bug

* build main

* alibaba#1529
distro 使用本地时间记录心跳

* Fix alibaba#1591

* Add unit tests for common.GroupKey and utils.MD5

Fully-qualified classname
com.alibaba.nacos.client.config.common.GroupKey
com.alibaba.nacos.client.config.utils.MD5

These tests were written using Diffblue Cover.

* Fix alibaba#1591

* feat: support change password

* upgrade the fastjson version

* Fix namespace vulnerability

* 修复alibaba#1583

* no message

* 编译 main.*

* no message

* fix build

* fix FE

* 后端支持

* npm build

* fix CI

* 没有过滤条件直接返回原始Service列表

* add refresh memory

* remove unness const

* no message

* clear code

* build console

* revert error code

* Remove unnecessary code

* Delete the code that caused the list multi-element

* fix bug

* Unified constant use

* reverse `Service Name` and `Group Name`

* Fix bug

* Update version to 1.1.2-SNAPSHOT

* fix: font privatization

* Subject to the actual startup context path

* if not set the context path with the WebServerInitializedEvent then real '/' is context path

* RunningConfig support get from spring.properties configuration file

* Update version to 1.1.2

* Update version to 1.1.3

* Add unit tests for com.alibaba.nacos.config.server.utils.GroupKey

These tests were written using Diffblue Cover

* Use dynamic server version

* 1. Optimize log printing
2. Improve the robustness and readability of your code

* support datum is null case

* repair httpGetLarge#httpGetLarge will call entity.getContentType().getElements() the contentType is NPE

* Normalize http response entity with ResponseEntity by spring

* feat:

* cluster conf support multi instance inline seperator with ','

* add comma division with some case to use

* add comma division with some case to use

* add comma division with some case to use

* resolve conflict

* fix: fix alibaba#1733

* 页面修复

* use API to create param

* use API to create param

* [ISSUE] alibaba#1671 Unified request header "Client-Version"

* [ISSUE] alibaba#1671 Unified request header "Client-Version"

* 🐛 remove server.contextPath

* Update service description error in Open API Guide

* fix: fix alibaba#1665

* fix alibaba#1764.

* Compatible with older versions

* [Issue] alibaba#1769 Solve the bug of the clone configuration function

* Fix alibaba#1764

* [Issue] alibaba#1769 Solve the bug of the clone configuration function

* [Issue] alibaba#1769 Solve the bug of the clone configuration function

* fix: closes alibaba#1759

* fixed(cluster): fixed raft cluster state

* chore(cluster): delete no used note

* alibaba#1507 close server from current dir

* repair speel error and add debug log

* Fix alibaba#1621

* fix alibaba#1609

* fix alibaba#1609

* Make error information more specifically

* feature(triggerFlag): add triggerFlag for service

* feture(triggerFlag): add frontend show triggerFlag

* style: Modifiers should be declared in the correct order;Map init 设置大小 避免扩容;

* style: Modifiers should be declared in the correct order;Map init 设置大小 避免扩容;

* refactor: 局部变量是线程安全的;
          urlPattern改成static final;
          GroupKey重构

* improve(triggerFlag): add pre check for triggerFlag

* refactor: IO改成try resource。instanceList循环直接改成addAll

* chore(triggerFlag): adjust some details

* improve(instanceHealth): add update logic

* feat:

* Avoiding conflicted for creating directory.

* improve(triggerFlag): adjust triggerFlag calculation chance

* clean controllers code

* chore(reiggerFlag): delete unused function

* merge

* improve(triggerFlag): improve instance health flag

* Add synchronized when add/remove instance

* Update jackson version, see https://nvd.nist.gov/vuln/detail/CVE-2019-16335

* Fix alibaba#1874

* alibaba#1873, set default server expire timeout to 10 seconds and configurable.

* fix bug alibaba#1775

fix bug alibaba#1775

* build fe

* Clean up redundant StringUtils

* bug fix 1841

bug fix alibaba#1841

* fix alibaba#1916

* Bump netty-all from 4.0.42.Final to 4.1.42.Final

Bumps [netty-all](https://github.com/netty/netty) from 4.0.42.Final to 4.1.42.Final.
- [Release notes](https://github.com/netty/netty/releases)
- [Commits](netty/netty@netty-4.0.42.Final...netty-4.1.42.Final)

Signed-off-by: dependabot[bot] <[email protected]>

* alibaba#1409 Introduce MCP server

* alibaba#1409 gRPC server tuned OK.

* alibaba#1409 Update from Nacos

* alibaba#1409 Fix PMD

* Fix alibaba#1906

* fix the getting subscribers error

* Support unique instance index for each registered server

Signed-off-by: dizhe <[email protected]>

* 创建字符串不需要带入双引号,否则调用时会报Error:Unable access jarfile

* Support snowflake instance id generator

Signed-off-by: Vettal Wu <[email protected]>

* Fix test case error.

* clean code

* fix the CI errors

* remove the useless code that make ci errors

* Fix findbugs

* Add switch to turn on/off MCP server

* Update version to 1.1.4

* issues:调用修改实例接口,未传的参数值会被清空
alibaba#1957

* Change MCP service port to 8848

* Fix add metadata method NPE.

* Fix PMD

* fix alibaba#1947

* alibaba#1947 add test cases.

* issues:调用修改实例接口,未传的参数值会被清空
alibaba#1957

* issues:调用修改实例接口,未传的参数值会被清空
alibaba#1957

* [alibaba#2006] change to throw NacosException to make client handle the right Exception case

* make RequestVote RPC handler thread-safe

* Modify the string splicing method of getgroupedname()

* Remove debug option in startup script

* fix alibaba#2000

* alibaba#2018 Close inpuststream instead of connection.

* fix alibaba#1842

* fix alibaba#1858

* Fix client beat task executing when health check is disabled.

* refactor(client/config): increase the client's read timeout

In order to prevent the server from handling the delay of the client's long task, increase the
client's read timeout to avoid this problem.

* refactor(client/config): update timeout compute

* fix startup for java 11

* remvoe classpath

* Bump jackson-databind from 2.9.10 to 2.9.10.1

Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.9.10 to 2.9.10.1.
- [Release notes](https://github.com/FasterXML/jackson/releases)
- [Commits](https://github.com/FasterXML/jackson/commits)

Signed-off-by: dependabot[bot] <[email protected]>

* add toUpperCase

* optimize: the Boolean.parseBoolean(String s) method should be used when converting a String to a Boolean type

* fix 2025

* fix default value of database field

* add client context path config

* 修复 alibaba#2098

* add nacos console cors

* format code

* Update version to 1.2.0-SNAPSHOT

* Fix close connection exception.

* Fix alibaba#2123

* Fix alibaba#2020

* Fix alibaba#2123
  • Loading branch information
xingguangsixian authored Dec 7, 2019
1 parent 1915e9c commit dafcb7c
Show file tree
Hide file tree
Showing 322 changed files with 37,653 additions and 3,531 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ It is super easy to get started with your first project.

You can download the package from the [latest stable release](https://github.com/alibaba/nacos/releases).

Take release nacos-server-0.9.0.zip for example.
Take release nacos-server-1.0.0.zip for example.
```
unzip nacos-server-0.9.0.zip
unzip nacos-server-1.0.0.zip
cd nacos/bin
```

Expand Down
2 changes: 1 addition & 1 deletion address/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<artifactId>nacos-all</artifactId>
<groupId>com.alibaba.nacos</groupId>
<version>1.1.0</version>
<version>1.2.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.alibaba.nacos.address;

import org.junit.Ignore;
import org.junit.Test;

import java.util.HashMap;
Expand All @@ -23,6 +24,7 @@
* @author pbting
* @date 2019-06-18 2:37 PM
*/
@Ignore
public class AddressServerControllerTests {

private static final String PRODUCT_NACOS = "nacos";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.address;

import com.alibaba.nacos.common.utils.IoUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -172,9 +174,7 @@ private static String doExecute(String reqUrl, Map<String, String> paramMap, Str
} catch (IOException e) {
e.printStackTrace();
} finally {
if (urlCon != null) {
urlCon.disconnect();
}
IoUtils.closeQuietly(urlCon);
}
return responseContent;
}
Expand Down
6 changes: 5 additions & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>1.1.0</version>
<version>1.2.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -62,5 +62,9 @@
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
/**
* The placeholder of {@link NacosProperties#ENABLE_REMOTE_SYNC_CONFIG enableRemoteSyncConfig}, the value is <code>"${nacos.enableRemoteSyncConfig:}"</code>
*/
String ENABLE_REMOTE_SYNC_CONFIG_PLACEHOLDER = "${" + PREFIX + ENABLE_REMOTE_SYNC_CONFIG + "}";
String ENABLE_REMOTE_SYNC_CONFIG_PLACEHOLDER = "${" + PREFIX + ENABLE_REMOTE_SYNC_CONFIG + ":}";

/**
* The property of "endpoint"
Expand Down
7 changes: 7 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,11 @@ public class Constants {
public static final String NULL_STRING = "null";

public static final String NUMBER_PATTERN = "^\\d+$";

public static final String ANY_PATTERN = ".*";

public static final String DEFAULT_INSTANCE_ID_GENERATOR = "simple";

public static final String SNOWFLAKE_INSTANCE_ID_GENERATOR = "snowflake";

}
37 changes: 37 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/common/ResponseCode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.api.common;


/**
* Response code definitions.
* <p>
* This class and inherited classes define codes separated from HTTP code to provide richer and preciser
* information of the API results. A recommended rule for defining response code is:
* <li> Global and common code starts with 10001.
* <li> Naming module code starts with 20001.
* <li> Config module code starts with 30001.
*
* @author nkorange
* @since 1.2.0
*/
public class ResponseCode {

/**
* Everything normal
*/
public static final int OK = 10200;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
*/
@SuppressWarnings("PMD.AbstractClassShouldStartWithAbstractNamingRule")
public abstract class AbstractSharedListener implements Listener {

private volatile String dataId;
private volatile String group;

final public void fillContext(String dataId, String group) {
public final void fillContext(String dataId, String group) {
this.dataId = dataId;
this.group = group;
}

@Override
final public void receiveConfigInfo(String configInfo) {
public final void receiveConfigInfo(String configInfo) {
innerReceive(dataId, group, configInfo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ public String toString() {
* no right(鉴权失败)
*/
public static final int NO_RIGHT = 403;
/**
* not found
*/
public static final int NOT_FOUND = 404;
/**
* conflict(写并发冲突)
*/
Expand All @@ -140,4 +144,6 @@ public String toString() {
*/
public static final int OVER_THRESHOLD = 503;

public static final int RESOURCE_NOT_FOUND = -404;

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
public class CommonParams {

public static final String CODE = "code";

public static final String SERVICE_NAME = "serviceName";

public static final String CLUSTER_NAME = "clusterName";
Expand All @@ -31,4 +33,5 @@ public class CommonParams {

public static final String GROUP_NAME = "groupName";

public static final String LIGHT_BEAT_ENABLED = "lightBeatEnabled";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.api.naming;

import com.alibaba.nacos.api.common.ResponseCode;

/**
* Business response code of naming module
*
* Every code stays between 20001 to 29999.
*
* @author nkorange
* @author 1.2.0
*/
public class NamingResponseCode extends ResponseCode {

/**
* The requested resource is not found
*/
public static final int RESOURCE_NOT_FOUND = 20404;

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ public class PreservedMetadataKeys {
public static final String IP_DELETE_TIMEOUT = "preserved.ip.delete.timeout";

public static final String HEART_BEAT_INTERVAL = "preserved.heart.beat.interval";

public static final String INSTANCE_ID_GENERATOR = "preserved.instance.id.generator";
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import com.google.common.base.Objects;

/**
* @author nkorange
Expand Down Expand Up @@ -138,7 +138,7 @@ public void jsonAdapterCallback(SerializeWriter writer) {

@Override
public int hashCode() {
return Objects.hash(path, headers, expectedResponseCode);
return Objects.hashCode(path, headers, expectedResponseCode);
}

@Override
Expand Down Expand Up @@ -184,7 +184,7 @@ public Tcp() {

@Override
public int hashCode() {
return Objects.hash(TYPE);
return Objects.hashCode(TYPE);
}

@Override
Expand Down Expand Up @@ -250,7 +250,7 @@ public void jsonAdapterCallback(SerializeWriter writer) {

@Override
public int hashCode() {
return Objects.hash(user, pwd, cmd);
return Objects.hashCode(user, pwd, cmd);
}

@Override
Expand Down
14 changes: 14 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/naming/pojo/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ public void setMetadata(Map<String, String> metadata) {
}

public void addMetadata(String key, String value) {
if (this.metadata == null) {
this.metadata = new HashMap<String, String>(4);
}
this.metadata.put(key, value);
}

Expand Down Expand Up @@ -209,6 +212,10 @@ public long getIpDeleteTimeout() {
return getMetaDataByKeyWithDefault(PreservedMetadataKeys.IP_DELETE_TIMEOUT, Constants.DEFAULT_IP_DELETE_TIMEOUT);
}

public String getInstanceIdGenerator() {
return getMetaDataByKeyWithDefault(PreservedMetadataKeys.INSTANCE_ID_GENERATOR, Constants.DEFAULT_INSTANCE_ID_GENERATOR);
}

private long getMetaDataByKeyWithDefault( String key, long defaultValue) {
if (getMetadata() == null || getMetadata().isEmpty()) {
return defaultValue;
Expand All @@ -220,4 +227,11 @@ private long getMetaDataByKeyWithDefault( String key, long defaultValue) {
return defaultValue;
}

private String getMetaDataByKeyWithDefault( String key, String defaultValue) {
if (getMetadata() == null || getMetadata().isEmpty()) {
return defaultValue;
}
return getMetadata().get(key);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
public class NamingUtils {

public static String getGroupedName(String serviceName, String groupName) {
return groupName + Constants.SERVICE_INFO_SPLITER + serviceName;
StringBuilder resultGroupedName = new StringBuilder()
.append(groupName)
.append(Constants.SERVICE_INFO_SPLITER)
.append(serviceName);
return resultGroupedName.toString().intern();
}

public static String getServiceName(String serviceNameWithGroup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.alibaba.nacos.api.annotation;

import com.alibaba.fastjson.JSON;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.mock.env.MockEnvironment;
Expand Down Expand Up @@ -74,4 +75,9 @@ private void testResolvePlaceholder(String placeholder, String propertyName, Str
String resolvedValue = environment.resolvePlaceholders(placeholder);
Assert.assertEquals(expectValue, resolvedValue);
}

@Test
public void testSort() {

}
}
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-all</artifactId>
<version>1.1.0</version>
<version>1.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import com.alibaba.nacos.client.config.utils.ContentUtils;
import com.alibaba.nacos.client.config.utils.ParamUtils;
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.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;

import java.io.IOException;
Expand Down Expand Up @@ -93,7 +93,7 @@ private void initNamespace(Properties properties) {
System.getProperty(SystemPropertyKeyConst.IS_USE_CLOUD_NAMESPACE_PARSING,
String.valueOf(Constants.DEFAULT_USE_CLOUD_NAMESPACE_PARSING)));

if (Boolean.valueOf(isUseCloudNamespaceParsing)) {
if (Boolean.parseBoolean(isUseCloudNamespaceParsing)) {
namespaceTmp = TemplateUtils.stringBlankAndThenExecute(namespaceTmp, new Callable<String>() {
@Override
public String call() {
Expand Down
Loading

0 comments on commit dafcb7c

Please sign in to comment.