Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DUBBO-3137]: step4 - move more constants from RemotingConstants into dubbo-remoting-api #4077

Merged
merged 2 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package org.apache.dubbo.rpc.cluster.configurator;

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.remoting.Constants;
import org.apache.dubbo.rpc.cluster.Configurator;

import java.util.HashSet;
Expand Down Expand Up @@ -119,7 +119,7 @@ private URL configureIfMatch(String host, URL url) {
|| configApplication.equals(currentApplication)) {
Set<String> conditionKeys = new HashSet<String>();
conditionKeys.add(CATEGORY_KEY);
conditionKeys.add(RemotingConstants.CHECK_KEY);
conditionKeys.add(Constants.CHECK_KEY);
conditionKeys.add(DYNAMIC_KEY);
conditionKeys.add(ENABLED_KEY);
conditionKeys.add(GROUP_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package org.apache.dubbo.rpc.cluster.support;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.remoting.Constants;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -76,8 +76,8 @@ public static URL mergeUrl(URL remoteUrl, Map<String, String> localMap) {
map.remove(ALIVE_KEY);
map.remove(DEFAULT_KEY_PREFIX + ALIVE_KEY);

map.remove(RemotingConstants.TRANSPORTER_KEY);
map.remove(DEFAULT_KEY_PREFIX + RemotingConstants.TRANSPORTER_KEY);
map.remove(Constants.TRANSPORTER_KEY);
map.remove(DEFAULT_KEY_PREFIX + Constants.TRANSPORTER_KEY);
}

if (localMap != null && localMap.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,82 +17,17 @@

package org.apache.dubbo.common.constants;

import java.util.concurrent.ExecutorService;

/**
* RemotingConstants
*/
public interface RemotingConstants {

String PAYLOAD_KEY = "payload";
/**
* 8M
*/
int DEFAULT_PAYLOAD = 8 * 1024 * 1024;

String CONNECT_TIMEOUT_KEY = "connect.timeout";

int DEFAULT_CONNECT_TIMEOUT = 3000;

String HEARTBEAT_KEY = "heartbeat";

int DEFAULT_HEARTBEAT = 60 * 1000;

String SERIALIZATION_KEY = "serialization";

String DEFAULT_REMOTING_SERIALIZATION = "hessian2";

String CODEC_KEY = "codec";

String SERVER_KEY = "server";

String DEFAULT_REMOTING_SERVER = "netty";

String CLIENT_KEY = "client";

String DEFAULT_REMOTING_CLIENT = "netty";

String TRANSPORTER_KEY = "transporter";

String DEFAULT_TRANSPORTER = "netty";

String EXCHANGER_KEY = "exchanger";

String DEFAULT_EXCHANGER = "header";

String DISPACTHER_KEY = "dispacther";

int DEFAULT_IO_THREADS = Math.min(Runtime.getRuntime().availableProcessors() + 1, 32);

String BIND_IP_KEY = "bind.ip";

String BIND_PORT_KEY = "bind.port";

String SENT_KEY = "sent";

String DISPATCHER_KEY = "dispatcher";

String CHANNEL_ATTRIBUTE_READONLY_KEY = "channel.readonly";

String CHANNEL_READONLYEVENT_SENT_KEY = "channel.readonly.sent";

String CHANNEL_SEND_READONLYEVENT_KEY = "channel.readonly.send";

String EXECUTOR_SERVICE_COMPONENT_KEY = ExecutorService.class.getName();

String BACKUP_KEY = "backup";

String HEARTBEAT_TIMEOUT_KEY = "heartbeat.timeout";

String RECONNECT_KEY = "reconnect";

int DEFAULT_RECONNECT_PERIOD = 2000;

String SEND_RECONNECT_KEY = "send.reconnect";

String CHECK_KEY = "check";

String PROMPT_KEY = "prompt";

String DEFAULT_PROMPT = "dubbo>";
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package org.apache.dubbo.config;

import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.config.support.Parameter;
import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.rpc.InvokerListener;
import org.apache.dubbo.rpc.support.ProtocolUtils;

Expand Down Expand Up @@ -187,7 +187,7 @@ public Boolean getStubevent() {
return stubevent;
}

@Parameter(key = RemotingConstants.RECONNECT_KEY)
@Parameter(key = Constants.RECONNECT_KEY)
public String getReconnect() {
return reconnect;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*/
package org.apache.dubbo.config;

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;
import org.apache.dubbo.common.threadpool.ThreadPool;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.config.support.Parameter;
import org.apache.dubbo.remoting.Codec;
import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.remoting.Dispatcher;
import org.apache.dubbo.remoting.Transporter;
import org.apache.dubbo.remoting.exchange.Exchanger;
Expand Down Expand Up @@ -325,7 +325,7 @@ public String getCodec() {

public void setCodec(String codec) {
if (DUBBO_PROTOCOL.equals(name)) {
checkMultiExtension(Codec.class, RemotingConstants.CODEC_KEY, codec);
checkMultiExtension(Codec.class, Constants.CODEC_KEY, codec);
}
this.codec = codec;
}
Expand All @@ -336,7 +336,7 @@ public String getSerialization() {

public void setSerialization(String serialization) {
if (DUBBO_PROTOCOL.equals(name)) {
checkMultiExtension(Serialization.class, RemotingConstants.SERIALIZATION_KEY, serialization);
checkMultiExtension(Serialization.class, Constants.SERIALIZATION_KEY, serialization);
}
this.serialization = serialization;
}
Expand Down Expand Up @@ -379,7 +379,7 @@ public String getServer() {

public void setServer(String server) {
if (DUBBO_PROTOCOL.equals(name)) {
checkMultiExtension(Transporter.class, RemotingConstants.SERVER_KEY, server);
checkMultiExtension(Transporter.class, Constants.SERVER_KEY, server);
}
this.server = server;
}
Expand All @@ -390,7 +390,7 @@ public String getClient() {

public void setClient(String client) {
if (DUBBO_PROTOCOL.equals(name)) {
checkMultiExtension(Transporter.class, RemotingConstants.CLIENT_KEY, client);
checkMultiExtension(Transporter.class, Constants.CLIENT_KEY, client);
}
this.client = client;
}
Expand Down Expand Up @@ -443,7 +443,7 @@ public String getTransporter() {
}

public void setTransporter(String transporter) {
checkExtension(Transporter.class, RemotingConstants.TRANSPORTER_KEY, transporter);
checkExtension(Transporter.class, Constants.TRANSPORTER_KEY, transporter);
this.transporter = transporter;
}

Expand All @@ -452,7 +452,7 @@ public String getExchanger() {
}

public void setExchanger(String exchanger) {
checkExtension(Exchanger.class, RemotingConstants.EXCHANGER_KEY, exchanger);
checkExtension(Exchanger.class, Constants.EXCHANGER_KEY, exchanger);
this.exchanger = exchanger;
}

Expand Down Expand Up @@ -482,7 +482,7 @@ public String getDispatcher() {
}

public void setDispatcher(String dispatcher) {
checkExtension(Dispatcher.class, RemotingConstants.DISPACTHER_KEY, dispatcher);
checkExtension(Dispatcher.class, Constants.DISPACTHER_KEY, dispatcher);
this.dispatcher = dispatcher;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/
package org.apache.dubbo.config;

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;
import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.remoting.Dispatcher;
import org.apache.dubbo.remoting.Transporter;
import org.apache.dubbo.remoting.exchange.Exchanger;
Expand Down Expand Up @@ -372,7 +372,7 @@ public String getTransporter() {
}

public void setTransporter(String transporter) {
checkExtension(Transporter.class, RemotingConstants.TRANSPORTER_KEY, transporter);
checkExtension(Transporter.class, Constants.TRANSPORTER_KEY, transporter);
this.transporter = transporter;
}

Expand All @@ -381,7 +381,7 @@ public String getExchanger() {
}

public void setExchanger(String exchanger) {
checkExtension(Exchanger.class, RemotingConstants.EXCHANGER_KEY, exchanger);
checkExtension(Exchanger.class, Constants.EXCHANGER_KEY, exchanger);
this.exchanger = exchanger;
}

Expand Down Expand Up @@ -411,7 +411,7 @@ public String getDispatcher() {
}

public void setDispatcher(String dispatcher) {
checkExtension(Dispatcher.class, RemotingConstants.DISPATCHER_KEY, dispatcher);
checkExtension(Dispatcher.class, Constants.DISPATCHER_KEY, dispatcher);
checkExtension(Dispatcher.class, "dispather", dispatcher);
this.dispatcher = dispatcher;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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;
Expand All @@ -30,6 +29,7 @@
import org.apache.dubbo.config.context.ConfigManager;
import org.apache.dubbo.config.support.Parameter;
import org.apache.dubbo.metadata.integration.MetadataReportService;
import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Protocol;
import org.apache.dubbo.rpc.ProxyFactory;
Expand Down Expand Up @@ -579,7 +579,7 @@ public String getClient() {
}

public void setClient(String client) {
checkName(RemotingConstants.CLIENT_KEY, client);
checkName(Constants.CLIENT_KEY, client);
this.client = client;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
*/
package org.apache.dubbo.config;

import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.config.support.Parameter;
import org.apache.dubbo.remoting.Constants;

import java.util.Map;

Expand Down Expand Up @@ -278,7 +278,7 @@ public String getTransporter() {
}

public void setTransporter(String transporter) {
checkName(RemotingConstants.TRANSPORTER_KEY, transporter);
checkName(Constants.TRANSPORTER_KEY, transporter);
/*if(transporter != null && transporter.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(transporter)){
throw new IllegalStateException("No such transporter type : " + transporter);
}*/
Expand All @@ -290,7 +290,7 @@ public String getServer() {
}

public void setServer(String server) {
checkName(RemotingConstants.SERVER_KEY, server);
checkName(Constants.SERVER_KEY, server);
/*if(server != null && server.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(server)){
throw new IllegalStateException("No such server type : " + server);
}*/
Expand All @@ -302,7 +302,7 @@ public String getClient() {
}

public void setClient(String client) {
checkName(RemotingConstants.CLIENT_KEY, client);
checkName(Constants.CLIENT_KEY, client);
/*if(client != null && client.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(client)){
throw new IllegalStateException("No such client type : " + client);
}*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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;
Expand All @@ -33,6 +32,7 @@
import org.apache.dubbo.config.invoker.DelegateProviderMetaDataInvoker;
import org.apache.dubbo.config.support.Parameter;
import org.apache.dubbo.metadata.integration.MetadataReportService;
import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.rpc.Exporter;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Protocol;
Expand Down Expand Up @@ -710,7 +710,7 @@ private String findConfigedHosts(ProtocolConfig protocolConfig, List<URL> regist
}
}

map.put(RemotingConstants.BIND_IP_KEY, hostToBind);
map.put(Constants.BIND_IP_KEY, hostToBind);

// registry ip is not used for bind ip by default
String hostToRegistry = getValueFromConfig(protocolConfig, DUBBO_IP_TO_REGISTRY);
Expand Down Expand Up @@ -762,7 +762,7 @@ private Integer findConfigedPorts(ProtocolConfig protocolConfig, String name, Ma
}

// save bind port, used as url's key later
map.put(RemotingConstants.BIND_PORT_KEY, String.valueOf(portToBind));
map.put(Constants.BIND_PORT_KEY, String.valueOf(portToBind));

// registry port, not used as bind port by default
String portToRegistryStr = getValueFromConfig(protocolConfig, DUBBO_PORT_TO_REGISTRY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.dubbo.config.annotation;

import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.constants.RpcConstants;
import org.apache.dubbo.rpc.ExporterListener;
import org.apache.dubbo.rpc.Filter;
Expand Down Expand Up @@ -103,7 +102,7 @@
* 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 RemotingConstants#DEFAULT_RECONNECT_PERIOD
* @see org.apache.dubbo.remoting.Constants#DEFAULT_RECONNECT_PERIOD
*/
String reconnect() default "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.dubbo.config;

import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.Constants;

import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -129,7 +129,7 @@ public void testReconnect() throws Exception {
Map<String, String> parameters = new HashMap<String, String>();
AbstractInterfaceConfig.appendParameters(parameters, referenceConfig);
assertThat(referenceConfig.getReconnect(), equalTo("reconnect"));
assertThat(parameters, hasKey(RemotingConstants.RECONNECT_KEY));
assertThat(parameters, hasKey(Constants.RECONNECT_KEY));
}

@Test
Expand Down
Loading