Skip to content

Commit cf5a171

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into feature_support_grpc_core
# Conflicts: # NOTICE # api/pom.xml # common/src/main/java/com/alibaba/nacos/common/notify/DefaultPublisher.java # config/src/main/java/com/alibaba/nacos/config/server/service/LongPollingService.java # naming/src/test/java/com/alibaba/nacos/naming/consistency/persistent/impl/NamingSnapshotOperationTest.java # naming/src/test/java/com/alibaba/nacos/naming/core/DomainsManagerTest.java # naming/src/test/java/com/alibaba/nacos/naming/healthcheck/ClientBeatCheckTaskTest.java # pom.xml # test/src/test/java/com/alibaba/nacos/test/core/JacksonUtils.java
2 parents 98aae39 + 4ecf293 commit cf5a171

File tree

64 files changed

+1810
-423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1810
-423
lines changed

.editorconfig

-16
This file was deleted.

NOTICE

+25-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,30 @@ Also, please refer to each LICENSE.<component>.txt file, which is located in
3131
the 'license' directory of the distribution file, for the license terms of the
3232
components that this product depends on.
3333

34+
35+
------
36+
com.alibaba.nacos.common.utils.InetAddressValidator.java in this product is
37+
copied from com.dynatrace.openkit.core.util.InetAddressValidator.java of openkit-java project.
38+
https://github.com/Dynatrace/openkit-java
39+
openkit-java
40+
======================
41+
42+
Copyright 2018-2021 Dynatrace LLC
43+
44+
Licensed under the Apache License, Version 2.0 (the "License");
45+
you may not use this file except in compliance with the License.
46+
You may obtain a copy of the License at
47+
48+
http://www.apache.org/licenses/LICENSE-2.0
49+
50+
Unless required by applicable law or agreed to in writing, software
51+
distributed under the License is distributed on an "AS IS" BASIS,
52+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53+
See the License for the specific language governing permissions and
54+
limitations under the License.
55+
3456
------
35-
This product has a bundle Protocol Buffers��
57+
This product has a bundle Protocol Buffers��
3658
Protocol Buffers
3759
=======================
3860
Protocol Buffers for Go with Gadgets
@@ -41,7 +63,7 @@ Copyright (c) 2013, The GoGo Authors. All rights reserved.
4163
http://github.com/gogo/protobuf
4264

4365
------
44-
This product has a bundle Istio��
66+
This product has a bundle Istio��
4567
Istio
4668
=======================
4769

@@ -57,4 +79,4 @@ This product has a bundle Istio
5779
distributed under the License is distributed on an "AS IS" BASIS,
5880
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5981
See the License for the specific language governing permissions and
60-
limitations under the License.
82+
limitations under the License.

address/pom.xml

-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@
3636
</properties>
3737

3838
<dependencies>
39-
<dependency>
40-
<groupId>junit</groupId>
41-
<artifactId>junit</artifactId>
42-
<scope>test</scope>
43-
</dependency>
4439
<dependency>
4540
<groupId>${project.groupId}</groupId>
4641
<artifactId>nacos-naming</artifactId>

api/src/main/java/com/alibaba/nacos/api/common/Constants.java

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public class Constants {
8383

8484
public static final String GLOBAL_ADMIN = "globalAdmin";
8585

86+
public static final String USERNAME = "username";
87+
8688
public static final String TOKEN_REFRESH_WINDOW = "tokenRefreshWindow";
8789

8890
/**

client/pom.xml

-11
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,10 @@
113113
<optional>true</optional>
114114
</dependency>
115115

116-
<dependency>
117-
<groupId>junit</groupId>
118-
<artifactId>junit</artifactId>
119-
<scope>test</scope>
120-
</dependency>
121-
122116
<dependency>
123117
<groupId>io.prometheus</groupId>
124118
<artifactId>simpleclient</artifactId>
125119
</dependency>
126-
<dependency>
127-
<groupId>org.mockito</groupId>
128-
<artifactId>mockito-core</artifactId>
129-
<scope>test</scope>
130-
</dependency>
131120
<dependency>
132121
<groupId>org.yaml</groupId>
133122
<artifactId>snakeyaml</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 1999-2018 Alibaba Group Holding Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.alibaba.nacos.client.config.common;
18+
19+
/**
20+
* config common constants.
21+
*
22+
* @author Nacos
23+
*/
24+
public class ConfigConstants {
25+
26+
public static final String TENANT = "tenant";
27+
28+
public static final String DATA_ID = "dataId";
29+
30+
public static final String GROUP = "group";
31+
32+
public static final String CONTENT = "content";
33+
34+
public static final String CONFIG_TYPE = "configType";
35+
36+
public static final String ENCRYPTED_DATA_KEY = "encryptedDataKey";
37+
}

client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigRequest.java

+13-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
import java.util.HashMap;
2323
import java.util.Map;
2424

25+
import static com.alibaba.nacos.client.config.common.ConfigConstants.CONTENT;
26+
import static com.alibaba.nacos.client.config.common.ConfigConstants.DATA_ID;
27+
import static com.alibaba.nacos.client.config.common.ConfigConstants.GROUP;
28+
import static com.alibaba.nacos.client.config.common.ConfigConstants.TENANT;
29+
2530
/**
2631
* Config Request.
2732
*
@@ -34,35 +39,35 @@ public class ConfigRequest implements IConfigRequest {
3439
private final IConfigContext configContext = new ConfigContext();
3540

3641
public String getTenant() {
37-
return (String) param.get("tenant");
42+
return (String) param.get(TENANT);
3843
}
3944

4045
public void setTenant(String tenant) {
41-
param.put("tenant", tenant);
46+
param.put(TENANT, tenant);
4247
}
4348

4449
public String getDataId() {
45-
return (String) param.get("dataId");
50+
return (String) param.get(DATA_ID);
4651
}
4752

4853
public void setDataId(String dataId) {
49-
param.put("dataId", dataId);
54+
param.put(DATA_ID, dataId);
5055
}
5156

5257
public String getGroup() {
53-
return (String) param.get("group");
58+
return (String) param.get(GROUP);
5459
}
5560

5661
public void setGroup(String group) {
57-
param.put("group", group);
62+
param.put(GROUP, group);
5863
}
5964

6065
public String getContent() {
61-
return (String) param.get("content");
66+
return (String) param.get(CONTENT);
6267
}
6368

6469
public void setContent(String content) {
65-
param.put("content", content);
70+
param.put(CONTENT, content);
6671
}
6772

6873
public void getType() {

client/src/main/java/com/alibaba/nacos/client/config/filter/impl/ConfigResponse.java

+19-12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
import java.util.HashMap;
2323
import java.util.Map;
2424

25+
import static com.alibaba.nacos.client.config.common.ConfigConstants.CONFIG_TYPE;
26+
import static com.alibaba.nacos.client.config.common.ConfigConstants.CONTENT;
27+
import static com.alibaba.nacos.client.config.common.ConfigConstants.DATA_ID;
28+
import static com.alibaba.nacos.client.config.common.ConfigConstants.ENCRYPTED_DATA_KEY;
29+
import static com.alibaba.nacos.client.config.common.ConfigConstants.GROUP;
30+
import static com.alibaba.nacos.client.config.common.ConfigConstants.TENANT;
31+
2532
/**
2633
* Config Response.
2734
*
@@ -34,51 +41,51 @@ public class ConfigResponse implements IConfigResponse {
3441
private final IConfigContext configContext = new ConfigContext();
3542

3643
public String getTenant() {
37-
return (String) param.get("tenant");
44+
return (String) param.get(TENANT);
3845
}
3946

4047
public void setTenant(String tenant) {
41-
param.put("tenant", tenant);
48+
param.put(TENANT, tenant);
4249
}
4350

4451
public String getDataId() {
45-
return (String) param.get("dataId");
52+
return (String) param.get(DATA_ID);
4653
}
4754

4855
public void setDataId(String dataId) {
49-
param.put("dataId", dataId);
56+
param.put(DATA_ID, dataId);
5057
}
5158

5259
public String getGroup() {
53-
return (String) param.get("group");
60+
return (String) param.get(GROUP);
5461
}
5562

5663
public void setGroup(String group) {
57-
param.put("group", group);
64+
param.put(GROUP, group);
5865
}
5966

6067
public String getContent() {
61-
return (String) param.get("content");
68+
return (String) param.get(CONTENT);
6269
}
6370

6471
public void setContent(String content) {
65-
param.put("content", content);
72+
param.put(CONTENT, content);
6673
}
6774

6875
public String getConfigType() {
69-
return (String) param.get("configType");
76+
return (String) param.get(CONFIG_TYPE);
7077
}
7178

7279
public void setConfigType(String configType) {
73-
param.put("configType", configType);
80+
param.put(CONFIG_TYPE, configType);
7481
}
7582

7683
public String getEncryptedDataKey() {
77-
return (String) param.get("encryptedDataKey");
84+
return (String) param.get(ENCRYPTED_DATA_KEY);
7885
}
7986

8087
public void setEncryptedDataKey(String encryptedDataKey) {
81-
param.put("encryptedDataKey", encryptedDataKey);
88+
param.put(ENCRYPTED_DATA_KEY, encryptedDataKey);
8289
}
8390

8491
@Override

client/src/main/java/com/alibaba/nacos/client/utils/ParamUtil.java

+31-12
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,48 @@ public class ParamUtil {
4848

4949
private static String appName;
5050

51-
private static final String DEFAULT_SERVER_PORT;
51+
private static final String DEFAULT_SERVER_PORT = "8848";
52+
53+
private static String serverPort;
5254

5355
private static String clientVersion = "unknown";
5456

5557
private static int connectTimeout;
5658

5759
private static double perTaskConfigSize = 3000;
5860

61+
private static final String NACOS_CLIENT_APP_KEY = "nacos.client.appKey";
62+
63+
private static final String BLANK_STR = "";
64+
65+
private static final String NACOS_CLIENT_CONTEXTPATH_KEY = "nacos.client.contextPath";
66+
67+
private static final String DEFAULT_NACOS_CLIENT_CONTEXTPATH = "nacos";
68+
69+
private static final String NACOS_SERVER_PORT_KEY = "nacos.server.port";
70+
71+
private static final String NACOS_CONNECT_TIMEOUT_KEY = "NACOS.CONNECT.TIMEOUT";
72+
73+
private static final String DEFAULT_NACOS_CONNECT_TIMEOUT = "1000";
74+
75+
private static final String PER_TASK_CONFIG_SIZE_KEY = "PER_TASK_CONFIG_SIZE";
76+
77+
private static final String DEFAULT_PER_TASK_CONFIG_SIZE_KEY = "3000";
78+
5979
static {
60-
// 客户端身份信息
61-
appKey = System.getProperty("nacos.client.appKey", "");
80+
// Client identity information
81+
appKey = System.getProperty(NACOS_CLIENT_APP_KEY, BLANK_STR);
6282

63-
defaultContextPath = System.getProperty("nacos.client.contextPath", "nacos");
83+
defaultContextPath = System.getProperty(NACOS_CLIENT_CONTEXTPATH_KEY, DEFAULT_NACOS_CLIENT_CONTEXTPATH);
6484

6585
appName = AppNameUtils.getAppName();
6686

67-
String defaultServerPortTmp = "8848";
68-
69-
DEFAULT_SERVER_PORT = System.getProperty("nacos.server.port", defaultServerPortTmp);
70-
LOGGER.info("[settings] [req-serv] nacos-server port:{}", DEFAULT_SERVER_PORT);
87+
serverPort = System.getProperty(NACOS_SERVER_PORT_KEY, DEFAULT_SERVER_PORT);
88+
LOGGER.info("[settings] [req-serv] nacos-server port:{}", serverPort);
7189

7290
String tmp = "1000";
7391
try {
74-
tmp = System.getProperty("NACOS.CONNECT.TIMEOUT", "1000");
92+
tmp = System.getProperty(NACOS_CONNECT_TIMEOUT_KEY, DEFAULT_NACOS_CONNECT_TIMEOUT);
7593
connectTimeout = Integer.parseInt(tmp);
7694
} catch (NumberFormatException e) {
7795
final String msg = "[http-client] invalid connect timeout:" + tmp;
@@ -83,7 +101,8 @@ public class ParamUtil {
83101
clientVersion = VersionUtils.version;
84102

85103
try {
86-
perTaskConfigSize = Double.valueOf(System.getProperty("PER_TASK_CONFIG_SIZE", "3000"));
104+
perTaskConfigSize = Double
105+
.valueOf(System.getProperty(PER_TASK_CONFIG_SIZE_KEY, DEFAULT_PER_TASK_CONFIG_SIZE_KEY));
87106
LOGGER.info("PER_TASK_CONFIG_SIZE: {}", perTaskConfigSize);
88107
} catch (Throwable t) {
89108
LOGGER.error("[PER_TASK_CONFIG_SIZE] PER_TASK_CONFIG_SIZE invalid", t);
@@ -139,7 +158,7 @@ public static void setPerTaskConfigSize(double perTaskConfigSize) {
139158
}
140159

141160
public static String getDefaultServerPort() {
142-
return DEFAULT_SERVER_PORT;
161+
return serverPort;
143162
}
144163

145164
public static String getDefaultNodesPath() {
@@ -188,7 +207,7 @@ public String call() {
188207
* @return end point rule
189208
*/
190209
public static String parsingEndpointRule(String endpointUrl) {
191-
// 配置文件中输入的话,以 ENV 中的优先,
210+
// If entered in the configuration file, the priority in ENV will be given priority.
192211
if (endpointUrl == null || !PATTERN.matcher(endpointUrl).find()) {
193212
// skip retrieve from system property and retrieve directly from system env
194213
String endpointUrlSource = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_URL);

0 commit comments

Comments
 (0)