@@ -48,30 +48,48 @@ public class ParamUtil {
48
48
49
49
private static String appName ;
50
50
51
- private static final String DEFAULT_SERVER_PORT ;
51
+ private static final String DEFAULT_SERVER_PORT = "8848" ;
52
+
53
+ private static String serverPort ;
52
54
53
55
private static String clientVersion = "unknown" ;
54
56
55
57
private static int connectTimeout ;
56
58
57
59
private static double perTaskConfigSize = 3000 ;
58
60
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
+
59
79
static {
60
- // 客户端身份信息
61
- appKey = System .getProperty ("nacos.client.appKey" , "" );
80
+ // Client identity information
81
+ appKey = System .getProperty (NACOS_CLIENT_APP_KEY , BLANK_STR );
62
82
63
- defaultContextPath = System .getProperty ("nacos.client.contextPath" , "nacos" );
83
+ defaultContextPath = System .getProperty (NACOS_CLIENT_CONTEXTPATH_KEY , DEFAULT_NACOS_CLIENT_CONTEXTPATH );
64
84
65
85
appName = AppNameUtils .getAppName ();
66
86
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 );
71
89
72
90
String tmp = "1000" ;
73
91
try {
74
- tmp = System .getProperty ("NACOS.CONNECT.TIMEOUT" , "1000" );
92
+ tmp = System .getProperty (NACOS_CONNECT_TIMEOUT_KEY , DEFAULT_NACOS_CONNECT_TIMEOUT );
75
93
connectTimeout = Integer .parseInt (tmp );
76
94
} catch (NumberFormatException e ) {
77
95
final String msg = "[http-client] invalid connect timeout:" + tmp ;
@@ -83,7 +101,8 @@ public class ParamUtil {
83
101
clientVersion = VersionUtils .version ;
84
102
85
103
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 ));
87
106
LOGGER .info ("PER_TASK_CONFIG_SIZE: {}" , perTaskConfigSize );
88
107
} catch (Throwable t ) {
89
108
LOGGER .error ("[PER_TASK_CONFIG_SIZE] PER_TASK_CONFIG_SIZE invalid" , t );
@@ -139,7 +158,7 @@ public static void setPerTaskConfigSize(double perTaskConfigSize) {
139
158
}
140
159
141
160
public static String getDefaultServerPort () {
142
- return DEFAULT_SERVER_PORT ;
161
+ return serverPort ;
143
162
}
144
163
145
164
public static String getDefaultNodesPath () {
@@ -188,7 +207,7 @@ public String call() {
188
207
* @return end point rule
189
208
*/
190
209
public static String parsingEndpointRule (String endpointUrl ) {
191
- // 配置文件中输入的话,以 ENV 中的优先,
210
+ // If entered in the configuration file, the priority in ENV will be given priority.
192
211
if (endpointUrl == null || !PATTERN .matcher (endpointUrl ).find ()) {
193
212
// skip retrieve from system property and retrieve directly from system env
194
213
String endpointUrlSource = System .getenv (PropertyKeyConst .SystemEnv .ALIBABA_ALIWARE_ENDPOINT_URL );
0 commit comments