[DUBBO-3137]: step3 - seperate constants for remoting (#4023)

* constants step3-remoting

* remove import

* modify
This commit is contained in:
huazhongming 2019-05-11 17:38:37 +08:00 committed by Ian Luo
parent 6a1dd65088
commit 8e3675ef06
113 changed files with 350 additions and 287 deletions

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.rpc.cluster.configurator;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.rpc.cluster.Configurator;
@ -104,7 +105,7 @@ public abstract class AbstractConfigurator implements Configurator {
|| configApplication.equals(currentApplication)) {
Set<String> conditionKeys = new HashSet<String>();
conditionKeys.add(Constants.CATEGORY_KEY);
conditionKeys.add(Constants.CHECK_KEY);
conditionKeys.add(RemotingConstants.CHECK_KEY);
conditionKeys.add(Constants.DYNAMIC_KEY);
conditionKeys.add(Constants.ENABLED_KEY);
conditionKeys.add(Constants.GROUP_KEY);

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.rpc.cluster.support;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.StringUtils;
import java.util.HashMap;
@ -59,8 +60,8 @@ public class ClusterUtils {
map.remove(Constants.ALIVE_KEY);
map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.ALIVE_KEY);
map.remove(Constants.TRANSPORTER_KEY);
map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.TRANSPORTER_KEY);
map.remove(RemotingConstants.TRANSPORTER_KEY);
map.remove(Constants.DEFAULT_KEY_PREFIX + RemotingConstants.TRANSPORTER_KEY);
map.remove(Constants.ASYNC_KEY);
map.remove(Constants.DEFAULT_KEY_PREFIX + Constants.ASYNC_KEY);

View File

@ -17,6 +17,8 @@
package org.apache.dubbo.common;
import org.apache.dubbo.common.constants.RemotingConstants;
import java.util.concurrent.ExecutorService;
import java.util.regex.Pattern;
@ -789,7 +791,7 @@ public class Constants {
public static final String COMPATIBLE_CONFIG_KEY = "compatible_config";
public static final String[] DEFAULT_REGISTER_PROVIDER_KEYS = {APPLICATION_KEY, CODEC_KEY, EXCHANGER_KEY, SERIALIZATION_KEY, CLUSTER_KEY, CONNECTIONS_KEY, DEPRECATED_KEY,
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,
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};
public static final String[] DEFAULT_REGISTER_CONSUMER_KEYS = {APPLICATION_KEY, VERSION_KEY, GROUP_KEY, DUBBO_VERSION_KEY, RELEASE_KEY};

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.common;
import org.apache.dubbo.common.config.Configuration;
import org.apache.dubbo.common.config.InmemoryConfiguration;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.ArrayUtils;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.NetUtils;
@ -414,7 +415,7 @@ class URL implements Serializable {
public String getBackupAddress(int defaultPort) {
StringBuilder address = new StringBuilder(appendDefaultPort(getAddress(), defaultPort));
String[] backups = getParameter(Constants.BACKUP_KEY, new String[0]);
String[] backups = getParameter(RemotingConstants.BACKUP_KEY, new String[0]);
if (ArrayUtils.isNotEmpty(backups)) {
for (String backup : backups) {
address.append(",");
@ -427,7 +428,7 @@ class URL implements Serializable {
public List<URL> getBackupUrls() {
List<URL> urls = new ArrayList<>();
urls.add(this);
String[] backups = getParameter(Constants.BACKUP_KEY, new String[0]);
String[] backups = getParameter(RemotingConstants.BACKUP_KEY, new String[0]);
if (backups != null && backups.length > 0) {
for (String backup : backups) {
urls.add(this.setAddress(backup));

View File

@ -19,17 +19,17 @@ package org.apache.dubbo.common.constants;
import static org.apache.dubbo.common.Constants.APPLICATION_KEY;
import static org.apache.dubbo.common.Constants.CLUSTER_KEY;
import static org.apache.dubbo.common.Constants.CODEC_KEY;
import static org.apache.dubbo.common.constants.RemotingConstants.CODEC_KEY;
import static org.apache.dubbo.common.Constants.CONNECTIONS_KEY;
import static org.apache.dubbo.common.Constants.DEPRECATED_KEY;
import static org.apache.dubbo.common.Constants.DUBBO_VERSION_KEY;
import static org.apache.dubbo.common.Constants.EXCHANGER_KEY;
import static org.apache.dubbo.common.constants.RemotingConstants.EXCHANGER_KEY;
import static org.apache.dubbo.common.Constants.GROUP_KEY;
import static org.apache.dubbo.common.Constants.LOADBALANCE_KEY;
import static org.apache.dubbo.common.Constants.MOCK_KEY;
import static org.apache.dubbo.common.Constants.PATH_KEY;
import static org.apache.dubbo.common.Constants.RELEASE_KEY;
import static org.apache.dubbo.common.Constants.SERIALIZATION_KEY;
import static org.apache.dubbo.common.constants.RemotingConstants.SERIALIZATION_KEY;
import static org.apache.dubbo.common.Constants.TIMEOUT_KEY;
import static org.apache.dubbo.common.Constants.TIMESTAMP_KEY;
import static org.apache.dubbo.common.Constants.TOKEN_KEY;

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.common.utils;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import java.util.ArrayList;
import java.util.HashMap;
@ -60,7 +61,7 @@ public class UrlUtils {
}
backup.append(addresses[i]);
}
url += URL_PARAM_STARTING_SYMBOL + Constants.BACKUP_KEY + "=" + backup.toString();
url += URL_PARAM_STARTING_SYMBOL + RemotingConstants.BACKUP_KEY + "=" + backup.toString();
}
}
String defaultProtocol = defaults == null ? null : defaults.get(Constants.PROTOCOL_KEY);
@ -468,12 +469,12 @@ public class UrlUtils {
}
public static int getHeartbeat(URL url) {
return url.getParameter(Constants.HEARTBEAT_KEY, Constants.DEFAULT_HEARTBEAT);
return url.getParameter(RemotingConstants.HEARTBEAT_KEY, RemotingConstants.DEFAULT_HEARTBEAT);
}
public static int getIdleTimeout(URL url) {
int heartBeat = getHeartbeat(url);
int idleTimeout = url.getParameter(Constants.HEARTBEAT_TIMEOUT_KEY, heartBeat * 3);
int idleTimeout = url.getParameter(RemotingConstants.HEARTBEAT_TIMEOUT_KEY, heartBeat * 3);
if (idleTimeout < heartBeat * 2) {
throw new IllegalStateException("idleTimeout < heartbeatInterval * 2");
}

View File

@ -17,6 +17,7 @@
package org.apache.dubbo.config;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.config.support.Parameter;
import org.apache.dubbo.rpc.InvokerListener;
import org.apache.dubbo.rpc.support.ProtocolUtils;
@ -179,7 +180,7 @@ public abstract class AbstractReferenceConfig extends AbstractInterfaceConfig {
return stubevent;
}
@Parameter(key = Constants.RECONNECT_KEY)
@Parameter(key = RemotingConstants.RECONNECT_KEY)
public String getReconnect() {
return reconnect;
}

View File

@ -17,6 +17,7 @@
package org.apache.dubbo.config;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.serialize.Serialization;
import org.apache.dubbo.common.status.StatusChecker;
@ -318,7 +319,7 @@ public class ProtocolConfig extends AbstractConfig {
public void setCodec(String codec) {
if (Constants.DUBBO_PROTOCOL.equals(name)) {
checkMultiExtension(Codec.class, Constants.CODEC_KEY, codec);
checkMultiExtension(Codec.class, RemotingConstants.CODEC_KEY, codec);
}
this.codec = codec;
}
@ -329,7 +330,7 @@ public class ProtocolConfig extends AbstractConfig {
public void setSerialization(String serialization) {
if (Constants.DUBBO_PROTOCOL.equals(name)) {
checkMultiExtension(Serialization.class, Constants.SERIALIZATION_KEY, serialization);
checkMultiExtension(Serialization.class, RemotingConstants.SERIALIZATION_KEY, serialization);
}
this.serialization = serialization;
}
@ -372,7 +373,7 @@ public class ProtocolConfig extends AbstractConfig {
public void setServer(String server) {
if (Constants.DUBBO_PROTOCOL.equals(name)) {
checkMultiExtension(Transporter.class, Constants.SERVER_KEY, server);
checkMultiExtension(Transporter.class, RemotingConstants.SERVER_KEY, server);
}
this.server = server;
}
@ -383,7 +384,7 @@ public class ProtocolConfig extends AbstractConfig {
public void setClient(String client) {
if (Constants.DUBBO_PROTOCOL.equals(name)) {
checkMultiExtension(Transporter.class, Constants.CLIENT_KEY, client);
checkMultiExtension(Transporter.class, RemotingConstants.CLIENT_KEY, client);
}
this.client = client;
}
@ -436,7 +437,7 @@ public class ProtocolConfig extends AbstractConfig {
}
public void setTransporter(String transporter) {
checkExtension(Transporter.class, Constants.TRANSPORTER_KEY, transporter);
checkExtension(Transporter.class, RemotingConstants.TRANSPORTER_KEY, transporter);
this.transporter = transporter;
}
@ -445,7 +446,7 @@ public class ProtocolConfig extends AbstractConfig {
}
public void setExchanger(String exchanger) {
checkExtension(Exchanger.class, Constants.EXCHANGER_KEY, exchanger);
checkExtension(Exchanger.class, RemotingConstants.EXCHANGER_KEY, exchanger);
this.exchanger = exchanger;
}
@ -475,7 +476,7 @@ public class ProtocolConfig extends AbstractConfig {
}
public void setDispatcher(String dispatcher) {
checkExtension(Dispatcher.class, Constants.DISPACTHER_KEY, dispatcher);
checkExtension(Dispatcher.class, RemotingConstants.DISPACTHER_KEY, dispatcher);
this.dispatcher = dispatcher;
}

View File

@ -17,6 +17,7 @@
package org.apache.dubbo.config;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.status.StatusChecker;
import org.apache.dubbo.common.threadpool.ThreadPool;
import org.apache.dubbo.config.support.Parameter;
@ -367,7 +368,7 @@ public class ProviderConfig extends AbstractServiceConfig {
}
public void setTransporter(String transporter) {
checkExtension(Transporter.class, Constants.TRANSPORTER_KEY, transporter);
checkExtension(Transporter.class, RemotingConstants.TRANSPORTER_KEY, transporter);
this.transporter = transporter;
}
@ -376,7 +377,7 @@ public class ProviderConfig extends AbstractServiceConfig {
}
public void setExchanger(String exchanger) {
checkExtension(Exchanger.class, Constants.EXCHANGER_KEY, exchanger);
checkExtension(Exchanger.class, RemotingConstants.EXCHANGER_KEY, exchanger);
this.exchanger = exchanger;
}
@ -406,7 +407,7 @@ public class ProviderConfig extends AbstractServiceConfig {
}
public void setDispatcher(String dispatcher) {
checkExtension(Dispatcher.class, Constants.DISPATCHER_KEY, dispatcher);
checkExtension(Dispatcher.class, RemotingConstants.DISPATCHER_KEY, dispatcher);
checkExtension(Dispatcher.class, "dispather", dispatcher);
this.dispatcher = dispatcher;
}

View File

@ -20,6 +20,7 @@ import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.bytecode.Wrapper;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.utils.ClassUtils;
import org.apache.dubbo.common.utils.CollectionUtils;
@ -561,7 +562,7 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
}
public void setClient(String client) {
checkName(Constants.CLIENT_KEY, client);
checkName(RemotingConstants.CLIENT_KEY, client);
this.client = client;
}

View File

@ -17,6 +17,7 @@
package org.apache.dubbo.config;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.config.support.Parameter;
@ -269,7 +270,7 @@ public class RegistryConfig extends AbstractConfig {
}
public void setTransporter(String transporter) {
checkName(Constants.TRANSPORTER_KEY, transporter);
checkName(RemotingConstants.TRANSPORTER_KEY, transporter);
/*if(transporter != null && transporter.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(transporter)){
throw new IllegalStateException("No such transporter type : " + transporter);
}*/
@ -281,7 +282,7 @@ public class RegistryConfig extends AbstractConfig {
}
public void setServer(String server) {
checkName(Constants.SERVER_KEY, server);
checkName(RemotingConstants.SERVER_KEY, server);
/*if(server != null && server.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(server)){
throw new IllegalStateException("No such server type : " + server);
}*/
@ -293,7 +294,7 @@ public class RegistryConfig extends AbstractConfig {
}
public void setClient(String client) {
checkName(Constants.CLIENT_KEY, client);
checkName(RemotingConstants.CLIENT_KEY, client);
/*if(client != null && client.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(client)){
throw new IllegalStateException("No such client type : " + client);
}*/

View File

@ -22,6 +22,7 @@ import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.bytecode.Wrapper;
import org.apache.dubbo.common.config.Environment;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.utils.ClassUtils;
import org.apache.dubbo.common.utils.CollectionUtils;
@ -684,7 +685,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
}
}
map.put(Constants.BIND_IP_KEY, hostToBind);
map.put(RemotingConstants.BIND_IP_KEY, hostToBind);
// registry ip is not used for bind ip by default
String hostToRegistry = getValueFromConfig(protocolConfig, Constants.DUBBO_IP_TO_REGISTRY);
@ -736,7 +737,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
}
// save bind port, used as url's key later
map.put(Constants.BIND_PORT_KEY, String.valueOf(portToBind));
map.put(RemotingConstants.BIND_PORT_KEY, String.valueOf(portToBind));
// registry port, not used as bind port by default
String portToRegistryStr = getValueFromConfig(protocolConfig, Constants.DUBBO_PORT_TO_REGISTRY);

View File

@ -17,6 +17,7 @@
package org.apache.dubbo.config.annotation;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.rpc.ExporterListener;
import org.apache.dubbo.rpc.Filter;
@ -101,7 +102,7 @@ public @interface Reference {
* Whether to reconnect if connection is lost, if not specify, reconnect is enabled by default, and the interval
* for retry connecting is 2000 ms
*
* @see Constants#DEFAULT_RECONNECT_PERIOD
* @see RemotingConstants#DEFAULT_RECONNECT_PERIOD
*/
String reconnect() default "";

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.config;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
@ -125,7 +126,7 @@ public class AbstractReferenceConfigTest {
Map<String, String> parameters = new HashMap<String, String>();
AbstractInterfaceConfig.appendParameters(parameters, referenceConfig);
assertThat(referenceConfig.getReconnect(), equalTo("reconnect"));
assertThat(parameters, hasKey(Constants.RECONNECT_KEY));
assertThat(parameters, hasKey(RemotingConstants.RECONNECT_KEY));
}
@Test

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.config;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.config.api.DemoService;
import org.apache.dubbo.config.api.Greeting;
import org.apache.dubbo.config.context.ConfigManager;
@ -132,8 +133,8 @@ public class ServiceConfigTest {
assertThat(url.getPath(), equalTo(DemoService.class.getName()));
assertThat(url.getParameters(), hasEntry(Constants.ANYHOST_KEY, "true"));
assertThat(url.getParameters(), hasEntry(Constants.APPLICATION_KEY, "app"));
assertThat(url.getParameters(), hasKey(Constants.BIND_IP_KEY));
assertThat(url.getParameters(), hasKey(Constants.BIND_PORT_KEY));
assertThat(url.getParameters(), hasKey(RemotingConstants.BIND_IP_KEY));
assertThat(url.getParameters(), hasKey(RemotingConstants.BIND_PORT_KEY));
assertThat(url.getParameters(), hasEntry(Constants.EXPORT_KEY, "true"));
assertThat(url.getParameters(), hasEntry("echo.0.callback", "false"));
assertThat(url.getParameters(), hasEntry(Constants.GENERIC_KEY, "false"));

View File

@ -44,7 +44,7 @@ import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY;
import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE;
import static com.alibaba.nacos.client.naming.utils.UtilAndComs.NACOS_NAMING_LOG_NAME;
import static org.apache.dubbo.common.Constants.BACKUP_KEY;
import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
import static org.apache.dubbo.common.Constants.CONFIG_NAMESPACE_KEY;
import static org.apache.dubbo.common.Constants.GROUP_CHAR_SEPERATOR;
import static org.apache.dubbo.common.Constants.PROPERTIES_CHAR_SEPERATOR;

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.metadata.integration;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
@ -78,7 +79,7 @@ public class MetadataReportService {
public void publishProvider(URL providerUrl) throws RpcException {
//first add into the list
// remove the individul param
providerUrl = providerUrl.removeParameters(Constants.PID_KEY, Constants.TIMESTAMP_KEY, Constants.BIND_IP_KEY, Constants.BIND_PORT_KEY, Constants.TIMESTAMP_KEY);
providerUrl = providerUrl.removeParameters(Constants.PID_KEY, Constants.TIMESTAMP_KEY, RemotingConstants.BIND_IP_KEY, RemotingConstants.BIND_PORT_KEY, Constants.TIMESTAMP_KEY);
try {
String interfaceName = providerUrl.getParameter(Constants.INTERFACE_KEY);
@ -98,7 +99,7 @@ public class MetadataReportService {
}
public void publishConsumer(URL consumerURL) throws RpcException {
consumerURL = consumerURL.removeParameters(Constants.PID_KEY, Constants.TIMESTAMP_KEY, Constants.BIND_IP_KEY, Constants.BIND_PORT_KEY, Constants.TIMESTAMP_KEY);
consumerURL = consumerURL.removeParameters(Constants.PID_KEY, Constants.TIMESTAMP_KEY, RemotingConstants.BIND_IP_KEY, RemotingConstants.BIND_PORT_KEY, Constants.TIMESTAMP_KEY);
metadataReport.storeConsumerMetadata(new MetadataIdentifier(consumerURL.getServiceInterface(),
consumerURL.getParameter(Constants.VERSION_KEY), consumerURL.getParameter(Constants.GROUP_KEY),Constants.CONSUMER_SIDE,
consumerURL.getParameter(Constants.APPLICATION_KEY)), consumerURL.getParameters());

View File

@ -26,7 +26,7 @@ import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Protocol;
import org.apache.dubbo.rpc.ProxyFactory;
import static org.apache.dubbo.common.Constants.CHECK_KEY;
import static org.apache.dubbo.common.constants.RemotingConstants.CHECK_KEY;
import static org.apache.dubbo.common.Constants.DUBBO_PROTOCOL;
import static org.apache.dubbo.common.Constants.PROTOCOL_KEY;
import static org.apache.dubbo.common.Constants.REFERENCE_FILTER_KEY;

View File

@ -28,6 +28,7 @@ import com.alibaba.metrics.common.MetricsCollector;
import com.alibaba.metrics.common.MetricsCollectorFactory;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
@ -165,7 +166,7 @@ public class MetricsFilter implements Filter {
private List<MetricObject> getThreadPoolMessage() {
DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension();
Map<String, Object> executors = dataStore.get(Constants.EXECUTOR_SERVICE_COMPONENT_KEY);
Map<String, Object> executors = dataStore.get(RemotingConstants.EXECUTOR_SERVICE_COMPONENT_KEY);
List<MetricObject> threadPoolMtricList = new ArrayList<>();
for (Map.Entry<String, Object> entry : executors.entrySet()) {

View File

@ -20,6 +20,7 @@ import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
@ -432,7 +433,7 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
providerUrl = overrideWithConfigurator(providerUrl);
providerUrl = providerUrl.addParameter(Constants.CHECK_KEY, String.valueOf(false)); // Do not check whether the connection is successful or not, always create Invoker!
providerUrl = providerUrl.addParameter(RemotingConstants.CHECK_KEY, String.valueOf(false)); // Do not check whether the connection is successful or not, always create Invoker!
// The combination of directoryUrl and override is at the end of notify, which can't be handled here
this.overrideDirectoryUrl = this.overrideDirectoryUrl.addParametersIfAbsent(providerUrl.getParameters()); // Merge the provider side parameters

View File

@ -55,10 +55,10 @@ import java.util.concurrent.ExecutorService;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static org.apache.dubbo.common.Constants.ACCEPT_FOREIGN_IP;
import static org.apache.dubbo.common.Constants.ANY_VALUE;
import static org.apache.dubbo.common.Constants.BIND_IP_KEY;
import static org.apache.dubbo.common.Constants.BIND_PORT_KEY;
import static org.apache.dubbo.common.constants.RemotingConstants.BIND_IP_KEY;
import static org.apache.dubbo.common.constants.RemotingConstants.BIND_PORT_KEY;
import static org.apache.dubbo.common.Constants.CATEGORY_KEY;
import static org.apache.dubbo.common.Constants.CHECK_KEY;
import static org.apache.dubbo.common.constants.RemotingConstants.CHECK_KEY;
import static org.apache.dubbo.common.Constants.COMMA_SPLIT_PATTERN;
import static org.apache.dubbo.common.Constants.CONFIGURATORS_CATEGORY;
import static org.apache.dubbo.common.Constants.CONFIGURATORS_SUFFIX;

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.registry.support;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.timer.HashedWheelTimer;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.NamedThreadFactory;
@ -233,8 +234,8 @@ public abstract class FailbackRegistry extends AbstractRegistry {
Throwable t = e;
// If the startup detection is opened, the Exception is thrown directly.
boolean check = getUrl().getParameter(Constants.CHECK_KEY, true)
&& url.getParameter(Constants.CHECK_KEY, true)
boolean check = getUrl().getParameter(RemotingConstants.CHECK_KEY, true)
&& url.getParameter(RemotingConstants.CHECK_KEY, true)
&& !Constants.CONSUMER_PROTOCOL.equals(url.getProtocol());
boolean skipFailback = t instanceof SkipFailbackWrapperException;
if (check || skipFailback) {
@ -263,8 +264,8 @@ public abstract class FailbackRegistry extends AbstractRegistry {
Throwable t = e;
// If the startup detection is opened, the Exception is thrown directly.
boolean check = getUrl().getParameter(Constants.CHECK_KEY, true)
&& url.getParameter(Constants.CHECK_KEY, true)
boolean check = getUrl().getParameter(RemotingConstants.CHECK_KEY, true)
&& url.getParameter(RemotingConstants.CHECK_KEY, true)
&& !Constants.CONSUMER_PROTOCOL.equals(url.getProtocol());
boolean skipFailback = t instanceof SkipFailbackWrapperException;
if (check || skipFailback) {
@ -297,8 +298,8 @@ public abstract class FailbackRegistry extends AbstractRegistry {
logger.error("Failed to subscribe " + url + ", Using cached list: " + urls + " from cache file: " + getUrl().getParameter(Constants.FILE_KEY, System.getProperty("user.home") + "/dubbo-registry-" + url.getHost() + ".cache") + ", cause: " + t.getMessage(), t);
} else {
// If the startup detection is opened, the Exception is thrown directly.
boolean check = getUrl().getParameter(Constants.CHECK_KEY, true)
&& url.getParameter(Constants.CHECK_KEY, true);
boolean check = getUrl().getParameter(RemotingConstants.CHECK_KEY, true)
&& url.getParameter(RemotingConstants.CHECK_KEY, true);
boolean skipFailback = t instanceof SkipFailbackWrapperException;
if (check || skipFailback) {
if (skipFailback) {
@ -326,8 +327,8 @@ public abstract class FailbackRegistry extends AbstractRegistry {
Throwable t = e;
// If the startup detection is opened, the Exception is thrown directly.
boolean check = getUrl().getParameter(Constants.CHECK_KEY, true)
&& url.getParameter(Constants.CHECK_KEY, true);
boolean check = getUrl().getParameter(RemotingConstants.CHECK_KEY, true)
&& url.getParameter(RemotingConstants.CHECK_KEY, true);
boolean skipFailback = t instanceof SkipFailbackWrapperException;
if (check || skipFailback) {
if (skipFailback) {

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.registry.dubbo;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ExecutorUtil;
@ -100,7 +101,7 @@ public class DubboRegistry extends FailbackRegistry {
clientLock.unlock();
}
} catch (Throwable t) { // Ignore all the exceptions and wait for the next retry
if (getUrl().getParameter(Constants.CHECK_KEY, true)) {
if (getUrl().getParameter(RemotingConstants.CHECK_KEY, true)) {
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}

View File

@ -20,6 +20,7 @@ import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.bytecode.Wrapper;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.registry.Registry;
@ -54,10 +55,10 @@ public class DubboRegistryFactory extends AbstractRegistryFactory {
.addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName())
.addParameter(Constants.CLUSTER_STICKY_KEY, "true")
.addParameter(Constants.LAZY_CONNECT_KEY, "true")
.addParameter(Constants.RECONNECT_KEY, "false")
.addParameter(RemotingConstants.RECONNECT_KEY, "false")
.addParameterIfAbsent(Constants.TIMEOUT_KEY, "10000")
.addParameterIfAbsent(Constants.CALLBACK_INSTANCES_LIMIT_KEY, "10000")
.addParameterIfAbsent(Constants.CONNECT_TIMEOUT_KEY, "10000")
.addParameterIfAbsent(RemotingConstants.CONNECT_TIMEOUT_KEY, "10000")
.addParameter(Constants.METHODS_KEY, StringUtils.join(new HashSet<>(Arrays.asList(Wrapper.getWrapper(RegistryService.class).getDeclaredMethodNames())), ","))
//.addParameter(Constants.STUB_KEY, RegistryServiceStub.class.getName())
//.addParameter(Constants.STUB_EVENT_KEY, Boolean.TRUE.toString()) //for event dispatch
@ -83,8 +84,8 @@ public class DubboRegistryFactory extends AbstractRegistryFactory {
public Registry createRegistry(URL url) {
url = getRegistryURL(url);
List<URL> urls = new ArrayList<>();
urls.add(url.removeParameter(Constants.BACKUP_KEY));
String backup = url.getParameter(Constants.BACKUP_KEY);
urls.add(url.removeParameter(RemotingConstants.BACKUP_KEY));
String backup = url.getParameter(RemotingConstants.BACKUP_KEY);
if (backup != null && backup.length() > 0) {
String[] addresses = Constants.COMMA_SPLIT_PATTERN.split(backup);
for (String address : addresses) {

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.registry.dubbo;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.NetUtils;
@ -55,10 +56,10 @@ public class DubboRegistryTest {
@BeforeEach
public void setUp() {
registryURL = new URL(Constants.REGISTRY_PROTOCOL, NetUtils.getLocalHost(), NetUtils.getAvailablePort())
.addParameter(Constants.CHECK_KEY, false)
.addParameter(RemotingConstants.CHECK_KEY, false)
.setServiceInterface(RegistryService.class.getName());
serviceURL = new URL(DubboProtocol.NAME, NetUtils.getLocalHost(), NetUtils.getAvailablePort())
.addParameter(Constants.CHECK_KEY, false)
.addParameter(RemotingConstants.CHECK_KEY, false)
.setServiceInterface(RegistryService.class.getName());
registryService = new MockDubboRegistry(registryURL);

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.registry.dubbo;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.utils.LogUtil;
import org.apache.dubbo.common.utils.NetUtils;
@ -371,7 +372,7 @@ public class RegistryDirectoryTest {
Invoker invoker = (Invoker) invokers.get(0);
URL url = invoker.getUrl();
Assertions.assertEquals(false, url.getParameter(Constants.CHECK_KEY, false));
Assertions.assertEquals(false, url.getParameter(RemotingConstants.CHECK_KEY, false));
}
{
serviceUrls.clear();

View File

@ -34,6 +34,7 @@
package org.apache.dubbo.registry.etcd;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ConcurrentHashSet;
@ -179,7 +180,7 @@ public class EtcdRegistry extends FailbackRegistry {
* eg: /dubbo/interface, /dubbo/interface and so on.
*/
subscribe(url.setPath(child).addParameters(Constants.INTERFACE_KEY, child,
Constants.CHECK_KEY, String.valueOf(false)), listener);
RemotingConstants.CHECK_KEY, String.valueOf(false)), listener);
}
}
});
@ -196,7 +197,7 @@ public class EtcdRegistry extends FailbackRegistry {
service = URL.decode(service);
anyServices.add(service);
subscribe(url.setPath(service).addParameters(Constants.INTERFACE_KEY, service,
Constants.CHECK_KEY, String.valueOf(false)), listener);
RemotingConstants.CHECK_KEY, String.valueOf(false)), listener);
}
} else {
List<URL> urls = new ArrayList<>();

View File

@ -52,6 +52,7 @@ package org.apache.dubbo.registry.etcd;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.registry.NotifyListener;
@ -95,7 +96,7 @@ public class EtcdRegistryTest {
+ Constants.ROUTERS_CATEGORY + ","
+ Constants.CONFIGURATORS_CATEGORY,
Constants.ENABLED_KEY, Constants.ANY_VALUE,
Constants.CHECK_KEY, String.valueOf(false));
RemotingConstants.CHECK_KEY, String.valueOf(false));
@Test
public void test_register() {

View File

@ -37,7 +37,7 @@ import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE;
import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY;
import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
import static com.alibaba.nacos.client.naming.utils.UtilAndComs.NACOS_NAMING_LOG_NAME;
import static org.apache.dubbo.common.Constants.BACKUP_KEY;
import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
/**
* Nacos {@link RegistryFactory}

View File

@ -20,6 +20,7 @@ import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ArrayUtils;
@ -125,7 +126,7 @@ public class RedisRegistry extends FailbackRegistry {
List<String> addresses = new ArrayList<>();
addresses.add(url.getAddress());
String[] backups = url.getParameter(Constants.BACKUP_KEY, new String[0]);
String[] backups = url.getParameter(RemotingConstants.BACKUP_KEY, new String[0]);
if (ArrayUtils.isNotEmpty(backups)) {
addresses.addAll(Arrays.asList(backups));
}

View File

@ -31,7 +31,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.apache.dubbo.common.Constants.BACKUP_KEY;
import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.registry.zookeeper;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
@ -131,7 +132,7 @@ public class ZookeeperRegistry extends FailbackRegistry {
if (!anyServices.contains(child)) {
anyServices.add(child);
subscribe(url.setPath(child).addParameters(Constants.INTERFACE_KEY, child,
Constants.CHECK_KEY, String.valueOf(false)), listener);
RemotingConstants.CHECK_KEY, String.valueOf(false)), listener);
}
}
});
@ -144,7 +145,7 @@ public class ZookeeperRegistry extends FailbackRegistry {
service = URL.decode(service);
anyServices.add(service);
subscribe(url.setPath(service).addParameters(Constants.INTERFACE_KEY, service,
Constants.CHECK_KEY, String.valueOf(false)), listener);
RemotingConstants.CHECK_KEY, String.valueOf(false)), listener);
}
}
} else {

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.remoting;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
@ -45,7 +45,7 @@ public interface Codec {
* @param output output stream.
* @param message message.
*/
@Adaptive({Constants.CODEC_KEY})
@Adaptive({RemotingConstants.CODEC_KEY})
void encode(Channel channel, OutputStream output, Object message) throws IOException;
/**
@ -56,7 +56,7 @@ public interface Codec {
* @return message or <code>NEED_MORE_INPUT</code> poison.
* @see #NEED_MORE_INPUT
*/
@Adaptive({Constants.CODEC_KEY})
@Adaptive({RemotingConstants.CODEC_KEY})
Object decode(Channel channel, InputStream input) throws IOException;
}

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.remoting;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
import org.apache.dubbo.remoting.buffer.ChannelBuffer;
@ -26,10 +26,10 @@ import java.io.IOException;
@SPI
public interface Codec2 {
@Adaptive({Constants.CODEC_KEY})
@Adaptive({RemotingConstants.CODEC_KEY})
void encode(Channel channel, ChannelBuffer buffer, Object message) throws IOException;
@Adaptive({Constants.CODEC_KEY})
@Adaptive({RemotingConstants.CODEC_KEY})
Object decode(Channel channel, ChannelBuffer buffer) throws IOException;

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
import org.apache.dubbo.remoting.transport.dispatcher.all.AllDispatcher;
@ -35,7 +35,7 @@ public interface Dispatcher {
* @param url
* @return channel handler
*/
@Adaptive({Constants.DISPATCHER_KEY, "dispather", "channel.handler"})
@Adaptive({RemotingConstants.DISPATCHER_KEY, "dispather", "channel.handler"})
// The last two parameters are reserved for compatibility with the old configuration
ChannelHandler dispatch(ChannelHandler handler, URL url);

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
@ -41,7 +41,7 @@ public interface Transporter {
* @throws RemotingException
* @see org.apache.dubbo.remoting.Transporters#bind(URL, ChannelHandler...)
*/
@Adaptive({Constants.SERVER_KEY, Constants.TRANSPORTER_KEY})
@Adaptive({RemotingConstants.SERVER_KEY, RemotingConstants.TRANSPORTER_KEY})
Server bind(URL url, ChannelHandler handler) throws RemotingException;
/**
@ -53,7 +53,7 @@ public interface Transporter {
* @throws RemotingException
* @see org.apache.dubbo.remoting.Transporters#connect(URL, ChannelHandler...)
*/
@Adaptive({Constants.CLIENT_KEY, Constants.TRANSPORTER_KEY})
@Adaptive({RemotingConstants.CLIENT_KEY, RemotingConstants.TRANSPORTER_KEY})
Client connect(URL url, ChannelHandler handler) throws RemotingException;
}

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.exchange;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
import org.apache.dubbo.remoting.RemotingException;
@ -39,7 +39,7 @@ public interface Exchanger {
* @param handler
* @return message server
*/
@Adaptive({Constants.EXCHANGER_KEY})
@Adaptive({RemotingConstants.EXCHANGER_KEY})
ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException;
/**
@ -49,7 +49,7 @@ public interface Exchanger {
* @param handler
* @return message channel
*/
@Adaptive({Constants.EXCHANGER_KEY})
@Adaptive({RemotingConstants.EXCHANGER_KEY})
ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException;
}

View File

@ -16,9 +16,9 @@
*/
package org.apache.dubbo.remoting.exchange;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.RemotingException;
@ -66,7 +66,7 @@ public class Exchangers {
if (handler == null) {
throw new IllegalArgumentException("handler == null");
}
url = url.addParameterIfAbsent(Constants.CODEC_KEY, "exchange");
url = url.addParameterIfAbsent(RemotingConstants.CODEC_KEY, "exchange");
return getExchanger(url).bind(url, handler);
}
@ -105,12 +105,12 @@ public class Exchangers {
if (handler == null) {
throw new IllegalArgumentException("handler == null");
}
url = url.addParameterIfAbsent(Constants.CODEC_KEY, "exchange");
url = url.addParameterIfAbsent(RemotingConstants.CODEC_KEY, "exchange");
return getExchanger(url).connect(url, handler);
}
public static Exchanger getExchanger(URL url) {
String type = url.getParameter(Constants.EXCHANGER_KEY, Constants.DEFAULT_EXCHANGER);
String type = url.getParameter(RemotingConstants.EXCHANGER_KEY, RemotingConstants.DEFAULT_EXCHANGER);
return getExchanger(type);
}

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.exchange.support.header;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.timer.HashedWheelTimer;
import org.apache.dubbo.common.utils.Assert;
import org.apache.dubbo.common.utils.NamedThreadFactory;
@ -45,7 +45,7 @@ public class HeaderExchangeClient implements ExchangeClient {
private final ExchangeChannel channel;
private static final HashedWheelTimer IDLE_CHECK_TIMER = new HashedWheelTimer(
new NamedThreadFactory("dubbo-client-idleCheck", true), 1, TimeUnit.SECONDS, Constants.TICKS_PER_WHEEL);
new NamedThreadFactory("dubbo-client-idleCheck", true), 1, TimeUnit.SECONDS, RemotingConstants.TICKS_PER_WHEEL);
private HeartbeatTimerTask heartBeatTimerTask;
private ReconnectTimerTask reconnectTimerTask;
@ -206,15 +206,15 @@ public class HeaderExchangeClient implements ExchangeClient {
* Each interval cannot be less than 1000ms.
*/
private long calculateLeastDuration(int time) {
if (time / Constants.HEARTBEAT_CHECK_TICK <= 0) {
return Constants.LEAST_HEARTBEAT_DURATION;
if (time / RemotingConstants.HEARTBEAT_CHECK_TICK <= 0) {
return RemotingConstants.LEAST_HEARTBEAT_DURATION;
} else {
return time / Constants.HEARTBEAT_CHECK_TICK;
return time / RemotingConstants.HEARTBEAT_CHECK_TICK;
}
}
private boolean shouldReconnect(URL url) {
return url.getParameter(Constants.RECONNECT_KEY, true);
return url.getParameter(RemotingConstants.RECONNECT_KEY, true);
}
@Override

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.exchange.support.header;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.NetUtils;
@ -73,7 +73,7 @@ public class HeaderExchangeHandler implements ChannelHandlerDelegate {
void handlerEvent(Channel channel, Request req) throws RemotingException {
if (req.getData() != null && req.getData().equals(Request.READONLY_EVENT)) {
channel.setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
channel.setAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
}
}

View File

@ -16,9 +16,9 @@
*/
package org.apache.dubbo.remoting.exchange.support.header;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.timer.HashedWheelTimer;
@ -53,7 +53,7 @@ public class HeaderExchangeServer implements ExchangeServer {
private AtomicBoolean closed = new AtomicBoolean(false);
private static final HashedWheelTimer IDLE_CHECK_TIMER = new HashedWheelTimer(new NamedThreadFactory("dubbo-server-idleCheck", true), 1,
TimeUnit.SECONDS, Constants.TICKS_PER_WHEEL);
TimeUnit.SECONDS, RemotingConstants.TICKS_PER_WHEEL);
private CloseTimerTask closeTimerTask;
@ -100,7 +100,7 @@ public class HeaderExchangeServer implements ExchangeServer {
if (timeout > 0) {
final long max = (long) timeout;
final long start = System.currentTimeMillis();
if (getUrl().getParameter(Constants.CHANNEL_SEND_READONLYEVENT_KEY, true)) {
if (getUrl().getParameter(RemotingConstants.CHANNEL_SEND_READONLYEVENT_KEY, true)) {
sendChannelReadOnlyEvent();
}
while (HeaderExchangeServer.this.isRunning()
@ -131,7 +131,7 @@ public class HeaderExchangeServer implements ExchangeServer {
for (Channel channel : channels) {
try {
if (channel.isConnected()) {
channel.send(request, getUrl().getParameter(Constants.CHANNEL_READONLYEVENT_SENT_KEY, true));
channel.send(request, getUrl().getParameter(RemotingConstants.CHANNEL_READONLYEVENT_SENT_KEY, true));
}
} catch (RemotingException e) {
logger.warn("send cannot write message error.", e);
@ -246,10 +246,10 @@ public class HeaderExchangeServer implements ExchangeServer {
* Each interval cannot be less than 1000ms.
*/
private long calculateLeastDuration(int time) {
if (time / Constants.HEARTBEAT_CHECK_TICK <= 0) {
return Constants.LEAST_HEARTBEAT_DURATION;
if (time / RemotingConstants.HEARTBEAT_CHECK_TICK <= 0) {
return RemotingConstants.LEAST_HEARTBEAT_DURATION;
} else {
return time / Constants.HEARTBEAT_CHECK_TICK;
return time / RemotingConstants.HEARTBEAT_CHECK_TICK;
}
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.remoting.exchange.support.header;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.Channel;
@ -69,7 +69,7 @@ public class HeartbeatHandler extends AbstractChannelHandlerDelegate {
res.setEvent(Response.HEARTBEAT_EVENT);
channel.send(res);
if (logger.isInfoEnabled()) {
int heartbeat = channel.getUrl().getParameter(Constants.HEARTBEAT_KEY, 0);
int heartbeat = channel.getUrl().getParameter(RemotingConstants.HEARTBEAT_KEY, 0);
if (logger.isDebugEnabled()) {
logger.debug("Received heartbeat from remote channel " + channel.getRemoteAddress()
+ ", cause: The channel has no data-transmission exceeds a heartbeat period"

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.telnet.codec;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
@ -60,7 +60,7 @@ public class TelnetCodec extends TransportCodec {
private static Charset getCharset(Channel channel) {
if (channel != null) {
Object attribute = channel.getAttribute(Constants.CHARSET_KEY);
Object attribute = channel.getAttribute(RemotingConstants.CHARSET_KEY);
if (attribute instanceof String) {
try {
return Charset.forName((String) attribute);
@ -72,7 +72,7 @@ public class TelnetCodec extends TransportCodec {
}
URL url = channel.getUrl();
if (url != null) {
String parameter = url.getParameter(Constants.CHARSET_KEY);
String parameter = url.getParameter(RemotingConstants.CHARSET_KEY);
if (StringUtils.isNotEmpty(parameter)) {
try {
return Charset.forName(parameter);
@ -83,7 +83,7 @@ public class TelnetCodec extends TransportCodec {
}
}
try {
return Charset.forName(Constants.DEFAULT_CHARSET);
return Charset.forName(RemotingConstants.DEFAULT_CHARSET);
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
}

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.telnet.support;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.remoting.Channel;
@ -31,7 +32,7 @@ public class TelnetHandlerAdapter extends ChannelHandlerAdapter implements Telne
@Override
public String telnet(Channel channel, String message) throws RemotingException {
String prompt = channel.getUrl().getParameterAndDecoded(Constants.PROMPT_KEY, Constants.DEFAULT_PROMPT);
String prompt = channel.getUrl().getParameterAndDecoded(RemotingConstants.PROMPT_KEY, RemotingConstants.DEFAULT_PROMPT);
boolean noprompt = message.contains("--no-prompt");
message = message.replace("--no-prompt", "");
StringBuilder buf = new StringBuilder();

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.remoting.transport;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
@ -50,7 +51,7 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client
public AbstractClient(URL url, ChannelHandler handler) throws RemotingException {
super(url, handler);
needReconnect = url.getParameter(Constants.SEND_RECONNECT_KEY, false);
needReconnect = url.getParameter(RemotingConstants.SEND_RECONNECT_KEY, false);
try {
doOpen();
@ -67,7 +68,7 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client
logger.info("Start " + getClass().getSimpleName() + " " + NetUtils.getLocalAddress() + " connect to the server " + getRemoteAddress());
}
} catch (RemotingException t) {
if (url.getParameter(Constants.CHECK_KEY, true)) {
if (url.getParameter(RemotingConstants.CHECK_KEY, true)) {
close();
throw t;
} else {

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.transport;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.serialize.Serialization;
@ -36,9 +37,9 @@ public abstract class AbstractCodec implements Codec2 {
private static final Logger logger = LoggerFactory.getLogger(AbstractCodec.class);
protected static void checkPayload(Channel channel, long size) throws IOException {
int payload = Constants.DEFAULT_PAYLOAD;
int payload = RemotingConstants.DEFAULT_PAYLOAD;
if (channel != null && channel.getUrl() != null) {
payload = channel.getUrl().getParameter(Constants.PAYLOAD_KEY, Constants.DEFAULT_PAYLOAD);
payload = channel.getUrl().getParameter(RemotingConstants.PAYLOAD_KEY, RemotingConstants.DEFAULT_PAYLOAD);
}
if (payload > 0 && size > payload) {
ExceedPayloadLimitException e = new ExceedPayloadLimitException("Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel);

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.remoting.transport;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.Resetable;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
@ -44,11 +45,11 @@ public abstract class AbstractEndpoint extends AbstractPeer implements Resetable
super(url, handler);
this.codec = getChannelCodec(url);
this.timeout = url.getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
this.connectTimeout = url.getPositiveParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT);
this.connectTimeout = url.getPositiveParameter(RemotingConstants.CONNECT_TIMEOUT_KEY, RemotingConstants.DEFAULT_CONNECT_TIMEOUT);
}
protected static Codec2 getChannelCodec(URL url) {
String codecName = url.getParameter(Constants.CODEC_KEY, "telnet");
String codecName = url.getParameter(RemotingConstants.CODEC_KEY, "telnet");
if (ExtensionLoader.getExtensionLoader(Codec2.class).hasExtension(codecName)) {
return ExtensionLoader.getExtensionLoader(Codec2.class).getExtension(codecName);
} else {
@ -74,8 +75,8 @@ public abstract class AbstractEndpoint extends AbstractPeer implements Resetable
logger.error(t.getMessage(), t);
}
try {
if (url.hasParameter(Constants.CONNECT_TIMEOUT_KEY)) {
int t = url.getParameter(Constants.CONNECT_TIMEOUT_KEY, 0);
if (url.hasParameter(RemotingConstants.CONNECT_TIMEOUT_KEY)) {
int t = url.getParameter(RemotingConstants.CONNECT_TIMEOUT_KEY, 0);
if (t > 0) {
this.connectTimeout = t;
}
@ -84,7 +85,7 @@ public abstract class AbstractEndpoint extends AbstractPeer implements Resetable
logger.error(t.getMessage(), t);
}
try {
if (url.hasParameter(Constants.CODEC_KEY)) {
if (url.hasParameter(RemotingConstants.CODEC_KEY)) {
this.codec = getChannelCodec(url);
}
} catch (Throwable t) {

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.transport;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.Endpoint;
@ -50,7 +50,7 @@ public abstract class AbstractPeer implements Endpoint, ChannelHandler {
@Override
public void send(Object message) throws RemotingException {
send(message, url.getParameter(Constants.SENT_KEY, false));
send(message, url.getParameter(RemotingConstants.SENT_KEY, false));
}
@Override

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.transport;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
@ -51,14 +52,14 @@ public abstract class AbstractServer extends AbstractEndpoint implements Server
super(url, handler);
localAddress = getUrl().toInetSocketAddress();
String bindIp = getUrl().getParameter(Constants.BIND_IP_KEY, getUrl().getHost());
int bindPort = getUrl().getParameter(Constants.BIND_PORT_KEY, getUrl().getPort());
String bindIp = getUrl().getParameter(RemotingConstants.BIND_IP_KEY, getUrl().getHost());
int bindPort = getUrl().getParameter(RemotingConstants.BIND_PORT_KEY, getUrl().getPort());
if (url.getParameter(Constants.ANYHOST_KEY, false) || NetUtils.isInvalidLocalHost(bindIp)) {
bindIp = Constants.ANYHOST_VALUE;
}
bindAddress = new InetSocketAddress(bindIp, bindPort);
this.accepts = url.getParameter(Constants.ACCEPTS_KEY, Constants.DEFAULT_ACCEPTS);
this.idleTimeout = url.getParameter(Constants.IDLE_TIMEOUT_KEY, Constants.DEFAULT_IDLE_TIMEOUT);
this.accepts = url.getParameter(RemotingConstants.ACCEPTS_KEY, RemotingConstants.DEFAULT_ACCEPTS);
this.idleTimeout = url.getParameter(RemotingConstants.IDLE_TIMEOUT_KEY, RemotingConstants.DEFAULT_IDLE_TIMEOUT);
try {
doOpen();
if (logger.isInfoEnabled()) {
@ -70,7 +71,7 @@ public abstract class AbstractServer extends AbstractEndpoint implements Server
}
//fixme replace this with better method
DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension();
executor = (ExecutorService) dataStore.get(Constants.EXECUTOR_SERVICE_COMPONENT_KEY, Integer.toString(url.getPort()));
executor = (ExecutorService) dataStore.get(RemotingConstants.EXECUTOR_SERVICE_COMPONENT_KEY, Integer.toString(url.getPort()));
}
protected abstract void doOpen() throws Throwable;
@ -83,8 +84,8 @@ public abstract class AbstractServer extends AbstractEndpoint implements Server
return;
}
try {
if (url.hasParameter(Constants.ACCEPTS_KEY)) {
int a = url.getParameter(Constants.ACCEPTS_KEY, 0);
if (url.hasParameter(RemotingConstants.ACCEPTS_KEY)) {
int a = url.getParameter(RemotingConstants.ACCEPTS_KEY, 0);
if (a > 0) {
this.accepts = a;
}
@ -93,8 +94,8 @@ public abstract class AbstractServer extends AbstractEndpoint implements Server
logger.error(t.getMessage(), t);
}
try {
if (url.hasParameter(Constants.IDLE_TIMEOUT_KEY)) {
int t = url.getParameter(Constants.IDLE_TIMEOUT_KEY, 0);
if (url.hasParameter(RemotingConstants.IDLE_TIMEOUT_KEY)) {
int t = url.getParameter(RemotingConstants.IDLE_TIMEOUT_KEY, 0);
if (t > 0) {
this.idleTimeout = t;
}

View File

@ -17,8 +17,8 @@
package org.apache.dubbo.remoting.transport;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
@ -67,12 +67,12 @@ public class CodecSupport {
public static Serialization getSerialization(URL url) {
return ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(
url.getParameter(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION));
url.getParameter(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION));
}
public static Serialization getSerialization(URL url, Byte id) throws IOException {
Serialization serialization = getSerializationById(id);
String serializationName = url.getParameter(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION);
String serializationName = url.getParameter(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION);
// Check if "serialization id" passed from network matches the id on this side(only take effect for JDK serialization), for security purpose.
if (serialization == null
|| ((id == JAVA_SERIALIZATION_ID || id == NATIVE_JAVA_SERIALIZATION_ID || id == COMPACTED_JAVA_SERIALIZATION_ID)

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.transport.dispatcher;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
@ -49,7 +50,7 @@ public class WrappedChannelHandler implements ChannelHandlerDelegate {
this.url = url;
executor = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url);
String componentKey = Constants.EXECUTOR_SERVICE_COMPONENT_KEY;
String componentKey = RemotingConstants.EXECUTOR_SERVICE_COMPONENT_KEY;
if (Constants.CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(Constants.SIDE_KEY))) {
componentKey = Constants.CONSUMER_SIDE;
}

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.transport.dispatcher.connection;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.threadpool.support.AbortPolicyWithReport;
import org.apache.dubbo.common.utils.NamedThreadFactory;
import org.apache.dubbo.remoting.Channel;
@ -46,11 +47,11 @@ public class ConnectionOrderedChannelHandler extends WrappedChannelHandler {
String threadName = url.getParameter(Constants.THREAD_NAME_KEY, Constants.DEFAULT_THREAD_NAME);
connectionExecutor = new ThreadPoolExecutor(1, 1,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(url.getPositiveParameter(Constants.CONNECT_QUEUE_CAPACITY, Integer.MAX_VALUE)),
new LinkedBlockingQueue<Runnable>(url.getPositiveParameter(RemotingConstants.CONNECT_QUEUE_CAPACITY, Integer.MAX_VALUE)),
new NamedThreadFactory(threadName, true),
new AbortPolicyWithReport(threadName, url)
); // FIXME There's no place to release connectionExecutor!
queuewarninglimit = url.getParameter(Constants.CONNECT_QUEUE_WARNING_SIZE, Constants.DEFAULT_CONNECT_QUEUE_WARNING_SIZE);
queuewarninglimit = url.getParameter(RemotingConstants.CONNECT_QUEUE_WARNING_SIZE, RemotingConstants.DEFAULT_CONNECT_QUEUE_WARNING_SIZE);
}
@Override

View File

@ -17,6 +17,7 @@
package org.apache.dubbo.remoting;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.exchange.ExchangeClient;
@ -79,8 +80,8 @@ public class ChanelHandlerTest {
return;
}
final String server = System.getProperty("server", "127.0.0.1:9911");
final String transporter = PerformanceUtils.getProperty(Constants.TRANSPORTER_KEY, Constants.DEFAULT_TRANSPORTER);
final String serialization = PerformanceUtils.getProperty(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION);
final String transporter = PerformanceUtils.getProperty(RemotingConstants.TRANSPORTER_KEY, RemotingConstants.DEFAULT_TRANSPORTER);
final String serialization = PerformanceUtils.getProperty(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION);
final int timeout = PerformanceUtils.getIntProperty(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
int sleep = PerformanceUtils.getIntProperty("sleep", 60 * 1000 * 60);

View File

@ -17,6 +17,7 @@
package org.apache.dubbo.remoting;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.exchange.ExchangeClient;
@ -43,8 +44,8 @@ public class PerformanceClientCloseTest {
return;
}
final String server = System.getProperty("server", "127.0.0.1:9911");
final String transporter = PerformanceUtils.getProperty(Constants.TRANSPORTER_KEY, Constants.DEFAULT_TRANSPORTER);
final String serialization = PerformanceUtils.getProperty(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION);
final String transporter = PerformanceUtils.getProperty(RemotingConstants.TRANSPORTER_KEY, RemotingConstants.DEFAULT_TRANSPORTER);
final String serialization = PerformanceUtils.getProperty(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION);
final int timeout = PerformanceUtils.getIntProperty(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
final int concurrent = PerformanceUtils.getIntProperty("concurrent", 1);
final int runs = PerformanceUtils.getIntProperty("runs", Integer.MAX_VALUE);

View File

@ -17,6 +17,7 @@
package org.apache.dubbo.remoting;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.exchange.ExchangeClient;
@ -40,8 +41,8 @@ public class PerformanceClientFixedTest {
return;
}
final String server = System.getProperty("server", "127.0.0.1:9911");
final String transporter = PerformanceUtils.getProperty(Constants.TRANSPORTER_KEY, Constants.DEFAULT_TRANSPORTER);
final String serialization = PerformanceUtils.getProperty(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION);
final String transporter = PerformanceUtils.getProperty(RemotingConstants.TRANSPORTER_KEY, RemotingConstants.DEFAULT_TRANSPORTER);
final String serialization = PerformanceUtils.getProperty(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION);
final int timeout = PerformanceUtils.getIntProperty(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
//final int length = PerformanceUtils.getIntProperty("length", 1024);
final int connectionCount = PerformanceUtils.getIntProperty(Constants.CONNECTIONS_KEY, 1);

View File

@ -17,13 +17,13 @@
package org.apache.dubbo.remoting;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.exchange.ExchangeClient;
import org.apache.dubbo.remoting.exchange.Exchangers;
import org.apache.dubbo.remoting.exchange.support.ExchangeHandlerAdapter;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.text.DecimalFormat;
@ -52,8 +52,8 @@ public class PerformanceClientTest {
return;
}
final String server = System.getProperty("server", "127.0.0.1:9911");
final String transporter = PerformanceUtils.getProperty(Constants.TRANSPORTER_KEY, Constants.DEFAULT_TRANSPORTER);
final String serialization = PerformanceUtils.getProperty(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION);
final String transporter = PerformanceUtils.getProperty(RemotingConstants.TRANSPORTER_KEY, RemotingConstants.DEFAULT_TRANSPORTER);
final String serialization = PerformanceUtils.getProperty(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION);
final int timeout = PerformanceUtils.getIntProperty(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
final int length = PerformanceUtils.getIntProperty("length", 1024);
final int connections = PerformanceUtils.getIntProperty(Constants.CONNECTIONS_KEY, 1);

View File

@ -17,6 +17,7 @@
package org.apache.dubbo.remoting;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.exchange.ExchangeChannel;
@ -61,13 +62,13 @@ public class PerformanceServerTest {
private static ExchangeServer statServer() throws Exception {
final int port = PerformanceUtils.getIntProperty("port", 9911);
final String transporter = PerformanceUtils.getProperty(Constants.TRANSPORTER_KEY, Constants.DEFAULT_TRANSPORTER);
final String serialization = PerformanceUtils.getProperty(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION);
final String transporter = PerformanceUtils.getProperty(RemotingConstants.TRANSPORTER_KEY, RemotingConstants.DEFAULT_TRANSPORTER);
final String serialization = PerformanceUtils.getProperty(RemotingConstants.SERIALIZATION_KEY, RemotingConstants.DEFAULT_REMOTING_SERIALIZATION);
final String threadpool = PerformanceUtils.getProperty(Constants.THREADPOOL_KEY, Constants.DEFAULT_THREADPOOL);
final int threads = PerformanceUtils.getIntProperty(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
final int iothreads = PerformanceUtils.getIntProperty(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS);
final int buffer = PerformanceUtils.getIntProperty(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
final String channelHandler = PerformanceUtils.getProperty(Constants.DISPATCHER_KEY, ExecutionDispatcher.NAME);
final int iothreads = PerformanceUtils.getIntProperty(Constants.IO_THREADS_KEY, RemotingConstants.DEFAULT_IO_THREADS);
final int buffer = PerformanceUtils.getIntProperty(RemotingConstants.BUFFER_KEY, RemotingConstants.DEFAULT_BUFFER_SIZE);
final String channelHandler = PerformanceUtils.getProperty(RemotingConstants.DISPATCHER_KEY, ExecutionDispatcher.NAME);
// Start server

View File

@ -17,8 +17,8 @@
package org.apache.dubbo.remoting.codec;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.io.Bytes;
import org.apache.dubbo.common.io.UnsafeByteArrayOutputStream;
@ -32,7 +32,6 @@ import org.apache.dubbo.remoting.exchange.Response;
import org.apache.dubbo.remoting.exchange.codec.ExchangeCodec;
import org.apache.dubbo.remoting.telnet.codec.TelnetCodec;
import org.apache.dubbo.remoting.transport.CodecSupport;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -65,7 +64,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
private static final short MAGIC = (short) 0xdabb;
private static final byte MAGIC_HIGH = (byte) Bytes.short2bytes(MAGIC)[0];
private static final byte MAGIC_LOW = (byte) Bytes.short2bytes(MAGIC)[1];
Serialization serialization = getSerialization(Constants.DEFAULT_REMOTING_SERIALIZATION);
Serialization serialization = getSerialization(RemotingConstants.DEFAULT_REMOTING_SERIALIZATION);
private static Serialization getSerialization(String name) {
Serialization serialization = ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(name);
@ -443,7 +442,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
Request request = new Request(1L);
request.setData("hello");
ChannelBuffer encodeBuffer = ChannelBuffers.dynamicBuffer(512);
AbstractMockChannel channel = getCliendSideChannel(url.addParameter(Constants.PAYLOAD_KEY, 4));
AbstractMockChannel channel = getCliendSideChannel(url.addParameter(RemotingConstants.PAYLOAD_KEY, 4));
try {
codec.encode(channel, encodeBuffer, request);
Assertions.fail();
@ -454,7 +453,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
Response response = new Response(1L);
response.setResult("hello");
encodeBuffer = ChannelBuffers.dynamicBuffer(512);
channel = getServerSideChannel(url.addParameter(Constants.PAYLOAD_KEY, 4));
channel = getServerSideChannel(url.addParameter(RemotingConstants.PAYLOAD_KEY, 4));
codec.encode(channel, encodeBuffer, response);
Assertions.assertTrue(channel.getReceivedMessage() instanceof Response);
Response receiveMessage = (Response) channel.getReceivedMessage();

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.remoting.exchange.support.header;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.timer.HashedWheelTimer;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.exchange.Request;
@ -42,7 +43,7 @@ public class HeartBeatTaskTest {
@BeforeEach
public void setup() throws Exception {
long tickDuration = 1000;
heartbeatTimer = new HashedWheelTimer(tickDuration / Constants.HEARTBEAT_CHECK_TICK, TimeUnit.MILLISECONDS);
heartbeatTimer = new HashedWheelTimer(tickDuration / RemotingConstants.HEARTBEAT_CHECK_TICK, TimeUnit.MILLISECONDS);
channel = new MockChannel() {
@ -53,7 +54,7 @@ public class HeartBeatTaskTest {
};
AbstractTimerTask.ChannelProvider cp = () -> Collections.<Channel>singletonList(channel);
heartbeatTimerTask = new HeartbeatTimerTask(cp, tickDuration / Constants.HEARTBEAT_CHECK_TICK, (int) tickDuration);
heartbeatTimerTask = new HeartbeatTimerTask(cp, tickDuration / RemotingConstants.HEARTBEAT_CHECK_TICK, (int) tickDuration);
}
@Test

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.remoting.handler;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.RemotingException;
import org.apache.dubbo.remoting.exchange.ExchangeChannel;
@ -160,7 +160,7 @@ public class HeaderExchangeHandlerTest {
final Channel mchannel = new MockedChannel();
HeaderExchangeHandler hexhandler = new HeaderExchangeHandler(new MockedExchangeHandler());
hexhandler.received(mchannel, request);
Assertions.assertTrue(mchannel.hasAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY));
Assertions.assertTrue(mchannel.hasAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY));
}
@Test

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.transport.codec;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.serialize.ObjectOutput;
@ -55,9 +56,9 @@ public class DeprecatedTelnetCodec implements Codec {
private static final List<?> EXIT = Arrays.asList(new Object[]{new byte[]{3} /* Windows Ctrl+C */, new byte[]{-1, -12, -1, -3, 6} /* Linux Ctrl+C */, new byte[]{-1, -19, -1, -3, 6} /* Linux Pause */});
static void checkPayload(Channel channel, long size) throws IOException {
int payload = Constants.DEFAULT_PAYLOAD;
int payload = RemotingConstants.DEFAULT_PAYLOAD;
if (channel != null && channel.getUrl() != null) {
payload = channel.getUrl().getPositiveParameter(Constants.PAYLOAD_KEY, Constants.DEFAULT_PAYLOAD);
payload = channel.getUrl().getPositiveParameter(RemotingConstants.PAYLOAD_KEY, RemotingConstants.DEFAULT_PAYLOAD);
}
if (size > payload) {
IOException e = new IOException("Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel);
@ -68,7 +69,7 @@ public class DeprecatedTelnetCodec implements Codec {
private static Charset getCharset(Channel channel) {
if (channel != null) {
Object attribute = channel.getAttribute(Constants.CHARSET_KEY);
Object attribute = channel.getAttribute(RemotingConstants.CHARSET_KEY);
if (attribute instanceof String) {
try {
return Charset.forName((String) attribute);
@ -80,7 +81,7 @@ public class DeprecatedTelnetCodec implements Codec {
}
URL url = channel.getUrl();
if (url != null) {
String parameter = url.getParameter(Constants.CHARSET_KEY);
String parameter = url.getParameter(RemotingConstants.CHARSET_KEY);
if (StringUtils.isNotEmpty(parameter)) {
try {
return Charset.forName(parameter);

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.remoting.etcd;
import static org.apache.dubbo.common.Constants.DEFAULT_IO_THREADS;
import static org.apache.dubbo.common.constants.RemotingConstants.DEFAULT_IO_THREADS;
public interface Constants {
String ETCD3_NOTIFY_MAXTHREADS_KEYS = "etcd3.notify.maxthreads";

View File

@ -33,15 +33,15 @@
*/
package org.apache.dubbo.remoting.etcd;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
@SPI("jetcd")
public interface EtcdTransporter {
@Adaptive({Constants.CLIENT_KEY, Constants.TRANSPORTER_KEY})
@Adaptive({RemotingConstants.CLIENT_KEY, RemotingConstants.TRANSPORTER_KEY})
EtcdClient connect(URL url);
}

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.transport.grizzly;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.Codec2;
@ -52,8 +52,8 @@ public class GrizzlyCodecAdapter extends BaseFilter {
this.codec = codec;
this.url = url;
this.handler = handler;
int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
int b = url.getPositiveParameter(RemotingConstants.BUFFER_KEY, RemotingConstants.DEFAULT_BUFFER_SIZE);
this.bufferSize = b >= RemotingConstants.MIN_BUFFER_SIZE && b <= RemotingConstants.MAX_BUFFER_SIZE ? b : RemotingConstants.DEFAULT_BUFFER_SIZE;
}
@Override

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.http;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
@ -33,7 +33,7 @@ public interface HttpBinder {
* @param url server url.
* @return server.
*/
@Adaptive({Constants.SERVER_KEY})
@Adaptive({RemotingConstants.SERVER_KEY})
HttpServer bind(URL url, HttpHandler handler);
}

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.http.jetty;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.NetUtils;
@ -51,7 +52,7 @@ public class JettyHttpServer extends AbstractHttpServer {
Log.setLog(new StdErrLog());
Log.getLog().setDebugEnabled(false);
DispatcherServlet.addHttpHandler(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), handler);
DispatcherServlet.addHttpHandler(url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort()), handler);
int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
QueuedThreadPool threadPool = new QueuedThreadPool();
@ -63,11 +64,11 @@ public class JettyHttpServer extends AbstractHttpServer {
ServerConnector connector = new ServerConnector(server);
String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost());
String bindIp = url.getParameter(RemotingConstants.BIND_IP_KEY, url.getHost());
if (!url.isAnyHost() && NetUtils.isValidLocalHost(bindIp)) {
connector.setHost(bindIp);
}
connector.setPort(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()));
connector.setPort(url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort()));
server.addConnector(connector);
@ -80,12 +81,12 @@ public class JettyHttpServer extends AbstractHttpServer {
// TODO Context.SESSIONS is the best option here? (In jetty 9.x, it becomes ServletContextHandler.SESSIONS)
ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
context.setServletHandler(servletHandler);
ServletManager.getInstance().addServletContext(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), context.getServletContext());
ServletManager.getInstance().addServletContext(url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort()), context.getServletContext());
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + url.getParameter(Constants.BIND_IP_KEY) + ":" + url.getParameter(Constants.BIND_PORT_KEY) + ", cause: "
throw new IllegalStateException("Failed to start jetty server on " + url.getParameter(RemotingConstants.BIND_IP_KEY) + ":" + url.getParameter(RemotingConstants.BIND_PORT_KEY) + ", cause: "
+ e.getMessage(), e);
}
}
@ -95,7 +96,7 @@ public class JettyHttpServer extends AbstractHttpServer {
super.close();
//
ServletManager.getInstance().removeServletContext(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()));
ServletManager.getInstance().removeServletContext(url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort()));
if (server != null) {
try {

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.http.servlet;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.http.HttpHandler;
import org.apache.dubbo.remoting.http.support.AbstractHttpServer;
@ -25,7 +25,7 @@ public class ServletHttpServer extends AbstractHttpServer {
public ServletHttpServer(URL url, HttpHandler handler) {
super(url, handler);
DispatcherServlet.addHttpHandler(url.getParameter(Constants.BIND_PORT_KEY, 8080), handler);
DispatcherServlet.addHttpHandler(url.getParameter(RemotingConstants.BIND_PORT_KEY, 8080), handler);
}
}

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.http.tomcat;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.http.HttpHandler;
@ -54,7 +55,7 @@ public class TomcatHttpServer extends AbstractHttpServer {
// "minSpareThreads", String.valueOf(url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS)));
tomcat.getConnector().setProperty(
"maxConnections", String.valueOf(url.getParameter(Constants.ACCEPTS_KEY, -1)));
"maxConnections", String.valueOf(url.getParameter(RemotingConstants.ACCEPTS_KEY, -1)));
tomcat.getConnector().setProperty("URIEncoding", "UTF-8");
tomcat.getConnector().setProperty("connectionTimeout", "60000");

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.http.jetty;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.remoting.http.HttpHandler;
import org.apache.dubbo.remoting.http.HttpServer;
@ -36,7 +36,7 @@ public class JettyHttpBinderTest {
public void shouldAbleHandleRequestForJettyBinder() throws Exception {
int port = NetUtils.getAvailablePort();
URL url = new URL("http", "localhost", port,
new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)});
new String[]{RemotingConstants.BIND_PORT_KEY, String.valueOf(port)});
HttpServer httpServer = new JettyHttpServer(url, new HttpHandler() {
@Override
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.http.tomcat;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.remoting.http.HttpHandler;
import org.apache.dubbo.remoting.http.HttpServer;
@ -37,7 +37,7 @@ public class TomcatHttpBinderTest {
public void shouldAbleHandleRequestForTomcatBinder() throws Exception {
int port = NetUtils.getAvailablePort();
URL url = new URL("http", "localhost", port,
new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)});
new String[]{RemotingConstants.BIND_PORT_KEY, String.valueOf(port)});
HttpServer httpServer = new TomcatHttpBinder().bind(url, new HttpHandler() {
@Override

View File

@ -16,9 +16,9 @@
*/
package org.apache.dubbo.remoting.transport.mina;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.NamedThreadFactory;
@ -71,7 +71,7 @@ public class MinaClient extends AbstractClient {
connector = c;
} else {
// set thread pool.
connector = new SocketConnector(Constants.DEFAULT_IO_THREADS,
connector = new SocketConnector(RemotingConstants.DEFAULT_IO_THREADS,
Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true)));
// config
SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig();

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.transport.mina;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.Codec2;
@ -54,8 +54,8 @@ final class MinaCodecAdapter implements ProtocolCodecFactory {
this.codec = codec;
this.url = url;
this.handler = handler;
int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
int b = url.getPositiveParameter(RemotingConstants.BUFFER_KEY, RemotingConstants.DEFAULT_BUFFER_SIZE);
this.bufferSize = b >= RemotingConstants.MIN_BUFFER_SIZE && b <= RemotingConstants.MAX_BUFFER_SIZE ? b : RemotingConstants.DEFAULT_BUFFER_SIZE;
}
@Override

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.transport.mina;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ExecutorUtil;
@ -56,7 +57,7 @@ public class MinaServer extends AbstractServer {
@Override
protected void doOpen() throws Throwable {
// set thread pool.
acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS),
acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, RemotingConstants.DEFAULT_IO_THREADS),
Executors.newCachedThreadPool(new NamedThreadFactory("MinaServerWorker",
true)));
// config

View File

@ -16,9 +16,9 @@
*/
package org.apache.dubbo.remoting.transport.netty;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.NamedThreadFactory;
@ -50,7 +50,7 @@ public class NettyClient extends AbstractClient {
// https://issues.jboss.org/browse/NETTY-424
private static final ChannelFactory CHANNEL_FACTORY = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(new NamedThreadFactory("NettyClientBoss", true)),
Executors.newCachedThreadPool(new NamedThreadFactory("NettyClientWorker", true)),
Constants.DEFAULT_IO_THREADS);
RemotingConstants.DEFAULT_IO_THREADS);
private ClientBootstrap bootstrap;
private volatile Channel channel; // volatile, please copy reference to use

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.transport.netty;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.Codec2;
import org.apache.dubbo.remoting.buffer.DynamicChannelBuffer;
@ -56,8 +56,8 @@ final class NettyCodecAdapter {
this.codec = codec;
this.url = url;
this.handler = handler;
int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE);
this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE;
int b = url.getPositiveParameter(RemotingConstants.BUFFER_KEY, RemotingConstants.DEFAULT_BUFFER_SIZE);
this.bufferSize = b >= RemotingConstants.MIN_BUFFER_SIZE && b <= RemotingConstants.MAX_BUFFER_SIZE ? b : RemotingConstants.DEFAULT_BUFFER_SIZE;
}
public ChannelHandler getEncoder() {

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.transport.netty;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
@ -67,7 +68,7 @@ public class NettyServer extends AbstractServer implements Server {
NettyHelper.setNettyLoggerFactory();
ExecutorService boss = Executors.newCachedThreadPool(new NamedThreadFactory("NettyServerBoss", true));
ExecutorService worker = Executors.newCachedThreadPool(new NamedThreadFactory("NettyServerWorker", true));
ChannelFactory channelFactory = new NioServerSocketChannelFactory(boss, worker, getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS));
ChannelFactory channelFactory = new NioServerSocketChannelFactory(boss, worker, getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, RemotingConstants.DEFAULT_IO_THREADS));
bootstrap = new ServerBootstrap(channelFactory);
final NettyHandler nettyHandler = new NettyHandler(getUrl(), this);

View File

@ -17,8 +17,8 @@
package org.apache.dubbo.remoting.exchange.support.header;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.Channel;
@ -61,17 +61,17 @@ public class HeartbeatHandlerTest {
@Test
public void testServerHeartbeat() throws Exception {
URL serverURL = URL.valueOf("header://localhost:55555?transporter=netty3");
serverURL = serverURL.addParameter(Constants.HEARTBEAT_KEY, 1000);
serverURL = serverURL.addParameter(RemotingConstants.HEARTBEAT_KEY, 1000);
TestHeartbeatHandler handler = new TestHeartbeatHandler();
server = Exchangers.bind(serverURL, handler);
System.out.println("Server bind successfully");
FakeChannelHandlers.setTestingChannelHandlers();
serverURL = serverURL.removeParameter(Constants.HEARTBEAT_KEY);
serverURL = serverURL.removeParameter(RemotingConstants.HEARTBEAT_KEY);
// Let the client not reply to the heartbeat, and turn off automatic reconnect to simulate the client dropped.
serverURL = serverURL.addParameter(Constants.HEARTBEAT_KEY, 600 * 1000);
serverURL = serverURL.addParameter(Constants.RECONNECT_KEY, false);
serverURL = serverURL.addParameter(RemotingConstants.HEARTBEAT_KEY, 600 * 1000);
serverURL = serverURL.addParameter(RemotingConstants.RECONNECT_KEY, false);
client = Exchangers.connect(serverURL);
Thread.sleep(10000);
@ -82,7 +82,7 @@ public class HeartbeatHandlerTest {
@Test
public void testHeartbeat() throws Exception {
URL serverURL = URL.valueOf("header://localhost:55555?transporter=netty3");
serverURL = serverURL.addParameter(Constants.HEARTBEAT_KEY, 1000);
serverURL = serverURL.addParameter(RemotingConstants.HEARTBEAT_KEY, 1000);
TestHeartbeatHandler handler = new TestHeartbeatHandler();
server = Exchangers.bind(serverURL, handler);
System.out.println("Server bind successfully");
@ -104,7 +104,7 @@ public class HeartbeatHandlerTest {
System.out.println("Server bind successfully");
FakeChannelHandlers.resetChannelHandlers();
serverURL = serverURL.addParameter(Constants.HEARTBEAT_KEY, 1000);
serverURL = serverURL.addParameter(RemotingConstants.HEARTBEAT_KEY, 1000);
client = Exchangers.connect(serverURL);
Thread.sleep(10000);
Assertions.assertTrue(handler.connectCount > 0);

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.remoting.transport.netty;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.DubboAppender;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.remoting.Channel;
@ -70,7 +70,7 @@ public class ClientReconnectTest {
public Client startClient(int port, int heartbeat) throws RemotingException {
final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?check=false&client=netty3&" + Constants.HEARTBEAT_KEY + "=" + heartbeat;
final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?check=false&client=netty3&" + RemotingConstants.HEARTBEAT_KEY + "=" + heartbeat;
return Exchangers.connect(url);
}

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.transport.netty;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.RemotingException;
import org.apache.dubbo.remoting.exchange.ExchangeChannel;
import org.apache.dubbo.remoting.exchange.ExchangeServer;
@ -32,14 +32,14 @@ public class NettyClientToServerTest extends ClientToServerTest {
protected ExchangeServer newServer(int port, Replier<?> receiver) throws RemotingException {
// add heartbeat cycle to avoid unstable ut.
URL url = URL.valueOf("exchange://localhost:" + port + "?server=netty3");
url = url.addParameter(Constants.HEARTBEAT_KEY, 600 * 1000);
url = url.addParameter(RemotingConstants.HEARTBEAT_KEY, 600 * 1000);
return Exchangers.bind(url, receiver);
}
protected ExchangeChannel newClient(int port) throws RemotingException {
// add heartbeat cycle to avoid unstable ut.
URL url = URL.valueOf("exchange://localhost:" + port + "?client=netty3&timeout=3000");
url = url.addParameter(Constants.HEARTBEAT_KEY, 600 * 1000);
url = url.addParameter(RemotingConstants.HEARTBEAT_KEY, 600 * 1000);
return Exchangers.connect(url);
}

View File

@ -16,9 +16,9 @@
*/
package org.apache.dubbo.remoting.transport.netty4;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ConfigUtils;
@ -51,7 +51,7 @@ public class NettyClient extends AbstractClient {
private static final Logger logger = LoggerFactory.getLogger(NettyClient.class);
private static final NioEventLoopGroup nioEventLoopGroup = new NioEventLoopGroup(Constants.DEFAULT_IO_THREADS, new DefaultThreadFactory("NettyClientWorker", true));
private static final NioEventLoopGroup nioEventLoopGroup = new NioEventLoopGroup(RemotingConstants.DEFAULT_IO_THREADS, new DefaultThreadFactory("NettyClientWorker", true));
private static final String SOCKS_PROXY_HOST = "socksProxyHost";

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.transport.netty4;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ExecutorUtil;
@ -74,7 +75,7 @@ public class NettyServer extends AbstractServer implements Server {
bootstrap = new ServerBootstrap();
bossGroup = new NioEventLoopGroup(1, new DefaultThreadFactory("NettyServerBoss", true));
workerGroup = new NioEventLoopGroup(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS),
workerGroup = new NioEventLoopGroup(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, RemotingConstants.DEFAULT_IO_THREADS),
new DefaultThreadFactory("NettyServerWorker", true));
final NettyServerHandler nettyServerHandler = new NettyServerHandler(getUrl(), this);

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.remoting.transport.netty4;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.DubboAppender;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.remoting.Channel;
@ -72,7 +72,7 @@ public class ClientReconnectTest {
public Client startClient(int port, int heartbeat) throws RemotingException {
final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?client=netty4&check=false&" + Constants.HEARTBEAT_KEY + "=" + heartbeat;
final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?client=netty4&check=false&" + RemotingConstants.HEARTBEAT_KEY + "=" + heartbeat;
return Exchangers.connect(url);
}

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.transport.netty4;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.RemotingException;
import org.apache.dubbo.remoting.exchange.ExchangeChannel;
import org.apache.dubbo.remoting.exchange.ExchangeServer;
@ -32,14 +32,14 @@ public class NettyClientToServerTest extends ClientToServerTest {
protected ExchangeServer newServer(int port, Replier<?> receiver) throws RemotingException {
// add heartbeat cycle to avoid unstable ut.
URL url = URL.valueOf("exchange://localhost:" + port + "?server=netty4");
url = url.addParameter(Constants.HEARTBEAT_KEY, 600 * 1000);
url = url.addParameter(RemotingConstants.HEARTBEAT_KEY, 600 * 1000);
return Exchangers.bind(url, receiver);
}
protected ExchangeChannel newClient(int port) throws RemotingException {
// add heartbeat cycle to avoid unstable ut.
URL url = URL.valueOf("exchange://localhost:" + port + "?client=netty4&timeout=3000");
url = url.addParameter(Constants.HEARTBEAT_KEY, 600 * 1000);
url = url.addParameter(RemotingConstants.HEARTBEAT_KEY, 600 * 1000);
return Exchangers.connect(url);
}

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.transport.netty4;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.RemotingException;
@ -36,7 +36,7 @@ public class NettyTransporterTest {
public void shouldAbleToBindNetty4() throws Exception {
int port = NetUtils.getAvailablePort();
URL url = new URL("http", "localhost", port,
new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)});
new String[]{RemotingConstants.BIND_PORT_KEY, String.valueOf(port)});
Server server = new NettyTransporter().bind(url, new ChannelHandlerAdapter());
@ -49,7 +49,7 @@ public class NettyTransporterTest {
int port = NetUtils.getAvailablePort();
URL url = new URL("http", "localhost", port,
new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)});
new String[]{RemotingConstants.BIND_PORT_KEY, String.valueOf(port)});
new NettyTransporter().bind(url, new ChannelHandlerAdapter() {

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.p2p.exchange.support;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.Channel;
@ -105,7 +105,7 @@ public class ExchangeServerPeer extends ExchangeServerDelegate implements Exchan
@Override
public void send(Object message) throws RemotingException {
send(message, getUrl().getParameter(Constants.SENT_KEY, false));
send(message, getUrl().getParameter(RemotingConstants.SENT_KEY, false));
}
@Override

View File

@ -16,8 +16,8 @@
*/
package org.apache.dubbo.remoting.p2p.support;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.Channel;
@ -92,7 +92,7 @@ public class ServerPeer extends ServerDelegate implements Peer {
@Override
public void send(Object message) throws RemotingException {
send(message, getUrl().getParameter(Constants.SENT_KEY, false));
send(message, getUrl().getParameter(RemotingConstants.SENT_KEY, false));
}
@Override

View File

@ -16,15 +16,15 @@
*/
package org.apache.dubbo.remoting.zookeeper;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
@SPI("curator")
public interface ZookeeperTransporter {
@Adaptive({Constants.CLIENT_KEY, Constants.TRANSPORTER_KEY})
@Adaptive({RemotingConstants.CLIENT_KEY, RemotingConstants.TRANSPORTER_KEY})
ZookeeperClient connect(URL url);
}

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.zookeeper.support;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
@ -110,7 +111,7 @@ public abstract class AbstractZookeeperTransporter implements ZookeeperTransport
List<String> addressList = new ArrayList<String>();
addressList.add(url.getAddress());
addressList.addAll(url.getParameter(Constants.BACKUP_KEY, Collections.EMPTY_LIST));
addressList.addAll(url.getParameter(RemotingConstants.BACKUP_KEY, Collections.EMPTY_LIST));
return addressList;
}
@ -138,8 +139,8 @@ public abstract class AbstractZookeeperTransporter implements ZookeeperTransport
if (url.getParameter(Constants.TIMEOUT_KEY) != null) {
parameterMap.put(Constants.TIMEOUT_KEY, url.getParameter(Constants.TIMEOUT_KEY));
}
if (url.getParameter(Constants.BACKUP_KEY) != null) {
parameterMap.put(Constants.BACKUP_KEY, url.getParameter(Constants.BACKUP_KEY));
if (url.getParameter(RemotingConstants.BACKUP_KEY) != null) {
parameterMap.put(RemotingConstants.BACKUP_KEY, url.getParameter(RemotingConstants.BACKUP_KEY));
}
return new URL(url.getProtocol(), url.getUsername(), url.getPassword(), url.getHost(), url.getPort(),
ZookeeperTransporter.class.getName(), parameterMap);

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.rpc.filter;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CompatibleTypeUtils;
@ -59,7 +59,7 @@ public class CompatibleFilter implements Filter {
Method method = invoker.getInterface().getMethod(invocation.getMethodName(), invocation.getParameterTypes());
Class<?> type = method.getReturnType();
Object newValue;
String serialization = invoker.getUrl().getParameter(Constants.SERIALIZATION_KEY);
String serialization = invoker.getUrl().getParameter(RemotingConstants.SERIALIZATION_KEY);
if ("json".equals(serialization)
|| "fastjson".equals(serialization)) {
// If the serialization key is json or fastjson

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.rpc.protocol;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.ConcurrentHashSet;
@ -44,7 +45,7 @@ public abstract class AbstractProtocol implements Protocol {
protected final Set<Invoker<?>> invokers = new ConcurrentHashSet<Invoker<?>>();
protected static String serviceKey(URL url) {
int port = url.getParameter(Constants.BIND_PORT_KEY, url.getPort());
int port = url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort());
return serviceKey(port, url.getPath(), url.getParameter(Constants.VERSION_KEY),
url.getParameter(Constants.GROUP_KEY));
}

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.rpc.protocol;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.rpc.Exporter;
import org.apache.dubbo.rpc.Invocation;
@ -130,11 +131,11 @@ public abstract class AbstractProxyProtocol extends AbstractProtocol {
}
protected String getAddr(URL url) {
String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost());
String bindIp = url.getParameter(RemotingConstants.BIND_IP_KEY, url.getHost());
if (url.getParameter(Constants.ANYHOST_KEY, false)) {
bindIp = Constants.ANYHOST_VALUE;
}
return NetUtils.getIpByHost(bindIp) + ":" + url.getParameter(Constants.BIND_PORT_KEY, url.getPort());
return NetUtils.getIpByHost(bindIp) + ":" + url.getParameter(RemotingConstants.BIND_PORT_KEY, url.getPort());
}
protected int getErrorCode(Throwable e) {

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.RemotingException;
@ -59,7 +60,7 @@ class ChannelWrappedInvoker<T> extends AbstractInvoker<T> {
try {
if (getUrl().getMethodParameter(invocation.getMethodName(), Constants.ASYNC_KEY, false)) { // may have concurrency issue
currentClient.send(inv, getUrl().getMethodParameter(invocation.getMethodName(), Constants.SENT_KEY, false));
currentClient.send(inv, getUrl().getMethodParameter(invocation.getMethodName(), RemotingConstants.SENT_KEY, false));
return new RpcResult();
}
int timeout = getUrl().getMethodParameter(invocation.getMethodName(), Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.config.ConfigurationUtils;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.AtomicPositiveInteger;
import org.apache.dubbo.remoting.RemotingException;
import org.apache.dubbo.remoting.TimeoutException;
@ -85,7 +86,7 @@ public class DubboInvoker<T> extends AbstractInvoker<T> {
boolean isOneway = RpcUtils.isOneway(getUrl(), invocation);
int timeout = getUrl().getMethodParameter(methodName, Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
if (isOneway) {
boolean isSent = getUrl().getMethodParameter(methodName, Constants.SENT_KEY, false);
boolean isSent = getUrl().getMethodParameter(methodName, RemotingConstants.SENT_KEY, false);
currentClient.send(inv, isSent);
RpcContext.getContext().setFuture(null);
return new RpcResult();
@ -120,7 +121,7 @@ public class DubboInvoker<T> extends AbstractInvoker<T> {
return false;
}
for (ExchangeClient client : clients) {
if (client.isConnected() && !client.hasAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY)) {
if (client.isConnected() && !client.hasAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY)) {
//cannot write == not Available ?
return true;
}

View File

@ -20,6 +20,7 @@ import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.config.ConfigurationUtils;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.serialize.support.SerializableClassRegistry;
import org.apache.dubbo.common.serialize.support.SerializationOptimizer;
@ -315,12 +316,12 @@ public class DubboProtocol extends AbstractProtocol {
private ExchangeServer createServer(URL url) {
url = URLBuilder.from(url)
// send readonly event when server closes, it's enabled by default
.addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString())
.addParameterIfAbsent(RemotingConstants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString())
// enable heartbeat by default
.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT))
.addParameter(Constants.CODEC_KEY, DubboCodec.NAME)
.addParameterIfAbsent(RemotingConstants.HEARTBEAT_KEY, String.valueOf(RemotingConstants.DEFAULT_HEARTBEAT))
.addParameter(RemotingConstants.CODEC_KEY, DubboCodec.NAME)
.build();
String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER);
String str = url.getParameter(RemotingConstants.SERVER_KEY, RemotingConstants.DEFAULT_REMOTING_SERVER);
if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) {
throw new RpcException("Unsupported server type: " + str + ", url: " + url);
@ -333,7 +334,7 @@ public class DubboProtocol extends AbstractProtocol {
throw new RpcException("Fail to start server(url: " + url + ") " + e.getMessage(), e);
}
str = url.getParameter(Constants.CLIENT_KEY);
str = url.getParameter(RemotingConstants.CLIENT_KEY);
if (str != null && str.length() > 0) {
Set<String> supportedTypes = ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions();
if (!supportedTypes.contains(str)) {
@ -555,11 +556,11 @@ public class DubboProtocol extends AbstractProtocol {
private ExchangeClient initClient(URL url) {
// client type setting.
String str = url.getParameter(Constants.CLIENT_KEY, url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_CLIENT));
String str = url.getParameter(RemotingConstants.CLIENT_KEY, url.getParameter(RemotingConstants.SERVER_KEY, RemotingConstants.DEFAULT_REMOTING_CLIENT));
url = url.addParameter(Constants.CODEC_KEY, DubboCodec.NAME);
url = url.addParameter(RemotingConstants.CODEC_KEY, DubboCodec.NAME);
// enable heartbeat by default
url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));
url = url.addParameterIfAbsent(RemotingConstants.HEARTBEAT_KEY, String.valueOf(RemotingConstants.DEFAULT_HEARTBEAT));
// BIO is not allowed since it has severe performance issue.
if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) {

View File

@ -19,6 +19,7 @@ package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.Parameters;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.NetUtils;
@ -59,7 +60,7 @@ final class LazyConnectExchangeClient implements ExchangeClient {
public LazyConnectExchangeClient(URL url, ExchangeHandler requestHandler) {
// lazy connect, need set send.reconnect = true, to avoid channel bad status.
this.url = url.addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString());
this.url = url.addParameter(RemotingConstants.SEND_RECONNECT_KEY, Boolean.TRUE.toString());
this.requestHandler = requestHandler;
this.initialState = url.getParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Constants.DEFAULT_LAZY_CONNECT_INITIAL_STATE);
this.requestWithWarning = url.getParameter(REQUEST_WITH_WARNING_KEY, false);

View File

@ -20,6 +20,7 @@ import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.Parameters;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.RemotingException;
import org.apache.dubbo.remoting.exchange.ExchangeClient;
@ -168,8 +169,8 @@ final class ReferenceCountExchangeClient implements ExchangeClient {
// this is a defensive operation to avoid client is closed by accident, the initial state of the client is false
URL lazyUrl = URLBuilder.from(url)
.addParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Boolean.FALSE)
.addParameter(Constants.RECONNECT_KEY, Boolean.FALSE)
.addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString())
.addParameter(RemotingConstants.RECONNECT_KEY, Boolean.FALSE)
.addParameter(RemotingConstants.SEND_RECONNECT_KEY, Boolean.TRUE.toString())
.addParameter("warning", Boolean.TRUE.toString())
.addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true)
.addParameter("_client_memo", "referencecounthandler.replacewithlazyclient")

View File

@ -17,6 +17,7 @@
package org.apache.dubbo.rpc.protocol.dubbo.filter;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
@ -103,7 +104,7 @@ public class TraceFilter implements Filter {
}
count = c.getAndIncrement();
if (count < max) {
String prompt = channel.getUrl().getParameter(Constants.PROMPT_KEY, Constants.DEFAULT_PROMPT);
String prompt = channel.getUrl().getParameter(RemotingConstants.PROMPT_KEY, RemotingConstants.DEFAULT_PROMPT);
channel.send("\r\n" + RpcContext.getContext().getRemoteAddress() + " -> "
+ invoker.getInterface().getName()
+ "." + invocation.getMethodName()

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.rpc.protocol.dubbo.status;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.status.Status;
@ -36,7 +36,7 @@ public class ThreadPoolStatusChecker implements StatusChecker {
@Override
public Status check() {
DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension();
Map<String, Object> executors = dataStore.get(Constants.EXECUTOR_SERVICE_COMPONENT_KEY);
Map<String, Object> executors = dataStore.get(RemotingConstants.EXECUTOR_SERVICE_COMPONENT_KEY);
StringBuilder msg = new StringBuilder();
Status.Level level = Status.Level.OK;

View File

@ -20,6 +20,7 @@ package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.config.ConfigurationUtils;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.remoting.exchange.ExchangeClient;
@ -76,12 +77,12 @@ public class DubboInvokerAvilableTest {
DubboInvoker<?> invoker = (DubboInvoker<?>) protocol.refer(IDemoService.class, url);
Assertions.assertEquals(true, invoker.isAvailable());
getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
getClients(invoker)[0].setAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
Assertions.assertEquals(false, invoker.isAvailable());
// reset status since connection is shared among invokers
getClients(invoker)[0].removeAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY);
getClients(invoker)[0].removeAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY);
}
@Disabled
@ -130,7 +131,7 @@ public class DubboInvokerAvilableTest {
Assertions.assertEquals(true, invoker.isAvailable());
try {
getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
getClients(invoker)[0].setAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
fail();
} catch (IllegalStateException e) {
@ -140,7 +141,7 @@ public class DubboInvokerAvilableTest {
Assertions.assertEquals("ok", service.get());
Assertions.assertEquals(true, invoker.isAvailable());
getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
getClients(invoker)[0].setAttribute(RemotingConstants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
Assertions.assertEquals(false, invoker.isAvailable());
}

View File

@ -17,8 +17,8 @@
package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.rpc.Protocol;
import org.apache.dubbo.rpc.ProxyFactory;
@ -96,8 +96,8 @@ public class DubboProtocolTest {
@Test
public void testDubboProtocolWithMina() throws Exception {
DemoService service = new DemoServiceImpl();
protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:9011/" + DemoService.class.getName()).addParameter(Constants.SERVER_KEY, "mina")));
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:9011/" + DemoService.class.getName()).addParameter(Constants.CLIENT_KEY, "mina").addParameter("timeout", 3000l)));
protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:9011/" + DemoService.class.getName()).addParameter(RemotingConstants.SERVER_KEY, "mina")));
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:9011/" + DemoService.class.getName()).addParameter(RemotingConstants.CLIENT_KEY, "mina").addParameter("timeout", 3000l)));
for (int i = 0; i < 10; i++) {
assertEquals(service.enumlength(new Type[]{}), Type.Lower);
assertEquals(service.getSize(null), -1);

Some files were not shown because too many files have changed in this diff Show More