[DUBBO-3137]: step3, remove constants completely. (#4053)
* [DUBBO-3137]: step3, start to use ConfigConstants, FilterConstants, and remove Constants.java completely. * remove Constants imports
This commit is contained in:
parent
d24d61401b
commit
0b380e3280
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.rpc.cluster.directory;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
|
@ -32,6 +31,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
|
||||
import static org.apache.dubbo.common.constants.MonitorConstants.MONITOR_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_PROTOCOL;
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ public abstract class AbstractDirectory<T> implements Directory<T> {
|
|||
}
|
||||
|
||||
if (url.getProtocol().equals(REGISTRY_PROTOCOL)) {
|
||||
Map<String, String> queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY));
|
||||
Map<String, String> queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(REFER_KEY));
|
||||
this.url = url.addParameters(queryMap).removeParameter(MONITOR_KEY);
|
||||
} else {
|
||||
this.url = url;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.rpc.cluster.router.condition;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
|
@ -48,6 +47,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY_PREF
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.METHOD_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.HOST_KEY;
|
||||
|
||||
/**
|
||||
* ConditionRouter
|
||||
|
|
@ -233,7 +233,7 @@ public class ConditionRouter extends AbstractRouter {
|
|||
sampleValue = invocation.getMethodName();
|
||||
} else if (ADDRESS_KEY.equals(key)) {
|
||||
sampleValue = url.getAddress();
|
||||
} else if (Constants.HOST_KEY.equals(key)) {
|
||||
} else if (HOST_KEY.equals(key)) {
|
||||
sampleValue = url.getHost();
|
||||
} else {
|
||||
sampleValue = sample.get(key);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.rpc.cluster.support;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
|
|
@ -50,6 +49,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||
|
||||
import static org.apache.dubbo.common.constants.ClusterConstants.CLUSTER_AVAILABLE_CHECK_KEY;
|
||||
import static org.apache.dubbo.common.constants.ClusterConstants.INVOCATION_NEED_MOCK;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
|
||||
import static org.apache.dubbo.common.constants.MonitorConstants.MONITOR_KEY;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
@ -225,7 +225,7 @@ public class AbstractClusterInvokerTest {
|
|||
@Test
|
||||
public void testCloseAvailablecheck() {
|
||||
LoadBalance lb = mock(LoadBalance.class);
|
||||
Map<String, String> queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY));
|
||||
Map<String, String> queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(REFER_KEY));
|
||||
URL tmpUrl = url.addParameters(queryMap).removeParameter(MONITOR_KEY);
|
||||
given(lb.select(invokers, tmpUrl, invocation)).willReturn(invoker1);
|
||||
initlistsize5();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.rpc.cluster.support;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.URLBuilder;
|
||||
|
||||
|
|
@ -33,6 +32,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.THREADPOOL_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.DUBBO_VERSION_KEY;
|
||||
|
||||
public class ClusterUtilsTest {
|
||||
|
|
@ -62,7 +62,7 @@ public class ClusterUtilsTest {
|
|||
.addParameter(DEFAULT_KEY_PREFIX + THREAD_NAME_KEY, "test")
|
||||
.build();
|
||||
|
||||
URL consumerURL = new URLBuilder(Constants.DUBBO_PROTOCOL, "localhost", 55555)
|
||||
URL consumerURL = new URLBuilder(DUBBO_PROTOCOL, "localhost", 55555)
|
||||
.addParameter(PID_KEY, "1234")
|
||||
.addParameter(THREADPOOL_KEY, "foo")
|
||||
.build();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.rpc.cluster.support.wrapper;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.rpc.Invocation;
|
||||
|
|
|
|||
|
|
@ -1,211 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dubbo.common;
|
||||
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DUBBO;
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
|
||||
|
||||
|
||||
// BEGIN dubbo-config-api
|
||||
public static final String CLUSTER_KEY = "cluster";
|
||||
|
||||
public static final String STATUS_KEY = "status";
|
||||
|
||||
public static final String CONTEXTPATH_KEY = "contextpath";
|
||||
|
||||
public static final String LISTENER_KEY = "listener";
|
||||
|
||||
public static final String LAYER_KEY = "layer";
|
||||
|
||||
/**
|
||||
* General
|
||||
*/
|
||||
/**
|
||||
* Application name;
|
||||
*/
|
||||
public static final String NAME = "name";
|
||||
|
||||
/**
|
||||
* Application owner name;
|
||||
*/
|
||||
public static final String OWNER = "owner";
|
||||
|
||||
/**
|
||||
* Running application organization name.
|
||||
*/
|
||||
public static final String ORGANIZATION = "organization";
|
||||
|
||||
/**
|
||||
* Application architecture name.
|
||||
*/
|
||||
public static final String ARCHITECTURE = "architecture";
|
||||
|
||||
/**
|
||||
* Environment name
|
||||
*/
|
||||
public static final String ENVIRONMENT = "environment";
|
||||
|
||||
/**
|
||||
* Test environment key.
|
||||
*/
|
||||
public static final String TEST_ENVIRONMENT = "test";
|
||||
|
||||
/**
|
||||
* Development environment key.
|
||||
*/
|
||||
public static final String DEVELOPMENT_ENVIRONMENT = "develop";
|
||||
|
||||
/**
|
||||
* Production environment key.
|
||||
*/
|
||||
public static final String PRODUCTION_ENVIRONMENT = "product";
|
||||
|
||||
public static final String CONFIG_CLUSTER_KEY = "config.cluster";
|
||||
public static final String CONFIG_NAMESPACE_KEY = "config.namespace";
|
||||
public static final String CONFIG_GROUP_KEY = "config.group";
|
||||
public static final String CONFIG_CHECK_KEY = "config.check";
|
||||
|
||||
public static final String CONFIG_CONFIGFILE_KEY = "config.config-file";
|
||||
public static final String CONFIG_ENABLE_KEY = "config.highest-priority";
|
||||
public static final String CONFIG_TIMEOUT_KEY = "config.timeout";
|
||||
public static final String CONFIG_APPNAME_KEY = "config.app-name";
|
||||
|
||||
public static final String USERNAME_KEY = "username";
|
||||
|
||||
public static final String PASSWORD_KEY = "password";
|
||||
|
||||
public static final String HOST_KEY = "host";
|
||||
|
||||
public static final String PORT_KEY = "port";
|
||||
|
||||
public static final String MULTICAST = "multicast";
|
||||
|
||||
public static final String REGISTER_IP_KEY = "register.ip";
|
||||
|
||||
public static final String DUBBO_IP_TO_REGISTRY = "DUBBO_IP_TO_REGISTRY";
|
||||
|
||||
public static final String DUBBO_PORT_TO_REGISTRY = "DUBBO_PORT_TO_REGISTRY";
|
||||
|
||||
public static final String DUBBO_IP_TO_BIND = "DUBBO_IP_TO_BIND";
|
||||
|
||||
public static final String DUBBO_PORT_TO_BIND = "DUBBO_PORT_TO_BIND";
|
||||
|
||||
public static final String SCOPE_KEY = "scope";
|
||||
|
||||
public static final String SCOPE_LOCAL = "local";
|
||||
|
||||
public static final String SCOPE_REMOTE = "remote";
|
||||
|
||||
public static final String SCOPE_NONE = "none";
|
||||
|
||||
public static final String ON_CONNECT_KEY = "onconnect";
|
||||
|
||||
public static final String ON_DISCONNECT_KEY = "ondisconnect";
|
||||
|
||||
public static final String ON_INVOKE_METHOD_KEY = "oninvoke.method";
|
||||
|
||||
public static final String ON_RETURN_METHOD_KEY = "onreturn.method";
|
||||
|
||||
public static final String ON_THROW_METHOD_KEY = "onthrow.method";
|
||||
|
||||
public static final String ON_INVOKE_INSTANCE_KEY = "oninvoke.instance";
|
||||
|
||||
public static final String ON_RETURN_INSTANCE_KEY = "onreturn.instance";
|
||||
|
||||
public static final String ON_THROW_INSTANCE_KEY = "onthrow.instance";
|
||||
|
||||
@Deprecated
|
||||
public static final String SHUTDOWN_WAIT_SECONDS_KEY = "dubbo.service.shutdown.wait.seconds";
|
||||
|
||||
public static final String SHUTDOWN_WAIT_KEY = "dubbo.service.shutdown.wait";
|
||||
|
||||
/**
|
||||
* The key name for export URL in register center
|
||||
*/
|
||||
public static final String EXPORT_KEY = "export";
|
||||
|
||||
/**
|
||||
* The key name for reference URL in register center
|
||||
*/
|
||||
public static final String REFER_KEY = "refer";
|
||||
|
||||
/**
|
||||
* To decide whether to make connection when the client is created
|
||||
*/
|
||||
public static final String LAZY_CONNECT_KEY = "lazy";
|
||||
|
||||
public static final String DUBBO_PROTOCOL = DUBBO;
|
||||
|
||||
public static final String ZOOKEEPER_PROTOCOL = "zookeeper";
|
||||
|
||||
// FIXME: is this still useful?
|
||||
public static final String SHUTDOWN_TIMEOUT_KEY = "shutdown.timeout";
|
||||
|
||||
public static final int DEFAULT_SHUTDOWN_TIMEOUT = 1000 * 60 * 15;
|
||||
|
||||
public static final String PROTOCOLS_SUFFIX = "dubbo.protocols.";
|
||||
|
||||
public static final String PROTOCOL_SUFFIX = "dubbo.protocol.";
|
||||
|
||||
public static final String REGISTRIES_SUFFIX = "dubbo.registries.";
|
||||
|
||||
public static final String TELNET = "telnet";
|
||||
|
||||
public static final String QOS_ENABLE = "qos.enable";
|
||||
|
||||
public static final String QOS_PORT = "qos.port";
|
||||
|
||||
public static final String ACCEPT_FOREIGN_IP = "qos.accept.foreign.ip";
|
||||
// END dubbo-congfig-api
|
||||
|
||||
// BEGIN dubbo-filter-cache
|
||||
public static final String CACHE_KEY = "cache";
|
||||
// END dubbo-filter-cache
|
||||
|
||||
|
||||
// BEGIN dubbo-filter-validation
|
||||
public static final String VALIDATION_KEY = "validation";
|
||||
// END dubbo-filter-validation
|
||||
|
||||
public static final String DEFAULT_CLUSTER = "failover";
|
||||
|
||||
/**
|
||||
* public static final int DEFAULT_REGISTRY_CONNECT_TIMEOUT = 5000;
|
||||
*/
|
||||
|
||||
public static final String DIRECTORY_KEY = "directory";
|
||||
|
||||
public static final String ASYNC_SUFFIX = "Async";
|
||||
|
||||
public static final String WAIT_KEY = "wait";
|
||||
|
||||
public static final String HESSIAN_VERSION_KEY = "hessian.version";
|
||||
|
||||
|
||||
public static final String CONFIG_PROTOCOL = "config";
|
||||
|
||||
|
||||
public static final String RELIABLE_PROTOCOL = "napoli";
|
||||
}
|
||||
|
|
@ -40,6 +40,8 @@ import java.util.Map;
|
|||
import java.util.TreeMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.HOST_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.PORT_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_VALUE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
|
||||
|
|
@ -50,6 +52,8 @@ import static org.apache.dubbo.common.constants.CommonConstants.LOCALHOST_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.PASSWORD_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.USERNAME_KEY;
|
||||
|
||||
/**
|
||||
* URL - Uniform Resource Locator (Immutable, ThreadSafe)
|
||||
|
|
@ -1137,16 +1141,16 @@ class URL implements Serializable {
|
|||
if (PROTOCOL_KEY.equals(key)) {
|
||||
return protocol;
|
||||
}
|
||||
if (Constants.USERNAME_KEY.equals(key)) {
|
||||
if (USERNAME_KEY.equals(key)) {
|
||||
return username;
|
||||
}
|
||||
if (Constants.PASSWORD_KEY.equals(key)) {
|
||||
if (PASSWORD_KEY.equals(key)) {
|
||||
return password;
|
||||
}
|
||||
if (Constants.HOST_KEY.equals(key)) {
|
||||
if (HOST_KEY.equals(key)) {
|
||||
return host;
|
||||
}
|
||||
if (Constants.PORT_KEY.equals(key)) {
|
||||
if (PORT_KEY.equals(key)) {
|
||||
return String.valueOf(port);
|
||||
}
|
||||
if (PATH_KEY.equals(key)) {
|
||||
|
|
@ -1161,16 +1165,16 @@ class URL implements Serializable {
|
|||
map.put(PROTOCOL_KEY, protocol);
|
||||
}
|
||||
if (username != null) {
|
||||
map.put(Constants.USERNAME_KEY, username);
|
||||
map.put(USERNAME_KEY, username);
|
||||
}
|
||||
if (password != null) {
|
||||
map.put(Constants.USERNAME_KEY, password);
|
||||
map.put(USERNAME_KEY, password);
|
||||
}
|
||||
if (host != null) {
|
||||
map.put(Constants.HOST_KEY, host);
|
||||
map.put(HOST_KEY, host);
|
||||
}
|
||||
if (port > 0) {
|
||||
map.put(Constants.PORT_KEY, String.valueOf(port));
|
||||
map.put(PORT_KEY, String.valueOf(port));
|
||||
}
|
||||
if (path != null) {
|
||||
map.put(PATH_KEY, path);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.common.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -28,6 +27,8 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_SERVER_SHUTDOWN_TIMEOUT;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_SECONDS_KEY;
|
||||
|
||||
/**
|
||||
* Utilities for manipulating configurations from different sources
|
||||
|
|
@ -40,7 +41,7 @@ public class ConfigurationUtils {
|
|||
public static int getServerShutdownTimeout() {
|
||||
int timeout = DEFAULT_SERVER_SHUTDOWN_TIMEOUT;
|
||||
Configuration configuration = Environment.getInstance().getConfiguration();
|
||||
String value = StringUtils.trim(configuration.getString(Constants.SHUTDOWN_WAIT_KEY));
|
||||
String value = StringUtils.trim(configuration.getString(SHUTDOWN_WAIT_KEY));
|
||||
|
||||
if (value != null && value.length() > 0) {
|
||||
try {
|
||||
|
|
@ -49,7 +50,7 @@ public class ConfigurationUtils {
|
|||
// ignore
|
||||
}
|
||||
} else {
|
||||
value = StringUtils.trim(configuration.getString(Constants.SHUTDOWN_WAIT_SECONDS_KEY));
|
||||
value = StringUtils.trim(configuration.getString(SHUTDOWN_WAIT_SECONDS_KEY));
|
||||
if (value != null && value.length() > 0) {
|
||||
try {
|
||||
timeout = Integer.parseInt(value) * 1000;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package org.apache.dubbo.common.constants;
|
|||
* ConfigConstants
|
||||
*/
|
||||
public interface ConfigConstants {
|
||||
// BEGIN dubbo-config-api
|
||||
String CLUSTER_KEY = "cluster";
|
||||
|
||||
String STATUS_KEY = "status";
|
||||
|
|
@ -171,5 +170,4 @@ public interface ConfigConstants {
|
|||
String QOS_PORT = "qos.port";
|
||||
|
||||
String ACCEPT_FOREIGN_IP = "qos.accept.foreign.ip";
|
||||
// END dubbo-congfig-api
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.common.utils;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.config.ConfigurationUtils;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
|
|
@ -37,9 +36,10 @@ import java.util.Optional;
|
|||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.LOCALHOST_VALUE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_VALUE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.LOCALHOST_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.LOCALHOST_VALUE;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_IP_TO_BIND;
|
||||
|
||||
/**
|
||||
* IP and Port Helper for RPC
|
||||
|
|
@ -208,7 +208,7 @@ public class NetUtils {
|
|||
}
|
||||
|
||||
public static String getIpByConfig() {
|
||||
String configIp = ConfigurationUtils.getProperty(Constants.DUBBO_IP_TO_BIND);
|
||||
String configIp = ConfigurationUtils.getProperty(DUBBO_IP_TO_BIND);
|
||||
if (configIp != null) {
|
||||
return configIp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
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;
|
||||
|
||||
|
|
@ -39,6 +38,11 @@ import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_SPLIT_PATTERN;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.REMOVE_VALUE_PREFIX;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.HOST_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.PASSWORD_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.PORT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.USERNAME_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_CATEGORY;
|
||||
|
|
@ -78,19 +82,19 @@ public class UrlUtils {
|
|||
}
|
||||
String defaultProtocol = defaults == null ? null : defaults.get(PROTOCOL_KEY);
|
||||
if (defaultProtocol == null || defaultProtocol.length() == 0) {
|
||||
defaultProtocol = Constants.DUBBO_PROTOCOL;
|
||||
defaultProtocol = DUBBO_PROTOCOL;
|
||||
}
|
||||
String defaultUsername = defaults == null ? null : defaults.get(Constants.USERNAME_KEY);
|
||||
String defaultPassword = defaults == null ? null : defaults.get(Constants.PASSWORD_KEY);
|
||||
int defaultPort = StringUtils.parseInteger(defaults == null ? null : defaults.get(Constants.PORT_KEY));
|
||||
String defaultUsername = defaults == null ? null : defaults.get(USERNAME_KEY);
|
||||
String defaultPassword = defaults == null ? null : defaults.get(PASSWORD_KEY);
|
||||
int defaultPort = StringUtils.parseInteger(defaults == null ? null : defaults.get(PORT_KEY));
|
||||
String defaultPath = defaults == null ? null : defaults.get(PATH_KEY);
|
||||
Map<String, String> defaultParameters = defaults == null ? null : new HashMap<String, String>(defaults);
|
||||
if (defaultParameters != null) {
|
||||
defaultParameters.remove(PROTOCOL_KEY);
|
||||
defaultParameters.remove(Constants.USERNAME_KEY);
|
||||
defaultParameters.remove(Constants.PASSWORD_KEY);
|
||||
defaultParameters.remove(Constants.HOST_KEY);
|
||||
defaultParameters.remove(Constants.PORT_KEY);
|
||||
defaultParameters.remove(USERNAME_KEY);
|
||||
defaultParameters.remove(PASSWORD_KEY);
|
||||
defaultParameters.remove(HOST_KEY);
|
||||
defaultParameters.remove(PORT_KEY);
|
||||
defaultParameters.remove(PATH_KEY);
|
||||
}
|
||||
URL u = URL.valueOf(url);
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@
|
|||
*/
|
||||
package org.apache.dubbo.common.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
@ -30,16 +30,16 @@ public class ConfigurationUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testGetServerShutdownTimeout () {
|
||||
System.setProperty(Constants.SHUTDOWN_WAIT_KEY, " 10000");
|
||||
System.setProperty(SHUTDOWN_WAIT_KEY, " 10000");
|
||||
Assertions.assertEquals(10000, ConfigurationUtils.getServerShutdownTimeout());
|
||||
System.clearProperty(Constants.SHUTDOWN_WAIT_KEY);
|
||||
System.clearProperty(SHUTDOWN_WAIT_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetProperty () {
|
||||
System.setProperty(Constants.SHUTDOWN_WAIT_KEY, " 10000");
|
||||
Assertions.assertEquals("10000", ConfigurationUtils.getProperty(Constants.SHUTDOWN_WAIT_KEY));
|
||||
System.clearProperty(Constants.SHUTDOWN_WAIT_KEY);
|
||||
System.setProperty(SHUTDOWN_WAIT_KEY, " 10000");
|
||||
Assertions.assertEquals("10000", ConfigurationUtils.getProperty(SHUTDOWN_WAIT_KEY));
|
||||
System.clearProperty(SHUTDOWN_WAIT_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -17,6 +17,16 @@
|
|||
|
||||
package com.alibaba.dubbo.common;
|
||||
|
||||
import org.apache.dubbo.common.constants.ClusterConstants;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.constants.ConfigConstants;
|
||||
import org.apache.dubbo.common.constants.FilterConstants;
|
||||
import org.apache.dubbo.common.constants.MonitorConstants;
|
||||
import org.apache.dubbo.common.constants.RegistryConstants;
|
||||
import org.apache.dubbo.common.constants.RemotingConstants;
|
||||
import org.apache.dubbo.common.constants.RpcConstants;
|
||||
|
||||
@Deprecated
|
||||
public class Constants extends org.apache.dubbo.common.Constants {
|
||||
public class Constants implements ClusterConstants, CommonConstants, ConfigConstants, FilterConstants,
|
||||
MonitorConstants, RegistryConstants, RemotingConstants, RpcConstants {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.config.ApplicationConfig;
|
||||
import com.alibaba.dubbo.config.MonitorConfig;
|
||||
import com.alibaba.dubbo.config.RegistryConfig;
|
||||
|
|
@ -30,6 +29,8 @@ import java.util.Map;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DUMP_DIRECTORY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ACCEPT_FOREIGN_IP;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.QOS_ENABLE;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
|
@ -152,7 +153,7 @@ public class ApplicationConfigTest {
|
|||
assertThat(application.getQosEnable(), is(true));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
ApplicationConfig.appendParameters(parameters, application);
|
||||
assertThat(parameters, hasEntry(Constants.QOS_ENABLE, "true"));
|
||||
assertThat(parameters, hasEntry(QOS_ENABLE, "true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -169,7 +170,7 @@ public class ApplicationConfigTest {
|
|||
assertThat(application.getQosAcceptForeignIp(), is(true));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
ApplicationConfig.appendParameters(parameters, application);
|
||||
assertThat(parameters, hasEntry(Constants.ACCEPT_FOREIGN_IP, "true"));
|
||||
assertThat(parameters, hasEntry(ACCEPT_FOREIGN_IP, "true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -180,6 +181,6 @@ public class ApplicationConfigTest {
|
|||
parameters.put("k1", "v1");
|
||||
ApplicationConfig.appendParameters(parameters, application);
|
||||
assertThat(parameters, hasEntry("k1", "v1"));
|
||||
assertThat(parameters, hasEntry(Constants.ACCEPT_FOREIGN_IP, "true"));
|
||||
assertThat(parameters, hasEntry(ACCEPT_FOREIGN_IP, "true"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,8 @@ package org.apache.dubbo.config;
|
|||
import org.apache.dubbo.rpc.model.ConsumerMethodModel;
|
||||
import org.apache.dubbo.service.Person;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.config.ArgumentConfig;
|
||||
import com.alibaba.dubbo.config.MethodConfig;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
@ -31,13 +29,19 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_INVOKE_INSTANCE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_INVOKE_METHOD_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_RETURN_INSTANCE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_RETURN_METHOD_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_THROW_INSTANCE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_THROW_METHOD_KEY;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasEntry;
|
||||
import static org.hamcrest.Matchers.hasKey;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class MethodConfigTest {
|
||||
|
|
@ -120,7 +124,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOnreturn(), equalTo((Object) "on-return-object"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_RETURN_INSTANCE_KEY, (Object) "on-return-object"));
|
||||
assertThat(attribute, hasEntry((Object) ON_RETURN_INSTANCE_KEY, (Object) "on-return-object"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
@ -133,7 +137,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOnreturnMethod(), equalTo("on-return-method"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_RETURN_METHOD_KEY, (Object) "on-return-method"));
|
||||
assertThat(attribute, hasEntry((Object) ON_RETURN_METHOD_KEY, (Object) "on-return-method"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
@ -146,7 +150,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOnthrow(), equalTo((Object) "on-throw-object"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_THROW_INSTANCE_KEY, (Object) "on-throw-object"));
|
||||
assertThat(attribute, hasEntry((Object) ON_THROW_INSTANCE_KEY, (Object) "on-throw-object"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
@ -159,7 +163,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOnthrowMethod(), equalTo("on-throw-method"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_THROW_METHOD_KEY, (Object) "on-throw-method"));
|
||||
assertThat(attribute, hasEntry((Object) ON_THROW_METHOD_KEY, (Object) "on-throw-method"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
@ -172,7 +176,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOninvoke(), equalTo((Object) "on-invoke-object"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_INVOKE_INSTANCE_KEY, (Object) "on-invoke-object"));
|
||||
assertThat(attribute, hasEntry((Object) ON_INVOKE_INSTANCE_KEY, (Object) "on-invoke-object"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
@ -185,7 +189,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOninvokeMethod(), equalTo("on-invoke-method"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_INVOKE_METHOD_KEY, (Object) "on-invoke-method"));
|
||||
assertThat(attribute, hasEntry((Object) ON_INVOKE_METHOD_KEY, (Object) "on-invoke-method"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
@ -197,4 +201,4 @@ public class MethodConfigTest {
|
|||
method.setReturn(true);
|
||||
assertThat(method.isReturn(), is(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,21 +17,20 @@
|
|||
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.config.RegistryConfig;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasEntry;
|
||||
import static org.hamcrest.Matchers.hasKey;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
public class RegistryConfigTest {
|
||||
@Test
|
||||
|
|
@ -70,7 +69,7 @@ public class RegistryConfigTest {
|
|||
RegistryConfig registry = new RegistryConfig();
|
||||
registry.setWait(10);
|
||||
assertThat(registry.getWait(), is(10));
|
||||
assertThat(System.getProperty(Constants.SHUTDOWN_WAIT_KEY), equalTo("10"));
|
||||
assertThat(System.getProperty(SHUTDOWN_WAIT_KEY), equalTo("10"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -173,4 +172,4 @@ public class RegistryConfigTest {
|
|||
registry.setDefault(true);
|
||||
assertThat(registry.isDefault(), is(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.URLBuilder;
|
||||
import org.apache.dubbo.common.Version;
|
||||
|
|
@ -65,6 +64,16 @@ import static org.apache.dubbo.common.constants.CommonConstants.PID_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CLUSTER_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_IP_TO_REGISTRY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.LAYER_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.LISTENER_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REGISTER_IP_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REGISTRIES_SUFFIX;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_SECONDS_KEY;
|
||||
import static org.apache.dubbo.common.constants.MonitorConstants.LOGSTAT_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTER_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_KEY;
|
||||
|
|
@ -211,13 +220,13 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
ApplicationModel.setApplication(application.getName());
|
||||
|
||||
// backward compatibility
|
||||
String wait = ConfigUtils.getProperty(Constants.SHUTDOWN_WAIT_KEY);
|
||||
String wait = ConfigUtils.getProperty(SHUTDOWN_WAIT_KEY);
|
||||
if (wait != null && wait.trim().length() > 0) {
|
||||
System.setProperty(Constants.SHUTDOWN_WAIT_KEY, wait.trim());
|
||||
System.setProperty(SHUTDOWN_WAIT_KEY, wait.trim());
|
||||
} else {
|
||||
wait = ConfigUtils.getProperty(Constants.SHUTDOWN_WAIT_SECONDS_KEY);
|
||||
wait = ConfigUtils.getProperty(SHUTDOWN_WAIT_SECONDS_KEY);
|
||||
if (wait != null && wait.trim().length() > 0) {
|
||||
System.setProperty(Constants.SHUTDOWN_WAIT_SECONDS_KEY, wait.trim());
|
||||
System.setProperty(SHUTDOWN_WAIT_SECONDS_KEY, wait.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -330,7 +339,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
map.put(PATH_KEY, RegistryService.class.getName());
|
||||
appendRuntimeParameters(map);
|
||||
if (!map.containsKey(PROTOCOL_KEY)) {
|
||||
map.put(PROTOCOL_KEY, Constants.DUBBO_PROTOCOL);
|
||||
map.put(PROTOCOL_KEY, DUBBO_PROTOCOL);
|
||||
}
|
||||
List<URL> urls = UrlUtils.parseURLs(address, map);
|
||||
|
||||
|
|
@ -363,14 +372,14 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
map.put(INTERFACE_KEY, MonitorService.class.getName());
|
||||
appendRuntimeParameters(map);
|
||||
//set ip
|
||||
String hostToRegistry = ConfigUtils.getSystemProperty(Constants.DUBBO_IP_TO_REGISTRY);
|
||||
String hostToRegistry = ConfigUtils.getSystemProperty(DUBBO_IP_TO_REGISTRY);
|
||||
if (StringUtils.isEmpty(hostToRegistry)) {
|
||||
hostToRegistry = NetUtils.getLocalHost();
|
||||
} else if (NetUtils.isInvalidLocalHost(hostToRegistry)) {
|
||||
throw new IllegalArgumentException("Specified invalid registry ip from property:" +
|
||||
Constants.DUBBO_IP_TO_REGISTRY + ", value:" + hostToRegistry);
|
||||
DUBBO_IP_TO_REGISTRY + ", value:" + hostToRegistry);
|
||||
}
|
||||
map.put(Constants.REGISTER_IP_KEY, hostToRegistry);
|
||||
map.put(REGISTER_IP_KEY, hostToRegistry);
|
||||
appendParameters(map, monitor);
|
||||
appendParameters(map, application);
|
||||
String address = monitor.getAddress();
|
||||
|
|
@ -383,15 +392,15 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
if (getExtensionLoader(MonitorFactory.class).hasExtension(LOGSTAT_PROTOCOL)) {
|
||||
map.put(PROTOCOL_KEY, LOGSTAT_PROTOCOL);
|
||||
} else {
|
||||
map.put(PROTOCOL_KEY, Constants.DUBBO_PROTOCOL);
|
||||
map.put(PROTOCOL_KEY, DUBBO_PROTOCOL);
|
||||
}
|
||||
}
|
||||
return UrlUtils.parseURL(address, map);
|
||||
} else if (REGISTRY_PROTOCOL.equals(monitor.getProtocol()) && registryURL != null) {
|
||||
return URLBuilder.from(registryURL)
|
||||
.setProtocol(Constants.DUBBO_PROTOCOL)
|
||||
.setProtocol(DUBBO_PROTOCOL)
|
||||
.addParameter(PROTOCOL_KEY, REGISTRY_PROTOCOL)
|
||||
.addParameterAndEncoded(Constants.REFER_KEY, StringUtils.toQueryString(map))
|
||||
.addParameterAndEncoded(REFER_KEY, StringUtils.toQueryString(map))
|
||||
.build();
|
||||
}
|
||||
return null;
|
||||
|
|
@ -538,9 +547,9 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
if (StringUtils.isEmpty(registryIds) && CollectionUtils.isEmpty(registries)) {
|
||||
Set<String> configedRegistries = new HashSet<>();
|
||||
configedRegistries.addAll(getSubProperties(Environment.getInstance().getExternalConfigurationMap(),
|
||||
Constants.REGISTRIES_SUFFIX));
|
||||
REGISTRIES_SUFFIX));
|
||||
configedRegistries.addAll(getSubProperties(Environment.getInstance().getAppExternalConfigurationMap(),
|
||||
Constants.REGISTRIES_SUFFIX));
|
||||
REGISTRIES_SUFFIX));
|
||||
|
||||
registryIds = String.join(COMMA_SEPARATOR, configedRegistries);
|
||||
}
|
||||
|
|
@ -674,7 +683,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
}
|
||||
|
||||
public void setCluster(String cluster) {
|
||||
checkExtension(Cluster.class, Constants.CLUSTER_KEY, cluster);
|
||||
checkExtension(Cluster.class, CLUSTER_KEY, cluster);
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
|
|
@ -711,7 +720,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
}
|
||||
|
||||
public void setListener(String listener) {
|
||||
checkMultiExtension(InvokerListener.class, Constants.LISTENER_KEY, listener);
|
||||
checkMultiExtension(InvokerListener.class, LISTENER_KEY, listener);
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
|
|
@ -720,7 +729,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
}
|
||||
|
||||
public void setLayer(String layer) {
|
||||
checkNameHasSymbol(Constants.LAYER_KEY, layer);
|
||||
checkNameHasSymbol(LAYER_KEY, layer);
|
||||
this.layer = layer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
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;
|
||||
|
|
@ -25,6 +24,7 @@ import org.apache.dubbo.rpc.support.ProtocolUtils;
|
|||
import static org.apache.dubbo.common.constants.ClusterConstants.CLUSTER_STICKY_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.LAZY_CONNECT_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.INVOKER_LISTENER_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.REFERENCE_FILTER_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.STUB_EVENT_KEY;
|
||||
|
|
@ -157,7 +157,7 @@ public abstract class AbstractReferenceConfig extends AbstractInterfaceConfig {
|
|||
super.setListener(listener);
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.LAZY_CONNECT_KEY)
|
||||
@Parameter(key = LAZY_CONNECT_KEY)
|
||||
public Boolean getLazy() {
|
||||
return lazy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.compiler.support.AdaptiveCompiler;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
|
|
@ -29,6 +28,18 @@ import java.util.Map;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DUMP_DIRECTORY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ACCEPT_FOREIGN_IP;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ARCHITECTURE;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DEVELOPMENT_ENVIRONMENT;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ENVIRONMENT;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.NAME;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ORGANIZATION;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.OWNER;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.PRODUCTION_ENVIRONMENT;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.QOS_ENABLE;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.QOS_PORT;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.TEST_ENVIRONMENT;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -139,7 +150,7 @@ public class ApplicationConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setName(String name) {
|
||||
checkName(Constants.NAME, name);
|
||||
checkName(NAME, name);
|
||||
this.name = name;
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
id = name;
|
||||
|
|
@ -160,7 +171,7 @@ public class ApplicationConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
checkMultiName(Constants.OWNER, owner);
|
||||
checkMultiName(OWNER, owner);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
|
|
@ -169,7 +180,7 @@ public class ApplicationConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setOrganization(String organization) {
|
||||
checkName(Constants.ORGANIZATION, organization);
|
||||
checkName(ORGANIZATION, organization);
|
||||
this.organization = organization;
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +189,7 @@ public class ApplicationConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setArchitecture(String architecture) {
|
||||
checkName(Constants.ARCHITECTURE, architecture);
|
||||
checkName(ARCHITECTURE, architecture);
|
||||
this.architecture = architecture;
|
||||
}
|
||||
|
||||
|
|
@ -187,18 +198,18 @@ public class ApplicationConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setEnvironment(String environment) {
|
||||
checkName(Constants.ENVIRONMENT, environment);
|
||||
checkName(ENVIRONMENT, environment);
|
||||
if (environment != null) {
|
||||
if (!(Constants.DEVELOPMENT_ENVIRONMENT.equals(environment)
|
||||
|| Constants.TEST_ENVIRONMENT.equals(environment)
|
||||
|| Constants.PRODUCTION_ENVIRONMENT.equals(environment))) {
|
||||
if (!(DEVELOPMENT_ENVIRONMENT.equals(environment)
|
||||
|| TEST_ENVIRONMENT.equals(environment)
|
||||
|| PRODUCTION_ENVIRONMENT.equals(environment))) {
|
||||
|
||||
throw new IllegalStateException(String.format("Unsupported environment: %s, only support %s/%s/%s, default is %s.",
|
||||
environment,
|
||||
Constants.DEVELOPMENT_ENVIRONMENT,
|
||||
Constants.TEST_ENVIRONMENT,
|
||||
Constants.PRODUCTION_ENVIRONMENT,
|
||||
Constants.PRODUCTION_ENVIRONMENT));
|
||||
DEVELOPMENT_ENVIRONMENT,
|
||||
TEST_ENVIRONMENT,
|
||||
PRODUCTION_ENVIRONMENT,
|
||||
PRODUCTION_ENVIRONMENT));
|
||||
}
|
||||
}
|
||||
this.environment = environment;
|
||||
|
|
@ -279,7 +290,7 @@ public class ApplicationConfig extends AbstractConfig {
|
|||
this.dumpDirectory = dumpDirectory;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.QOS_ENABLE)
|
||||
@Parameter(key = QOS_ENABLE)
|
||||
public Boolean getQosEnable() {
|
||||
return qosEnable;
|
||||
}
|
||||
|
|
@ -288,7 +299,7 @@ public class ApplicationConfig extends AbstractConfig {
|
|||
this.qosEnable = qosEnable;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.QOS_PORT)
|
||||
@Parameter(key = QOS_PORT)
|
||||
public Integer getQosPort() {
|
||||
return qosPort;
|
||||
}
|
||||
|
|
@ -297,7 +308,7 @@ public class ApplicationConfig extends AbstractConfig {
|
|||
this.qosPort = qosPort;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.ACCEPT_FOREIGN_IP)
|
||||
@Parameter(key = ACCEPT_FOREIGN_IP)
|
||||
public Boolean getQosAcceptForeignIp() {
|
||||
return qosAcceptForeignIp;
|
||||
}
|
||||
|
|
@ -320,7 +331,7 @@ public class ApplicationConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setShutwait(String shutwait) {
|
||||
System.setProperty(Constants.SHUTDOWN_WAIT_KEY, shutwait);
|
||||
System.setProperty(SHUTDOWN_WAIT_KEY, shutwait);
|
||||
this.shutwait = shutwait;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.config.Environment;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -29,6 +28,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_VALUE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_APPNAME_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_CHECK_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_CLUSTER_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_CONFIGFILE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_ENABLE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_NAMESPACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ZOOKEEPER_PROTOCOL;
|
||||
|
||||
/**
|
||||
* ConfigCenterConfig
|
||||
|
|
@ -65,7 +73,7 @@ public class ConfigCenterConfig extends AbstractConfig {
|
|||
map.put(PATH_KEY, ConfigCenterConfig.class.getSimpleName());
|
||||
// use 'zookeeper' as the default configcenter.
|
||||
if (StringUtils.isEmpty(map.get(PROTOCOL_KEY))) {
|
||||
map.put(PROTOCOL_KEY, Constants.ZOOKEEPER_PROTOCOL);
|
||||
map.put(PROTOCOL_KEY, ZOOKEEPER_PROTOCOL);
|
||||
}
|
||||
return UrlUtils.parseURL(address, map);
|
||||
}
|
||||
|
|
@ -99,7 +107,7 @@ public class ConfigCenterConfig extends AbstractConfig {
|
|||
this.address = address;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.CONFIG_CLUSTER_KEY, useKeyAsProperty = false)
|
||||
@Parameter(key = CONFIG_CLUSTER_KEY, useKeyAsProperty = false)
|
||||
public String getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
|
@ -108,7 +116,7 @@ public class ConfigCenterConfig extends AbstractConfig {
|
|||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.CONFIG_NAMESPACE_KEY, useKeyAsProperty = false)
|
||||
@Parameter(key = CONFIG_NAMESPACE_KEY, useKeyAsProperty = false)
|
||||
public String getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
|
@ -117,7 +125,7 @@ public class ConfigCenterConfig extends AbstractConfig {
|
|||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.CONFIG_GROUP_KEY, useKeyAsProperty = false)
|
||||
@Parameter(key = CONFIG_GROUP_KEY, useKeyAsProperty = false)
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
|
@ -126,7 +134,7 @@ public class ConfigCenterConfig extends AbstractConfig {
|
|||
this.group = group;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.CONFIG_CHECK_KEY, useKeyAsProperty = false)
|
||||
@Parameter(key = CONFIG_CHECK_KEY, useKeyAsProperty = false)
|
||||
public Boolean isCheck() {
|
||||
return check;
|
||||
}
|
||||
|
|
@ -135,7 +143,7 @@ public class ConfigCenterConfig extends AbstractConfig {
|
|||
this.check = check;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.CONFIG_ENABLE_KEY, useKeyAsProperty = false)
|
||||
@Parameter(key = CONFIG_ENABLE_KEY, useKeyAsProperty = false)
|
||||
public Boolean isHighestPriority() {
|
||||
return highestPriority;
|
||||
}
|
||||
|
|
@ -160,7 +168,7 @@ public class ConfigCenterConfig extends AbstractConfig {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.CONFIG_TIMEOUT_KEY, useKeyAsProperty = false)
|
||||
@Parameter(key = CONFIG_TIMEOUT_KEY, useKeyAsProperty = false)
|
||||
public Long getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
|
@ -169,7 +177,7 @@ public class ConfigCenterConfig extends AbstractConfig {
|
|||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.CONFIG_CONFIGFILE_KEY, useKeyAsProperty = false)
|
||||
@Parameter(key = CONFIG_CONFIGFILE_KEY, useKeyAsProperty = false)
|
||||
public String getConfigFile() {
|
||||
return configFile;
|
||||
}
|
||||
|
|
@ -187,7 +195,7 @@ public class ConfigCenterConfig extends AbstractConfig {
|
|||
this.appConfigFile = appConfigFile;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.CONFIG_APPNAME_KEY, useKeyAsProperty = false)
|
||||
@Parameter(key = CONFIG_APPNAME_KEY, useKeyAsProperty = false)
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.config.annotation.Method;
|
||||
|
|
@ -26,6 +25,13 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_INVOKE_INSTANCE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_INVOKE_METHOD_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_RETURN_INSTANCE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_RETURN_METHOD_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_THROW_INSTANCE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_THROW_METHOD_KEY;
|
||||
|
||||
/**
|
||||
* The method configuration
|
||||
*
|
||||
|
|
@ -231,7 +237,7 @@ public class MethodConfig extends AbstractMethodConfig {
|
|||
this.sticky = sticky;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.ON_RETURN_INSTANCE_KEY, excluded = true, attribute = true)
|
||||
@Parameter(key = ON_RETURN_INSTANCE_KEY, excluded = true, attribute = true)
|
||||
public Object getOnreturn() {
|
||||
return onreturn;
|
||||
}
|
||||
|
|
@ -240,7 +246,7 @@ public class MethodConfig extends AbstractMethodConfig {
|
|||
this.onreturn = onreturn;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.ON_RETURN_METHOD_KEY, excluded = true, attribute = true)
|
||||
@Parameter(key = ON_RETURN_METHOD_KEY, excluded = true, attribute = true)
|
||||
public String getOnreturnMethod() {
|
||||
return onreturnMethod;
|
||||
}
|
||||
|
|
@ -249,7 +255,7 @@ public class MethodConfig extends AbstractMethodConfig {
|
|||
this.onreturnMethod = onreturnMethod;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.ON_THROW_INSTANCE_KEY, excluded = true, attribute = true)
|
||||
@Parameter(key = ON_THROW_INSTANCE_KEY, excluded = true, attribute = true)
|
||||
public Object getOnthrow() {
|
||||
return onthrow;
|
||||
}
|
||||
|
|
@ -258,7 +264,7 @@ public class MethodConfig extends AbstractMethodConfig {
|
|||
this.onthrow = onthrow;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.ON_THROW_METHOD_KEY, excluded = true, attribute = true)
|
||||
@Parameter(key = ON_THROW_METHOD_KEY, excluded = true, attribute = true)
|
||||
public String getOnthrowMethod() {
|
||||
return onthrowMethod;
|
||||
}
|
||||
|
|
@ -267,7 +273,7 @@ public class MethodConfig extends AbstractMethodConfig {
|
|||
this.onthrowMethod = onthrowMethod;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.ON_INVOKE_INSTANCE_KEY, excluded = true, attribute = true)
|
||||
@Parameter(key = ON_INVOKE_INSTANCE_KEY, excluded = true, attribute = true)
|
||||
public Object getOninvoke() {
|
||||
return oninvoke;
|
||||
}
|
||||
|
|
@ -276,7 +282,7 @@ public class MethodConfig extends AbstractMethodConfig {
|
|||
this.oninvoke = oninvoke;
|
||||
}
|
||||
|
||||
@Parameter(key = Constants.ON_INVOKE_METHOD_KEY, excluded = true, attribute = true)
|
||||
@Parameter(key = ON_INVOKE_METHOD_KEY, excluded = true, attribute = true)
|
||||
public String getOninvokeMethod() {
|
||||
return oninvokeMethod;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.config.support.Parameter;
|
||||
|
|
@ -24,6 +23,10 @@ import org.apache.dubbo.config.support.Parameter;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.NAME;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ORGANIZATION;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.OWNER;
|
||||
|
||||
/**
|
||||
* The module info
|
||||
*
|
||||
|
|
@ -81,7 +84,7 @@ public class ModuleConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setName(String name) {
|
||||
checkName(Constants.NAME, name);
|
||||
checkName(NAME, name);
|
||||
this.name = name;
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
id = name;
|
||||
|
|
@ -102,7 +105,7 @@ public class ModuleConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
checkName(Constants.OWNER, owner);
|
||||
checkName(OWNER, owner);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +114,7 @@ public class ModuleConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setOrganization(String organization) {
|
||||
checkName(Constants.ORGANIZATION, organization);
|
||||
checkName(ORGANIZATION, organization);
|
||||
this.organization = organization;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
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;
|
||||
|
|
@ -34,6 +33,10 @@ import org.apache.dubbo.rpc.Protocol;
|
|||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREADPOOL_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.HOST_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.PROTOCOLS_SUFFIX;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.TELNET;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.DUBBO_VERSION_KEY;
|
||||
|
||||
/**
|
||||
|
|
@ -233,7 +236,7 @@ public class ProtocolConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
checkName(Constants.HOST_KEY, host);
|
||||
checkName(HOST_KEY, host);
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
|
|
@ -321,7 +324,7 @@ public class ProtocolConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setCodec(String codec) {
|
||||
if (Constants.DUBBO_PROTOCOL.equals(name)) {
|
||||
if (DUBBO_PROTOCOL.equals(name)) {
|
||||
checkMultiExtension(Codec.class, RemotingConstants.CODEC_KEY, codec);
|
||||
}
|
||||
this.codec = codec;
|
||||
|
|
@ -332,7 +335,7 @@ public class ProtocolConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setSerialization(String serialization) {
|
||||
if (Constants.DUBBO_PROTOCOL.equals(name)) {
|
||||
if (DUBBO_PROTOCOL.equals(name)) {
|
||||
checkMultiExtension(Serialization.class, RemotingConstants.SERIALIZATION_KEY, serialization);
|
||||
}
|
||||
this.serialization = serialization;
|
||||
|
|
@ -375,7 +378,7 @@ public class ProtocolConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setServer(String server) {
|
||||
if (Constants.DUBBO_PROTOCOL.equals(name)) {
|
||||
if (DUBBO_PROTOCOL.equals(name)) {
|
||||
checkMultiExtension(Transporter.class, RemotingConstants.SERVER_KEY, server);
|
||||
}
|
||||
this.server = server;
|
||||
|
|
@ -386,7 +389,7 @@ public class ProtocolConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setClient(String client) {
|
||||
if (Constants.DUBBO_PROTOCOL.equals(name)) {
|
||||
if (DUBBO_PROTOCOL.equals(name)) {
|
||||
checkMultiExtension(Transporter.class, RemotingConstants.CLIENT_KEY, client);
|
||||
}
|
||||
this.client = client;
|
||||
|
|
@ -405,7 +408,7 @@ public class ProtocolConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setTelnet(String telnet) {
|
||||
checkMultiExtension(TelnetHandler.class, Constants.TELNET, telnet);
|
||||
checkMultiExtension(TelnetHandler.class, TELNET, telnet);
|
||||
this.telnet = telnet;
|
||||
}
|
||||
|
||||
|
|
@ -544,7 +547,7 @@ public class ProtocolConfig extends AbstractConfig {
|
|||
}
|
||||
super.refresh();
|
||||
if (StringUtils.isNotEmpty(this.getId())) {
|
||||
this.setPrefix(Constants.PROTOCOLS_SUFFIX);
|
||||
this.setPrefix(PROTOCOLS_SUFFIX);
|
||||
super.refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
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;
|
||||
|
|
@ -30,6 +29,9 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREADPOOL_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONTEXTPATH_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.STATUS_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.TELNET;
|
||||
|
||||
/**
|
||||
* The service provider default configuration
|
||||
|
|
@ -210,7 +212,7 @@ public class ProviderConfig extends AbstractServiceConfig {
|
|||
}
|
||||
|
||||
public void setContextpath(String contextpath) {
|
||||
checkPathName(Constants.CONTEXTPATH_KEY, contextpath);
|
||||
checkPathName(CONTEXTPATH_KEY, contextpath);
|
||||
this.contextpath = contextpath;
|
||||
}
|
||||
|
||||
|
|
@ -308,7 +310,7 @@ public class ProviderConfig extends AbstractServiceConfig {
|
|||
}
|
||||
|
||||
public void setTelnet(String telnet) {
|
||||
checkMultiExtension(TelnetHandler.class, Constants.TELNET, telnet);
|
||||
checkMultiExtension(TelnetHandler.class, TELNET, telnet);
|
||||
this.telnet = telnet;
|
||||
}
|
||||
|
||||
|
|
@ -326,7 +328,7 @@ public class ProviderConfig extends AbstractServiceConfig {
|
|||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
checkMultiExtension(StatusChecker.class, Constants.STATUS_KEY, status);
|
||||
checkMultiExtension(StatusChecker.class, STATUS_KEY, status);
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
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;
|
||||
|
|
@ -66,6 +65,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.REVISION_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SEMICOLON_SPLIT_PATTERN;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CLUSTER_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_IP_TO_REGISTRY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REGISTER_IP_KEY;
|
||||
import static org.apache.dubbo.common.constants.MonitorConstants.MONITOR_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMER_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_PROTOCOL;
|
||||
|
|
@ -316,13 +319,13 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
|||
}
|
||||
}
|
||||
|
||||
String hostToRegistry = ConfigUtils.getSystemProperty(Constants.DUBBO_IP_TO_REGISTRY);
|
||||
String hostToRegistry = ConfigUtils.getSystemProperty(DUBBO_IP_TO_REGISTRY);
|
||||
if (StringUtils.isEmpty(hostToRegistry)) {
|
||||
hostToRegistry = NetUtils.getLocalHost();
|
||||
} else if (isInvalidLocalHost(hostToRegistry)) {
|
||||
throw new IllegalArgumentException("Specified invalid registry ip from property:" + Constants.DUBBO_IP_TO_REGISTRY + ", value:" + hostToRegistry);
|
||||
throw new IllegalArgumentException("Specified invalid registry ip from property:" + DUBBO_IP_TO_REGISTRY + ", value:" + hostToRegistry);
|
||||
}
|
||||
map.put(Constants.REGISTER_IP_KEY, hostToRegistry);
|
||||
map.put(REGISTER_IP_KEY, hostToRegistry);
|
||||
|
||||
ref = createProxy(map);
|
||||
|
||||
|
|
@ -362,7 +365,7 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
|||
url = url.setPath(interfaceName);
|
||||
}
|
||||
if (REGISTRY_PROTOCOL.equals(url.getProtocol())) {
|
||||
urls.add(url.addParameterAndEncoded(Constants.REFER_KEY, StringUtils.toQueryString(map)));
|
||||
urls.add(url.addParameterAndEncoded(REFER_KEY, StringUtils.toQueryString(map)));
|
||||
} else {
|
||||
urls.add(ClusterUtils.mergeUrl(url, map));
|
||||
}
|
||||
|
|
@ -379,7 +382,7 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
|||
if (monitorUrl != null) {
|
||||
map.put(MONITOR_KEY, URL.encode(monitorUrl.toFullString()));
|
||||
}
|
||||
urls.add(u.addParameterAndEncoded(Constants.REFER_KEY, StringUtils.toQueryString(map)));
|
||||
urls.add(u.addParameterAndEncoded(REFER_KEY, StringUtils.toQueryString(map)));
|
||||
}
|
||||
}
|
||||
if (urls.isEmpty()) {
|
||||
|
|
@ -401,7 +404,7 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
|||
}
|
||||
if (registryURL != null) { // registry url is available
|
||||
// use RegistryAwareCluster only when register's CLUSTER is available
|
||||
URL u = registryURL.addParameter(Constants.CLUSTER_KEY, RegistryAwareCluster.NAME);
|
||||
URL u = registryURL.addParameter(CLUSTER_KEY, RegistryAwareCluster.NAME);
|
||||
// The invoker wrap relation would be: RegistryAwareClusterInvoker(StaticDirectory) -> FailoverClusterInvoker(RegistryDirectory, will execute route) -> Invoker
|
||||
invoker = CLUSTER.join(new StaticDirectory(u, invokers));
|
||||
} else { // not a registry url, must be direct invoke.
|
||||
|
|
@ -424,7 +427,7 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
|||
*/
|
||||
MetadataReportService metadataReportService = null;
|
||||
if ((metadataReportService = getMetadataReportService()) != null) {
|
||||
URL consumerURL = new URL(CONSUMER_PROTOCOL, map.remove(Constants.REGISTER_IP_KEY), 0, map.get(INTERFACE_KEY), map);
|
||||
URL consumerURL = new URL(CONSUMER_PROTOCOL, map.remove(REGISTER_IP_KEY), 0, map.get(INTERFACE_KEY), map);
|
||||
metadataReportService.publishConsumer(consumerURL);
|
||||
}
|
||||
// create service proxy
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
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;
|
||||
|
|
@ -25,6 +24,11 @@ import java.util.Map;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.FILE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.PASSWORD_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REGISTRIES_SUFFIX;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.USERNAME_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ZOOKEEPER_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.EXTRA_KEYS_KEY;
|
||||
|
||||
/**
|
||||
|
|
@ -195,7 +199,7 @@ public class RegistryConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
checkName(Constants.USERNAME_KEY, username);
|
||||
checkName(USERNAME_KEY, username);
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
|
@ -204,7 +208,7 @@ public class RegistryConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
checkLength(Constants.PASSWORD_KEY, password);
|
||||
checkLength(PASSWORD_KEY, password);
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
|
@ -227,7 +231,7 @@ public class RegistryConfig extends AbstractConfig {
|
|||
public void setWait(Integer wait) {
|
||||
this.wait = wait;
|
||||
if (wait != null && wait > 0) {
|
||||
System.setProperty(Constants.SHUTDOWN_WAIT_KEY, String.valueOf(wait));
|
||||
System.setProperty(SHUTDOWN_WAIT_KEY, String.valueOf(wait));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -408,15 +412,15 @@ public class RegistryConfig extends AbstractConfig {
|
|||
if (!isValid()) {
|
||||
return false;
|
||||
}
|
||||
return Constants.ZOOKEEPER_PROTOCOL.equals(getProtocol())
|
||||
|| getAddress().startsWith(Constants.ZOOKEEPER_PROTOCOL);
|
||||
return ZOOKEEPER_PROTOCOL.equals(getProtocol())
|
||||
|| getAddress().startsWith(ZOOKEEPER_PROTOCOL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
super.refresh();
|
||||
if (StringUtils.isNotEmpty(this.getId())) {
|
||||
this.setPrefix(Constants.REGISTRIES_SUFFIX);
|
||||
this.setPrefix(REGISTRIES_SUFFIX);
|
||||
super.refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.URLBuilder;
|
||||
import org.apache.dubbo.common.Version;
|
||||
|
|
@ -72,6 +71,17 @@ import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.REVISION_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_IP_TO_BIND;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_IP_TO_REGISTRY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PORT_TO_BIND;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PORT_TO_REGISTRY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.EXPORT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.MULTICAST;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.PROTOCOLS_SUFFIX;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SCOPE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SCOPE_LOCAL;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SCOPE_NONE;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SCOPE_REMOTE;
|
||||
import static org.apache.dubbo.common.constants.MonitorConstants.MONITOR_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.GENERIC_KEY;
|
||||
|
|
@ -557,16 +567,16 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
.getExtension(url.getProtocol()).getConfigurator(url).configure(url);
|
||||
}
|
||||
|
||||
String scope = url.getParameter(Constants.SCOPE_KEY);
|
||||
String scope = url.getParameter(SCOPE_KEY);
|
||||
// don't export when none is configured
|
||||
if (!Constants.SCOPE_NONE.equalsIgnoreCase(scope)) {
|
||||
if (!SCOPE_NONE.equalsIgnoreCase(scope)) {
|
||||
|
||||
// export to local if the config is not remote (export to remote only when config is remote)
|
||||
if (!Constants.SCOPE_REMOTE.equalsIgnoreCase(scope)) {
|
||||
if (!SCOPE_REMOTE.equalsIgnoreCase(scope)) {
|
||||
exportLocal(url);
|
||||
}
|
||||
// export to remote if the config is not local (export to local only when config is local)
|
||||
if (!Constants.SCOPE_LOCAL.equalsIgnoreCase(scope)) {
|
||||
if (!SCOPE_LOCAL.equalsIgnoreCase(scope)) {
|
||||
if (!isOnlyInJvm() && logger.isInfoEnabled()) {
|
||||
logger.info("Export dubbo service " + interfaceClass.getName() + " to url " + url);
|
||||
}
|
||||
|
|
@ -591,7 +601,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
registryURL = registryURL.addParameter(PROXY_KEY, proxy);
|
||||
}
|
||||
|
||||
Invoker<?> invoker = proxyFactory.getInvoker(ref, (Class) interfaceClass, registryURL.addParameterAndEncoded(Constants.EXPORT_KEY, url.toFullString()));
|
||||
Invoker<?> invoker = proxyFactory.getInvoker(ref, (Class) interfaceClass, registryURL.addParameterAndEncoded(EXPORT_KEY, url.toFullString()));
|
||||
DelegateProviderMetaDataInvoker wrapperInvoker = new DelegateProviderMetaDataInvoker(invoker, this);
|
||||
|
||||
Exporter<?> exporter = protocol.export(wrapperInvoker);
|
||||
|
|
@ -658,9 +668,9 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
private String findConfigedHosts(ProtocolConfig protocolConfig, List<URL> registryURLs, Map<String, String> map) {
|
||||
boolean anyhost = false;
|
||||
|
||||
String hostToBind = getValueFromConfig(protocolConfig, Constants.DUBBO_IP_TO_BIND);
|
||||
String hostToBind = getValueFromConfig(protocolConfig, DUBBO_IP_TO_BIND);
|
||||
if (hostToBind != null && hostToBind.length() > 0 && isInvalidLocalHost(hostToBind)) {
|
||||
throw new IllegalArgumentException("Specified invalid bind ip from property:" + Constants.DUBBO_IP_TO_BIND + ", value:" + hostToBind);
|
||||
throw new IllegalArgumentException("Specified invalid bind ip from property:" + DUBBO_IP_TO_BIND + ", value:" + hostToBind);
|
||||
}
|
||||
|
||||
// if bind ip is not found in environment, keep looking up
|
||||
|
|
@ -679,7 +689,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
if (isInvalidLocalHost(hostToBind)) {
|
||||
if (CollectionUtils.isNotEmpty(registryURLs)) {
|
||||
for (URL registryURL : registryURLs) {
|
||||
if (Constants.MULTICAST.equalsIgnoreCase(registryURL.getParameter("registry"))) {
|
||||
if (MULTICAST.equalsIgnoreCase(registryURL.getParameter("registry"))) {
|
||||
// skip multicast registry since we cannot connect to it via Socket
|
||||
continue;
|
||||
}
|
||||
|
|
@ -703,9 +713,9 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
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);
|
||||
String hostToRegistry = getValueFromConfig(protocolConfig, DUBBO_IP_TO_REGISTRY);
|
||||
if (hostToRegistry != null && hostToRegistry.length() > 0 && isInvalidLocalHost(hostToRegistry)) {
|
||||
throw new IllegalArgumentException("Specified invalid registry ip from property:" + Constants.DUBBO_IP_TO_REGISTRY + ", value:" + hostToRegistry);
|
||||
throw new IllegalArgumentException("Specified invalid registry ip from property:" + DUBBO_IP_TO_REGISTRY + ", value:" + hostToRegistry);
|
||||
} else if (StringUtils.isEmpty(hostToRegistry)) {
|
||||
// bind ip is used as registry ip by default
|
||||
hostToRegistry = hostToBind;
|
||||
|
|
@ -729,7 +739,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
Integer portToBind = null;
|
||||
|
||||
// parse bind port from environment
|
||||
String port = getValueFromConfig(protocolConfig, Constants.DUBBO_PORT_TO_BIND);
|
||||
String port = getValueFromConfig(protocolConfig, DUBBO_PORT_TO_BIND);
|
||||
portToBind = parsePort(port);
|
||||
|
||||
// if there's no bind port found from environment, keep looking up.
|
||||
|
|
@ -755,7 +765,7 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
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);
|
||||
String portToRegistryStr = getValueFromConfig(protocolConfig, DUBBO_PORT_TO_REGISTRY);
|
||||
Integer portToRegistry = parsePort(portToRegistryStr);
|
||||
if (portToRegistry == null) {
|
||||
portToRegistry = portToBind;
|
||||
|
|
@ -858,9 +868,9 @@ public class ServiceConfig<T> extends AbstractServiceConfig {
|
|||
if (StringUtils.isEmpty(protocolIds) && CollectionUtils.isEmpty(protocols)) {
|
||||
List<String> configedProtocols = new ArrayList<>();
|
||||
configedProtocols.addAll(getSubProperties(Environment.getInstance()
|
||||
.getExternalConfigurationMap(), Constants.PROTOCOLS_SUFFIX));
|
||||
.getExternalConfigurationMap(), PROTOCOLS_SUFFIX));
|
||||
configedProtocols.addAll(getSubProperties(Environment.getInstance()
|
||||
.getAppExternalConfigurationMap(), Constants.PROTOCOLS_SUFFIX));
|
||||
.getAppExternalConfigurationMap(), PROTOCOLS_SUFFIX));
|
||||
|
||||
protocolIds = String.join(",", configedProtocols);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,16 +16,17 @@
|
|||
*/
|
||||
package org.apache.dubbo.config.builders;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.config.ApplicationConfig;
|
||||
import org.apache.dubbo.config.MonitorConfig;
|
||||
import org.apache.dubbo.config.RegistryConfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.PRODUCTION_ENVIRONMENT;
|
||||
|
||||
/**
|
||||
* This is a builder for build {@link ApplicationConfig}.
|
||||
* @since 2.7
|
||||
|
|
@ -36,7 +37,7 @@ public class ApplicationBuilder extends AbstractBuilder<ApplicationConfig, Appli
|
|||
private String owner;
|
||||
private String organization;
|
||||
private String architecture;
|
||||
private String environment = Constants.PRODUCTION_ENVIRONMENT;
|
||||
private String environment = PRODUCTION_ENVIRONMENT;
|
||||
private String compiler;
|
||||
private String logger;
|
||||
private List<RegistryConfig> registries;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.utils.ConfigUtils;
|
||||
|
|
@ -47,6 +46,9 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_SECONDS_KEY;
|
||||
|
||||
public class AbstractInterfaceConfigTest {
|
||||
private static File dubboProperties;
|
||||
|
||||
|
|
@ -90,29 +92,29 @@ public class AbstractInterfaceConfigTest {
|
|||
public void checkApplication1() {
|
||||
try {
|
||||
ConfigUtils.setProperties(null);
|
||||
System.clearProperty(Constants.SHUTDOWN_WAIT_KEY);
|
||||
System.clearProperty(Constants.SHUTDOWN_WAIT_SECONDS_KEY);
|
||||
System.clearProperty(SHUTDOWN_WAIT_KEY);
|
||||
System.clearProperty(SHUTDOWN_WAIT_SECONDS_KEY);
|
||||
|
||||
writeDubboProperties(Constants.SHUTDOWN_WAIT_KEY, "100");
|
||||
writeDubboProperties(SHUTDOWN_WAIT_KEY, "100");
|
||||
System.setProperty("dubbo.application.name", "demo");
|
||||
InterfaceConfig interfaceConfig = new InterfaceConfig();
|
||||
interfaceConfig.checkApplication();
|
||||
ApplicationConfig appConfig = interfaceConfig.getApplication();
|
||||
Assertions.assertEquals("demo", appConfig.getName());
|
||||
Assertions.assertEquals("100", System.getProperty(Constants.SHUTDOWN_WAIT_KEY));
|
||||
Assertions.assertEquals("100", System.getProperty(SHUTDOWN_WAIT_KEY));
|
||||
|
||||
System.clearProperty(Constants.SHUTDOWN_WAIT_KEY);
|
||||
System.clearProperty(SHUTDOWN_WAIT_KEY);
|
||||
ConfigUtils.setProperties(null);
|
||||
writeDubboProperties(Constants.SHUTDOWN_WAIT_SECONDS_KEY, "1000");
|
||||
writeDubboProperties(SHUTDOWN_WAIT_SECONDS_KEY, "1000");
|
||||
System.setProperty("dubbo.application.name", "demo");
|
||||
interfaceConfig = new InterfaceConfig();
|
||||
interfaceConfig.checkApplication();
|
||||
Assertions.assertEquals("1000", System.getProperty(Constants.SHUTDOWN_WAIT_SECONDS_KEY));
|
||||
Assertions.assertEquals("1000", System.getProperty(SHUTDOWN_WAIT_SECONDS_KEY));
|
||||
} finally {
|
||||
ConfigUtils.setProperties(null);
|
||||
System.clearProperty("dubbo.application.name");
|
||||
System.clearProperty(Constants.SHUTDOWN_WAIT_KEY);
|
||||
System.clearProperty(Constants.SHUTDOWN_WAIT_SECONDS_KEY);
|
||||
System.clearProperty(SHUTDOWN_WAIT_KEY);
|
||||
System.clearProperty(SHUTDOWN_WAIT_SECONDS_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
@ -28,6 +26,8 @@ import java.util.Map;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DUMP_DIRECTORY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ACCEPT_FOREIGN_IP;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.QOS_ENABLE;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
|
@ -150,7 +150,7 @@ public class ApplicationConfigTest {
|
|||
assertThat(application.getQosEnable(), is(true));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
ApplicationConfig.appendParameters(parameters, application);
|
||||
assertThat(parameters, hasEntry(Constants.QOS_ENABLE, "true"));
|
||||
assertThat(parameters, hasEntry(QOS_ENABLE, "true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -167,7 +167,7 @@ public class ApplicationConfigTest {
|
|||
assertThat(application.getQosAcceptForeignIp(), is(true));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
ApplicationConfig.appendParameters(parameters, application);
|
||||
assertThat(parameters, hasEntry(Constants.ACCEPT_FOREIGN_IP, "true"));
|
||||
assertThat(parameters, hasEntry(ACCEPT_FOREIGN_IP, "true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -178,6 +178,6 @@ public class ApplicationConfigTest {
|
|||
parameters.put("k1", "v1");
|
||||
ApplicationConfig.appendParameters(parameters, application);
|
||||
assertThat(parameters, hasEntry("k1", "v1"));
|
||||
assertThat(parameters, hasEntry(Constants.ACCEPT_FOREIGN_IP, "true"));
|
||||
assertThat(parameters, hasEntry(ACCEPT_FOREIGN_IP, "true"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.constants.ConfigConstants;
|
||||
import org.apache.dubbo.config.annotation.Argument;
|
||||
import org.apache.dubbo.config.annotation.Method;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
|
|
@ -30,6 +30,11 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_INVOKE_INSTANCE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_RETURN_INSTANCE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_RETURN_METHOD_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_THROW_INSTANCE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_THROW_METHOD_KEY;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
|
@ -155,7 +160,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOnreturn(), equalTo((Object) "on-return-object"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_RETURN_INSTANCE_KEY, (Object) "on-return-object"));
|
||||
assertThat(attribute, hasEntry((Object) ON_RETURN_INSTANCE_KEY, (Object) "on-return-object"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
@ -168,7 +173,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOnreturnMethod(), equalTo("on-return-method"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_RETURN_METHOD_KEY, (Object) "on-return-method"));
|
||||
assertThat(attribute, hasEntry((Object) ON_RETURN_METHOD_KEY, (Object) "on-return-method"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
@ -181,7 +186,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOnthrow(), equalTo((Object) "on-throw-object"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_THROW_INSTANCE_KEY, (Object) "on-throw-object"));
|
||||
assertThat(attribute, hasEntry((Object) ON_THROW_INSTANCE_KEY, (Object) "on-throw-object"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
@ -194,7 +199,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOnthrowMethod(), equalTo("on-throw-method"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_THROW_METHOD_KEY, (Object) "on-throw-method"));
|
||||
assertThat(attribute, hasEntry((Object) ON_THROW_METHOD_KEY, (Object) "on-throw-method"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
@ -207,7 +212,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOninvoke(), equalTo((Object) "on-invoke-object"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_INVOKE_INSTANCE_KEY, (Object) "on-invoke-object"));
|
||||
assertThat(attribute, hasEntry((Object) ON_INVOKE_INSTANCE_KEY, (Object) "on-invoke-object"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
@ -220,7 +225,7 @@ public class MethodConfigTest {
|
|||
assertThat(method.getOninvokeMethod(), equalTo("on-invoke-method"));
|
||||
Map<String, Object> attribute = new HashMap<String, Object>();
|
||||
MethodConfig.appendAttributes(attribute, method);
|
||||
assertThat(attribute, hasEntry((Object) Constants.ON_INVOKE_METHOD_KEY, (Object) "on-invoke-method"));
|
||||
assertThat(attribute, hasEntry((Object) ConfigConstants.ON_INVOKE_METHOD_KEY, (Object) "on-invoke-method"));
|
||||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
MethodConfig.appendParameters(parameters, method);
|
||||
assertThat(parameters.size(), is(0));
|
||||
|
|
|
|||
|
|
@ -17,20 +17,20 @@
|
|||
|
||||
package org.apache.dubbo.config;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasEntry;
|
||||
import static org.hamcrest.Matchers.hasKey;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
public class RegistryConfigTest {
|
||||
@Test
|
||||
|
|
@ -70,9 +70,9 @@ public class RegistryConfigTest {
|
|||
RegistryConfig registry = new RegistryConfig();
|
||||
registry.setWait(10);
|
||||
assertThat(registry.getWait(), is(10));
|
||||
assertThat(System.getProperty(Constants.SHUTDOWN_WAIT_KEY), equalTo("10"));
|
||||
assertThat(System.getProperty(SHUTDOWN_WAIT_KEY), equalTo("10"));
|
||||
} finally {
|
||||
System.clearProperty(Constants.SHUTDOWN_TIMEOUT_KEY);
|
||||
System.clearProperty(SHUTDOWN_TIMEOUT_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,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;
|
||||
|
|
@ -43,16 +41,21 @@ import org.mockito.Mockito;
|
|||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.GENERIC_SERIALIZATION_BEAN;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.GENERIC_SERIALIZATION_DEFAULT;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.GENERIC_SERIALIZATION_NATIVE_JAVA;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.EXPORT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_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.RpcConstants.GENERIC_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.GENERIC_SERIALIZATION_BEAN;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.GENERIC_SERIALIZATION_DEFAULT;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.GENERIC_SERIALIZATION_NATIVE_JAVA;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
|
|
@ -140,9 +143,9 @@ public class ServiceConfigTest {
|
|||
assertThat(url.getPath(), equalTo(DemoService.class.getName()));
|
||||
assertThat(url.getParameters(), hasEntry(ANYHOST_KEY, "true"));
|
||||
assertThat(url.getParameters(), hasEntry(APPLICATION_KEY, "app"));
|
||||
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(), hasKey(BIND_IP_KEY));
|
||||
assertThat(url.getParameters(), hasKey(BIND_PORT_KEY));
|
||||
assertThat(url.getParameters(), hasEntry(EXPORT_KEY, "true"));
|
||||
assertThat(url.getParameters(), hasEntry("echo.0.callback", "false"));
|
||||
assertThat(url.getParameters(), hasEntry(GENERIC_KEY, "false"));
|
||||
assertThat(url.getParameters(), hasEntry(INTERFACE_KEY, DemoService.class.getName()));
|
||||
|
|
@ -173,14 +176,14 @@ public class ServiceConfigTest {
|
|||
@Test
|
||||
@Disabled("cannot pass in travis")
|
||||
public void testUnexport() throws Exception {
|
||||
System.setProperty(Constants.SHUTDOWN_WAIT_KEY, "0");
|
||||
System.setProperty(SHUTDOWN_WAIT_KEY, "0");
|
||||
try {
|
||||
service.export();
|
||||
service.unexport();
|
||||
Thread.sleep(1000);
|
||||
Mockito.verify(exporter, Mockito.atLeastOnce()).unexport();
|
||||
} finally {
|
||||
System.clearProperty(Constants.SHUTDOWN_TIMEOUT_KEY);
|
||||
System.clearProperty(SHUTDOWN_TIMEOUT_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.config.url;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.config.ConsumerConfig;
|
||||
|
|
@ -35,13 +34,15 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SCOPE_REMOTE;
|
||||
|
||||
|
||||
public class InvokerSideConfigUrlTest extends UrlTestBase {
|
||||
private static final Logger log = LoggerFactory.getLogger(InvokerSideConfigUrlTest.class);
|
||||
|
||||
// ======================================================
|
||||
// invoker related data preparing
|
||||
// ======================================================
|
||||
// ======================================================
|
||||
private RegistryConfig regConfForConsumer;
|
||||
private RegistryConfig regConfForReference;
|
||||
private MethodConfig methodConfForReference;
|
||||
|
|
@ -57,10 +58,10 @@ public class InvokerSideConfigUrlTest extends UrlTestBase {
|
|||
};
|
||||
|
||||
private Object regConfForConsumerTable[][] = {
|
||||
// {"timeout", "registry.timeout", "int", 5000, 9000, "", "", "", "", ""},
|
||||
// {"file", "registry.file", "string", "", "regConfForServiceTable.log", "", "", "", "", ""},
|
||||
// {"wait", "registry.wait", "int", 0, 9000, "", "", "", "", ""},
|
||||
// {"transport", "registry.transporter", "string", "netty", "mina", "", "", "", "", ""},
|
||||
// {"timeout", "registry.timeout", "int", 5000, 9000, "", "", "", "", ""},
|
||||
// {"file", "registry.file", "string", "", "regConfForServiceTable.log", "", "", "", "", ""},
|
||||
// {"wait", "registry.wait", "int", 0, 9000, "", "", "", "", ""},
|
||||
// {"transport", "registry.transporter", "string", "netty", "mina", "", "", "", "", ""},
|
||||
{"subscribe", "subscribe", "boolean", true, false, "", "", "", "", ""},
|
||||
{"dynamic", "dynamic", "boolean", true, false, "", "", "", "", ""},
|
||||
};
|
||||
|
|
@ -83,21 +84,21 @@ public class InvokerSideConfigUrlTest extends UrlTestBase {
|
|||
};
|
||||
|
||||
private Object refConfTable[][] = {
|
||||
// {"version", "version", "string", "0.0.0", "1.2.3", "", "", "", "", ""},
|
||||
// {"group", "group", "string", "", "HaominTest", "", "", "", "", ""},
|
||||
// {"version", "version", "string", "0.0.0", "1.2.3", "", "", "", "", ""},
|
||||
// {"group", "group", "string", "", "HaominTest", "", "", "", "", ""},
|
||||
|
||||
// {"delay", "delay", "int", 0, 5, "", "", "", "", ""}, // not boolean
|
||||
// {"delay", "delay", "int", 0, 5, "", "", "", "", ""}, // not boolean
|
||||
{"timeout", "timeout", "int", 5000, 3000, "", "", "", "", ""},
|
||||
{"retries", "retries", "int", 2, 5, "", "", "", "", ""},
|
||||
{"connections", "connections", "boolean", 100, 20, "", "", "", "", ""},
|
||||
{"loadbalance", "loadbalance", "string", "random", "roundrobin", "leastactive", "", "", ""},
|
||||
{"async", "async", "boolean", false, true, "", "", "", "", ""},
|
||||
//excluded = true
|
||||
// {"generic", "generic", "boolean", false, true, "", "", "", "", ""},
|
||||
// {"generic", "generic", "boolean", false, true, "", "", "", "", ""},
|
||||
{"check", "check", "boolean", false, true, "", "", "", "", ""},
|
||||
//{"local", "local", "string", "false", "HelloServiceLocal", "true", "", "", "", ""},
|
||||
//{"local", "local", "string", "false", "true", "", "", "", "", ""},
|
||||
//{"mock", "mock", "string", "false", "dubbo.test.HelloServiceMock", "true", "", "", "", ""},
|
||||
//{"local", "local", "string", "false", "HelloServiceLocal", "true", "", "", "", ""},
|
||||
//{"local", "local", "string", "false", "true", "", "", "", "", ""},
|
||||
//{"mock", "mock", "string", "false", "dubbo.test.HelloServiceMock", "true", "", "", "", ""},
|
||||
{"mock", "mock", "string", "false", "false", "", "", "", "", ""},
|
||||
{"proxy", "proxy", "boolean", "javassist", "jdk", "", "", "", "", ""},
|
||||
{"client", "client", "string", "netty", "mina", "", "", "", "", ""},
|
||||
|
|
@ -106,25 +107,25 @@ public class InvokerSideConfigUrlTest extends UrlTestBase {
|
|||
{"actives", "actives", "int", 0, 30, "", "", "", "", ""},
|
||||
{"cluster", "cluster", "string", "failover", "failfast", "failsafe", "failback", "forking", "", ""},
|
||||
//excluded = true
|
||||
// {"filter", "service.filter", "string", "default", "-generic", "", "", "", "", ""},
|
||||
// {"filter", "service.filter", "string", "default", "-generic", "", "", "", "", ""},
|
||||
//excluded = true
|
||||
// {"listener", "exporter.listener", "string", "default", "-deprecated", "", "", "", "", ""},
|
||||
//{"", "", "", "", "", "", "", "", "", ""},
|
||||
// {"listener", "exporter.listener", "string", "default", "-deprecated", "", "", "", "", ""},
|
||||
//{"", "", "", "", "", "", "", "", "", ""},
|
||||
};
|
||||
|
||||
private Object consumerConfTable[][] = {{"timeout", "timeout", "int", 5000, 8000, "", "", "", "", ""}, {"retries", "retries", "int", 2, 5, "", "", "", "", ""}, {"loadbalance", "loadbalance", "string", "random", "leastactive", "", "", "", "", ""}, {"async", "async", "boolean", false, true, "", "", "", "", ""}, {"connections", "connections", "int", 100, 5, "", "", "", "", ""},
|
||||
// {"generic", "generic", "boolean", false, false, "", "", "", "", ""},
|
||||
// {"generic", "generic", "boolean", false, false, "", "", "", "", ""},
|
||||
{"check", "check", "boolean", true, false, "", "", "", "", ""},
|
||||
{"proxy", "proxy", "string", "javassist", "jdk", "javassist", "", "", "", ""},
|
||||
{"owner", "owner", "string", "", "haomin", "", "", "", "", ""}, {"actives", "actives", "int", 0, 5, "", "", "", "", ""}, {"cluster", "cluster", "string", "failover", "forking", "", "", "", "", ""},
|
||||
{"filter", "", "string", "", "", "", "", "", "", ""},
|
||||
{"listener", "", "string", "", "", "", "", "", "", ""},
|
||||
// {"", "", "", "", "", "", "", "", "", ""},
|
||||
// {"", "", "", "", "", "", "", "", "", ""},
|
||||
};
|
||||
|
||||
// ======================================================
|
||||
// test Start
|
||||
// ======================================================
|
||||
// ======================================================
|
||||
|
||||
@BeforeAll
|
||||
public static void start() {
|
||||
|
|
@ -164,7 +165,7 @@ public class InvokerSideConfigUrlTest extends UrlTestBase {
|
|||
|
||||
// ======================================================
|
||||
// private helper
|
||||
// ======================================================
|
||||
// ======================================================
|
||||
private void initRefConf() {
|
||||
regConfForConsumer = new RegistryConfig();
|
||||
regConfForReference = new RegistryConfig();
|
||||
|
|
@ -188,7 +189,7 @@ public class InvokerSideConfigUrlTest extends UrlTestBase {
|
|||
|
||||
refConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForReference}));
|
||||
|
||||
refConf.setScope(Constants.SCOPE_REMOTE);
|
||||
refConf.setScope(SCOPE_REMOTE);
|
||||
}
|
||||
|
||||
private <T> void verifyInvokerUrlGeneration(T config, Object[][] dataTable) {
|
||||
|
|
@ -214,4 +215,4 @@ public class InvokerSideConfigUrlTest extends UrlTestBase {
|
|||
private String getSubscribedUrlString() {
|
||||
return MockRegistry.getSubscribedUrl().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.config.spring;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URLBuilder;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
|
|
@ -30,6 +29,7 @@ import java.net.ServerSocket;
|
|||
|
||||
import static org.apache.dubbo.common.constants.ClusterConstants.CLUSTER_STICKY_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.CALLBACK_INSTANCES_LIMIT_KEY;
|
||||
|
||||
/**
|
||||
|
|
@ -56,7 +56,7 @@ public class SimpleRegistryExporter {
|
|||
|
||||
public static Exporter<RegistryService> export(int port, RegistryService registryService) {
|
||||
return protocol.export(proxyFactory.getInvoker(registryService, RegistryService.class,
|
||||
new URLBuilder(Constants.DUBBO_PROTOCOL, NetUtils.getLocalHost(), port, RegistryService.class.getName())
|
||||
new URLBuilder(DUBBO_PROTOCOL, NetUtils.getLocalHost(), port, RegistryService.class.getName())
|
||||
.setPath(RegistryService.class.getName())
|
||||
.addParameter(INTERFACE_KEY, RegistryService.class.getName())
|
||||
.addParameter(CLUSTER_STICKY_KEY, "true")
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.configcenter.support.apollo;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
|
@ -43,6 +42,10 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_VALUE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_CHECK_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_CLUSTER_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_NAMESPACE_KEY;
|
||||
|
||||
/**
|
||||
* Apollo implementation, https://github.com/ctripcorp/apollo
|
||||
|
|
@ -63,7 +66,7 @@ public class ApolloDynamicConfiguration implements DynamicConfiguration {
|
|||
// Instead of using Dubbo's configuration, I would suggest use the original configuration method Apollo provides.
|
||||
String configEnv = url.getParameter(APOLLO_ENV_KEY);
|
||||
String configAddr = getAddressWithProtocolPrefix(url);
|
||||
String configCluster = url.getParameter(Constants.CONFIG_CLUSTER_KEY);
|
||||
String configCluster = url.getParameter(CONFIG_CLUSTER_KEY);
|
||||
if (configEnv != null) {
|
||||
System.setProperty(APOLLO_ENV_KEY, configEnv);
|
||||
}
|
||||
|
|
@ -74,9 +77,9 @@ public class ApolloDynamicConfiguration implements DynamicConfiguration {
|
|||
System.setProperty(APOLLO_CLUSTER_KEY, configCluster);
|
||||
}
|
||||
|
||||
dubboConfig = ConfigService.getConfig(url.getParameter(Constants.CONFIG_NAMESPACE_KEY, DEFAULT_GROUP));
|
||||
dubboConfig = ConfigService.getConfig(url.getParameter(CONFIG_NAMESPACE_KEY, DEFAULT_GROUP));
|
||||
// Decide to fail or to continue when failed to connect to remote server.
|
||||
boolean check = url.getParameter(Constants.CONFIG_CHECK_KEY, true);
|
||||
boolean check = url.getParameter(CONFIG_CHECK_KEY, true);
|
||||
if (dubboConfig.getSourceType() != ConfigSourceType.REMOTE) {
|
||||
if (check) {
|
||||
throw new IllegalStateException("Failed to connect to config center, the config center is Apollo, " +
|
||||
|
|
@ -133,7 +136,7 @@ public class ApolloDynamicConfiguration implements DynamicConfiguration {
|
|||
*/
|
||||
@Override
|
||||
public String getConfig(String key, String group, long timeout) throws IllegalStateException {
|
||||
if (StringUtils.isNotEmpty(group) && !url.getParameter(Constants.CONFIG_GROUP_KEY, DEFAULT_GROUP).equals(group)) {
|
||||
if (StringUtils.isNotEmpty(group) && !url.getParameter(CONFIG_GROUP_KEY, DEFAULT_GROUP).equals(group)) {
|
||||
Config config = ConfigService.getAppConfig();
|
||||
return config.getProperty(key, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ import java.util.concurrent.ConcurrentMap;
|
|||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import static java.util.concurrent.Executors.newCachedThreadPool;
|
||||
import static org.apache.dubbo.common.Constants.CONFIG_NAMESPACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_NAMESPACE_KEY;
|
||||
import static org.apache.dubbo.configcenter.ConfigChangeType.ADDED;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,15 +17,6 @@
|
|||
|
||||
package org.apache.dubbo.configcenter.support.etcd;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.etcd.jetcd.api.Event;
|
||||
import io.etcd.jetcd.api.WatchCancelRequest;
|
||||
import io.etcd.jetcd.api.WatchCreateRequest;
|
||||
import io.etcd.jetcd.api.WatchGrpc;
|
||||
import io.etcd.jetcd.api.WatchRequest;
|
||||
import io.etcd.jetcd.api.WatchResponse;
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.configcenter.ConfigChangeEvent;
|
||||
|
|
@ -35,12 +26,22 @@ import org.apache.dubbo.configcenter.DynamicConfiguration;
|
|||
import org.apache.dubbo.remoting.etcd.StateListener;
|
||||
import org.apache.dubbo.remoting.etcd.jetcd.JEtcdClient;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.etcd.jetcd.api.Event;
|
||||
import io.etcd.jetcd.api.WatchCancelRequest;
|
||||
import io.etcd.jetcd.api.WatchCreateRequest;
|
||||
import io.etcd.jetcd.api.WatchGrpc;
|
||||
import io.etcd.jetcd.api.WatchRequest;
|
||||
import io.etcd.jetcd.api.WatchResponse;
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.apache.dubbo.common.Constants.CONFIG_NAMESPACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_NAMESPACE_KEY;
|
||||
|
||||
/**
|
||||
* The etcd implementation of {@link DynamicConfiguration}
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ 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.RemotingConstants.BACKUP_KEY;
|
||||
import static org.apache.dubbo.common.Constants.CONFIG_NAMESPACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_CHAR_SEPERATOR;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROPERTIES_CHAR_SEPERATOR;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_NAMESPACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
|
||||
|
||||
/**
|
||||
* The nacos implementation of {@link DynamicConfiguration}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static org.apache.dubbo.common.Constants.CONFIG_NAMESPACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CONFIG_NAMESPACE_KEY;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ package org.apache.dubbo.cache.filter;
|
|||
|
||||
import org.apache.dubbo.cache.Cache;
|
||||
import org.apache.dubbo.cache.CacheFactory;
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.common.utils.ConfigUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -32,6 +30,10 @@ import org.apache.dubbo.rpc.RpcResult;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER;
|
||||
import static org.apache.dubbo.common.constants.FilterConstants.CACHE_KEY;
|
||||
|
||||
/**
|
||||
* CacheFilter is a core component of dubbo.Enabling <b>cache</b> key of service,method,consumer or provider dubbo will cache method return value.
|
||||
* Along with cache key we need to configure cache type. Dubbo default implemented cache types are
|
||||
|
|
@ -61,7 +63,7 @@ import java.io.Serializable;
|
|||
* @see org.apache.dubbo.cache.support.expiring.ExpiringCacheFactory
|
||||
* @see org.apache.dubbo.cache.support.expiring.ExpiringCache
|
||||
*/
|
||||
@Activate(group = {CommonConstants.CONSUMER, CommonConstants.PROVIDER}, value = Constants.CACHE_KEY)
|
||||
@Activate(group = {CONSUMER, PROVIDER}, value = CACHE_KEY)
|
||||
public class CacheFilter implements Filter {
|
||||
|
||||
private CacheFactory cacheFactory;
|
||||
|
|
@ -89,7 +91,7 @@ public class CacheFilter implements Filter {
|
|||
*/
|
||||
@Override
|
||||
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
|
||||
if (cacheFactory != null && ConfigUtils.isNotEmpty(invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.CACHE_KEY))) {
|
||||
if (cacheFactory != null && ConfigUtils.isNotEmpty(invoker.getUrl().getMethodParameter(invocation.getMethodName(), CACHE_KEY))) {
|
||||
Cache cache = cacheFactory.getCache(invoker.getUrl(), invocation);
|
||||
if (cache != null) {
|
||||
String key = StringUtils.toArgumentString(invocation.getArguments());
|
||||
|
|
|
|||
|
|
@ -16,11 +16,12 @@
|
|||
*/
|
||||
package org.apache.dubbo.validation;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.Adaptive;
|
||||
import org.apache.dubbo.common.extension.SPI;
|
||||
|
||||
import static org.apache.dubbo.common.constants.FilterConstants.VALIDATION_KEY;
|
||||
|
||||
/**
|
||||
* Instance of Validation interface provide instance of {@link Validator} based on the value of <b>validation</b> attribute.
|
||||
*/
|
||||
|
|
@ -32,7 +33,7 @@ public interface Validation {
|
|||
* @param url Invocation url
|
||||
* @return Instance of {@link Validator}
|
||||
*/
|
||||
@Adaptive(Constants.VALIDATION_KEY)
|
||||
@Adaptive(VALIDATION_KEY)
|
||||
Validator getValidator(URL url);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.validation.filter;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.common.utils.ConfigUtils;
|
||||
import org.apache.dubbo.rpc.Filter;
|
||||
|
|
@ -29,6 +27,10 @@ import org.apache.dubbo.rpc.RpcResult;
|
|||
import org.apache.dubbo.validation.Validation;
|
||||
import org.apache.dubbo.validation.Validator;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER;
|
||||
import static org.apache.dubbo.common.constants.FilterConstants.VALIDATION_KEY;
|
||||
|
||||
/**
|
||||
* ValidationFilter invoke the validation by finding the right {@link Validator} instance based on the
|
||||
* configured <b>validation</b> attribute value of invoker url before the actual method invocation.
|
||||
|
|
@ -56,7 +58,7 @@ import org.apache.dubbo.validation.Validator;
|
|||
* @see Filter
|
||||
* @see org.apache.dubbo.validation.support.AbstractValidation
|
||||
*/
|
||||
@Activate(group = {CommonConstants.CONSUMER, CommonConstants.PROVIDER}, value = Constants.VALIDATION_KEY, order = 10000)
|
||||
@Activate(group = {CONSUMER, PROVIDER}, value = VALIDATION_KEY, order = 10000)
|
||||
public class ValidationFilter implements Filter {
|
||||
|
||||
private Validation validation;
|
||||
|
|
@ -79,7 +81,7 @@ public class ValidationFilter implements Filter {
|
|||
@Override
|
||||
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
|
||||
if (validation != null && !invocation.getMethodName().startsWith("$")
|
||||
&& ConfigUtils.isNotEmpty(invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.VALIDATION_KEY))) {
|
||||
&& ConfigUtils.isNotEmpty(invoker.getUrl().getMethodParameter(invocation.getMethodName(), VALIDATION_KEY))) {
|
||||
try {
|
||||
Validator validator = validation.getValidator(invoker.getUrl());
|
||||
if (validator != null) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.metadata.support;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.metadata.store.MetadataReport;
|
||||
import org.apache.dubbo.metadata.store.MetadataReportFactory;
|
||||
|
|
@ -25,6 +24,9 @@ import java.util.Map;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.EXPORT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
|
||||
|
||||
/**
|
||||
*/
|
||||
public abstract class AbstractMetadataReportFactory implements MetadataReportFactory {
|
||||
|
|
@ -38,7 +40,7 @@ public abstract class AbstractMetadataReportFactory implements MetadataReportFac
|
|||
@Override
|
||||
public MetadataReport getMetadataReport(URL url) {
|
||||
url = url.setPath(MetadataReport.class.getName())
|
||||
.removeParameters(Constants.EXPORT_KEY, Constants.REFER_KEY);
|
||||
.removeParameters(EXPORT_KEY, REFER_KEY);
|
||||
String key = url.toServiceString();
|
||||
// Lock the registry access process to ensure a single instance of the registry
|
||||
LOCK.lock();
|
||||
|
|
|
|||
|
|
@ -16,18 +16,16 @@
|
|||
*/
|
||||
package org.apache.dubbo.metadata.integration;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.metadata.definition.model.FullServiceDefinition;
|
||||
import org.apache.dubbo.metadata.store.test.JTestMetadataReport4Test;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,26 +16,26 @@
|
|||
*/
|
||||
package org.apache.dubbo.metadata.store.nacos;
|
||||
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.google.gson.Gson;
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.metadata.definition.ServiceDefinitionBuilder;
|
||||
import org.apache.dubbo.metadata.definition.model.FullServiceDefinition;
|
||||
import org.apache.dubbo.metadata.identifier.MetadataIdentifier;
|
||||
|
||||
import com.alibaba.nacos.api.config.ConfigService;
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.SESSION_TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.SESSION_TIMEOUT_KEY;
|
||||
|
||||
@Disabled
|
||||
public class NacosMetadataReportTest {
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ 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.RemotingConstants.CHECK_KEY;
|
||||
import static org.apache.dubbo.common.Constants.DUBBO_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.REFERENCE_FILTER_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.RemotingConstants.CHECK_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.REFERENCE_FILTER_KEY;
|
||||
|
||||
/**
|
||||
* DefaultMonitorFactory
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.monitor.dubbo;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.URLBuilder;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
|
|
@ -30,6 +29,7 @@ import org.apache.dubbo.rpc.Protocol;
|
|||
import org.apache.dubbo.rpc.ProxyFactory;
|
||||
import org.apache.dubbo.rpc.Result;
|
||||
import org.apache.dubbo.rpc.RpcException;
|
||||
|
||||
import org.hamcrest.CustomMatcher;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -38,11 +38,12 @@ import org.mockito.ArgumentCaptor;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
|
|
@ -93,7 +94,7 @@ public class DubboMonitorTest {
|
|||
@Test
|
||||
public void testCount() throws Exception {
|
||||
DubboMonitor monitor = new DubboMonitor(monitorInvoker, monitorService);
|
||||
URL statistics = new URLBuilder(Constants.DUBBO_PROTOCOL, "10.20.153.10", 0)
|
||||
URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.10", 0)
|
||||
.addParameter(MonitorService.APPLICATION, "morgan")
|
||||
.addParameter(MonitorService.INTERFACE, "MemberService")
|
||||
.addParameter(MonitorService.METHOD, "findPerson")
|
||||
|
|
@ -129,7 +130,7 @@ public class DubboMonitorTest {
|
|||
@Test
|
||||
public void testMonitorFactory() throws Exception {
|
||||
MockMonitorService monitorService = new MockMonitorService();
|
||||
URL statistics = new URLBuilder(Constants.DUBBO_PROTOCOL, "10.20.153.10", 0)
|
||||
URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.10", 0)
|
||||
.addParameter(MonitorService.APPLICATION, "morgan")
|
||||
.addParameter(MonitorService.INTERFACE, "MemberService")
|
||||
.addParameter(MonitorService.METHOD, "findPerson")
|
||||
|
|
@ -191,7 +192,7 @@ public class DubboMonitorTest {
|
|||
|
||||
@Test
|
||||
public void testSum() {
|
||||
URL statistics = new URLBuilder(Constants.DUBBO_PROTOCOL, "10.20.153.11", 0)
|
||||
URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.11", 0)
|
||||
.addParameter(MonitorService.APPLICATION, "morgan")
|
||||
.addParameter(MonitorService.INTERFACE, "MemberService")
|
||||
.addParameter(MonitorService.METHOD, "findPerson")
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.monitor.dubbo;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.URLBuilder;
|
||||
import org.apache.dubbo.monitor.MonitorService;
|
||||
|
|
@ -24,6 +23,7 @@ import org.apache.dubbo.monitor.MonitorService;
|
|||
import org.hamcrest.MatcherAssert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
|
@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.not;
|
|||
public class StatisticsTest {
|
||||
@Test
|
||||
public void testEquals() {
|
||||
URL statistics = new URLBuilder(Constants.DUBBO_PROTOCOL, "10.20.153.10", 0)
|
||||
URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.10", 0)
|
||||
.addParameter(MonitorService.APPLICATION, "morgan")
|
||||
.addParameter(MonitorService.INTERFACE, "MemberService")
|
||||
.addParameter(MonitorService.METHOD, "findPerson")
|
||||
|
|
@ -74,7 +74,7 @@ public class StatisticsTest {
|
|||
statistics.setService("MemberService");
|
||||
assertThat(statistics.toString(), is("dubbo://10.20.153.10"));
|
||||
|
||||
Statistics statisticsWithDetailInfo = new Statistics(new URLBuilder(Constants.DUBBO_PROTOCOL, "10.20.153.10", 0)
|
||||
Statistics statisticsWithDetailInfo = new Statistics(new URLBuilder(DUBBO_PROTOCOL, "10.20.153.10", 0)
|
||||
.addParameter(MonitorService.APPLICATION, "morgan")
|
||||
.addParameter(MonitorService.INTERFACE, "MemberService")
|
||||
.addParameter(MonitorService.METHOD, "findPerson")
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ import org.apache.dubbo.rpc.RpcException;
|
|||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.apache.dubbo.common.Constants.ACCEPT_FOREIGN_IP;
|
||||
import static org.apache.dubbo.common.Constants.QOS_ENABLE;
|
||||
import static org.apache.dubbo.common.Constants.QOS_PORT;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ACCEPT_FOREIGN_IP;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.QOS_ENABLE;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.QOS_PORT;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_PROTOCOL;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.qos.protocol;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.qos.command.BaseCommand;
|
||||
import org.apache.dubbo.qos.server.Server;
|
||||
|
|
@ -28,6 +27,9 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ACCEPT_FOREIGN_IP;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.QOS_ENABLE;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.QOS_PORT;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_PROTOCOL;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
|
@ -44,9 +46,9 @@ public class QosProtocolWrapperTest {
|
|||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
when(url.getParameter(Constants.QOS_ENABLE, true)).thenReturn(true);
|
||||
when(url.getParameter(Constants.QOS_PORT, 22222)).thenReturn(12345);
|
||||
when(url.getParameter(Constants.ACCEPT_FOREIGN_IP, true)).thenReturn(false);
|
||||
when(url.getParameter(QOS_ENABLE, true)).thenReturn(true);
|
||||
when(url.getParameter(QOS_PORT, 22222)).thenReturn(12345);
|
||||
when(url.getParameter(ACCEPT_FOREIGN_IP, true)).thenReturn(false);
|
||||
when(invoker.getUrl()).thenReturn(url);
|
||||
when(url.getProtocol()).thenReturn(REGISTRY_PROTOCOL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.registry.integration;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.URLBuilder;
|
||||
import org.apache.dubbo.common.Version;
|
||||
|
|
@ -67,6 +66,8 @@ import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
|
||||
import static org.apache.dubbo.common.constants.MonitorConstants.MONITOR_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.APP_DYNAMIC_CONFIGURATORS_CATEGORY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
|
||||
|
|
@ -136,7 +137,7 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
|
|||
}
|
||||
this.serviceType = serviceType;
|
||||
this.serviceKey = url.getServiceKey();
|
||||
this.queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY));
|
||||
this.queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(REFER_KEY));
|
||||
this.overrideDirectoryUrl = this.directoryUrl = turnRegistryUrlToConsumerUrl(url);
|
||||
String group = directoryUrl.getParameter(GROUP_KEY, "");
|
||||
this.multiGroup = group != null && (ANY_VALUE.equals(group) || group.contains(","));
|
||||
|
|
@ -452,7 +453,7 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
|
|||
this.overrideDirectoryUrl = this.overrideDirectoryUrl.addParametersIfAbsent(providerUrl.getParameters()); // Merge the provider side parameters
|
||||
|
||||
if ((providerUrl.getPath() == null || providerUrl.getPath()
|
||||
.length() == 0) && Constants.DUBBO_PROTOCOL.equals(providerUrl.getProtocol())) { // Compatible version 1.0
|
||||
.length() == 0) && DUBBO_PROTOCOL.equals(providerUrl.getProtocol())) { // Compatible version 1.0
|
||||
//fix by tony.chenl DUBBO-44
|
||||
String path = directoryUrl.getParameter(INTERFACE_KEY);
|
||||
if (path != null) {
|
||||
|
|
|
|||
|
|
@ -52,13 +52,6 @@ import java.util.concurrent.ConcurrentMap;
|
|||
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.EXPORT_KEY;
|
||||
import static org.apache.dubbo.common.Constants.QOS_ENABLE;
|
||||
import static org.apache.dubbo.common.Constants.QOS_PORT;
|
||||
import static org.apache.dubbo.common.Constants.REFER_KEY;
|
||||
import static org.apache.dubbo.common.Constants.REGISTER_IP_KEY;
|
||||
import static org.apache.dubbo.common.Constants.VALIDATION_KEY;
|
||||
import static org.apache.dubbo.common.constants.ClusterConstants.LOADBALANCE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ClusterConstants.WARMUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.ClusterConstants.WEIGHT_KEY;
|
||||
|
|
@ -74,7 +67,14 @@ import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ACCEPT_FOREIGN_IP;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.CLUSTER_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.EXPORT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.QOS_ENABLE;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.QOS_PORT;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REGISTER_IP_KEY;
|
||||
import static org.apache.dubbo.common.constants.FilterConstants.VALIDATION_KEY;
|
||||
import static org.apache.dubbo.common.constants.MonitorConstants.MONITOR_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.registry.support;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.URLBuilder;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
|
|
@ -32,6 +31,8 @@ import java.util.Map;
|
|||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.EXPORT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
|
||||
|
||||
/**
|
||||
* AbstractRegistryFactory. (SPI, Singleton, ThreadSafe)
|
||||
|
|
@ -88,7 +89,7 @@ public abstract class AbstractRegistryFactory implements RegistryFactory {
|
|||
url = URLBuilder.from(url)
|
||||
.setPath(RegistryService.class.getName())
|
||||
.addParameter(INTERFACE_KEY, RegistryService.class.getName())
|
||||
.removeParameters(Constants.EXPORT_KEY, Constants.REFER_KEY)
|
||||
.removeParameters(EXPORT_KEY, REFER_KEY)
|
||||
.build();
|
||||
String key = url.toServiceStringWithoutResolving();
|
||||
// Lock the registry access process to ensure a single instance of the registry
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@
|
|||
*/
|
||||
package org.apache.dubbo.registry.dubbo;
|
||||
|
||||
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;
|
||||
|
|
@ -43,7 +41,13 @@ import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATT
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.EXPORT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.LAZY_CONNECT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMER_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.RemotingConstants.CONNECT_TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.RemotingConstants.RECONNECT_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.CALLBACK_INSTANCES_LIMIT_KEY;
|
||||
|
||||
/**
|
||||
|
|
@ -59,14 +63,14 @@ public class DubboRegistryFactory extends AbstractRegistryFactory {
|
|||
private static URL getRegistryURL(URL url) {
|
||||
return URLBuilder.from(url)
|
||||
.setPath(RegistryService.class.getName())
|
||||
.removeParameter(Constants.EXPORT_KEY).removeParameter(Constants.REFER_KEY)
|
||||
.removeParameter(EXPORT_KEY).removeParameter(REFER_KEY)
|
||||
.addParameter(INTERFACE_KEY, RegistryService.class.getName())
|
||||
.addParameter(CLUSTER_STICKY_KEY, "true")
|
||||
.addParameter(Constants.LAZY_CONNECT_KEY, "true")
|
||||
.addParameter(RemotingConstants.RECONNECT_KEY, "false")
|
||||
.addParameter(LAZY_CONNECT_KEY, "true")
|
||||
.addParameter(RECONNECT_KEY, "false")
|
||||
.addParameterIfAbsent(TIMEOUT_KEY, "10000")
|
||||
.addParameterIfAbsent(CALLBACK_INSTANCES_LIMIT_KEY, "10000")
|
||||
.addParameterIfAbsent(RemotingConstants.CONNECT_TIMEOUT_KEY, "10000")
|
||||
.addParameterIfAbsent(CONNECT_TIMEOUT_KEY, "10000")
|
||||
.addParameter(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
|
||||
|
|
@ -92,15 +96,15 @@ public class DubboRegistryFactory extends AbstractRegistryFactory {
|
|||
public Registry createRegistry(URL url) {
|
||||
url = getRegistryURL(url);
|
||||
List<URL> urls = new ArrayList<>();
|
||||
urls.add(url.removeParameter(RemotingConstants.BACKUP_KEY));
|
||||
String backup = url.getParameter(RemotingConstants.BACKUP_KEY);
|
||||
urls.add(url.removeParameter(BACKUP_KEY));
|
||||
String backup = url.getParameter(BACKUP_KEY);
|
||||
if (backup != null && backup.length() > 0) {
|
||||
String[] addresses = COMMA_SPLIT_PATTERN.split(backup);
|
||||
for (String address : addresses) {
|
||||
urls.add(url.setAddress(address));
|
||||
}
|
||||
}
|
||||
RegistryDirectory<RegistryService> directory = new RegistryDirectory<>(RegistryService.class, url.addParameter(INTERFACE_KEY, RegistryService.class.getName()).addParameterAndEncoded(Constants.REFER_KEY, url.toParameterString()));
|
||||
RegistryDirectory<RegistryService> directory = new RegistryDirectory<>(RegistryService.class, url.addParameter(INTERFACE_KEY, RegistryService.class.getName()).addParameterAndEncoded(REFER_KEY, url.toParameterString()));
|
||||
Invoker<RegistryService> registryInvoker = cluster.join(directory);
|
||||
RegistryService registryService = proxyFactory.getProxy(registryInvoker);
|
||||
DubboRegistry registry = new DubboRegistry(registryInvoker, registryService);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
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;
|
||||
|
|
@ -62,6 +61,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.DISABLED_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL;
|
||||
|
|
@ -136,7 +136,7 @@ public class RegistryDirectoryTest {
|
|||
|
||||
@Test
|
||||
public void test_Constructor_CheckStatus() throws Exception {
|
||||
URL url = URL.valueOf("notsupported://10.20.30.40/" + service + "?a=b").addParameterAndEncoded(Constants.REFER_KEY,
|
||||
URL url = URL.valueOf("notsupported://10.20.30.40/" + service + "?a=b").addParameterAndEncoded(REFER_KEY,
|
||||
"foo=bar");
|
||||
RegistryDirectory reg = getRegistryDirectory(url);
|
||||
Field field = reg.getClass().getDeclaredField("queryMap");
|
||||
|
|
@ -329,7 +329,7 @@ public class RegistryDirectoryTest {
|
|||
@Test
|
||||
public void testParametersMerge() {
|
||||
RegistryDirectory registryDirectory = getRegistryDirectory();
|
||||
URL regurl = noMeaningUrl.addParameter("test", "reg").addParameterAndEncoded(Constants.REFER_KEY,
|
||||
URL regurl = noMeaningUrl.addParameter("test", "reg").addParameterAndEncoded(REFER_KEY,
|
||||
"key=query&" + LOADBALANCE_KEY + "=" + LeastActiveLoadBalance.NAME);
|
||||
RegistryDirectory<RegistryDirectoryTest> registryDirectory2 = new RegistryDirectory(
|
||||
RegistryDirectoryTest.class,
|
||||
|
|
@ -1012,7 +1012,7 @@ public class RegistryDirectoryTest {
|
|||
@Test
|
||||
public void test_Notified_acceptProtocol1() {
|
||||
URL errorPathUrl = URL.valueOf("notsupport:/xxx");
|
||||
errorPathUrl = errorPathUrl.addParameterAndEncoded(Constants.REFER_KEY, "interface=" + service + "&protocol=dubbo");
|
||||
errorPathUrl = errorPathUrl.addParameterAndEncoded(REFER_KEY, "interface=" + service + "&protocol=dubbo");
|
||||
RegistryDirectory registryDirectory = getRegistryDirectory(errorPathUrl);
|
||||
List<URL> serviceUrls = new ArrayList<URL>();
|
||||
URL dubbo1URL = URL.valueOf("dubbo://127.0.0.1:9098?lazy=true&methods=getXXX");
|
||||
|
|
@ -1031,7 +1031,7 @@ public class RegistryDirectoryTest {
|
|||
@Test
|
||||
public void test_Notified_acceptProtocol2() {
|
||||
URL errorPathUrl = URL.valueOf("notsupport:/xxx");
|
||||
errorPathUrl = errorPathUrl.addParameterAndEncoded(Constants.REFER_KEY, "interface=" + service + "&protocol=dubbo,injvm");
|
||||
errorPathUrl = errorPathUrl.addParameterAndEncoded(REFER_KEY, "interface=" + service + "&protocol=dubbo,injvm");
|
||||
RegistryDirectory registryDirectory = getRegistryDirectory(errorPathUrl);
|
||||
List<URL> serviceUrls = new ArrayList<URL>();
|
||||
URL dubbo1URL = URL.valueOf("dubbo://127.0.0.1:9098?lazy=true&methods=getXXX");
|
||||
|
|
@ -1048,7 +1048,7 @@ public class RegistryDirectoryTest {
|
|||
|
||||
@Test
|
||||
public void test_Notified_withGroupFilter() {
|
||||
URL directoryUrl = noMeaningUrl.addParameterAndEncoded(Constants.REFER_KEY, "interface" + service + "&group=group1,group2");
|
||||
URL directoryUrl = noMeaningUrl.addParameterAndEncoded(REFER_KEY, "interface" + service + "&group=group1,group2");
|
||||
RegistryDirectory directory = this.getRegistryDirectory(directoryUrl);
|
||||
URL provider1 = URL.valueOf("dubbo://10.134.108.1:20880/" + service + "?methods=getXXX&group=group1&mock=false&application=mockApplication");
|
||||
URL provider2 = URL.valueOf("dubbo://10.134.108.1:20880/" + service + "?methods=getXXX&group=group2&mock=false&application=mockApplication");
|
||||
|
|
@ -1066,7 +1066,7 @@ public class RegistryDirectoryTest {
|
|||
Assertions.assertTrue(invokers.get(0) instanceof MockClusterInvoker);
|
||||
Assertions.assertTrue(invokers.get(1) instanceof MockClusterInvoker);
|
||||
|
||||
directoryUrl = noMeaningUrl.addParameterAndEncoded(Constants.REFER_KEY, "interface" + service + "&group=group1");
|
||||
directoryUrl = noMeaningUrl.addParameterAndEncoded(REFER_KEY, "interface" + service + "&group=group1");
|
||||
directory = this.getRegistryDirectory(directoryUrl);
|
||||
directory.notify(providers);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.registry.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.extension.ExtensionLoader;
|
||||
|
|
@ -42,6 +41,7 @@ import org.junit.jupiter.api.Test;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.EXPORT_KEY;
|
||||
import static org.apache.dubbo.registry.integration.RegistryProtocol.DEFAULT_REGISTER_PROVIDER_KEYS;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ public class RegistryProtocolTest {
|
|||
|
||||
Protocol dubboProtocol = DubboProtocol.getDubboProtocol();
|
||||
registryProtocol.setProtocol(dubboProtocol);
|
||||
URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl);
|
||||
URL newRegistryUrl = registryUrl.addParameter(EXPORT_KEY, serviceUrl);
|
||||
DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class,
|
||||
newRegistryUrl, new ExchangeClient[]{new MockedClient("10.20.20.20", 2222, true)});
|
||||
Exporter<DemoService> exporter = registryProtocol.export(invoker);
|
||||
|
|
@ -101,7 +101,7 @@ public class RegistryProtocolTest {
|
|||
|
||||
@Test
|
||||
public void testNotifyOverride() throws Exception {
|
||||
URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl);
|
||||
URL newRegistryUrl = registryUrl.addParameter(EXPORT_KEY, serviceUrl);
|
||||
Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl);
|
||||
Exporter<?> exporter = protocol.export(invoker);
|
||||
RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol();
|
||||
|
|
@ -131,7 +131,7 @@ public class RegistryProtocolTest {
|
|||
*/
|
||||
@Test
|
||||
public void testNotifyOverride_notmatch() throws Exception {
|
||||
URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl);
|
||||
URL newRegistryUrl = registryUrl.addParameter(EXPORT_KEY, serviceUrl);
|
||||
Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl);
|
||||
Exporter<?> exporter = protocol.export(invoker);
|
||||
RegistryProtocol rprotocol = RegistryProtocol.getRegistryProtocol();
|
||||
|
|
@ -150,7 +150,7 @@ public class RegistryProtocolTest {
|
|||
*/
|
||||
@Test
|
||||
public void testDestoryRegistry() {
|
||||
URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl);
|
||||
URL newRegistryUrl = registryUrl.addParameter(EXPORT_KEY, serviceUrl);
|
||||
Invoker<RegistryProtocolTest> invoker = new MockInvoker<RegistryProtocolTest>(RegistryProtocolTest.class, newRegistryUrl);
|
||||
Exporter<?> exporter = protocol.export(invoker);
|
||||
destroyRegistryProtocol();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.registry.dubbo;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URLBuilder;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
|
|
@ -30,6 +29,7 @@ import java.net.ServerSocket;
|
|||
|
||||
import static org.apache.dubbo.common.constants.ClusterConstants.CLUSTER_STICKY_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.CALLBACK_INSTANCES_LIMIT_KEY;
|
||||
|
||||
/**
|
||||
|
|
@ -57,7 +57,7 @@ public class SimpleRegistryExporter {
|
|||
|
||||
public static Exporter<RegistryService> export(int port, RegistryService registryService) {
|
||||
return protocol.export(proxyFactory.getInvoker(registryService, RegistryService.class,
|
||||
new URLBuilder(Constants.DUBBO_PROTOCOL, NetUtils.getLocalHost(), port, RegistryService.class.getName())
|
||||
new URLBuilder(DUBBO_PROTOCOL, NetUtils.getLocalHost(), port, RegistryService.class.getName())
|
||||
.setPath(RegistryService.class.getName())
|
||||
.addParameter(INTERFACE_KEY, RegistryService.class.getName())
|
||||
.addParameter(CLUSTER_STICKY_KEY, "true")
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
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;
|
||||
|
|
@ -27,6 +26,7 @@ import org.apache.dubbo.remoting.telnet.TelnetHandler;
|
|||
import org.apache.dubbo.remoting.transport.ChannelHandlerAdapter;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.TELNET;
|
||||
|
||||
public class TelnetHandlerAdapter extends ChannelHandlerAdapter implements TelnetHandler {
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ public class TelnetHandlerAdapter extends ChannelHandlerAdapter implements Telne
|
|||
}
|
||||
|
||||
private boolean commandEnabled(URL url, String command) {
|
||||
String supportCommands = url.getParameter(Constants.TELNET);
|
||||
String supportCommands = url.getParameter(TELNET);
|
||||
if (StringUtils.isEmpty(supportCommands)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -16,13 +16,14 @@
|
|||
*/
|
||||
package org.apache.dubbo.remoting.transport.grizzly;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.remoting.Server;
|
||||
import org.apache.dubbo.remoting.transport.ChannelHandlerAdapter;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.apache.dubbo.common.constants.RemotingConstants.BIND_PORT_KEY;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
|
|
@ -31,10 +32,10 @@ public class GrizzlyTransporterTest {
|
|||
public void shouldAbleToBindGrizzly() throws Exception {
|
||||
int port = NetUtils.getAvailablePort();
|
||||
URL url = new URL("http", "localhost", port,
|
||||
new String[]{Constants.BIND_PORT_KEY, String.valueOf(port)});
|
||||
new String[]{BIND_PORT_KEY, String.valueOf(port)});
|
||||
|
||||
Server server = new GrizzlyTransporter().bind(url, new ChannelHandlerAdapter());
|
||||
|
||||
assertThat(server.isBound(), is(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,13 @@
|
|||
*/
|
||||
package org.apache.dubbo.rpc;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.constants.ClusterConstants;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.constants.ConfigConstants;
|
||||
import org.apache.dubbo.common.constants.FilterConstants;
|
||||
import org.apache.dubbo.common.constants.MonitorConstants;
|
||||
import org.apache.dubbo.common.constants.RegistryConstants;
|
||||
import org.apache.dubbo.common.constants.RemotingConstants;
|
||||
|
||||
/**
|
||||
* RpcConstants
|
||||
|
|
@ -24,9 +30,10 @@ import org.apache.dubbo.common.Constants;
|
|||
* @deprecated Replace to org.apache.dubbo.common.Constants
|
||||
*/
|
||||
@Deprecated
|
||||
public final class RpcConstants extends Constants {
|
||||
public final class RpcConstants implements ClusterConstants, CommonConstants, ConfigConstants, FilterConstants,
|
||||
MonitorConstants, RegistryConstants, RemotingConstants, org.apache.dubbo.common.constants.RpcConstants {
|
||||
|
||||
private RpcConstants() {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.rpc.protocol.dubbo;
|
||||
|
||||
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;
|
||||
|
|
@ -65,16 +64,19 @@ import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.SHARE_CONNECTIONS_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.DEFAULT_SHARE_CONNECTIONS;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.LAZY_CONNECT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_CONNECT_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_DISCONNECT_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.CALLBACK_SERVICE_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.IS_CALLBACK_SERVICE;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.OPTIMIZER_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.IS_SERVER_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.STUB_EVENT_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.DEFAULT_STUB_EVENT;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.STUB_EVENT_METHODS_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.CONNECTIONS_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.DEFAULT_SHARE_CONNECTIONS;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.DEFAULT_STUB_EVENT;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.IS_CALLBACK_SERVICE;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.IS_SERVER_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.OPTIMIZER_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.SHARE_CONNECTIONS_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.STUB_EVENT_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.STUB_EVENT_METHODS_KEY;
|
||||
|
||||
/**
|
||||
* dubbo protocol support.
|
||||
|
|
@ -163,7 +165,7 @@ public class DubboProtocol extends AbstractProtocol {
|
|||
|
||||
@Override
|
||||
public void connected(Channel channel) throws RemotingException {
|
||||
invoke(channel, Constants.ON_CONNECT_KEY);
|
||||
invoke(channel, ON_CONNECT_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -171,7 +173,7 @@ public class DubboProtocol extends AbstractProtocol {
|
|||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("disconnected from " + channel.getRemoteAddress() + ",url:" + channel.getUrl());
|
||||
}
|
||||
invoke(channel, Constants.ON_DISCONNECT_KEY);
|
||||
invoke(channel, ON_DISCONNECT_KEY);
|
||||
}
|
||||
|
||||
private void invoke(Channel channel, String methodKey) {
|
||||
|
|
@ -586,7 +588,7 @@ public class DubboProtocol extends AbstractProtocol {
|
|||
ExchangeClient client;
|
||||
try {
|
||||
// connection should be lazy
|
||||
if (url.getParameter(Constants.LAZY_CONNECT_KEY, false)) {
|
||||
if (url.getParameter(LAZY_CONNECT_KEY, false)) {
|
||||
client = new LazyConnectExchangeClient(url, requestHandler);
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -17,9 +17,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;
|
||||
|
|
@ -27,15 +25,17 @@ import org.apache.dubbo.remoting.exchange.ExchangeClient;
|
|||
import org.apache.dubbo.rpc.Exporter;
|
||||
import org.apache.dubbo.rpc.ProxyFactory;
|
||||
import org.apache.dubbo.rpc.protocol.dubbo.support.ProtocolUtils;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SHUTDOWN_WAIT_KEY;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
|
|
@ -97,10 +97,10 @@ public class DubboInvokerAvilableTest {
|
|||
long start = System.currentTimeMillis();
|
||||
|
||||
try{
|
||||
System.setProperty(Constants.SHUTDOWN_WAIT_KEY, "2000");
|
||||
System.setProperty(SHUTDOWN_WAIT_KEY, "2000");
|
||||
protocol.destroy();
|
||||
}finally {
|
||||
System.getProperties().remove(Constants.SHUTDOWN_WAIT_KEY);
|
||||
System.getProperties().remove(SHUTDOWN_WAIT_KEY);
|
||||
}
|
||||
|
||||
long waitTime = System.currentTimeMillis() - start;
|
||||
|
|
@ -164,4 +164,4 @@ public class DubboInvokerAvilableTest {
|
|||
return "ok";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package org.apache.dubbo.rpc.protocol.dubbo;
|
||||
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.rpc.RpcException;
|
||||
|
|
@ -29,6 +28,8 @@ import org.junit.jupiter.api.BeforeAll;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.LAZY_CONNECT_KEY;
|
||||
|
||||
/**
|
||||
* dubbo protocol lazy connect test
|
||||
*/
|
||||
|
|
@ -57,14 +58,14 @@ public class DubboLazyConnectTest {
|
|||
|
||||
@Test
|
||||
public void testSticky2() {
|
||||
URL url = URL.valueOf("dubbo://127.0.0.1:9090/org.apache.dubbo.rpc.protocol.dubbo.IDemoService?" + Constants.LAZY_CONNECT_KEY + "=true");
|
||||
URL url = URL.valueOf("dubbo://127.0.0.1:9090/org.apache.dubbo.rpc.protocol.dubbo.IDemoService?" + LAZY_CONNECT_KEY + "=true");
|
||||
ProtocolUtils.refer(IDemoService.class, url);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSticky3() {
|
||||
Assertions.assertThrows(RpcException.class, () -> {
|
||||
URL url = URL.valueOf("dubbo://127.0.0.1:9090/org.apache.dubbo.rpc.protocol.dubbo.IDemoService?" + Constants.LAZY_CONNECT_KEY + "=true");
|
||||
URL url = URL.valueOf("dubbo://127.0.0.1:9090/org.apache.dubbo.rpc.protocol.dubbo.IDemoService?" + LAZY_CONNECT_KEY + "=true");
|
||||
IDemoService service = (IDemoService) ProtocolUtils.refer(IDemoService.class, url);
|
||||
service.get();
|
||||
});
|
||||
|
|
@ -73,7 +74,7 @@ public class DubboLazyConnectTest {
|
|||
@Test
|
||||
public void testSticky4() {
|
||||
int port = NetUtils.getAvailablePort();
|
||||
URL url = URL.valueOf("dubbo://127.0.0.1:" + port + "/org.apache.dubbo.rpc.protocol.dubbo.IDemoService?" + Constants.LAZY_CONNECT_KEY + "=true&timeout=20000");
|
||||
URL url = URL.valueOf("dubbo://127.0.0.1:" + port + "/org.apache.dubbo.rpc.protocol.dubbo.IDemoService?" + LAZY_CONNECT_KEY + "=true&timeout=20000");
|
||||
|
||||
ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
|
||||
|
||||
|
|
@ -86,4 +87,4 @@ public class DubboLazyConnectTest {
|
|||
return "ok";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.rpc.protocol.dubbo;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.rpc.Filter;
|
||||
import org.apache.dubbo.rpc.Invoker;
|
||||
|
|
@ -31,6 +30,7 @@ import org.junit.jupiter.api.Assertions;
|
|||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.ON_THROW_METHOD_KEY;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
@ -77,10 +77,10 @@ public class FutureFilterTest {
|
|||
RpcResult result = new RpcResult();
|
||||
result.setException(new RuntimeException());
|
||||
given(invoker.invoke(invocation)).willReturn(result);
|
||||
URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1&" + Constants.ON_THROW_METHOD_KEY + "=echo");
|
||||
URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1&" + ON_THROW_METHOD_KEY + "=echo");
|
||||
given(invoker.getUrl()).willReturn(url);
|
||||
|
||||
eventFilter.invoke(invoker, invocation).recreate();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package org.apache.dubbo.rpc.protocol.dubbo;
|
||||
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.rpc.Exporter;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.dubbo.rpc.protocol.injvm;
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
|
|
@ -30,6 +29,9 @@ import org.apache.dubbo.rpc.support.ProtocolUtils;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SCOPE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SCOPE_LOCAL;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SCOPE_REMOTE;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.GENERIC_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.LOCAL_PROTOCOL;
|
||||
|
||||
|
|
@ -96,13 +98,13 @@ public class InjvmProtocol extends AbstractProtocol implements Protocol {
|
|||
}
|
||||
|
||||
public boolean isInjvmRefer(URL url) {
|
||||
String scope = url.getParameter(Constants.SCOPE_KEY);
|
||||
String scope = url.getParameter(SCOPE_KEY);
|
||||
// Since injvm protocol is configured explicitly, we don't need to set any extra flag, use normal refer process.
|
||||
if (Constants.SCOPE_LOCAL.equals(scope) || (url.getParameter(LOCAL_PROTOCOL, false))) {
|
||||
if (SCOPE_LOCAL.equals(scope) || (url.getParameter(LOCAL_PROTOCOL, false))) {
|
||||
// if it's declared as local reference
|
||||
// 'scope=local' is equivalent to 'injvm=true', injvm will be deprecated in the future release
|
||||
return true;
|
||||
} else if (Constants.SCOPE_REMOTE.equals(scope)) {
|
||||
} else if (SCOPE_REMOTE.equals(scope)) {
|
||||
// it's declared as remote reference
|
||||
return false;
|
||||
} else if (url.getParameter(GENERIC_KEY, false)) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package org.apache.dubbo.rpc.protocol.injvm;
|
||||
|
||||
|
||||
import org.apache.dubbo.common.Constants;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.rpc.Exporter;
|
||||
|
|
@ -35,13 +34,15 @@ import java.util.List;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SCOPE_KEY;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SCOPE_LOCAL;
|
||||
import static org.apache.dubbo.common.constants.ConfigConstants.SCOPE_REMOTE;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.GENERIC_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.LOCAL_PROTOCOL;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.GENERIC_KEY;
|
||||
import static org.apache.dubbo.common.constants.RpcConstants.LOCAL_PROTOCOL;
|
||||
|
||||
/**
|
||||
* <code>ProxiesTest</code>
|
||||
*/
|
||||
|
|
@ -95,13 +96,13 @@ public class InjvmProtocolTest {
|
|||
.addParameter(VERSION_KEY, "*");
|
||||
assertTrue(InjvmProtocol.getInjvmProtocol().isInjvmRefer(url));
|
||||
|
||||
url = URL.valueOf("fake://127.0.0.1/TestService").addParameter(Constants.SCOPE_KEY, Constants.SCOPE_LOCAL);
|
||||
url = URL.valueOf("fake://127.0.0.1/TestService").addParameter(SCOPE_KEY, SCOPE_LOCAL);
|
||||
assertTrue(InjvmProtocol.getInjvmProtocol().isInjvmRefer(url));
|
||||
|
||||
url = URL.valueOf("fake://127.0.0.1/TestService").addParameter(LOCAL_PROTOCOL,true);
|
||||
assertTrue(InjvmProtocol.getInjvmProtocol().isInjvmRefer(url));
|
||||
|
||||
url = URL.valueOf("fake://127.0.0.1/TestService").addParameter(Constants.SCOPE_KEY, Constants.SCOPE_REMOTE);
|
||||
url = URL.valueOf("fake://127.0.0.1/TestService").addParameter(SCOPE_KEY, SCOPE_REMOTE);
|
||||
assertFalse(InjvmProtocol.getInjvmProtocol().isInjvmRefer(url));
|
||||
|
||||
url = URL.valueOf("fake://127.0.0.1/TestService").addParameter(GENERIC_KEY, true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue