Skip to content

Commit 8e3675e

Browse files
CrazyHZMbeiwei30
authored andcommitted
[DUBBO-3137]: step3 - seperate constants for remoting (#4023)
* constants step3-remoting * remove import * modify
1 parent 6a1dd65 commit 8e3675e

File tree

113 files changed

+350
-287
lines changed

Some content is hidden

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

113 files changed

+350
-287
lines changed

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/configurator/AbstractConfigurator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.dubbo.common.Constants;
2020
import org.apache.dubbo.common.URL;
21+
import org.apache.dubbo.common.constants.RemotingConstants;
2122
import org.apache.dubbo.common.utils.NetUtils;
2223
import org.apache.dubbo.common.utils.StringUtils;
2324
import org.apache.dubbo.rpc.cluster.Configurator;
@@ -104,7 +105,7 @@ private URL configureIfMatch(String host, URL url) {
104105
|| configApplication.equals(currentApplication)) {
105106
Set<String> conditionKeys = new HashSet<String>();
106107
conditionKeys.add(Constants.CATEGORY_KEY);
107-
conditionKeys.add(Constants.CHECK_KEY);
108+
conditionKeys.add(RemotingConstants.CHECK_KEY);
108109
conditionKeys.add(Constants.DYNAMIC_KEY);
109110
conditionKeys.add(Constants.ENABLED_KEY);
110111
conditionKeys.add(Constants.GROUP_KEY);

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.dubbo.common.Constants;
2020
import org.apache.dubbo.common.URL;
21+
import org.apache.dubbo.common.constants.RemotingConstants;
2122
import org.apache.dubbo.common.utils.StringUtils;
2223

2324
import java.util.HashMap;
@@ -59,8 +60,8 @@ public static URL mergeUrl(URL remoteUrl, Map<String, String> localMap) {
5960
map.remove(Constants.ALIVE_KEY);
6061
map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.ALIVE_KEY);
6162

62-
map.remove(Constants.TRANSPORTER_KEY);
63-
map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.TRANSPORTER_KEY);
63+
map.remove(RemotingConstants.TRANSPORTER_KEY);
64+
map.remove(Constants.DEFAULT_KEY_PREFIX + RemotingConstants.TRANSPORTER_KEY);
6465

6566
map.remove(Constants.ASYNC_KEY);
6667
map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.ASYNC_KEY);

dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.dubbo.common;
1919

20+
import org.apache.dubbo.common.constants.RemotingConstants;
21+
2022
import java.util.concurrent.ExecutorService;
2123
import java.util.regex.Pattern;
2224

@@ -789,7 +791,7 @@ public class Constants {
789791

790792
public static final String COMPATIBLE_CONFIG_KEY = "compatible_config";
791793

792-
public static final String[] DEFAULT_REGISTER_PROVIDER_KEYS = {APPLICATION_KEY, CODEC_KEY, EXCHANGER_KEY, SERIALIZATION_KEY, CLUSTER_KEY, CONNECTIONS_KEY, DEPRECATED_KEY,
794+
public static final String[] DEFAULT_REGISTER_PROVIDER_KEYS = {APPLICATION_KEY, RemotingConstants.CODEC_KEY, RemotingConstants.EXCHANGER_KEY, RemotingConstants.SERIALIZATION_KEY, CLUSTER_KEY, CONNECTIONS_KEY, DEPRECATED_KEY,
793795
GROUP_KEY, LOADBALANCE_KEY, MOCK_KEY, PATH_KEY, TIMEOUT_KEY, TOKEN_KEY, VERSION_KEY, WARMUP_KEY, WEIGHT_KEY, TIMESTAMP_KEY, DUBBO_VERSION_KEY, RELEASE_KEY};
794796

795797
public static final String[] DEFAULT_REGISTER_CONSUMER_KEYS = {APPLICATION_KEY, VERSION_KEY, GROUP_KEY, DUBBO_VERSION_KEY, RELEASE_KEY};

dubbo-common/src/main/java/org/apache/dubbo/common/URL.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.dubbo.common.config.Configuration;
2020
import org.apache.dubbo.common.config.InmemoryConfiguration;
21+
import org.apache.dubbo.common.constants.RemotingConstants;
2122
import org.apache.dubbo.common.utils.ArrayUtils;
2223
import org.apache.dubbo.common.utils.CollectionUtils;
2324
import org.apache.dubbo.common.utils.NetUtils;
@@ -414,7 +415,7 @@ public String getBackupAddress() {
414415

415416
public String getBackupAddress(int defaultPort) {
416417
StringBuilder address = new StringBuilder(appendDefaultPort(getAddress(), defaultPort));
417-
String[] backups = getParameter(Constants.BACKUP_KEY, new String[0]);
418+
String[] backups = getParameter(RemotingConstants.BACKUP_KEY, new String[0]);
418419
if (ArrayUtils.isNotEmpty(backups)) {
419420
for (String backup : backups) {
420421
address.append(",");
@@ -427,7 +428,7 @@ public String getBackupAddress(int defaultPort) {
427428
public List<URL> getBackupUrls() {
428429
List<URL> urls = new ArrayList<>();
429430
urls.add(this);
430-
String[] backups = getParameter(Constants.BACKUP_KEY, new String[0]);
431+
String[] backups = getParameter(RemotingConstants.BACKUP_KEY, new String[0]);
431432
if (backups != null && backups.length > 0) {
432433
for (String backup : backups) {
433434
urls.add(this.setAddress(backup));

dubbo-common/src/main/java/org/apache/dubbo/common/constants/RegistryConstants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919

2020
import static org.apache.dubbo.common.Constants.APPLICATION_KEY;
2121
import static org.apache.dubbo.common.Constants.CLUSTER_KEY;
22-
import static org.apache.dubbo.common.Constants.CODEC_KEY;
22+
import static org.apache.dubbo.common.constants.RemotingConstants.CODEC_KEY;
2323
import static org.apache.dubbo.common.Constants.CONNECTIONS_KEY;
2424
import static org.apache.dubbo.common.Constants.DEPRECATED_KEY;
2525
import static org.apache.dubbo.common.Constants.DUBBO_VERSION_KEY;
26-
import static org.apache.dubbo.common.Constants.EXCHANGER_KEY;
26+
import static org.apache.dubbo.common.constants.RemotingConstants.EXCHANGER_KEY;
2727
import static org.apache.dubbo.common.Constants.GROUP_KEY;
2828
import static org.apache.dubbo.common.Constants.LOADBALANCE_KEY;
2929
import static org.apache.dubbo.common.Constants.MOCK_KEY;
3030
import static org.apache.dubbo.common.Constants.PATH_KEY;
3131
import static org.apache.dubbo.common.Constants.RELEASE_KEY;
32-
import static org.apache.dubbo.common.Constants.SERIALIZATION_KEY;
32+
import static org.apache.dubbo.common.constants.RemotingConstants.SERIALIZATION_KEY;
3333
import static org.apache.dubbo.common.Constants.TIMEOUT_KEY;
3434
import static org.apache.dubbo.common.Constants.TIMESTAMP_KEY;
3535
import static org.apache.dubbo.common.Constants.TOKEN_KEY;

dubbo-common/src/main/java/org/apache/dubbo/common/utils/UrlUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.dubbo.common.Constants;
2020
import org.apache.dubbo.common.URL;
21+
import org.apache.dubbo.common.constants.RemotingConstants;
2122

2223
import java.util.ArrayList;
2324
import java.util.HashMap;
@@ -60,7 +61,7 @@ public static URL parseURL(String address, Map<String, String> defaults) {
6061
}
6162
backup.append(addresses[i]);
6263
}
63-
url += URL_PARAM_STARTING_SYMBOL + Constants.BACKUP_KEY + "=" + backup.toString();
64+
url += URL_PARAM_STARTING_SYMBOL + RemotingConstants.BACKUP_KEY + "=" + backup.toString();
6465
}
6566
}
6667
String defaultProtocol = defaults == null ? null : defaults.get(Constants.PROTOCOL_KEY);
@@ -468,12 +469,12 @@ public static boolean isProvider(URL url) {
468469
}
469470

470471
public static int getHeartbeat(URL url) {
471-
return url.getParameter(Constants.HEARTBEAT_KEY, Constants.DEFAULT_HEARTBEAT);
472+
return url.getParameter(RemotingConstants.HEARTBEAT_KEY, RemotingConstants.DEFAULT_HEARTBEAT);
472473
}
473474

474475
public static int getIdleTimeout(URL url) {
475476
int heartBeat = getHeartbeat(url);
476-
int idleTimeout = url.getParameter(Constants.HEARTBEAT_TIMEOUT_KEY, heartBeat * 3);
477+
int idleTimeout = url.getParameter(RemotingConstants.HEARTBEAT_TIMEOUT_KEY, heartBeat * 3);
477478
if (idleTimeout < heartBeat * 2) {
478479
throw new IllegalStateException("idleTimeout < heartbeatInterval * 2");
479480
}

dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.dubbo.config;
1818

1919
import org.apache.dubbo.common.Constants;
20+
import org.apache.dubbo.common.constants.RemotingConstants;
2021
import org.apache.dubbo.config.support.Parameter;
2122
import org.apache.dubbo.rpc.InvokerListener;
2223
import org.apache.dubbo.rpc.support.ProtocolUtils;
@@ -179,7 +180,7 @@ public Boolean getStubevent() {
179180
return stubevent;
180181
}
181182

182-
@Parameter(key = Constants.RECONNECT_KEY)
183+
@Parameter(key = RemotingConstants.RECONNECT_KEY)
183184
public String getReconnect() {
184185
return reconnect;
185186
}

dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProtocolConfig.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.dubbo.config;
1818

1919
import org.apache.dubbo.common.Constants;
20+
import org.apache.dubbo.common.constants.RemotingConstants;
2021
import org.apache.dubbo.common.extension.ExtensionLoader;
2122
import org.apache.dubbo.common.serialize.Serialization;
2223
import org.apache.dubbo.common.status.StatusChecker;
@@ -318,7 +319,7 @@ public String getCodec() {
318319

319320
public void setCodec(String codec) {
320321
if (Constants.DUBBO_PROTOCOL.equals(name)) {
321-
checkMultiExtension(Codec.class, Constants.CODEC_KEY, codec);
322+
checkMultiExtension(Codec.class, RemotingConstants.CODEC_KEY, codec);
322323
}
323324
this.codec = codec;
324325
}
@@ -329,7 +330,7 @@ public String getSerialization() {
329330

330331
public void setSerialization(String serialization) {
331332
if (Constants.DUBBO_PROTOCOL.equals(name)) {
332-
checkMultiExtension(Serialization.class, Constants.SERIALIZATION_KEY, serialization);
333+
checkMultiExtension(Serialization.class, RemotingConstants.SERIALIZATION_KEY, serialization);
333334
}
334335
this.serialization = serialization;
335336
}
@@ -372,7 +373,7 @@ public String getServer() {
372373

373374
public void setServer(String server) {
374375
if (Constants.DUBBO_PROTOCOL.equals(name)) {
375-
checkMultiExtension(Transporter.class, Constants.SERVER_KEY, server);
376+
checkMultiExtension(Transporter.class, RemotingConstants.SERVER_KEY, server);
376377
}
377378
this.server = server;
378379
}
@@ -383,7 +384,7 @@ public String getClient() {
383384

384385
public void setClient(String client) {
385386
if (Constants.DUBBO_PROTOCOL.equals(name)) {
386-
checkMultiExtension(Transporter.class, Constants.CLIENT_KEY, client);
387+
checkMultiExtension(Transporter.class, RemotingConstants.CLIENT_KEY, client);
387388
}
388389
this.client = client;
389390
}
@@ -436,7 +437,7 @@ public String getTransporter() {
436437
}
437438

438439
public void setTransporter(String transporter) {
439-
checkExtension(Transporter.class, Constants.TRANSPORTER_KEY, transporter);
440+
checkExtension(Transporter.class, RemotingConstants.TRANSPORTER_KEY, transporter);
440441
this.transporter = transporter;
441442
}
442443

@@ -445,7 +446,7 @@ public String getExchanger() {
445446
}
446447

447448
public void setExchanger(String exchanger) {
448-
checkExtension(Exchanger.class, Constants.EXCHANGER_KEY, exchanger);
449+
checkExtension(Exchanger.class, RemotingConstants.EXCHANGER_KEY, exchanger);
449450
this.exchanger = exchanger;
450451
}
451452

@@ -475,7 +476,7 @@ public String getDispatcher() {
475476
}
476477

477478
public void setDispatcher(String dispatcher) {
478-
checkExtension(Dispatcher.class, Constants.DISPACTHER_KEY, dispatcher);
479+
checkExtension(Dispatcher.class, RemotingConstants.DISPACTHER_KEY, dispatcher);
479480
this.dispatcher = dispatcher;
480481
}
481482

dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ProviderConfig.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.dubbo.config;
1818

1919
import org.apache.dubbo.common.Constants;
20+
import org.apache.dubbo.common.constants.RemotingConstants;
2021
import org.apache.dubbo.common.status.StatusChecker;
2122
import org.apache.dubbo.common.threadpool.ThreadPool;
2223
import org.apache.dubbo.config.support.Parameter;
@@ -367,7 +368,7 @@ public String getTransporter() {
367368
}
368369

369370
public void setTransporter(String transporter) {
370-
checkExtension(Transporter.class, Constants.TRANSPORTER_KEY, transporter);
371+
checkExtension(Transporter.class, RemotingConstants.TRANSPORTER_KEY, transporter);
371372
this.transporter = transporter;
372373
}
373374

@@ -376,7 +377,7 @@ public String getExchanger() {
376377
}
377378

378379
public void setExchanger(String exchanger) {
379-
checkExtension(Exchanger.class, Constants.EXCHANGER_KEY, exchanger);
380+
checkExtension(Exchanger.class, RemotingConstants.EXCHANGER_KEY, exchanger);
380381
this.exchanger = exchanger;
381382
}
382383

@@ -406,7 +407,7 @@ public String getDispatcher() {
406407
}
407408

408409
public void setDispatcher(String dispatcher) {
409-
checkExtension(Dispatcher.class, Constants.DISPATCHER_KEY, dispatcher);
410+
checkExtension(Dispatcher.class, RemotingConstants.DISPATCHER_KEY, dispatcher);
410411
checkExtension(Dispatcher.class, "dispather", dispatcher);
411412
this.dispatcher = dispatcher;
412413
}

dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.dubbo.common.URL;
2121
import org.apache.dubbo.common.Version;
2222
import org.apache.dubbo.common.bytecode.Wrapper;
23+
import org.apache.dubbo.common.constants.RemotingConstants;
2324
import org.apache.dubbo.common.extension.ExtensionLoader;
2425
import org.apache.dubbo.common.utils.ClassUtils;
2526
import org.apache.dubbo.common.utils.CollectionUtils;
@@ -561,7 +562,7 @@ public String getClient() {
561562
}
562563

563564
public void setClient(String client) {
564-
checkName(Constants.CLIENT_KEY, client);
565+
checkName(RemotingConstants.CLIENT_KEY, client);
565566
this.client = client;
566567
}
567568

0 commit comments

Comments
 (0)