parent
a0367b7da2
commit
8acf34d8e3
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.common;
|
||||
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -30,6 +30,7 @@ import java.util.Map;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY_PREFIX;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.HIDE_KEY_PREFIX;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* Parameters for backward compatibility for version prior to 2.0.5
|
||||
|
|
@ -38,7 +39,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.HIDE_KEY_PREFIX;
|
|||
*/
|
||||
@Deprecated
|
||||
public class Parameters {
|
||||
protected static final Logger logger = LoggerFactory.getLogger(Parameters.class);
|
||||
protected static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(Parameters.class);
|
||||
private final Map<String, String> parameters;
|
||||
|
||||
public Parameters(String... pairs) {
|
||||
|
|
@ -91,7 +92,7 @@ public class Parameters {
|
|||
try {
|
||||
value = URLDecoder.decode(value, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.common;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.ClassUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -32,11 +32,13 @@ import java.util.Set;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* Version
|
||||
*/
|
||||
public final class Version {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Version.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(Version.class);
|
||||
|
||||
private static final Pattern PREFIX_DIGITS_PATTERN = Pattern.compile("^([0-9]*).*");
|
||||
|
||||
|
|
@ -74,9 +76,10 @@ public final class Version {
|
|||
|
||||
/**
|
||||
* Compare versions
|
||||
*
|
||||
* @return the value {@code 0} if {@code version1 == version2};
|
||||
* a value less than {@code 0} if {@code version1 < version2}; and
|
||||
* a value greater than {@code 0} if {@code version1 > version2}
|
||||
* a value less than {@code 0} if {@code version1 < version2}; and
|
||||
* a value greater than {@code 0} if {@code version1 > version2}
|
||||
*/
|
||||
public static int compare(String version1, String version2) {
|
||||
return Integer.compare(getIntVersion(version1), getIntVersion(version2));
|
||||
|
|
@ -131,9 +134,9 @@ public final class Version {
|
|||
v = v * 100;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("Please make sure your version value has the right format: " +
|
||||
"\n 1. only contains digital number: 2.0.0; \n 2. with string suffix: 2.6.7-stable. " +
|
||||
"\nIf you are using Dubbo before v2.6.2, the version value is the same with the jar version.");
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Please make sure your version value has the right format: " +
|
||||
"\n 1. only contains digital number: 2.0.0; \n 2. with string suffix: 2.6.7-stable. " +
|
||||
"\nIf you are using Dubbo before v2.6.2, the version value is the same with the jar version.");
|
||||
v = LEGACY_DUBBO_PROTOCOL_VERSION;
|
||||
}
|
||||
VERSION2INT.put(version, v);
|
||||
|
|
@ -190,11 +193,11 @@ public final class Version {
|
|||
}
|
||||
|
||||
URL location = codeSource.getLocation();
|
||||
if (location == null){
|
||||
if (location == null) {
|
||||
logger.info("No location for class " + cls.getName() + " when getVersion, use default version " + defaultVersion);
|
||||
return defaultVersion;
|
||||
}
|
||||
String file = location.getFile();
|
||||
String file = location.getFile();
|
||||
if (!StringUtils.isEmpty(file) && file.endsWith(".jar")) {
|
||||
version = getFromFile(file);
|
||||
}
|
||||
|
|
@ -203,7 +206,7 @@ public final class Version {
|
|||
return StringUtils.isEmpty(version) ? defaultVersion : version;
|
||||
} catch (Throwable e) {
|
||||
// return default version when any exception is thrown
|
||||
logger.error("return default version, ignore exception " + e.getMessage(), e);
|
||||
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", "return default version, ignore exception " + e.getMessage(), e);
|
||||
return defaultVersion;
|
||||
}
|
||||
}
|
||||
|
|
@ -257,11 +260,11 @@ public final class Version {
|
|||
if (failOnError) {
|
||||
throw new IllegalStateException(error);
|
||||
} else {
|
||||
logger.error(error);
|
||||
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", error);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import org.apache.dubbo.common.beans.support.InstantiationStrategy;
|
|||
import org.apache.dubbo.common.extension.ExtensionAccessor;
|
||||
import org.apache.dubbo.common.extension.ExtensionAccessorAware;
|
||||
import org.apache.dubbo.common.extension.ExtensionPostProcessor;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.resource.Disposable;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -37,12 +37,14 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_DESTROY_INVOKER;
|
||||
|
||||
/**
|
||||
* A bean factory for internal sharing.
|
||||
*/
|
||||
public class ScopeBeanFactory {
|
||||
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(ScopeBeanFactory.class);
|
||||
protected static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(ScopeBeanFactory.class);
|
||||
|
||||
private final ScopeBeanFactory parent;
|
||||
private ExtensionAccessor extensionAccessor;
|
||||
|
|
@ -239,14 +241,14 @@ public class ScopeBeanFactory {
|
|||
}
|
||||
|
||||
public void destroy() {
|
||||
if (destroyed.compareAndSet(false, true)){
|
||||
if (destroyed.compareAndSet(false, true)) {
|
||||
for (BeanInfo beanInfo : registeredBeanInfos) {
|
||||
if (beanInfo.instance instanceof Disposable) {
|
||||
try {
|
||||
Disposable beanInstance = (Disposable) beanInfo.instance;
|
||||
beanInstance.destroy();
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("An error occurred when destroy bean [name=" + beanInfo.name + ", bean=" + beanInfo.instance + "]: " + e, e);
|
||||
LOGGER.error(CONFIG_FAILED_DESTROY_INVOKER, "", "", "An error occurred when destroy bean [name=" + beanInfo.name + ", bean=" + beanInfo.instance + "]: " + e, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.common.config;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.ArrayUtils;
|
||||
|
||||
|
|
@ -24,11 +24,13 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_LOAD_ENV_VARIABLE;
|
||||
|
||||
/**
|
||||
* This is an abstraction specially customized for the sequence Dubbo retrieves properties.
|
||||
*/
|
||||
public class CompositeConfiguration implements Configuration {
|
||||
private final Logger logger = LoggerFactory.getLogger(CompositeConfiguration.class);
|
||||
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(CompositeConfiguration.class);
|
||||
|
||||
/**
|
||||
* List holding all the configuration
|
||||
|
|
@ -80,7 +82,7 @@ public class CompositeConfiguration implements Configuration {
|
|||
return value;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Error when trying to get value for key " + key + " from " + config + ", " +
|
||||
logger.error(CONFIG_FAILED_LOAD_ENV_VARIABLE, "", "", "Error when trying to get value for key " + key + " from " + config + ", " +
|
||||
"will continue to try the next one.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package org.apache.dubbo.common.config;
|
|||
import org.apache.dubbo.common.config.configcenter.DynamicConfigurationFactory;
|
||||
import org.apache.dubbo.common.extension.ExtensionAccessor;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -44,6 +44,7 @@ import java.util.Set;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_SERVER_SHUTDOWN_TIMEOUT;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SHUTDOWN_WAIT_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SHUTDOWN_WAIT_SECONDS_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* Utilities for manipulating configurations from different sources
|
||||
|
|
@ -57,7 +58,7 @@ public final class ConfigurationUtils {
|
|||
throw new UnsupportedOperationException("No instance of 'ConfigurationUtils' for you! ");
|
||||
}
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ConfigurationUtils.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ConfigurationUtils.class);
|
||||
private static final List<String> securityKey;
|
||||
|
||||
static {
|
||||
|
|
@ -108,6 +109,7 @@ public final class ConfigurationUtils {
|
|||
|
||||
/**
|
||||
* Server shutdown wait timeout mills
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
@ -172,30 +174,30 @@ public final class ConfigurationUtils {
|
|||
public static Map<String, String> parseProperties(String content) throws IOException {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (StringUtils.isEmpty(content)) {
|
||||
logger.warn("Config center was specified, but no config item found.");
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Config center was specified, but no config item found.");
|
||||
} else {
|
||||
Properties properties = new Properties();
|
||||
properties.load(new StringReader(content));
|
||||
properties.stringPropertyNames().forEach(
|
||||
k -> {
|
||||
boolean deny = false;
|
||||
for (String key : securityKey) {
|
||||
if (k.contains(key)) {
|
||||
deny = true;
|
||||
break;
|
||||
}
|
||||
k -> {
|
||||
boolean deny = false;
|
||||
for (String key : securityKey) {
|
||||
if (k.contains(key)) {
|
||||
deny = true;
|
||||
break;
|
||||
}
|
||||
if (!deny) {
|
||||
map.put(k, properties.getProperty(k));
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!deny) {
|
||||
map.put(k, properties.getProperty(k));
|
||||
}
|
||||
});
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static boolean isEmptyValue(Object value) {
|
||||
return value == null ||
|
||||
value instanceof String && StringUtils.isBlank((String) value);
|
||||
value instanceof String && StringUtils.isBlank((String) value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -212,6 +214,7 @@ public final class ConfigurationUtils {
|
|||
* props: {"name": "dubbo", "port" : "1234"}
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @param configMaps
|
||||
* @param prefix
|
||||
* @param <V>
|
||||
|
|
@ -239,11 +242,11 @@ public final class ConfigurationUtils {
|
|||
}
|
||||
|
||||
if (CollectionUtils.isNotEmptyMap(configMap)) {
|
||||
Map<String,V> copy ;
|
||||
synchronized (configMap){
|
||||
Map<String, V> copy;
|
||||
synchronized (configMap) {
|
||||
copy = new HashMap<>(configMap);
|
||||
}
|
||||
for(Map.Entry<String, V> entry : copy.entrySet()) {
|
||||
for (Map.Entry<String, V> entry : copy.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
V val = entry.getValue();
|
||||
if (StringUtils.startsWithIgnoreCase(key, prefix)
|
||||
|
|
@ -280,8 +283,8 @@ public final class ConfigurationUtils {
|
|||
if (!prefix.endsWith(".")) {
|
||||
prefix += ".";
|
||||
}
|
||||
Map<String,V> copy ;
|
||||
synchronized (configMap){
|
||||
Map<String, V> copy;
|
||||
synchronized (configMap) {
|
||||
copy = new HashMap<>(configMap);
|
||||
}
|
||||
for (Map.Entry<String, V> entry : copy.entrySet()) {
|
||||
|
|
@ -319,8 +322,8 @@ public final class ConfigurationUtils {
|
|||
}
|
||||
Set<String> ids = new LinkedHashSet<>();
|
||||
for (Map<String, V> configMap : configMaps) {
|
||||
Map<String,V> copy ;
|
||||
synchronized (configMap){
|
||||
Map<String, V> copy;
|
||||
synchronized (configMap) {
|
||||
copy = new HashMap<>(configMap);
|
||||
}
|
||||
for (Map.Entry<String, V> entry : copy.entrySet()) {
|
||||
|
|
@ -357,6 +360,7 @@ public final class ConfigurationUtils {
|
|||
|
||||
/**
|
||||
* For compact single instance
|
||||
*
|
||||
* @deprecated Replaced to {@link ConfigurationUtils#getSystemConfiguration(ScopeModel)}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
@ -366,6 +370,7 @@ public final class ConfigurationUtils {
|
|||
|
||||
/**
|
||||
* For compact single instance
|
||||
*
|
||||
* @deprecated Replaced to {@link ConfigurationUtils#getEnvConfiguration(ScopeModel)}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
@ -375,6 +380,7 @@ public final class ConfigurationUtils {
|
|||
|
||||
/**
|
||||
* For compact single instance
|
||||
*
|
||||
* @deprecated Replaced to {@link ConfigurationUtils#getGlobalConfiguration(ScopeModel)}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
@ -384,6 +390,7 @@ public final class ConfigurationUtils {
|
|||
|
||||
/**
|
||||
* For compact single instance
|
||||
*
|
||||
* @deprecated Replaced to {@link ConfigurationUtils#getDynamicGlobalConfiguration(ScopeModel)}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
@ -393,6 +400,7 @@ public final class ConfigurationUtils {
|
|||
|
||||
/**
|
||||
* For compact single instance
|
||||
*
|
||||
* @deprecated Replaced to {@link ConfigurationUtils#getCachedDynamicProperty(ScopeModel, String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
@ -402,6 +410,7 @@ public final class ConfigurationUtils {
|
|||
|
||||
/**
|
||||
* For compact single instance
|
||||
*
|
||||
* @deprecated Replaced to {@link ConfigurationUtils#getDynamicProperty(ScopeModel, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
@ -411,6 +420,7 @@ public final class ConfigurationUtils {
|
|||
|
||||
/**
|
||||
* For compact single instance
|
||||
*
|
||||
* @deprecated Replaced to {@link ConfigurationUtils#getDynamicProperty(ScopeModel, String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
@ -420,6 +430,7 @@ public final class ConfigurationUtils {
|
|||
|
||||
/**
|
||||
* For compact single instance
|
||||
*
|
||||
* @deprecated Replaced to {@link ConfigurationUtils#getProperty(ScopeModel, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
@ -429,6 +440,7 @@ public final class ConfigurationUtils {
|
|||
|
||||
/**
|
||||
* For compact single instance
|
||||
*
|
||||
* @deprecated Replaced to {@link ConfigurationUtils#getProperty(ScopeModel, String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
@ -438,6 +450,7 @@ public final class ConfigurationUtils {
|
|||
|
||||
/**
|
||||
* For compact single instance
|
||||
*
|
||||
* @deprecated Replaced to {@link ConfigurationUtils#get(ScopeModel, String, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import org.apache.dubbo.common.constants.CommonConstants;
|
|||
import org.apache.dubbo.common.context.ApplicationExt;
|
||||
import org.apache.dubbo.common.context.LifecycleAdapter;
|
||||
import org.apache.dubbo.common.extension.DisableInject;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.ConfigUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -35,8 +35,10 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
|
||||
public class Environment extends LifecycleAdapter implements ApplicationExt {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Environment.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(Environment.class);
|
||||
|
||||
public static final String NAME = "environment";
|
||||
|
||||
|
|
@ -160,6 +162,7 @@ public class Environment extends LifecycleAdapter implements ApplicationExt {
|
|||
|
||||
/**
|
||||
* Merge target map properties into app configuration
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
public void updateAppConfigMap(Map<String, String> map) {
|
||||
|
|
@ -215,6 +218,7 @@ public class Environment extends LifecycleAdapter implements ApplicationExt {
|
|||
|
||||
/**
|
||||
* Get configuration map list for target instance
|
||||
*
|
||||
* @param config
|
||||
* @param prefix
|
||||
* @return
|
||||
|
|
@ -238,6 +242,7 @@ public class Environment extends LifecycleAdapter implements ApplicationExt {
|
|||
|
||||
/**
|
||||
* Get global configuration as map list
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, String>> getConfigurationMaps() {
|
||||
|
|
@ -263,7 +268,7 @@ public class Environment extends LifecycleAdapter implements ApplicationExt {
|
|||
try {
|
||||
defaultDynamicConfiguration.close();
|
||||
} catch (Exception e) {
|
||||
logger.warn("close dynamic configuration failed: " + e.getMessage(), e);
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "close dynamic configuration failed: " + e.getMessage(), e);
|
||||
}
|
||||
defaultDynamicConfiguration = null;
|
||||
}
|
||||
|
|
@ -322,7 +327,7 @@ public class Environment extends LifecycleAdapter implements ApplicationExt {
|
|||
if (defaultDynamicGlobalConfiguration == null) {
|
||||
if (defaultDynamicConfiguration == null) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("dynamicConfiguration is null , return globalConfiguration.");
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "dynamicConfiguration is null , return globalConfiguration.");
|
||||
}
|
||||
return getConfiguration();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.apache.dubbo.common.config;
|
|||
import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
|
||||
import org.apache.dubbo.common.context.ModuleExt;
|
||||
import org.apache.dubbo.common.extension.DisableInject;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.config.AbstractConfig;
|
||||
import org.apache.dubbo.rpc.model.ModuleModel;
|
||||
|
|
@ -29,11 +29,13 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
|
||||
public class ModuleEnvironment extends Environment implements ModuleExt {
|
||||
|
||||
// delegate
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ModuleEnvironment.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ModuleEnvironment.class);
|
||||
|
||||
public static final String NAME = "moduleEnvironment";
|
||||
|
||||
|
|
@ -97,7 +99,7 @@ public class ModuleEnvironment extends Environment implements ModuleExt {
|
|||
if (dynamicGlobalConfiguration == null) {
|
||||
if (dynamicConfiguration == null) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("dynamicConfiguration is null , return globalConfiguration.");
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "dynamicConfiguration is null , return globalConfiguration.");
|
||||
}
|
||||
return getConfiguration();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* The abstract implementation of {@link DynamicConfiguration}
|
||||
|
|
@ -88,14 +89,14 @@ public abstract class AbstractDynamicConfiguration implements DynamicConfigurati
|
|||
|
||||
protected AbstractDynamicConfiguration(URL url) {
|
||||
this(getThreadPoolPrefixName(url), getThreadPoolSize(url), getThreadPoolKeepAliveTime(url), getGroup(url),
|
||||
getTimeout(url));
|
||||
getTimeout(url));
|
||||
}
|
||||
|
||||
protected AbstractDynamicConfiguration(String threadPoolPrefixName,
|
||||
int threadPoolSize,
|
||||
long keepAliveTime,
|
||||
String group,
|
||||
long timeout) {
|
||||
int threadPoolSize,
|
||||
long keepAliveTime,
|
||||
String group,
|
||||
long timeout) {
|
||||
this.workersThreadPool = initWorkersThreadPool(threadPoolPrefixName, threadPoolSize, keepAliveTime);
|
||||
this.group = group;
|
||||
this.timeout = timeout;
|
||||
|
|
@ -212,7 +213,7 @@ public abstract class AbstractDynamicConfiguration implements DynamicConfigurati
|
|||
}
|
||||
} catch (Exception e) {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
|
|
@ -236,7 +237,7 @@ public abstract class AbstractDynamicConfiguration implements DynamicConfigurati
|
|||
int threadPoolSize,
|
||||
long keepAliveTime) {
|
||||
return new ThreadPoolExecutor(threadPoolSize, threadPoolSize, keepAliveTime,
|
||||
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory(threadPoolPrefixName, true));
|
||||
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory(threadPoolPrefixName, true));
|
||||
}
|
||||
|
||||
protected static String getThreadPoolPrefixName(URL url) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.common.config.configcenter.wrapper;
|
|||
|
||||
import org.apache.dubbo.common.config.configcenter.ConfigurationListener;
|
||||
import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
|
@ -26,6 +26,8 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* support multiple config center, simply iterating each concrete config center.
|
||||
*/
|
||||
|
|
@ -33,7 +35,7 @@ public class CompositeDynamicConfiguration implements DynamicConfiguration {
|
|||
|
||||
public static final String NAME = "COMPOSITE";
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompositeDynamicConfiguration.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(CompositeDynamicConfiguration.class);
|
||||
|
||||
private Set<DynamicConfiguration> configurations = new HashSet<>();
|
||||
|
||||
|
|
@ -90,7 +92,7 @@ public class CompositeDynamicConfiguration implements DynamicConfiguration {
|
|||
try {
|
||||
configuration.close();
|
||||
} catch (Exception e) {
|
||||
logger.warn("close dynamic configuration " + configuration.getClass().getName() + "failed: " + e.getMessage(), e);
|
||||
logger.warn(REGISTRY_UNEXPECTED_EXCEPTION, "", "", "close dynamic configuration " + configuration.getClass().getName() + "failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
configurations.clear();
|
||||
|
|
|
|||
|
|
@ -41,6 +41,40 @@ public interface LoggerCodeConstants {
|
|||
|
||||
String COMMON_FAILED_NOTIFY_EVENT = "0-9";
|
||||
|
||||
String COMMON_UNSUPPORTED_INVOKER = "0-10";
|
||||
|
||||
String COMMON_FAILED_STOP_HTTP_SERVER = "0-11";
|
||||
|
||||
String COMMON_UNEXPECTED_EXCEPTION = "0-12";
|
||||
|
||||
String COMMON_METRICS_COLLECTOR_EXCEPTION = "0-13";
|
||||
|
||||
String COMMON_MONITOR_EXCEPTION = "0-14";
|
||||
|
||||
String COMMON_ERROR_LOAD_EXTENSION = "0-15";
|
||||
|
||||
String COMMON_EXECUTORS_NO_FOUND = "0-16";
|
||||
|
||||
String COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN = "0-17";
|
||||
|
||||
String COMMON_ERROR_USE_THREAD_POOL = "0-18";
|
||||
|
||||
String COMMON_ERROR_RUN_THREAD_TASK = "0-19";
|
||||
|
||||
String COMMON_UNEXPECTED_CREATE_DUMP = "0-20";
|
||||
|
||||
String COMMON_ERROR_TOO_MANY_INSTANCES = "0-21";
|
||||
|
||||
String COMMON_IO_EXCEPTION = "0-22";
|
||||
|
||||
String COMMON_JSON_CONVERT_EXCEPTION = "0-23";
|
||||
|
||||
String COMMON_FAILED_OVERRIDE_FIELD = "0-24";
|
||||
|
||||
String COMMON_FAILED_LOAD_MAPPING_CACHE = "0-24";
|
||||
|
||||
String COMMON_METADATA_PROCESSOR = "0-25";
|
||||
|
||||
// registry module
|
||||
String REGISTRY_ADDRESS_INVALID = "1-1";
|
||||
|
||||
|
|
@ -110,6 +144,14 @@ public interface LoggerCodeConstants {
|
|||
|
||||
String REGISTRY_ERROR_PARSING_XDS = "1-34";
|
||||
|
||||
String REGISTRY_ZOOKEEPER_EXCEPTION = "1-35";
|
||||
|
||||
String REGISTRY_UNEXPECTED_EXCEPTION = "1-36";
|
||||
|
||||
String REGISTRY_NACOS_EXCEPTION = "1-37";
|
||||
|
||||
String REGISTRY_SOCKET_EXCEPTION = "1-38";
|
||||
|
||||
// cluster module
|
||||
String CLUSTER_FAILED_SITE_SELECTION = "2-1";
|
||||
|
||||
|
|
@ -164,6 +206,8 @@ public interface LoggerCodeConstants {
|
|||
|
||||
String PROXY_UNSUPPORTED_INVOKER = "3-6";
|
||||
|
||||
String PROXY_TIMEOUT_RESPONSE = "3-7";
|
||||
|
||||
// protocol module
|
||||
String PROTOCOL_UNSUPPORTED = "4-1";
|
||||
|
||||
|
|
@ -283,6 +327,47 @@ public interface LoggerCodeConstants {
|
|||
|
||||
String TRANSPORT_CLIENT_CONNECT_TIMEOUT = "6-2";
|
||||
|
||||
String TRANSPORT_FAILED_CLOSE = "6-3";
|
||||
|
||||
String TRANSPORT_UNEXPECTED_EXCEPTION = "6-4";
|
||||
|
||||
String TRANSPORT_FAILED_DISCONNECT_PROVIDER = "6-5";
|
||||
|
||||
String TRANSPORT_UNSUPPORTED_MESSAGE = "6-6";
|
||||
|
||||
String TRANSPORT_CONNECTION_LIMIT_EXCEED = "6-7";
|
||||
|
||||
String TRANSPORT_FAILED_DECODE = "6-8";
|
||||
|
||||
String TRANSPORT_FAILED_SERIALIZATION = "6-9";
|
||||
|
||||
String TRANSPORT_EXCEED_PAYLOAD_LIMIT = "6-10";
|
||||
|
||||
String TRANSPORT_UNSUPPORTED_CHARSET = "6-11";
|
||||
|
||||
String TRANSPORT_FAILED_DESTROY_ZOOKEEPER = "6-12";
|
||||
|
||||
String TRANSPORT_FAILED_CLOSE_STREAM = "6-13";
|
||||
|
||||
String TRANSPORT_FAILED_RESPONSE = "6-14";
|
||||
|
||||
String TRANSPORT_SKIP_UNUSED_STREAM = "6-15";
|
||||
|
||||
String TRANSPORT_FAILED_RECONNECT = "6-3";
|
||||
|
||||
// qos plugin
|
||||
String QOS_PROFILER_DISABLED = "7-1";
|
||||
|
||||
String QOS_PROFILER_ENABLED = "7-2";
|
||||
|
||||
String QOS_PROFILER_WARN_PERCENT = "7-3";
|
||||
|
||||
String QOS_FAILED_START_SERVER = "7-4";
|
||||
|
||||
String QOS_COMMAND_NOT_FOUND = "7-5";
|
||||
|
||||
String QOS_UNEXPECTED_EXCEPTION = "7-6";
|
||||
|
||||
// Internal unknown error.
|
||||
|
||||
String INTERNAL_ERROR = "99-0";
|
||||
|
|
|
|||
|
|
@ -16,13 +16,14 @@
|
|||
*/
|
||||
package org.apache.dubbo.common.deploy;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.rpc.model.ScopeModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_MONITOR_EXCEPTION;
|
||||
import static org.apache.dubbo.common.deploy.DeployState.FAILED;
|
||||
import static org.apache.dubbo.common.deploy.DeployState.PENDING;
|
||||
import static org.apache.dubbo.common.deploy.DeployState.STARTED;
|
||||
|
|
@ -32,7 +33,7 @@ import static org.apache.dubbo.common.deploy.DeployState.STOPPING;
|
|||
|
||||
public abstract class AbstractDeployer<E extends ScopeModel> implements Deployer<E> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractDeployer.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractDeployer.class);
|
||||
|
||||
private volatile DeployState state = PENDING;
|
||||
|
||||
|
|
@ -108,7 +109,7 @@ public abstract class AbstractDeployer<E extends ScopeModel> implements Deployer
|
|||
try {
|
||||
listener.onStarting(scopeModel);
|
||||
} catch (Throwable e) {
|
||||
logger.error(getIdentifier() + " an exception occurred when handle starting event", e);
|
||||
logger.error(COMMON_MONITOR_EXCEPTION, "", "", getIdentifier() + " an exception occurred when handle starting event", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -119,17 +120,18 @@ public abstract class AbstractDeployer<E extends ScopeModel> implements Deployer
|
|||
try {
|
||||
listener.onStarted(scopeModel);
|
||||
} catch (Throwable e) {
|
||||
logger.error(getIdentifier() + " an exception occurred when handle started event", e);
|
||||
logger.error(COMMON_MONITOR_EXCEPTION, "", "", getIdentifier() + " an exception occurred when handle started event", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setStopping() {
|
||||
this.state = STOPPING;
|
||||
for (DeployListener<E> listener : listeners) {
|
||||
try {
|
||||
listener.onStopping(scopeModel);
|
||||
} catch (Throwable e) {
|
||||
logger.error(getIdentifier() + " an exception occurred when handle stopping event", e);
|
||||
logger.error(COMMON_MONITOR_EXCEPTION, "", "", getIdentifier() + " an exception occurred when handle stopping event", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -140,7 +142,7 @@ public abstract class AbstractDeployer<E extends ScopeModel> implements Deployer
|
|||
try {
|
||||
listener.onStopped(scopeModel);
|
||||
} catch (Throwable e) {
|
||||
logger.error(getIdentifier() + " an exception occurred when handle stopped event", e);
|
||||
logger.error(COMMON_MONITOR_EXCEPTION, "", "", getIdentifier() + " an exception occurred when handle stopped event", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -152,7 +154,7 @@ public abstract class AbstractDeployer<E extends ScopeModel> implements Deployer
|
|||
try {
|
||||
listener.onFailure(scopeModel, error);
|
||||
} catch (Throwable e) {
|
||||
logger.error(getIdentifier() + " an exception occurred when handle failed event", e);
|
||||
logger.error(COMMON_MONITOR_EXCEPTION, "", "", getIdentifier() + " an exception occurred when handle failed event", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.apache.dubbo.common.context.Lifecycle;
|
|||
import org.apache.dubbo.common.extension.support.ActivateComparator;
|
||||
import org.apache.dubbo.common.extension.support.WrapperComparator;
|
||||
import org.apache.dubbo.common.lang.Prioritized;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.resource.Disposable;
|
||||
import org.apache.dubbo.common.utils.ArrayUtils;
|
||||
|
|
@ -80,6 +80,8 @@ import static java.util.stream.StreamSupport.stream;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.REMOVE_VALUE_PREFIX;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_ERROR_LOAD_EXTENSION;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_LOAD_ENV_VARIABLE;
|
||||
|
||||
/**
|
||||
* {@link org.apache.dubbo.rpc.model.ApplicationModel}, {@code DubboBootstrap} and this class are
|
||||
|
|
@ -101,7 +103,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.REMOVE_VALUE_PRE
|
|||
*/
|
||||
public class ExtensionLoader<T> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExtensionLoader.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ExtensionLoader.class);
|
||||
|
||||
private static final Pattern NAME_SEPARATOR = Pattern.compile("\\s*[,]+\\s*");
|
||||
private static final String SPECIAL_SPI_PROPERTIES = "special_spi.properties";
|
||||
|
|
@ -131,9 +133,9 @@ public class ExtensionLoader<T> {
|
|||
|
||||
private static volatile LoadingStrategy[] strategies = loadLoadingStrategies();
|
||||
|
||||
private static Map<String,String> specialSPILoadingStrategyMap = getSpecialSPILoadingStrategyMap();
|
||||
private static Map<String, String> specialSPILoadingStrategyMap = getSpecialSPILoadingStrategyMap();
|
||||
|
||||
private static SoftReference<Map<java.net.URL,List<String>>> urlListMapCache = new SoftReference<>(new ConcurrentHashMap<>());
|
||||
private static SoftReference<Map<java.net.URL, List<String>>> urlListMapCache = new SoftReference<>(new ConcurrentHashMap<>());
|
||||
|
||||
private static List<String> ignoredInjectMethodsDesc = getIgnoredInjectMethodsDesc();
|
||||
|
||||
|
|
@ -169,6 +171,7 @@ public class ExtensionLoader<T> {
|
|||
/**
|
||||
* some spi are implements by dubbo framework only and scan multi classloaders resources may cause
|
||||
* application startup very slow
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static Map<String, String> getSpecialSPILoadingStrategyMap() {
|
||||
|
|
@ -243,7 +246,7 @@ public class ExtensionLoader<T> {
|
|||
try {
|
||||
disposable.destroy();
|
||||
} catch (Exception e) {
|
||||
logger.error("Error destroying extension " + disposable, e);
|
||||
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Error destroying extension " + disposable, e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -257,7 +260,7 @@ public class ExtensionLoader<T> {
|
|||
try {
|
||||
disposable.destroy();
|
||||
} catch (Exception e) {
|
||||
logger.error("Error destroying extension " + disposable, e);
|
||||
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Error destroying extension " + disposable, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -875,12 +878,12 @@ public class ExtensionLoader<T> {
|
|||
method.invoke(instance, object);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to inject via method " + method.getName()
|
||||
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Failed to inject via method " + method.getName()
|
||||
+ " of interface " + type.getName() + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", e.getMessage(), e);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
|
@ -935,7 +938,7 @@ public class ExtensionLoader<T> {
|
|||
try {
|
||||
classes = loadExtensionClasses();
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("Exception occurred when loading extension class (interface: " + type + ")", e);
|
||||
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Exception occurred when loading extension class (interface: " + type + ")", e);
|
||||
throw new IllegalStateException("Exception occurred when loading extension class (interface: " + type + ")", e);
|
||||
}
|
||||
cachedClasses.set(classes);
|
||||
|
|
@ -1017,16 +1020,16 @@ public class ExtensionLoader<T> {
|
|||
}
|
||||
}
|
||||
|
||||
if (specialSPILoadingStrategyMap.containsKey(type)){
|
||||
if (specialSPILoadingStrategyMap.containsKey(type)) {
|
||||
String internalDirectoryType = specialSPILoadingStrategyMap.get(type);
|
||||
//skip to load spi when name don't match
|
||||
if (!LoadingStrategy.ALL.equals(internalDirectoryType)
|
||||
&& !internalDirectoryType.equals(loadingStrategy.getName())){
|
||||
&& !internalDirectoryType.equals(loadingStrategy.getName())) {
|
||||
return;
|
||||
}
|
||||
classLoadersToLoad.clear();
|
||||
classLoadersToLoad.add(ExtensionLoader.class.getClassLoader());
|
||||
}else {
|
||||
} else {
|
||||
// load from scope model
|
||||
Set<ClassLoader> classLoaders = scopeModel.getClassLoaders();
|
||||
|
||||
|
|
@ -1055,7 +1058,7 @@ public class ExtensionLoader<T> {
|
|||
} catch (InterruptedException e) {
|
||||
throw e;
|
||||
} catch (Throwable t) {
|
||||
logger.error("Exception occurred when loading extension class (interface: " +
|
||||
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Exception occurred when loading extension class (interface: " +
|
||||
type + ", description file: " + fileName + ").", t);
|
||||
}
|
||||
}
|
||||
|
|
@ -1095,7 +1098,7 @@ public class ExtensionLoader<T> {
|
|||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.error("Exception occurred when loading extension class (interface: " +
|
||||
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", "Exception occurred when loading extension class (interface: " +
|
||||
type + ", class file: " + resourceURL + ") in " + resourceURL, t);
|
||||
}
|
||||
}
|
||||
|
|
@ -1111,7 +1114,7 @@ public class ExtensionLoader<T> {
|
|||
}
|
||||
}
|
||||
|
||||
List<String> contentList = urlListMap.computeIfAbsent(resourceURL,key->{
|
||||
List<String> contentList = urlListMap.computeIfAbsent(resourceURL, key -> {
|
||||
List<String> newContentList = new ArrayList<>();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceURL.openStream(), StandardCharsets.UTF_8))) {
|
||||
|
|
@ -1222,7 +1225,7 @@ public class ExtensionLoader<T> {
|
|||
// duplicate implementation is unacceptable
|
||||
unacceptableExceptions.add(name);
|
||||
String duplicateMsg = "Duplicate extension " + type.getName() + " name " + name + " on " + c.getName() + " and " + clazz.getName();
|
||||
logger.error(duplicateMsg);
|
||||
logger.error(COMMON_ERROR_LOAD_EXTENSION, "", "", duplicateMsg);
|
||||
throw new IllegalStateException(duplicateMsg);
|
||||
}
|
||||
}
|
||||
|
|
@ -1360,7 +1363,7 @@ public class ExtensionLoader<T> {
|
|||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
logger.error("load properties failed.", ex);
|
||||
logger.error(CONFIG_FAILED_LOAD_ENV_VARIABLE, "", "", "load properties failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,16 +16,18 @@
|
|||
*/
|
||||
package org.apache.dubbo.common.reference;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_ERROR_CLOSE_CLIENT;
|
||||
|
||||
/**
|
||||
* inspired by Netty
|
||||
*/
|
||||
public abstract class ReferenceCountedResource implements AutoCloseable {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ReferenceCountedResource.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ReferenceCountedResource.class);
|
||||
private static final AtomicLongFieldUpdater<ReferenceCountedResource> COUNTER_UPDATER
|
||||
= AtomicLongFieldUpdater.newUpdater(ReferenceCountedResource.class, "counter");
|
||||
|
||||
|
|
@ -53,7 +55,7 @@ public abstract class ReferenceCountedResource implements AutoCloseable {
|
|||
destroy();
|
||||
return true;
|
||||
} else if (remainingCount <= -1) {
|
||||
logger.warn("This instance has been destroyed");
|
||||
logger.warn(PROTOCOL_ERROR_CLOSE_CLIENT, "", "", "This instance has been destroyed");
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.common.resource;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.NamedThreadFactory;
|
||||
|
||||
|
|
@ -26,13 +26,15 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* Global resource repository between all framework models.
|
||||
* It will be destroyed only after all framework model is destroyed.
|
||||
*/
|
||||
public class GlobalResourcesRepository {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GlobalResourcesRepository.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(GlobalResourcesRepository.class);
|
||||
|
||||
private volatile static GlobalResourcesRepository instance;
|
||||
private volatile ExecutorService executorService;
|
||||
|
|
@ -56,6 +58,7 @@ public class GlobalResourcesRepository {
|
|||
/**
|
||||
* Register a global reused disposable. The disposable will be executed when all dubbo FrameworkModels are destroyed.
|
||||
* Note: the global disposable should be registered in static code, it's reusable and will not be removed when dubbo shutdown.
|
||||
*
|
||||
* @param disposable
|
||||
*/
|
||||
public static void registerGlobalDisposable(Disposable disposable) {
|
||||
|
|
@ -107,7 +110,7 @@ public class GlobalResourcesRepository {
|
|||
try {
|
||||
disposable.destroy();
|
||||
} catch (Exception e) {
|
||||
logger.warn("destroy resources failed: " + e.getMessage(), e);
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "destroy resources failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
// clear one-off disposable
|
||||
|
|
@ -118,7 +121,7 @@ public class GlobalResourcesRepository {
|
|||
try {
|
||||
disposable.destroy();
|
||||
} catch (Exception e) {
|
||||
logger.warn("destroy resources failed: " + e.getMessage(), e);
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "destroy resources failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -129,6 +132,7 @@ public class GlobalResourcesRepository {
|
|||
|
||||
/**
|
||||
* Register a one-off disposable, the disposable is removed automatically on first shutdown.
|
||||
*
|
||||
* @param disposable
|
||||
*/
|
||||
public void registerDisposable(Disposable disposable) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.dubbo.common.system;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.MethodUtils;
|
||||
|
||||
|
|
@ -28,19 +28,21 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_CLASS_NOT_FOUND;
|
||||
|
||||
/**
|
||||
* OperatingSystemBeanManager related.
|
||||
*/
|
||||
public class OperatingSystemBeanManager {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OperatingSystemBeanManager.class);
|
||||
private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(OperatingSystemBeanManager.class);
|
||||
|
||||
/**
|
||||
* com.ibm for J9
|
||||
* com.sun for HotSpot
|
||||
*/
|
||||
private static final List<String> OPERATING_SYSTEM_BEAN_CLASS_NAMES = Arrays.asList(
|
||||
"com.sun.management.OperatingSystemMXBean", "com.ibm.lang.management.OperatingSystemMXBean");
|
||||
"com.sun.management.OperatingSystemMXBean", "com.ibm.lang.management.OperatingSystemMXBean");
|
||||
|
||||
private static final OperatingSystemMXBean OPERATING_SYSTEM_BEAN;
|
||||
|
||||
|
|
@ -57,7 +59,8 @@ public class OperatingSystemBeanManager {
|
|||
PROCESS_CPU_USAGE_METHOD = deduceMethod("getProcessCpuLoad");
|
||||
}
|
||||
|
||||
private OperatingSystemBeanManager() {}
|
||||
private OperatingSystemBeanManager() {
|
||||
}
|
||||
|
||||
public static OperatingSystemMXBean getOperatingSystemBean() {
|
||||
return OPERATING_SYSTEM_BEAN;
|
||||
|
|
@ -76,7 +79,7 @@ public class OperatingSystemBeanManager {
|
|||
try {
|
||||
return Class.forName(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
LOGGER.warn("[OperatingSystemBeanManager] Failed to load operating system bean class.", e);
|
||||
LOGGER.warn(COMMON_CLASS_NOT_FOUND, "", "", "[OperatingSystemBeanManager] Failed to load operating system bean class.", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.apache.dubbo.common.threadpool.manager;
|
|||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.ExtensionAccessor;
|
||||
import org.apache.dubbo.common.extension.ExtensionAccessorAware;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.store.DataStore;
|
||||
import org.apache.dubbo.common.threadpool.ThreadPool;
|
||||
|
|
@ -51,12 +51,15 @@ import static org.apache.dubbo.common.constants.CommonConstants.INTERNAL_EXECUTO
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_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.LoggerCodeConstants.COMMON_ERROR_USE_THREAD_POOL;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_EXECUTORS_NO_FOUND;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN;
|
||||
|
||||
/**
|
||||
* Consider implementing {@code Licycle} to enable executors shutdown when the process stops.
|
||||
*/
|
||||
public class DefaultExecutorRepository implements ExecutorRepository, ExtensionAccessorAware {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DefaultExecutorRepository.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DefaultExecutorRepository.class);
|
||||
|
||||
private volatile ScheduledExecutorService serviceExportExecutor;
|
||||
|
||||
|
|
@ -127,7 +130,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
|
|||
|
||||
}
|
||||
|
||||
if (CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(SIDE_KEY))){
|
||||
if (CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(SIDE_KEY))) {
|
||||
executorKey = CONSUMER_SHARED_EXECUTOR_SERVICE_COMPONENT_KEY;
|
||||
}
|
||||
return executorKey;
|
||||
|
|
@ -146,7 +149,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
|
|||
* have Executor instances generated and stored.
|
||||
*/
|
||||
if (executors == null) {
|
||||
logger.warn("No available executors, this is not expected, framework should call createExecutorIfAbsent first " +
|
||||
logger.warn(COMMON_EXECUTORS_NO_FOUND, "", "", "No available executors, this is not expected, framework should call createExecutorIfAbsent first" +
|
||||
"before coming to here.");
|
||||
|
||||
return null;
|
||||
|
|
@ -192,7 +195,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
|
|||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
logger.error(COMMON_ERROR_USE_THREAD_POOL, "", "", t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -218,7 +221,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
|
|||
serviceExportExecutor.shutdown();
|
||||
} catch (Throwable ignored) {
|
||||
// ignored
|
||||
logger.warn(ignored.getMessage(), ignored);
|
||||
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", ignored.getMessage(), ignored);
|
||||
}
|
||||
}
|
||||
serviceExportExecutor = null;
|
||||
|
|
@ -246,7 +249,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
|
|||
try {
|
||||
serviceReferExecutor.shutdown();
|
||||
} catch (Throwable ignored) {
|
||||
logger.warn(ignored.getMessage(), ignored);
|
||||
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", ignored.getMessage(), ignored);
|
||||
}
|
||||
}
|
||||
serviceReferExecutor = null;
|
||||
|
|
@ -331,7 +334,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
|
|||
ExecutorUtil.shutdownNow(executor, 100);
|
||||
} catch (Throwable ignored) {
|
||||
// ignored
|
||||
logger.warn(ignored.getMessage(), ignored);
|
||||
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", ignored.getMessage(), ignored);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -345,7 +348,7 @@ public class DefaultExecutorRepository implements ExecutorRepository, ExtensionA
|
|||
executorService.shutdownNow();
|
||||
} catch (Exception e) {
|
||||
String msg = "shutdown executor service [" + name + "] failed: ";
|
||||
logger.warn(msg + e.getMessage(), e);
|
||||
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", msg + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.common.threadpool.manager;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.resource.Disposable;
|
||||
import org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory;
|
||||
|
|
@ -30,8 +30,10 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN;
|
||||
|
||||
public class FrameworkExecutorRepository implements Disposable {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FrameworkExecutorRepository.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(FrameworkExecutorRepository.class);
|
||||
|
||||
private final ExecutorService sharedExecutor;
|
||||
private final ScheduledExecutorService sharedScheduledExecutor;
|
||||
|
|
@ -211,7 +213,7 @@ public class FrameworkExecutorRepository implements Disposable {
|
|||
executorService.shutdownNow();
|
||||
} catch (Exception e) {
|
||||
String msg = "shutdown executor service [" + name + "] failed: ";
|
||||
logger.warn(msg + e.getMessage(), e);
|
||||
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", msg + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.dubbo.common.threadpool.serial;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.threadlocal.InternalThreadLocal;
|
||||
|
||||
|
|
@ -26,6 +26,8 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_ERROR_RUN_THREAD_TASK;
|
||||
|
||||
/**
|
||||
* Executor ensuring that all {@link Runnable} tasks submitted are executed in order
|
||||
* using the provided {@link Executor}, and serially such that no two will ever be
|
||||
|
|
@ -33,7 +35,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
*/
|
||||
public final class SerializingExecutor implements Executor, Runnable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SerializingExecutor.class);
|
||||
private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(SerializingExecutor.class);
|
||||
|
||||
/**
|
||||
* Use false to stop and true to run
|
||||
|
|
@ -100,7 +102,7 @@ public final class SerializingExecutor implements Executor, Runnable {
|
|||
InternalThreadLocal.removeAll();
|
||||
r.run();
|
||||
} catch (RuntimeException e) {
|
||||
LOGGER.error("Exception while executing runnable " + r, e);
|
||||
LOGGER.error(COMMON_ERROR_RUN_THREAD_TASK, "", "", "Exception while executing runnable " + r, e);
|
||||
} finally {
|
||||
InternalThreadLocal.removeAll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.OS_NAME_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.OS_WIN_PREFIX;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREAD_POOL_EXHAUSTED_LISTENERS_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_THREAD_POOL_EXHAUSTED;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_CREATE_DUMP;
|
||||
|
||||
/**
|
||||
* Abort Policy.
|
||||
|
|
@ -162,7 +163,7 @@ public class AbortPolicyWithReport extends ThreadPoolExecutor.AbortPolicy {
|
|||
new File(dumpPath, "Dubbo_JStack.log" + "." + dateStr))) {
|
||||
JVMUtil.jstack(jStackStream);
|
||||
} catch (Throwable t) {
|
||||
logger.error("dump jStack error", t);
|
||||
logger.error(COMMON_UNEXPECTED_CREATE_DUMP, "", "", "dump jStack error", t);
|
||||
} finally {
|
||||
guard.release();
|
||||
}
|
||||
|
|
@ -183,7 +184,7 @@ public class AbortPolicyWithReport extends ThreadPoolExecutor.AbortPolicy {
|
|||
if (dumpDirectory.mkdirs()) {
|
||||
logger.info(format("Dubbo dump directory[%s] created", dumpDirectory.getAbsolutePath()));
|
||||
} else {
|
||||
logger.warn(format("Dubbo dump directory[%s] can't be created, use the 'user.home'[%s]",
|
||||
logger.warn(COMMON_UNEXPECTED_CREATE_DUMP, "", "", format("Dubbo dump directory[%s] can't be created, use the 'user.home'[%s]",
|
||||
dumpDirectory.getAbsolutePath(), USER_HOME));
|
||||
return USER_HOME;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.apache.dubbo.common.timer;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.ClassUtils;
|
||||
|
||||
|
|
@ -38,6 +38,8 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.OS_NAME_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.OS_WIN_PREFIX;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_ERROR_RUN_THREAD_TASK;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_ERROR_TOO_MANY_INSTANCES;
|
||||
|
||||
/**
|
||||
* A {@link Timer} optimized for approximated I/O timeout scheduling.
|
||||
|
|
@ -87,13 +89,13 @@ public class HashedWheelTimer implements Timer {
|
|||
*/
|
||||
public static final String NAME = "hased";
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HashedWheelTimer.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(HashedWheelTimer.class);
|
||||
|
||||
private static final AtomicInteger INSTANCE_COUNTER = new AtomicInteger();
|
||||
private static final AtomicBoolean WARNED_TOO_MANY_INSTANCES = new AtomicBoolean();
|
||||
private static final int INSTANCE_COUNT_LIMIT = 64;
|
||||
private static final AtomicIntegerFieldUpdater<HashedWheelTimer> WORKER_STATE_UPDATER =
|
||||
AtomicIntegerFieldUpdater.newUpdater(HashedWheelTimer.class, "workerState");
|
||||
AtomicIntegerFieldUpdater.newUpdater(HashedWheelTimer.class, "workerState");
|
||||
|
||||
private final Worker worker = new Worker();
|
||||
private final Thread workerThread;
|
||||
|
|
@ -181,7 +183,7 @@ public class HashedWheelTimer implements Timer {
|
|||
* @throws IllegalArgumentException if {@code tickDuration} is <= 0
|
||||
*/
|
||||
public HashedWheelTimer(
|
||||
ThreadFactory threadFactory, long tickDuration, TimeUnit unit) {
|
||||
ThreadFactory threadFactory, long tickDuration, TimeUnit unit) {
|
||||
this(threadFactory, tickDuration, unit, 512);
|
||||
}
|
||||
|
||||
|
|
@ -198,8 +200,8 @@ public class HashedWheelTimer implements Timer {
|
|||
* @throws IllegalArgumentException if either of {@code tickDuration} and {@code ticksPerWheel} is <= 0
|
||||
*/
|
||||
public HashedWheelTimer(
|
||||
ThreadFactory threadFactory,
|
||||
long tickDuration, TimeUnit unit, int ticksPerWheel) {
|
||||
ThreadFactory threadFactory,
|
||||
long tickDuration, TimeUnit unit, int ticksPerWheel) {
|
||||
this(threadFactory, tickDuration, unit, ticksPerWheel, -1);
|
||||
}
|
||||
|
||||
|
|
@ -221,9 +223,9 @@ public class HashedWheelTimer implements Timer {
|
|||
* @throws IllegalArgumentException if either of {@code tickDuration} and {@code ticksPerWheel} is <= 0
|
||||
*/
|
||||
public HashedWheelTimer(
|
||||
ThreadFactory threadFactory,
|
||||
long tickDuration, TimeUnit unit, int ticksPerWheel,
|
||||
long maxPendingTimeouts) {
|
||||
ThreadFactory threadFactory,
|
||||
long tickDuration, TimeUnit unit, int ticksPerWheel,
|
||||
long maxPendingTimeouts) {
|
||||
|
||||
if (threadFactory == null) {
|
||||
throw new NullPointerException("threadFactory");
|
||||
|
|
@ -248,15 +250,15 @@ public class HashedWheelTimer implements Timer {
|
|||
// Prevent overflow.
|
||||
if (this.tickDuration >= Long.MAX_VALUE / wheel.length) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"tickDuration: %d (expected: 0 < tickDuration in nanos < %d",
|
||||
tickDuration, Long.MAX_VALUE / wheel.length));
|
||||
"tickDuration: %d (expected: 0 < tickDuration in nanos < %d",
|
||||
tickDuration, Long.MAX_VALUE / wheel.length));
|
||||
}
|
||||
workerThread = threadFactory.newThread(worker);
|
||||
|
||||
this.maxPendingTimeouts = maxPendingTimeouts;
|
||||
|
||||
if (INSTANCE_COUNTER.incrementAndGet() > INSTANCE_COUNT_LIMIT &&
|
||||
WARNED_TOO_MANY_INSTANCES.compareAndSet(false, true)) {
|
||||
WARNED_TOO_MANY_INSTANCES.compareAndSet(false, true)) {
|
||||
reportTooManyInstances();
|
||||
}
|
||||
}
|
||||
|
|
@ -277,11 +279,11 @@ public class HashedWheelTimer implements Timer {
|
|||
private static HashedWheelBucket[] createWheel(int ticksPerWheel) {
|
||||
if (ticksPerWheel <= 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"ticksPerWheel must be greater than 0: " + ticksPerWheel);
|
||||
"ticksPerWheel must be greater than 0: " + ticksPerWheel);
|
||||
}
|
||||
if (ticksPerWheel > 1073741824) {
|
||||
throw new IllegalArgumentException(
|
||||
"ticksPerWheel may not be greater than 2^30: " + ticksPerWheel);
|
||||
"ticksPerWheel may not be greater than 2^30: " + ticksPerWheel);
|
||||
}
|
||||
|
||||
ticksPerWheel = normalizeTicksPerWheel(ticksPerWheel);
|
||||
|
|
@ -338,9 +340,9 @@ public class HashedWheelTimer implements Timer {
|
|||
public Set<Timeout> stop() {
|
||||
if (Thread.currentThread() == workerThread) {
|
||||
throw new IllegalStateException(
|
||||
HashedWheelTimer.class.getSimpleName() +
|
||||
".stop() cannot be called from " +
|
||||
TimerTask.class.getSimpleName());
|
||||
HashedWheelTimer.class.getSimpleName() +
|
||||
".stop() cannot be called from " +
|
||||
TimerTask.class.getSimpleName());
|
||||
}
|
||||
|
||||
if (!WORKER_STATE_UPDATER.compareAndSet(this, WORKER_STATE_STARTED, WORKER_STATE_SHUTDOWN)) {
|
||||
|
|
@ -391,8 +393,8 @@ public class HashedWheelTimer implements Timer {
|
|||
if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) {
|
||||
pendingTimeouts.decrementAndGet();
|
||||
throw new RejectedExecutionException("Number of pending timeouts ("
|
||||
+ pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending "
|
||||
+ "timeouts (" + maxPendingTimeouts + ")");
|
||||
+ pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending "
|
||||
+ "timeouts (" + maxPendingTimeouts + ")");
|
||||
}
|
||||
|
||||
start();
|
||||
|
|
@ -419,9 +421,9 @@ public class HashedWheelTimer implements Timer {
|
|||
|
||||
private static void reportTooManyInstances() {
|
||||
String resourceType = ClassUtils.simpleClassName(HashedWheelTimer.class);
|
||||
logger.error("You are creating too many " + resourceType + " instances. " +
|
||||
resourceType + " is a shared resource that must be reused across the JVM," +
|
||||
"so that only a few instances are created.");
|
||||
logger.error(COMMON_ERROR_TOO_MANY_INSTANCES, "", "", "You are creating too many " + resourceType + " instances. " +
|
||||
resourceType + " is a shared resource that must be reused across the JVM," +
|
||||
"so that only a few instances are created.");
|
||||
}
|
||||
|
||||
private final class Worker implements Runnable {
|
||||
|
|
@ -447,7 +449,7 @@ public class HashedWheelTimer implements Timer {
|
|||
int idx = (int) (tick & mask);
|
||||
processCancelledTasks();
|
||||
HashedWheelBucket bucket =
|
||||
wheel[idx];
|
||||
wheel[idx];
|
||||
transferTimeoutsToBuckets();
|
||||
bucket.expireTimeouts(deadline);
|
||||
tick++;
|
||||
|
|
@ -507,7 +509,7 @@ public class HashedWheelTimer implements Timer {
|
|||
timeout.remove();
|
||||
} catch (Throwable t) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("An exception was thrown while process a cancellation task", t);
|
||||
logger.warn(COMMON_ERROR_RUN_THREAD_TASK, "", "", "An exception was thrown while process a cancellation task", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -559,7 +561,7 @@ public class HashedWheelTimer implements Timer {
|
|||
private static final int ST_CANCELLED = 1;
|
||||
private static final int ST_EXPIRED = 2;
|
||||
private static final AtomicIntegerFieldUpdater<HashedWheelTimeout> STATE_UPDATER =
|
||||
AtomicIntegerFieldUpdater.newUpdater(HashedWheelTimeout.class, "state");
|
||||
AtomicIntegerFieldUpdater.newUpdater(HashedWheelTimeout.class, "state");
|
||||
|
||||
private final HashedWheelTimer timer;
|
||||
private final TimerTask task;
|
||||
|
|
@ -651,7 +653,7 @@ public class HashedWheelTimer implements Timer {
|
|||
task.run(this);
|
||||
} catch (Throwable t) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("An exception was thrown by " + TimerTask.class.getSimpleName() + '.', t);
|
||||
logger.warn(COMMON_ERROR_RUN_THREAD_TASK, "", "", "An exception was thrown by " + TimerTask.class.getSimpleName() + '.', t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -663,15 +665,15 @@ public class HashedWheelTimer implements Timer {
|
|||
String simpleClassName = ClassUtils.simpleClassName(this.getClass());
|
||||
|
||||
StringBuilder buf = new StringBuilder(192)
|
||||
.append(simpleClassName)
|
||||
.append('(')
|
||||
.append("deadline: ");
|
||||
.append(simpleClassName)
|
||||
.append('(')
|
||||
.append("deadline: ");
|
||||
if (remaining > 0) {
|
||||
buf.append(remaining)
|
||||
.append(" ns later");
|
||||
.append(" ns later");
|
||||
} else if (remaining < 0) {
|
||||
buf.append(-remaining)
|
||||
.append(" ns ago");
|
||||
.append(" ns ago");
|
||||
} else {
|
||||
buf.append("now");
|
||||
}
|
||||
|
|
@ -681,9 +683,9 @@ public class HashedWheelTimer implements Timer {
|
|||
}
|
||||
|
||||
return buf.append(", task: ")
|
||||
.append(task())
|
||||
.append(')')
|
||||
.toString();
|
||||
.append(task())
|
||||
.append(')')
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -731,7 +733,7 @@ public class HashedWheelTimer implements Timer {
|
|||
} else {
|
||||
// The timeout was placed into a wrong slot. This should never happen.
|
||||
throw new IllegalStateException(String.format(
|
||||
"timeout.deadline (%d) > deadline (%d)", timeout.deadline, deadline));
|
||||
"timeout.deadline (%d) > deadline (%d)", timeout.deadline, deadline));
|
||||
}
|
||||
} else if (timeout.isCancelled()) {
|
||||
next = remove(timeout);
|
||||
|
|
@ -808,9 +810,9 @@ public class HashedWheelTimer implements Timer {
|
|||
return head;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final boolean IS_OS_WINDOWS = System.getProperty(OS_NAME_KEY, "").toLowerCase(Locale.US).contains(OS_WIN_PREFIX);
|
||||
|
||||
|
||||
private boolean isWindows() {
|
||||
return IS_OS_WINDOWS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.apache.dubbo.common.config.Configuration;
|
|||
import org.apache.dubbo.common.config.InmemoryConfiguration;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.ExtensionDirector;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
@ -46,10 +46,11 @@ import java.util.regex.Pattern;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.REMOVE_VALUE_PREFIX;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_IO_EXCEPTION;
|
||||
|
||||
public class ConfigUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ConfigUtils.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ConfigUtils.class);
|
||||
private static Pattern VARIABLE_PATTERN = Pattern.compile(
|
||||
"\\$\\s*\\{?\\s*([\\._0-9a-zA-Z]+)\\s*\\}?");
|
||||
private static int PID = -1;
|
||||
|
|
@ -136,7 +137,7 @@ public class ConfigUtils {
|
|||
}
|
||||
|
||||
public static String replaceProperty(String expression, Configuration configuration) {
|
||||
if (StringUtils.isEmpty(expression)|| expression.indexOf('$') < 0) {
|
||||
if (StringUtils.isEmpty(expression) || expression.indexOf('$') < 0) {
|
||||
return expression;
|
||||
}
|
||||
Matcher matcher = VARIABLE_PATTERN.matcher(expression);
|
||||
|
|
@ -221,7 +222,7 @@ public class ConfigUtils {
|
|||
input.close();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warn("Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
|
||||
logger.warn(COMMON_IO_EXCEPTION, "", "", "Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
|
@ -236,12 +237,12 @@ public class ConfigUtils {
|
|||
return a;
|
||||
});
|
||||
} catch (Throwable t) {
|
||||
logger.warn("Fail to load " + fileName + " file: " + t.getMessage(), t);
|
||||
logger.warn(COMMON_IO_EXCEPTION, "", "", "Fail to load " + fileName + " file: " + t.getMessage(), t);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(set)) {
|
||||
if (!optional) {
|
||||
logger.warn("No " + fileName + " found on the class path.");
|
||||
logger.warn(COMMON_IO_EXCEPTION, "", "", "No " + fileName + " found on the class path.");
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
|
@ -250,14 +251,14 @@ public class ConfigUtils {
|
|||
if (set.size() > 1) {
|
||||
String errMsg = String.format("only 1 %s file is expected, but %d dubbo.properties files found on class path: %s",
|
||||
fileName, set.size(), set);
|
||||
logger.warn(errMsg);
|
||||
logger.warn(COMMON_IO_EXCEPTION, "", "", errMsg);
|
||||
}
|
||||
|
||||
// fall back to use method getResourceAsStream
|
||||
try {
|
||||
properties.load(ClassUtils.getClassLoader().getResourceAsStream(fileName));
|
||||
} catch (Throwable e) {
|
||||
logger.warn("Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
|
||||
logger.warn(COMMON_IO_EXCEPTION, "", "", "Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
|
@ -280,7 +281,7 @@ public class ConfigUtils {
|
|||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warn("Fail to load " + fileName + " file from " + url + "(ignore this file): " + e.getMessage(), e);
|
||||
logger.warn(COMMON_IO_EXCEPTION, "", "", "Fail to load " + fileName + " file from " + url + "(ignore this file): " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +296,7 @@ public class ConfigUtils {
|
|||
return readString(input);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warn("Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
|
||||
logger.warn(COMMON_IO_EXCEPTION, "", "", "Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +313,7 @@ public class ConfigUtils {
|
|||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warn("Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
|
||||
logger.warn(COMMON_IO_EXCEPTION, "", "", "Failed to load " + fileName + " file from " + fileName + "(ignore this file): " + e.getMessage(), e);
|
||||
}
|
||||
return rawRule;
|
||||
}
|
||||
|
|
@ -330,7 +331,7 @@ public class ConfigUtils {
|
|||
buffer = new char[10];
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error("Read migration file error.", e);
|
||||
logger.error(COMMON_IO_EXCEPTION, "", "", "Read migration file error.", e);
|
||||
}
|
||||
|
||||
return stringBuilder.toString();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.common.utils;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
|
@ -28,13 +28,14 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN;
|
||||
|
||||
public class ExecutorUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExecutorUtil.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ExecutorUtil.class);
|
||||
private static final ThreadPoolExecutor SHUTDOWN_EXECUTOR = new ThreadPoolExecutor(0, 1,
|
||||
0L, TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(100),
|
||||
new NamedThreadFactory("Close-ExecutorService-Timer", true));
|
||||
0L, TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(100),
|
||||
new NamedThreadFactory("Close-ExecutorService-Timer", true));
|
||||
|
||||
public static boolean isTerminated(Executor executor) {
|
||||
if (executor instanceof ExecutorService) {
|
||||
|
|
@ -110,7 +111,7 @@ public class ExecutorUtil {
|
|||
} catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(COMMON_UNEXPECTED_EXECUTORS_SHUTDOWN, "", "", e.getMessage(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,23 +17,24 @@
|
|||
|
||||
package org.apache.dubbo.common.utils;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* MD5 util.
|
||||
*/
|
||||
public class MD5Utils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MD5Utils.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(MD5Utils.class);
|
||||
|
||||
private static final char[] hexDigits = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
|
||||
};
|
||||
|
||||
private MessageDigest mdInst;
|
||||
|
|
@ -42,12 +43,13 @@ public class MD5Utils {
|
|||
try {
|
||||
mdInst = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
logger.error("Failed to obtain md5", e);
|
||||
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", "Failed to obtain md5", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculation md5 value of specify string
|
||||
*
|
||||
* @param input
|
||||
*/
|
||||
public String getMd5(String input) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.common.utils;
|
|||
|
||||
import org.apache.dubbo.common.config.ConfigurationUtils;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
|
@ -58,6 +58,7 @@ import java.util.concurrent.ConcurrentSkipListMap;
|
|||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_REFLECT;
|
||||
import static org.apache.dubbo.common.utils.ClassUtils.isAssignableFrom;
|
||||
|
||||
/**
|
||||
|
|
@ -71,12 +72,12 @@ import static org.apache.dubbo.common.utils.ClassUtils.isAssignableFrom;
|
|||
* </ul>
|
||||
* <p/>
|
||||
* Other type will be covert to a map which contains the attributes and value pair of object.
|
||||
*
|
||||
* <p>
|
||||
* TODO: exact PojoUtils to scope bean
|
||||
*/
|
||||
public class PojoUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PojoUtils.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(PojoUtils.class);
|
||||
private static final ConcurrentMap<String, Method> NAME_METHODS_CACHE = new ConcurrentHashMap<String, Method>();
|
||||
private static final ConcurrentMap<Class<?>, ConcurrentMap<String, Field>> CLASS_FIELD_CACHE = new ConcurrentHashMap<Class<?>, ConcurrentMap<String, Field>>();
|
||||
|
||||
|
|
@ -144,7 +145,7 @@ public class PojoUtils {
|
|||
if (ReflectUtils.isPrimitives(pojo.getClass())) {
|
||||
return pojo;
|
||||
}
|
||||
|
||||
|
||||
if (pojo instanceof LocalDate || pojo instanceof LocalDateTime || pojo instanceof LocalTime) {
|
||||
return pojo.toString();
|
||||
}
|
||||
|
|
@ -525,7 +526,7 @@ public class PojoUtils {
|
|||
} catch (Exception e) {
|
||||
String exceptionDescription = "Failed to set pojo " + dest.getClass().getSimpleName() + " property " + name
|
||||
+ " value " + value.getClass() + ", cause: " + e.getMessage();
|
||||
logger.error(exceptionDescription, e);
|
||||
logger.error(COMMON_FAILED_REFLECT, "", "", exceptionDescription, e);
|
||||
throw new RuntimeException(exceptionDescription, e);
|
||||
}
|
||||
} else if (field != null) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.apache.dubbo.common.utils;
|
|||
import org.apache.dubbo.common.beanutil.JavaBeanSerializeUtil;
|
||||
import org.apache.dubbo.common.config.ConfigurationUtils;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -32,9 +32,11 @@ import static org.apache.dubbo.common.constants.CommonConstants.CLASS_DESERIALIZ
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.CLASS_DESERIALIZE_BLOCKED_LIST;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.CLASS_DESERIALIZE_BLOCK_ALL;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SERIALIZE_BLOCKED_LIST_FILE_PATH;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_IO_EXCEPTION;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_UNSAFE_SERIALIZATION;
|
||||
|
||||
public class SerializeClassChecker {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SerializeClassChecker.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SerializeClassChecker.class);
|
||||
|
||||
private static volatile SerializeClassChecker INSTANCE = null;
|
||||
|
||||
|
|
@ -54,7 +56,7 @@ public class SerializeClassChecker {
|
|||
OPEN_CHECK_CLASS = Boolean.parseBoolean(openCheckClass);
|
||||
|
||||
String blockAllClassExceptAllow = ConfigurationUtils.getProperty(CLASS_DESERIALIZE_BLOCK_ALL, "false");
|
||||
|
||||
|
||||
BLOCK_ALL_CLASS_EXCEPT_ALLOW = Boolean.parseBoolean(blockAllClassExceptAllow);
|
||||
|
||||
String[] lines;
|
||||
|
|
@ -74,7 +76,7 @@ public class SerializeClassChecker {
|
|||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error("Failed to load blocked class list! Will ignore default blocked list.", e);
|
||||
logger.error(COMMON_IO_EXCEPTION, "", "", "Failed to load blocked class list! Will ignore default blocked list.", e);
|
||||
}
|
||||
|
||||
String allowedClassList = ConfigurationUtils.getProperty(CLASS_DESERIALIZE_ALLOWED_LIST, "").trim().toLowerCase(Locale.ROOT);
|
||||
|
|
@ -114,11 +116,11 @@ public class SerializeClassChecker {
|
|||
/**
|
||||
* Check if a class is in block list, using prefix match
|
||||
*
|
||||
* @throws IllegalArgumentException if class is blocked
|
||||
* @param name class name ( all are convert to lower case )
|
||||
* @throws IllegalArgumentException if class is blocked
|
||||
*/
|
||||
public void validateClass(String name) {
|
||||
if(!OPEN_CHECK_CLASS){
|
||||
if (!OPEN_CHECK_CLASS) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -150,14 +152,14 @@ public class SerializeClassChecker {
|
|||
|
||||
private void error(String name) {
|
||||
String notice = "Trigger the safety barrier! " +
|
||||
"Catch not allowed serialize class. " +
|
||||
"Class name: " + name + " . " +
|
||||
"This means currently maybe being attacking by others." +
|
||||
"If you are sure this is a mistake, " +
|
||||
"please add this class name to `" + CLASS_DESERIALIZE_ALLOWED_LIST +
|
||||
"` as a system environment property.";
|
||||
"Catch not allowed serialize class. " +
|
||||
"Class name: " + name + " . " +
|
||||
"This means currently maybe being attacking by others." +
|
||||
"If you are sure this is a mistake, " +
|
||||
"please add this class name to `" + CLASS_DESERIALIZE_ALLOWED_LIST +
|
||||
"` as a system environment property.";
|
||||
if (counter.incrementAndGet() % 1000 == 0 || counter.get() < 100) {
|
||||
logger.error(notice);
|
||||
logger.error(PROTOCOL_UNSAFE_SERIALIZATION, "", "", notice);
|
||||
}
|
||||
throw new IllegalArgumentException(notice);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.common.utils;
|
||||
|
||||
import org.apache.dubbo.common.io.UnsafeStringWriter;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
|
@ -46,6 +46,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.SEPARATOR_REGEX;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.UNDERLINE_SEPARATOR;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_JSON_CONVERT_EXCEPTION;
|
||||
|
||||
/**
|
||||
* StringUtils
|
||||
|
|
@ -57,7 +58,7 @@ public final class StringUtils {
|
|||
public static final int INDEX_NOT_FOUND = -1;
|
||||
public static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StringUtils.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(StringUtils.class);
|
||||
private static final Pattern KVP_PATTERN = Pattern.compile("([_.a-zA-Z0-9][-_.a-zA-Z0-9]*)[=](.*)"); //key value pair pattern.
|
||||
private static final Pattern NUM_PATTERN = Pattern.compile("^\\d+$");
|
||||
private static final Pattern PARAMETERS_PATTERN = Pattern.compile("^\\[((\\s*\\{\\s*[\\w_\\-\\.]+\\s*:\\s*.+?\\s*\\}\\s*,?\\s*)+)\\s*\\]$");
|
||||
|
|
@ -1031,7 +1032,7 @@ public final class StringUtils {
|
|||
try {
|
||||
buf.append(JsonUtils.getJson().toJson(arg));
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(COMMON_JSON_CONVERT_EXCEPTION, "", "", e.getMessage(), e);
|
||||
buf.append(arg);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import org.apache.dubbo.common.config.Environment;
|
|||
import org.apache.dubbo.common.config.InmemoryConfiguration;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.ClassUtils;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
|
|
@ -60,6 +60,9 @@ import java.util.Set;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_OVERRIDE_FIELD;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_REFLECT;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
import static org.apache.dubbo.common.utils.ClassUtils.isSimpleType;
|
||||
import static org.apache.dubbo.common.utils.ReflectUtils.findMethodByMethodSignature;
|
||||
import static org.apache.dubbo.config.Constants.PARAMETERS;
|
||||
|
|
@ -71,7 +74,7 @@ import static org.apache.dubbo.config.Constants.PARAMETERS;
|
|||
*/
|
||||
public abstract class AbstractConfig implements Serializable {
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(AbstractConfig.class);
|
||||
protected static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractConfig.class);
|
||||
private static final long serialVersionUID = 4267533505537413570L;
|
||||
|
||||
/**
|
||||
|
|
@ -494,7 +497,7 @@ public abstract class AbstractConfig implements Serializable {
|
|||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.error(COMMON_FAILED_REFLECT, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -648,7 +651,7 @@ public abstract class AbstractConfig implements Serializable {
|
|||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
logger.error("Failed to override field value of config bean: " + this, t);
|
||||
logger.error(COMMON_FAILED_OVERRIDE_FIELD, "", "", "Failed to override field value of config bean: " + this, t);
|
||||
throw new IllegalStateException("Failed to override field value of config bean: " + this, t);
|
||||
}
|
||||
}
|
||||
|
|
@ -703,7 +706,7 @@ public abstract class AbstractConfig implements Serializable {
|
|||
processExtraRefresh(preferredPrefix, subPropsConfiguration);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to override field value of config bean: " + this, e);
|
||||
logger.error(COMMON_FAILED_OVERRIDE_FIELD, "", "", "Failed to override field value of config bean: " + this, e);
|
||||
throw new IllegalStateException("Failed to override field value of config bean: " + this, e);
|
||||
}
|
||||
|
||||
|
|
@ -811,7 +814,7 @@ public abstract class AbstractConfig implements Serializable {
|
|||
private boolean isPropertySet(Method[] methods, String propertyName) {
|
||||
try {
|
||||
String getterName = calculatePropertyToGetter(propertyName);
|
||||
Method getterMethod = findGetMethod(methods,getterName);
|
||||
Method getterMethod = findGetMethod(methods, getterName);
|
||||
if (getterMethod == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -943,13 +946,13 @@ public abstract class AbstractConfig implements Serializable {
|
|||
buf.append('\"');
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
buf.append(" />");
|
||||
return buf.toString();
|
||||
} catch (Throwable t) {
|
||||
logger.warn(t.getMessage(), t);
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
|
||||
return super.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.REFERENCE_FILTER
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TAG_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_NO_METHOD_FOUND;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMETHEUS;
|
||||
|
||||
|
||||
|
|
@ -84,7 +85,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
* The remote service group the customer/provider side will reference
|
||||
*/
|
||||
protected String group;
|
||||
|
||||
|
||||
protected ServiceMetadata serviceMetadata;
|
||||
/**
|
||||
* Local impl class name for the service interface
|
||||
|
|
@ -253,7 +254,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
for (RegistryConfig registryConfig : registries) {
|
||||
if (!registryConfig.isValid()) {
|
||||
throw new IllegalStateException("No registry config found or it's not a valid config! " +
|
||||
"The registry config is: " + registryConfig);
|
||||
"The registry config is: " + registryConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -285,6 +286,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
|
||||
/**
|
||||
* To obtain the method list in the port, use reflection when in native mode and javassist otherwise.
|
||||
*
|
||||
* @param interfaceClass
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -312,7 +314,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
return;
|
||||
}
|
||||
if (!interfaceClass.isInterface()) {
|
||||
throw new IllegalStateException(interfaceName+" is not an interface");
|
||||
throw new IllegalStateException(interfaceName + " is not an interface");
|
||||
}
|
||||
|
||||
// Auto create MethodConfig/ArgumentConfig according to config props
|
||||
|
|
@ -378,7 +380,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
"<dubbo:service interface=\"" + interfaceName + "\" ... >" +
|
||||
"<dubbo:method name=\"\" ... /></<dubbo:reference>";
|
||||
if (ignoreInvalidMethodConfig) {
|
||||
logger.warn(msg);
|
||||
logger.warn(CONFIG_NO_METHOD_FOUND, "", "", msg);
|
||||
return false;
|
||||
} else {
|
||||
throw new IllegalStateException(msg);
|
||||
|
|
@ -390,7 +392,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
String msg = "Found invalid method config, the interface " + interfaceClass.getName() + " not found method \""
|
||||
+ methodName + "\" : [" + methodConfig + "]";
|
||||
if (ignoreInvalidMethodConfig) {
|
||||
logger.warn(msg);
|
||||
logger.warn(CONFIG_NO_METHOD_FOUND, "", "", msg);
|
||||
return false;
|
||||
} else {
|
||||
throw new IllegalStateException(msg);
|
||||
|
|
@ -437,18 +439,18 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
verifyStubAndLocal(stub, "Stub", interfaceClass);
|
||||
}
|
||||
|
||||
private void verifyStubAndLocal(String className, String label, Class<?> interfaceClass){
|
||||
private void verifyStubAndLocal(String className, String label, Class<?> interfaceClass) {
|
||||
if (ConfigUtils.isNotEmpty(className)) {
|
||||
Class<?> localClass = ConfigUtils.isDefault(className) ?
|
||||
ReflectUtils.forName(interfaceClass.getName() + label) : ReflectUtils.forName(className);
|
||||
verify(interfaceClass, localClass);
|
||||
}
|
||||
ReflectUtils.forName(interfaceClass.getName() + label) : ReflectUtils.forName(className);
|
||||
verify(interfaceClass, localClass);
|
||||
}
|
||||
}
|
||||
|
||||
private void verify(Class<?> interfaceClass, Class<?> localClass) {
|
||||
if (!interfaceClass.isAssignableFrom(localClass)) {
|
||||
throw new IllegalStateException("The local implementation class " + localClass.getName() +
|
||||
" not implement interface " + interfaceClass.getName());
|
||||
" not implement interface " + interfaceClass.getName());
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -456,7 +458,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
ReflectUtils.findConstructor(localClass, interfaceClass);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new IllegalStateException("No such constructor \"public " + localClass.getSimpleName() +
|
||||
"(" + interfaceClass.getName() + ")\" in local implementation class " + localClass.getName());
|
||||
"(" + interfaceClass.getName() + ")\" in local implementation class " + localClass.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -524,7 +526,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void computeValidRegistryIds() {
|
||||
if (application != null && notHasSelfRegistryProperty()) {
|
||||
setRegistries(application.getRegistries());
|
||||
|
|
@ -640,8 +642,8 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link AbstractInterfaceConfig#setScopeModel(ScopeModel)}
|
||||
* @param application
|
||||
* @deprecated Use {@link AbstractInterfaceConfig#setScopeModel(ScopeModel)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setApplication(ApplicationConfig application) {
|
||||
|
|
@ -659,8 +661,8 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link AbstractInterfaceConfig#setScopeModel(ScopeModel)}
|
||||
* @param module
|
||||
* @deprecated Use {@link AbstractInterfaceConfig#setScopeModel(ScopeModel)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setModule(ModuleConfig module) {
|
||||
|
|
@ -877,7 +879,7 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
public String getVersion(AbstractInterfaceConfig interfaceConfig) {
|
||||
return StringUtils.isEmpty(getVersion()) ? (interfaceConfig != null ? interfaceConfig.getVersion() : getVersion()) : getVersion();
|
||||
}
|
||||
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
|
@ -893,11 +895,11 @@ public abstract class AbstractInterfaceConfig extends AbstractMethodConfig {
|
|||
public void setGroup(String group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
|
||||
public String getInterface() {
|
||||
return interfaceName;
|
||||
}
|
||||
|
||||
|
||||
public void setInterface(String interfaceName) {
|
||||
this.interfaceName = interfaceName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.config;
|
|||
|
||||
import org.apache.dubbo.common.compiler.support.AdaptiveCompiler;
|
||||
import org.apache.dubbo.common.infra.InfraAdapter;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -47,6 +47,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.READINESS_PROBE_
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_LOCAL_FILE_CACHE_ENABLED;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SHUTDOWN_WAIT_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.STARTUP_PROBE;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP_COMPATIBLE;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE;
|
||||
|
|
@ -68,7 +69,7 @@ import static org.apache.dubbo.config.Constants.TEST_ENVIRONMENT;
|
|||
* @export
|
||||
*/
|
||||
public class ApplicationConfig extends AbstractConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationConfig.class);
|
||||
private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(ApplicationConfig.class);
|
||||
|
||||
private static final long serialVersionUID = 5508512956753757169L;
|
||||
|
||||
|
|
@ -229,7 +230,7 @@ public class ApplicationConfig extends AbstractConfig {
|
|||
try {
|
||||
hostname = InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
LOGGER.warn("Failed to get the hostname of current instance.", e);
|
||||
LOGGER.warn(COMMON_UNEXPECTED_EXCEPTION,"","","Failed to get the hostname of current instance.", e);
|
||||
hostname = "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import java.util.Properties;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DUBBO;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.UNLOAD_CLUSTER_RELATED;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* ReferenceConfig
|
||||
|
|
@ -130,8 +131,8 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
|
|||
super.preProcessRefresh();
|
||||
if (consumer == null) {
|
||||
consumer = getModuleConfigManager()
|
||||
.getDefaultConsumer()
|
||||
.orElseThrow(() -> new IllegalStateException("Default consumer is not initialized"));
|
||||
.getDefaultConsumer()
|
||||
.orElseThrow(() -> new IllegalStateException("Default consumer is not initialized"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -166,6 +167,7 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
|
|||
/**
|
||||
* Get service interface class of this reference.
|
||||
* The actual service type of remote provider.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Class<?> getServiceInterfaceClass() {
|
||||
|
|
@ -187,6 +189,7 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
|
|||
/**
|
||||
* Get proxy interface class of this reference.
|
||||
* The proxy interface class is used to create proxy instance.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Class<?> getInterfaceClass() {
|
||||
|
|
@ -208,6 +211,7 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
|
|||
|
||||
/**
|
||||
* Determine the interface of the proxy class
|
||||
*
|
||||
* @param generic
|
||||
* @param interfaceName
|
||||
* @return
|
||||
|
|
@ -303,9 +307,9 @@ public abstract class ReferenceConfigBase<T> extends AbstractReferenceConfig {
|
|||
url = resolve;
|
||||
if (logger.isWarnEnabled()) {
|
||||
if (resolveFile != null) {
|
||||
logger.warn("Using default dubbo resolve file " + resolveFile + " replace " + interfaceName + "" + resolve + " to p2p invoke remote service.");
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Using default dubbo resolve file " + resolveFile + " replace " + interfaceName + "" + resolve + " to p2p invoke remote service.");
|
||||
} else {
|
||||
logger.warn("Using -D" + interfaceName + "=" + resolve + " to p2p invoke remote service.");
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Using -D" + interfaceName + "=" + resolve + " to p2p invoke remote service.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import org.apache.dubbo.common.config.Environment;
|
|||
import org.apache.dubbo.common.config.PropertiesConfiguration;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.dubbo.common.context.LifecycleAdapter;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.common.utils.ConcurrentHashSet;
|
||||
|
|
@ -60,13 +60,15 @@ import static java.lang.Boolean.TRUE;
|
|||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Optional.ofNullable;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DUBBO;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_PROPERTY_MISSPELLING;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
import static org.apache.dubbo.config.AbstractConfig.getTagName;
|
||||
|
||||
public abstract class AbstractConfigManager extends LifecycleAdapter {
|
||||
|
||||
private static final String CONFIG_NAME_READ_METHOD = "getName";
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractConfigManager.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractConfigManager.class);
|
||||
private static Set<Class<? extends AbstractConfig>> uniqueConfigTypes = new ConcurrentHashSet<>();
|
||||
|
||||
final Map<String, Map<String, AbstractConfig>> configsCache = new ConcurrentHashMap<>();
|
||||
|
|
@ -119,7 +121,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
String msg = "Illegal '" + ConfigKeys.DUBBO_CONFIG_MODE + "' config value [" + configModeStr + "], available values " + Arrays.toString(ConfigMode.values());
|
||||
logger.error(msg, e);
|
||||
logger.error(COMMON_PROPERTY_MISSPELLING, "", "", msg, e);
|
||||
throw new IllegalArgumentException(msg, e);
|
||||
}
|
||||
|
||||
|
|
@ -213,7 +215,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
|
|||
C existedConfig = configsMap.get(key);
|
||||
if (existedConfig != null && !isEquals(existedConfig, config)) {
|
||||
String type = config.getClass().getSimpleName();
|
||||
logger.warn(String.format("Duplicate %s found, there already has one default %s or more than two %ss have the same id, " +
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", String.format("Duplicate %s found, there already has one default %s or more than two %ss have the same id, " +
|
||||
"you can try to give each %s a different id, override previous config with later config. id: %s, prev: %s, later: %s",
|
||||
type, type, type, type, key, existedConfig, config));
|
||||
}
|
||||
|
|
@ -224,7 +226,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
|
|||
}
|
||||
|
||||
protected <C extends AbstractConfig> boolean removeIfAbsent(C config, Map<String, C> configsMap) {
|
||||
if(config.getId() != null) {
|
||||
if (config.getId() != null) {
|
||||
return configsMap.remove(config.getId(), config);
|
||||
}
|
||||
return configsMap.values().removeIf(c -> config == c);
|
||||
|
|
@ -439,7 +441,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
|
|||
case IGNORE: {
|
||||
// ignore later config
|
||||
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
|
||||
logger.warn(msgPrefix + "keep previous config and ignore later config");
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", msgPrefix + "keep previous config and ignore later config");
|
||||
}
|
||||
return Optional.of(oldOne);
|
||||
}
|
||||
|
|
@ -447,7 +449,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
|
|||
// clear previous config, add new config
|
||||
configsMap.clear();
|
||||
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
|
||||
logger.warn(msgPrefix + "override previous config with later config");
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", msgPrefix + "override previous config with later config");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -455,7 +457,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
|
|||
// override old one's properties with the new one
|
||||
oldOne.overrideWithConfig(config, true);
|
||||
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
|
||||
logger.warn(msgPrefix + "override previous config with later config");
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", msgPrefix + "override previous config with later config");
|
||||
}
|
||||
return Optional.of(oldOne);
|
||||
}
|
||||
|
|
@ -463,7 +465,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
|
|||
// override old one's properties with the new one
|
||||
oldOne.overrideWithConfig(config, false);
|
||||
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
|
||||
logger.warn(msgPrefix + "override previous config with later config");
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", msgPrefix + "override previous config with later config");
|
||||
}
|
||||
return Optional.of(oldOne);
|
||||
}
|
||||
|
|
@ -504,7 +506,7 @@ public abstract class AbstractConfigManager extends LifecycleAdapter {
|
|||
this.addConfig(config);
|
||||
tmpConfigs.add(config);
|
||||
} catch (Exception e) {
|
||||
logger.error("load config failed, id: " + id + ", type:" + cls.getSimpleName(), e);
|
||||
logger.error(COMMON_PROPERTY_MISSPELLING, "", "", "load config failed, id: " + id + ", type:" + cls.getSimpleName(), e);
|
||||
throw new IllegalStateException("load config failed, id: " + id + ", type:" + cls.getSimpleName());
|
||||
} finally {
|
||||
if (addDefaultNameConfig && key != null) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.config.context;
|
|||
|
||||
import org.apache.dubbo.common.context.ModuleExt;
|
||||
import org.apache.dubbo.common.extension.DisableInject;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.config.AbstractConfig;
|
||||
|
|
@ -46,6 +46,7 @@ import java.util.Optional;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static java.util.Optional.ofNullable;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
import static org.apache.dubbo.config.AbstractConfig.getTagName;
|
||||
|
||||
/**
|
||||
|
|
@ -53,7 +54,7 @@ import static org.apache.dubbo.config.AbstractConfig.getTagName;
|
|||
*/
|
||||
public class ModuleConfigManager extends AbstractConfigManager implements ModuleExt {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ModuleConfigManager.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ModuleConfigManager.class);
|
||||
|
||||
public static final String NAME = "moduleConfig";
|
||||
|
||||
|
|
@ -204,7 +205,7 @@ public class ModuleConfigManager extends AbstractConfigManager implements Module
|
|||
|
||||
@Override
|
||||
protected <C extends AbstractConfig> boolean removeIfAbsent(C config, Map<String, C> configsMap) {
|
||||
if(super.removeIfAbsent(config, configsMap)) {
|
||||
if (super.removeIfAbsent(config, configsMap)) {
|
||||
if (config instanceof ReferenceConfigBase || config instanceof ServiceConfigBase) {
|
||||
removeInterfaceConfig((AbstractInterfaceConfig) config);
|
||||
}
|
||||
|
|
@ -240,7 +241,7 @@ public class ModuleConfigManager extends AbstractConfigManager implements Module
|
|||
if (prevConfig.equals(config)) {
|
||||
// Is there any problem with ignoring duplicate and equivalent but different ReferenceConfig instances?
|
||||
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
|
||||
logger.warn("Ignore duplicated and equal config: " + config);
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Ignore duplicated and equal config: " + config);
|
||||
}
|
||||
return prevConfig;
|
||||
}
|
||||
|
|
@ -252,7 +253,7 @@ public class ModuleConfigManager extends AbstractConfigManager implements Module
|
|||
"If multiple instances are required for the same interface, please use a different group or version.";
|
||||
|
||||
if (logger.isWarnEnabled() && duplicatedConfigs.add(config)) {
|
||||
logger.warn(msg);
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", msg);
|
||||
}
|
||||
if (!this.ignoreDuplicatedInterface) {
|
||||
throw new IllegalStateException(msg);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.metadata.definition.builder;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.metadata.definition.TypeDefinitionBuilder;
|
||||
import org.apache.dubbo.metadata.definition.model.TypeDefinition;
|
||||
|
|
@ -25,11 +25,13 @@ import java.lang.reflect.Method;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* 2015/1/27.
|
||||
*/
|
||||
public class EnumTypeBuilder implements TypeBuilder {
|
||||
private static final Logger logger = LoggerFactory.getLogger(TypeDefinitionBuilder.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(TypeDefinitionBuilder.class);
|
||||
|
||||
@Override
|
||||
public boolean accept(Class<?> clazz) {
|
||||
|
|
@ -61,7 +63,7 @@ public class EnumTypeBuilder implements TypeBuilder {
|
|||
}
|
||||
return td;
|
||||
} catch (Throwable t) {
|
||||
logger.error("There is an error while process class " + clazz, t);
|
||||
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", "There is an error while process class " + clazz, t);
|
||||
}
|
||||
return td;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.dubbo.rpc.model;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.stream.StreamObserver;
|
||||
import org.apache.dubbo.common.utils.ReflectUtils;
|
||||
|
|
@ -32,9 +32,10 @@ import java.util.stream.Stream;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.$INVOKE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.$INVOKE_ASYNC;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_REFLECT;
|
||||
|
||||
public class ReflectionMethodDescriptor implements MethodDescriptor {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ReflectionMethodDescriptor.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ReflectionMethodDescriptor.class);
|
||||
|
||||
private final ConcurrentMap<String, Object> attributeMap = new ConcurrentHashMap<>();
|
||||
public final String methodName;
|
||||
|
|
@ -57,7 +58,7 @@ public class ReflectionMethodDescriptor implements MethodDescriptor {
|
|||
try {
|
||||
returnTypesResult = ReflectUtils.getReturnTypes(method);
|
||||
} catch (Throwable throwable) {
|
||||
logger.error(
|
||||
logger.error(COMMON_FAILED_REFLECT, "", "",
|
||||
"fail to get return types. Method name: " + methodName + " Declaring class:" + method.getDeclaringClass()
|
||||
.getName(), throwable);
|
||||
returnTypesResult = new Type[]{returnClass, returnClass};
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import org.apache.dubbo.common.config.Environment;
|
|||
import org.apache.dubbo.common.extension.ExtensionAccessor;
|
||||
import org.apache.dubbo.common.extension.ExtensionDirector;
|
||||
import org.apache.dubbo.common.extension.ExtensionScope;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.ConcurrentHashSet;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -35,8 +35,10 @@ import java.util.Set;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_UNABLE_DESTROY_MODEL;
|
||||
|
||||
public abstract class ScopeModel implements ExtensionAccessor {
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(ScopeModel.class);
|
||||
protected static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(ScopeModel.class);
|
||||
|
||||
/**
|
||||
* The internal id is used to represent the hierarchy of the model tree, such as:
|
||||
|
|
@ -122,7 +124,7 @@ public abstract class ScopeModel implements ExtensionAccessor {
|
|||
extensionDirector.destroy();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
LOGGER.error("Error happened when destroying ScopeModel.", t);
|
||||
LOGGER.error(CONFIG_UNABLE_DESTROY_MODEL, "", "", "Error happened when destroying ScopeModel.", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.apache.dubbo.rpc.model.FrameworkModel;
|
|||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ADDRESS_INVALID;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
|
|
@ -45,8 +46,8 @@ public class FailsafeErrorTypeAwareLoggerTest {
|
|||
doThrow(new RuntimeException()).when(failLogger).debug(anyString());
|
||||
doThrow(new RuntimeException()).when(failLogger).trace(anyString());
|
||||
|
||||
failsafeLogger.error("1-1", "Registry center", "May be it's offline.", "error");
|
||||
failsafeLogger.warn("1-1", "Registry center", "May be it's offline.", "warn");
|
||||
failsafeLogger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "error");
|
||||
failsafeLogger.warn(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "warn");
|
||||
|
||||
doThrow(new RuntimeException()).when(failLogger).error(any(Throwable.class));
|
||||
doThrow(new RuntimeException()).when(failLogger).warn(any(Throwable.class));
|
||||
|
|
@ -54,8 +55,8 @@ public class FailsafeErrorTypeAwareLoggerTest {
|
|||
doThrow(new RuntimeException()).when(failLogger).debug(any(Throwable.class));
|
||||
doThrow(new RuntimeException()).when(failLogger).trace(any(Throwable.class));
|
||||
|
||||
failsafeLogger.error("1-1", "Registry center", "May be it's offline.", "error", new Exception("error"));
|
||||
failsafeLogger.warn("1-1", "Registry center", "May be it's offline.", "warn", new Exception("warn"));
|
||||
failsafeLogger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "error", new Exception("error"));
|
||||
failsafeLogger.warn(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "warn", new Exception("warn"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -63,14 +64,14 @@ public class FailsafeErrorTypeAwareLoggerTest {
|
|||
Logger successLogger = mock(Logger.class);
|
||||
FailsafeErrorTypeAwareLogger failsafeLogger = new FailsafeErrorTypeAwareLogger(successLogger);
|
||||
|
||||
failsafeLogger.error("1-1", "Registry center", "May be it's offline.", "error");
|
||||
failsafeLogger.warn("1-1", "Registry center", "May be it's offline.", "warn");
|
||||
failsafeLogger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "error");
|
||||
failsafeLogger.warn(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "warn");
|
||||
|
||||
verify(successLogger).error(anyString());
|
||||
verify(successLogger).warn(anyString());
|
||||
|
||||
failsafeLogger.error("1-1", "Registry center", "May be it's offline.", "error", new Exception("error"));
|
||||
failsafeLogger.warn("1-1", "Registry center", "May be it's offline.", "warn", new Exception("warn"));
|
||||
failsafeLogger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "error", new Exception("error"));
|
||||
failsafeLogger.warn(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.", "warn", new Exception("warn"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -90,10 +91,10 @@ public class FailsafeErrorTypeAwareLoggerTest {
|
|||
|
||||
ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(FailsafeErrorTypeAwareLoggerTest.class);
|
||||
|
||||
logger.error("1-1", "Registry center", "May be it's offline.",
|
||||
logger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.",
|
||||
"error message", new Exception("error"));
|
||||
|
||||
logger.error("-1", "Registry center", "May be it's offline.",
|
||||
logger.error(REGISTRY_ADDRESS_INVALID, "Registry center", "May be it's offline.",
|
||||
"error message", new Exception("error"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.metadata;
|
|||
|
||||
import org.apache.dubbo.common.cache.FileCacheStore;
|
||||
import org.apache.dubbo.common.cache.FileCacheStoreFactory;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.resource.Disposable;
|
||||
import org.apache.dubbo.common.utils.JsonUtils;
|
||||
|
|
@ -32,8 +32,10 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_LOAD_MAPPING_CACHE;
|
||||
|
||||
public abstract class AbstractCacheManager<V> implements Disposable {
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
protected final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
|
||||
|
||||
private ScheduledExecutorService executorService;
|
||||
|
||||
|
|
@ -61,7 +63,7 @@ public abstract class AbstractCacheManager<V> implements Disposable {
|
|||
|
||||
this.executorService.scheduleWithFixedDelay(new CacheRefreshTask<>(this.cacheStore, this.cache, this, fileSize), 10, interval, TimeUnit.MINUTES);
|
||||
} catch (Exception e) {
|
||||
logger.error("Load mapping from local cache file error ", e);
|
||||
logger.error(COMMON_FAILED_LOAD_MAPPING_CACHE, "", "", "Load mapping from local cache file error ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +119,7 @@ public abstract class AbstractCacheManager<V> implements Disposable {
|
|||
}
|
||||
|
||||
public static class CacheRefreshTask<V> implements Runnable {
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
|
||||
private static final String DEFAULT_COMMENT = "Dubbo cache";
|
||||
private final FileCacheStore cacheStore;
|
||||
private final LRUCache<String, V> cache;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.metadata;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
|
|
@ -43,6 +43,7 @@ import static java.util.Collections.emptySet;
|
|||
import static java.util.Collections.unmodifiableSet;
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
import static java.util.stream.Stream.of;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_LOAD_MAPPING_CACHE;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDED_BY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.SUBSCRIBED_SERVICE_NAMES_KEY;
|
||||
import static org.apache.dubbo.common.utils.CollectionUtils.isEmpty;
|
||||
|
|
@ -50,7 +51,7 @@ import static org.apache.dubbo.common.utils.CollectionUtils.toTreeSet;
|
|||
import static org.apache.dubbo.common.utils.StringUtils.isBlank;
|
||||
|
||||
public abstract class AbstractServiceNameMapping implements ServiceNameMapping {
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
protected final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
|
||||
protected ApplicationModel applicationModel;
|
||||
private final MappingCacheManager mappingCacheManager;
|
||||
private final Map<String, Set<MappingListener>> mappingListeners = new ConcurrentHashMap<>();
|
||||
|
|
@ -63,13 +64,13 @@ public abstract class AbstractServiceNameMapping implements ServiceNameMapping {
|
|||
this.applicationModel = applicationModel;
|
||||
boolean enableFileCache = true;
|
||||
Optional<ApplicationConfig> application = applicationModel.getApplicationConfigManager().getApplication();
|
||||
if(application.isPresent()) {
|
||||
if (application.isPresent()) {
|
||||
enableFileCache = Boolean.TRUE.equals(application.get().getEnableFileCache()) ? true : false;
|
||||
}
|
||||
this.mappingCacheManager = new MappingCacheManager(enableFileCache,
|
||||
applicationModel.tryGetApplicationName(),
|
||||
applicationModel.getFrameworkModel().getBeanFactory()
|
||||
.getBean(FrameworkExecutorRepository.class).getCacheRefreshingScheduledExecutor());
|
||||
.getBean(FrameworkExecutorRepository.class).getCacheRefreshingScheduledExecutor());
|
||||
}
|
||||
|
||||
// just for test
|
||||
|
|
@ -293,7 +294,7 @@ public abstract class AbstractServiceNameMapping implements ServiceNameMapping {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed getting mapping info from remote center. ", e);
|
||||
logger.error(COMMON_FAILED_LOAD_MAPPING_CACHE, "", "", "Failed getting mapping info from remote center. ", e);
|
||||
}
|
||||
return mappedServices;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.metadata.report.support;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.common.utils.ConfigUtils;
|
||||
|
|
@ -67,6 +67,8 @@ import static org.apache.dubbo.common.constants.CommonConstants.REPORT_METADATA_
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.RETRY_PERIOD_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.RETRY_TIMES_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SYNC_REPORT_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_FAILED_EXPORT_SERVICE;
|
||||
import static org.apache.dubbo.common.utils.StringUtils.replace;
|
||||
import static org.apache.dubbo.metadata.report.support.Constants.CACHE;
|
||||
import static org.apache.dubbo.metadata.report.support.Constants.DEFAULT_METADATA_REPORT_CYCLE_REPORT;
|
||||
|
|
@ -82,7 +84,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
|
|||
private static final int ONE_DAY_IN_MILLISECONDS = 60 * 24 * 60 * 1000;
|
||||
private static final int FOUR_HOURS_IN_MILLISECONDS = 60 * 4 * 60 * 1000;
|
||||
// Log output
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
protected final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
|
||||
|
||||
// Local disk cache, where the special key value.registries records the list of metadata centers, and the others are the list of notified service providers
|
||||
final Properties properties = new Properties();
|
||||
|
|
@ -203,7 +205,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
|
|||
} else {
|
||||
reportCacheExecutor.execute(new SaveProperties(lastCacheChanged.incrementAndGet()));
|
||||
}
|
||||
logger.warn("Failed to save service store file, cause: " + e.getMessage(), e);
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Failed to save service store file, cause: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +217,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
|
|||
logger.info("Load service store file " + file + ", data: " + properties);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warn("Failed to load service store file " + file, e);
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "Failed to load service store file" + file, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -239,7 +241,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
|
|||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
logger.warn(t.getMessage(), t);
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +286,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
|
|||
// retry again. If failed again, throw exception.
|
||||
failedReports.put(providerMetadataIdentifier, serviceDefinition);
|
||||
metadataReportRetry.startRetryTask();
|
||||
logger.error("Failed to put provider metadata " + providerMetadataIdentifier + " in " + serviceDefinition + ", cause: " + e.getMessage(), e);
|
||||
logger.error(PROXY_FAILED_EXPORT_SERVICE, "", "", "Failed to put provider metadata " + providerMetadataIdentifier + " in " + serviceDefinition + ", cause: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +314,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
|
|||
// retry again. If failed again, throw exception.
|
||||
failedReports.put(consumerMetadataIdentifier, serviceParameterMap);
|
||||
metadataReportRetry.startRetryTask();
|
||||
logger.error("Failed to put consumer metadata " + consumerMetadataIdentifier + "; " + serviceParameterMap + ", cause: " + e.getMessage(), e);
|
||||
logger.error(PROXY_FAILED_EXPORT_SERVICE, "", "", "Failed to put consumer metadata " + consumerMetadataIdentifier + "; " + serviceParameterMap + ", cause: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -435,7 +437,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
|
|||
}
|
||||
|
||||
class MetadataReportRetry {
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
protected final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
|
||||
|
||||
final ScheduledExecutorService retryExecutor = Executors.newScheduledThreadPool(0, new NamedThreadFactory("DubboMetadataReportRetryTimer", true));
|
||||
volatile ScheduledFuture retryScheduledFuture;
|
||||
|
|
@ -468,7 +470,7 @@ public abstract class AbstractMetadataReport implements MetadataReport {
|
|||
cancelRetryTask();
|
||||
}
|
||||
} catch (Throwable t) { // Defensive fault tolerance
|
||||
logger.error("Unexpected error occur at failed retry, cause: " + t.getMessage(), t);
|
||||
logger.error(COMMON_UNEXPECTED_EXCEPTION, "", "", "Unexpected error occur at failed retry, cause: " + t.getMessage(), t);
|
||||
}
|
||||
}, 500, retryPeriod, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.metadata.report.support;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.metadata.report.MetadataReport;
|
||||
import org.apache.dubbo.metadata.report.MetadataReportFactory;
|
||||
|
|
@ -27,10 +27,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.CHECK_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_FAILED_EXPORT_SERVICE;
|
||||
|
||||
public abstract class AbstractMetadataReportFactory implements MetadataReportFactory {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractMetadataReportFactory.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractMetadataReportFactory.class);
|
||||
private static final String EXPORT_KEY = "export";
|
||||
private static final String REFER_KEY = "refer";
|
||||
|
||||
|
|
@ -67,7 +69,7 @@ public abstract class AbstractMetadataReportFactory implements MetadataReportFac
|
|||
metadataReport = createMetadataReport(url);
|
||||
} catch (Exception e) {
|
||||
if (!check) {
|
||||
logger.warn("The metadata reporter failed to initialize", e);
|
||||
logger.warn(PROXY_FAILED_EXPORT_SERVICE, "", "", "The metadata reporter failed to initialize", e);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
|
@ -91,11 +93,11 @@ public abstract class AbstractMetadataReportFactory implements MetadataReportFac
|
|||
lock.lock();
|
||||
try {
|
||||
for (MetadataReport metadataReport : serviceStoreMap.values()) {
|
||||
try{
|
||||
try {
|
||||
metadataReport.destroy();
|
||||
}catch (Throwable ignored){
|
||||
} catch (Throwable ignored) {
|
||||
// ignored
|
||||
logger.warn(ignored.getMessage(),ignored);
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", ignored.getMessage(), ignored);
|
||||
}
|
||||
}
|
||||
serviceStoreMap.clear();
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@
|
|||
package org.apache.dubbo.metadata.annotation.processing.util;
|
||||
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_METADATA_PROCESSOR;
|
||||
|
||||
/**
|
||||
* Logger Utils
|
||||
|
|
@ -29,7 +30,7 @@ import static java.lang.String.format;
|
|||
*/
|
||||
public interface LoggerUtils {
|
||||
|
||||
Logger LOGGER = LoggerFactory.getLogger("dubbo-metadata-processor");
|
||||
ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger("dubbo-metadata-processor");
|
||||
|
||||
static void info(String format, Object... args) {
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
|
|
@ -39,7 +40,7 @@ public interface LoggerUtils {
|
|||
|
||||
static void warn(String format, Object... args) {
|
||||
if (LOGGER.isWarnEnabled()) {
|
||||
LOGGER.warn(format(format, args));
|
||||
LOGGER.warn(COMMON_METADATA_PROCESSOR, "", "", format(format, args));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ import java.util.concurrent.Executor;
|
|||
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_NACOS_EXCEPTION;
|
||||
import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
|
||||
import static org.apache.dubbo.common.utils.StringConstantFieldValuePredicate.of;
|
||||
import static org.apache.dubbo.common.utils.StringUtils.HYPHEN_CHAR;
|
||||
|
|
@ -108,9 +109,9 @@ public class NacosMetadataReport extends AbstractMetadataReport {
|
|||
|
||||
private void setServerAddr(URL url, Properties properties) {
|
||||
StringBuilder serverAddrBuilder =
|
||||
new StringBuilder(url.getHost()) // Host
|
||||
.append(':')
|
||||
.append(url.getPort()); // Port
|
||||
new StringBuilder(url.getHost()) // Host
|
||||
.append(':')
|
||||
.append(url.getPort()); // Port
|
||||
// Append backup parameter as other servers
|
||||
String backup = url.getParameter(BACKUP_KEY);
|
||||
if (backup != null) {
|
||||
|
|
@ -227,7 +228,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
|
|||
}
|
||||
return configService.publishConfigCas(key, group, content, (String) ticket);
|
||||
} catch (NacosException e) {
|
||||
logger.warn("nacos publishConfigCas failed.", e);
|
||||
logger.warn(REGISTRY_NACOS_EXCEPTION, "", "", "nacos publishConfigCas failed.", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -273,7 +274,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
|
|||
try {
|
||||
return configService.getConfig(dataId, group);
|
||||
} catch (NacosException e) {
|
||||
logger.error(e.getMessage());
|
||||
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -298,12 +299,12 @@ public class NacosMetadataReport extends AbstractMetadataReport {
|
|||
public void addListener(String key, String group, ConfigurationListener listener) {
|
||||
String listenerKey = buildListenerKey(key, group);
|
||||
NacosConfigListener nacosConfigListener =
|
||||
watchListenerMap.computeIfAbsent(listenerKey, k -> createTargetListener(key, group));
|
||||
watchListenerMap.computeIfAbsent(listenerKey, k -> createTargetListener(key, group));
|
||||
nacosConfigListener.addListener(listener);
|
||||
try {
|
||||
configService.addListener(key, group, nacosConfigListener);
|
||||
} catch (NacosException e) {
|
||||
logger.error(e.getMessage());
|
||||
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -319,7 +320,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
|
|||
}
|
||||
}
|
||||
} catch (NacosException e) {
|
||||
logger.error(e.getMessage());
|
||||
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -341,7 +342,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
|
|||
throw new RuntimeException("publish nacos metadata failed");
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.error("Failed to put " + identifier + " to nacos " + value + ", cause: " + t.getMessage(), t);
|
||||
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", "Failed to put " + identifier + " to nacos " + value + ", cause: " + t.getMessage(), t);
|
||||
throw new RuntimeException("Failed to put " + identifier + " to nacos " + value + ", cause: " + t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
|
@ -353,7 +354,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
|
|||
throw new RuntimeException("remove nacos metadata failed");
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.error("Failed to remove " + identifier + " from nacos , cause: " + t.getMessage(), t);
|
||||
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", "Failed to remove " + identifier + " from nacos , cause: " + t.getMessage(), t);
|
||||
throw new RuntimeException("Failed to remove " + identifier + " from nacos , cause: " + t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
|
@ -362,7 +363,7 @@ public class NacosMetadataReport extends AbstractMetadataReport {
|
|||
try {
|
||||
return configService.getConfig(identifier.getUniqueKey(KeyTypeEnum.UNIQUE_KEY), group, 3000L);
|
||||
} catch (Throwable t) {
|
||||
logger.error("Failed to get " + identifier + " from nacos , cause: " + t.getMessage(), t);
|
||||
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", "Failed to get " + identifier + " from nacos , cause: " + t.getMessage(), t);
|
||||
throw new RuntimeException("Failed to get " + identifier + " from nacos , cause: " + t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.metadata.store.zookeeper;
|
|||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.config.configcenter.ConfigItem;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.JsonUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -47,6 +47,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION;
|
||||
import static org.apache.dubbo.metadata.ServiceNameMapping.DEFAULT_MAPPING_GROUP;
|
||||
import static org.apache.dubbo.metadata.ServiceNameMapping.getAppNames;
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ import static org.apache.dubbo.metadata.ServiceNameMapping.getAppNames;
|
|||
*/
|
||||
public class ZookeeperMetadataReport extends AbstractMetadataReport {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ZookeeperMetadataReport.class);
|
||||
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ZookeeperMetadataReport.class);
|
||||
|
||||
private final String root;
|
||||
|
||||
|
|
@ -200,7 +201,7 @@ public class ZookeeperMetadataReport extends AbstractMetadataReport {
|
|||
zkClient.createOrUpdate(pathKey, content, false, ticket == null ? 0 : ((Stat) ticket).getVersion());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.warn("zookeeper publishConfigCas failed.", e);
|
||||
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "zookeeper publishConfigCas failed.", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
|
|||
import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.lang.ShutdownHookCallbacks;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.metrics.MetricsReporter;
|
||||
import org.apache.dubbo.common.metrics.collector.DefaultMetricsCollector;
|
||||
|
|
@ -46,6 +46,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_METRICS_COLLECTOR_EXCEPTION;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.ENABLE_JVM_METRICS_KEY;
|
||||
|
||||
/**
|
||||
|
|
@ -53,7 +54,7 @@ import static org.apache.dubbo.common.constants.MetricsConstants.ENABLE_JVM_METR
|
|||
*/
|
||||
public abstract class AbstractMetricsReporter implements MetricsReporter {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(AbstractMetricsReporter.class);
|
||||
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractMetricsReporter.class);
|
||||
|
||||
private final AtomicBoolean initialized = new AtomicBoolean(false);
|
||||
|
||||
|
|
@ -144,7 +145,7 @@ public abstract class AbstractMetricsReporter implements MetricsReporter {
|
|||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("error occurred when synchronize metrics collector.", e);
|
||||
logger.error(COMMON_METRICS_COLLECTOR_EXCEPTION, "", "", "error occurred when synchronize metrics collector.", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import io.micrometer.prometheus.PrometheusMeterRegistry;
|
|||
import io.prometheus.client.exporter.BasicAuthHttpConnectionFactory;
|
||||
import io.prometheus.client.exporter.PushGateway;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.NamedThreadFactory;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -37,6 +37,7 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_METRICS_COLLECTOR_EXCEPTION;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.PROMETHEUS_EXPORTER_ENABLED_KEY;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.PROMETHEUS_EXPORTER_METRICS_PORT_KEY;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.PROMETHEUS_DEFAULT_METRICS_PORT;
|
||||
|
|
@ -56,7 +57,7 @@ import static org.apache.dubbo.common.constants.MetricsConstants.PROMETHEUS_PUSH
|
|||
*/
|
||||
public class PrometheusMetricsReporter extends AbstractMetricsReporter {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(PrometheusMetricsReporter.class);
|
||||
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(PrometheusMetricsReporter.class);
|
||||
|
||||
private final PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
|
||||
private ScheduledExecutorService pushJobExecutor = null;
|
||||
|
|
@ -125,7 +126,7 @@ public class PrometheusMetricsReporter extends AbstractMetricsReporter {
|
|||
try {
|
||||
pushGateway.pushAdd(prometheusRegistry.getPrometheusRegistry(), job);
|
||||
} catch (IOException e) {
|
||||
logger.error("Error occurred when pushing metrics to prometheus: ", e);
|
||||
logger.error(COMMON_METRICS_COLLECTOR_EXCEPTION, "", "", "Error occurred when pushing metrics to prometheus: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.monitor.support;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.NamedThreadFactory;
|
||||
import org.apache.dubbo.monitor.Monitor;
|
||||
|
|
@ -36,12 +36,13 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_MONITOR_EXCEPTION;
|
||||
|
||||
/**
|
||||
* AbstractMonitorFactory. (SPI, Singleton, ThreadSafe)
|
||||
*/
|
||||
public abstract class AbstractMonitorFactory implements MonitorFactory {
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractMonitorFactory.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractMonitorFactory.class);
|
||||
|
||||
/**
|
||||
* The lock for getting monitor center
|
||||
|
|
@ -90,7 +91,7 @@ public abstract class AbstractMonitorFactory implements MonitorFactory {
|
|||
FUTURES.remove(key);
|
||||
return m;
|
||||
} catch (Throwable e) {
|
||||
logger.warn("Create monitor failed, monitor data will not be collected until you fix this problem. monitorUrl: " + monitorUrl, e);
|
||||
logger.warn(COMMON_MONITOR_EXCEPTION, "", "", "Create monitor failed, monitor data will not be collected until you fix this problem. monitorUrl: " + monitorUrl, e);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.monitor.support;
|
|||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.url.component.ServiceConfigURL;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
|
|
@ -46,6 +46,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.MONITOR_KEY;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_MONITOR_EXCEPTION;
|
||||
import static org.apache.dubbo.monitor.Constants.CONCURRENT_KEY;
|
||||
import static org.apache.dubbo.monitor.Constants.COUNT_PROTOCOL;
|
||||
import static org.apache.dubbo.monitor.Constants.ELAPSED_KEY;
|
||||
|
|
@ -60,7 +61,7 @@ import static org.apache.dubbo.rpc.Constants.OUTPUT_KEY;
|
|||
@Activate(group = {PROVIDER})
|
||||
public class MonitorFilter implements Filter, Filter.Listener {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MonitorFilter.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(MonitorFilter.class);
|
||||
private static final String MONITOR_FILTER_START_TIME = "monitor_filter_start_time";
|
||||
private static final String MONITOR_REMOTE_HOST_STORE = "monitor_remote_host_store";
|
||||
|
||||
|
|
@ -158,7 +159,7 @@ public class MonitorFilter implements Filter, Filter.Listener {
|
|||
monitor.collect(statisticsUrl.toSerializableURL());
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.warn("Failed to monitor count service " + invoker.getUrl() + ", cause: " + t.getMessage(), t);
|
||||
logger.warn(COMMON_MONITOR_EXCEPTION, "", "", "Failed to monitor count service " + invoker.getUrl() + ", cause: " + t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.monitor.dubbo;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository;
|
||||
import org.apache.dubbo.common.utils.ExecutorUtil;
|
||||
|
|
@ -36,6 +36,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_MONITOR_EXCEPTION;
|
||||
import static org.apache.dubbo.monitor.Constants.CONCURRENT_KEY;
|
||||
import static org.apache.dubbo.monitor.Constants.DEFAULT_MONITOR_SEND_DATA_INTERVAL;
|
||||
import static org.apache.dubbo.monitor.Constants.ELAPSED_KEY;
|
||||
|
|
@ -54,7 +55,7 @@ import static org.apache.dubbo.monitor.Constants.SUCCESS_KEY;
|
|||
*/
|
||||
public class DubboMonitor implements Monitor {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DubboMonitor.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DubboMonitor.class);
|
||||
|
||||
/**
|
||||
* The timer for sending statistics
|
||||
|
|
@ -85,7 +86,7 @@ public class DubboMonitor implements Monitor {
|
|||
// collect data
|
||||
send();
|
||||
} catch (Throwable t) {
|
||||
logger.error("Unexpected error occur at send statistic, cause: " + t.getMessage(), t);
|
||||
logger.error(COMMON_MONITOR_EXCEPTION, "", "", "Unexpected error occur at send statistic, cause: " + t.getMessage(), t);
|
||||
}
|
||||
}, monitorInterval, monitorInterval, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
|
@ -196,7 +197,7 @@ public class DubboMonitor implements Monitor {
|
|||
try {
|
||||
ExecutorUtil.cancelScheduledFuture(sendFuture);
|
||||
} catch (Throwable t) {
|
||||
logger.error("Unexpected error occur at cancel sender timer, cause: " + t.getMessage(), t);
|
||||
logger.error(COMMON_MONITOR_EXCEPTION, "", "", "Unexpected error occur at cancel sender timer, cause: " + t.getMessage(), t);
|
||||
}
|
||||
monitorInvoker.destroy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,21 +16,23 @@
|
|||
*/
|
||||
package org.apache.dubbo.qos.command.impl;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.profiler.ProfilerSwitch;
|
||||
import org.apache.dubbo.qos.command.BaseCommand;
|
||||
import org.apache.dubbo.qos.command.CommandContext;
|
||||
import org.apache.dubbo.qos.command.annotation.Cmd;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_PROFILER_DISABLED;
|
||||
|
||||
@Cmd(name = "disableDetailProfiler", summary = "Disable Dubbo Invocation Profiler.")
|
||||
public class DisableDetailProfiler implements BaseCommand {
|
||||
private final static Logger logger = LoggerFactory.getLogger(DisableDetailProfiler.class);
|
||||
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DisableDetailProfiler.class);
|
||||
|
||||
@Override
|
||||
public String execute(CommandContext commandContext, String[] args) {
|
||||
ProfilerSwitch.disableDetailProfiler();
|
||||
logger.warn("Dubbo Invocation Profiler has been disabled.");
|
||||
logger.warn(QOS_PROFILER_DISABLED, "", "", "Dubbo Invocation Profiler has been disabled.");
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,21 +16,23 @@
|
|||
*/
|
||||
package org.apache.dubbo.qos.command.impl;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.profiler.ProfilerSwitch;
|
||||
import org.apache.dubbo.qos.command.BaseCommand;
|
||||
import org.apache.dubbo.qos.command.CommandContext;
|
||||
import org.apache.dubbo.qos.command.annotation.Cmd;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_PROFILER_DISABLED;
|
||||
|
||||
@Cmd(name = "disableSimpleProfiler", summary = "Disable Dubbo Invocation Profiler.")
|
||||
public class DisableSimpleProfiler implements BaseCommand {
|
||||
private final static Logger logger = LoggerFactory.getLogger(DisableSimpleProfiler.class);
|
||||
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DisableSimpleProfiler.class);
|
||||
|
||||
@Override
|
||||
public String execute(CommandContext commandContext, String[] args) {
|
||||
ProfilerSwitch.disableSimpleProfiler();
|
||||
logger.warn("Dubbo Invocation Profiler has been disabled.");
|
||||
logger.warn(QOS_PROFILER_DISABLED, "", "", "Dubbo Invocation Profiler has been disabled.");
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,21 +16,23 @@
|
|||
*/
|
||||
package org.apache.dubbo.qos.command.impl;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.profiler.ProfilerSwitch;
|
||||
import org.apache.dubbo.qos.command.BaseCommand;
|
||||
import org.apache.dubbo.qos.command.CommandContext;
|
||||
import org.apache.dubbo.qos.command.annotation.Cmd;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_PROFILER_ENABLED;
|
||||
|
||||
@Cmd(name = "enableDetailProfiler", summary = "Enable Dubbo Invocation Profiler.")
|
||||
public class EnableDetailProfiler implements BaseCommand {
|
||||
private final static Logger logger = LoggerFactory.getLogger(EnableDetailProfiler.class);
|
||||
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(EnableDetailProfiler.class);
|
||||
|
||||
@Override
|
||||
public String execute(CommandContext commandContext, String[] args) {
|
||||
ProfilerSwitch.enableDetailProfiler();
|
||||
logger.warn("Dubbo Invocation Profiler has been enabled.");
|
||||
logger.warn(QOS_PROFILER_ENABLED, "", "", "Dubbo Invocation Profiler has been enabled.");
|
||||
return "OK. This will cause performance degradation, please be careful!";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,21 +16,23 @@
|
|||
*/
|
||||
package org.apache.dubbo.qos.command.impl;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.profiler.ProfilerSwitch;
|
||||
import org.apache.dubbo.qos.command.BaseCommand;
|
||||
import org.apache.dubbo.qos.command.CommandContext;
|
||||
import org.apache.dubbo.qos.command.annotation.Cmd;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_PROFILER_ENABLED;
|
||||
|
||||
@Cmd(name = "enableSimpleProfiler", summary = "Enable Dubbo Invocation Profiler.")
|
||||
public class EnableSimpleProfiler implements BaseCommand {
|
||||
private final static Logger logger = LoggerFactory.getLogger(EnableSimpleProfiler.class);
|
||||
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(EnableSimpleProfiler.class);
|
||||
|
||||
@Override
|
||||
public String execute(CommandContext commandContext, String[] args) {
|
||||
ProfilerSwitch.enableSimpleProfiler();
|
||||
logger.warn("Dubbo Invocation Profiler has been enabled.");
|
||||
logger.warn(QOS_PROFILER_ENABLED, "", "", "Dubbo Invocation Profiler has been enabled.");
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.qos.command.impl;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository;
|
||||
import org.apache.dubbo.common.utils.ArrayUtils;
|
||||
|
|
@ -30,12 +30,14 @@ import org.apache.dubbo.rpc.model.FrameworkModel;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_PARAMETER_FORMAT_ERROR;
|
||||
|
||||
@Cmd(name = "publishMetadata", summary = "update service metadata and service instance", example = {
|
||||
"publishMetadata",
|
||||
"publishMetadata 5"
|
||||
"publishMetadata",
|
||||
"publishMetadata 5"
|
||||
})
|
||||
public class PublishMetadata implements BaseCommand {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PublishMetadata.class);
|
||||
public class PublishMetadata implements BaseCommand {
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(PublishMetadata.class);
|
||||
private final FrameworkModel frameworkModel;
|
||||
|
||||
public PublishMetadata(FrameworkModel frameworkModel) {
|
||||
|
|
@ -60,7 +62,7 @@ public class PublishMetadata implements BaseCommand {
|
|||
frameworkExecutorRepository.nextScheduledExecutor()
|
||||
.schedule(() -> ServiceInstanceMetadataUtils.refreshMetadataAndInstance(applicationModel), delay, TimeUnit.SECONDS);
|
||||
} catch (NumberFormatException e) {
|
||||
logger.error("Wrong delay param", e);
|
||||
logger.error(CONFIG_PARAMETER_FORMAT_ERROR, "", "", "Wrong delay param", e);
|
||||
return "publishMetadata failed! Wrong delay param!";
|
||||
}
|
||||
stringBuilder.append("publish task submitted, will publish in ").append(args[0]).append(" seconds. App:").append(applicationModel.getApplicationName()).append("\n");
|
||||
|
|
|
|||
|
|
@ -16,16 +16,18 @@
|
|||
*/
|
||||
package org.apache.dubbo.qos.command.impl;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.profiler.ProfilerSwitch;
|
||||
import org.apache.dubbo.qos.command.BaseCommand;
|
||||
import org.apache.dubbo.qos.command.CommandContext;
|
||||
import org.apache.dubbo.qos.command.annotation.Cmd;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_PROFILER_WARN_PERCENT;
|
||||
|
||||
@Cmd(name = "setProfilerWarnPercent", example = "setProfilerWarnPercent 0.75", summary = "Disable Dubbo Invocation Profiler.")
|
||||
public class SetProfilerWarnPercent implements BaseCommand {
|
||||
private final static Logger logger = LoggerFactory.getLogger(SetProfilerWarnPercent.class);
|
||||
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SetProfilerWarnPercent.class);
|
||||
|
||||
@Override
|
||||
public String execute(CommandContext commandContext, String[] args) {
|
||||
|
|
@ -33,7 +35,7 @@ public class SetProfilerWarnPercent implements BaseCommand {
|
|||
return "args error. example: setProfilerWarnPercent 0.75";
|
||||
}
|
||||
ProfilerSwitch.setWarnPercent(Double.parseDouble(args[0]));
|
||||
logger.warn("Dubbo Invocation Profiler warn percent has been set to " + args[0]);
|
||||
logger.warn(QOS_PROFILER_WARN_PERCENT, "", "", "Dubbo Invocation Profiler warn percent has been set to " + args[0]);
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.qos.protocol;
|
|||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.Activate;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.qos.common.QosConstants;
|
||||
import org.apache.dubbo.qos.pu.QosWireProtocol;
|
||||
|
|
@ -35,6 +35,7 @@ import org.apache.dubbo.rpc.model.ScopeModelAware;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_FAILED_START_SERVER;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE;
|
||||
import static org.apache.dubbo.common.constants.QosConstants.QOS_HOST;
|
||||
|
|
@ -43,7 +44,7 @@ import static org.apache.dubbo.common.constants.QosConstants.QOS_PORT;
|
|||
@Activate(order = 200)
|
||||
public class QosProtocolWrapper implements Protocol, ScopeModelAware {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(QosProtocolWrapper.class);
|
||||
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(QosProtocolWrapper.class);
|
||||
|
||||
private AtomicBoolean hasStarted = new AtomicBoolean(false);
|
||||
|
||||
|
|
@ -99,7 +100,7 @@ public class QosProtocolWrapper implements Protocol, ScopeModelAware {
|
|||
|
||||
boolean qosEnable = url.getParameter(QOS_ENABLE, true);
|
||||
WireProtocol qosWireProtocol = frameworkModel.getExtensionLoader(WireProtocol.class).getExtension("qos");
|
||||
if(qosWireProtocol != null) {
|
||||
if (qosWireProtocol != null) {
|
||||
((QosWireProtocol) qosWireProtocol).setQosEnable(qosEnable);
|
||||
}
|
||||
if (!qosEnable) {
|
||||
|
|
@ -124,7 +125,7 @@ public class QosProtocolWrapper implements Protocol, ScopeModelAware {
|
|||
server.start();
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
logger.warn("Fail to start qos server: ", throwable);
|
||||
logger.warn(QOS_FAILED_START_SERVER, "", "", "Fail to start qos server: ", throwable);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.qos.server;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.qos.server.handler.QosProcessHandler;
|
||||
|
|
@ -33,6 +33,8 @@ import io.netty.util.concurrent.DefaultThreadFactory;
|
|||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_FAILED_START_SERVER;
|
||||
|
||||
/**
|
||||
* A server serves for both telnet access and http access
|
||||
* <ul>
|
||||
|
|
@ -43,7 +45,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
*/
|
||||
public class Server {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Server.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(Server.class);
|
||||
|
||||
private String host;
|
||||
|
||||
|
|
@ -107,7 +109,7 @@ public class Server {
|
|||
|
||||
logger.info("qos-server bind localhost:" + port);
|
||||
} catch (Throwable throwable) {
|
||||
logger.error("qos-server can not bind localhost:" + port, throwable);
|
||||
logger.error(QOS_FAILED_START_SERVER, "", "", "qos-server can not bind localhost:" + port, throwable);
|
||||
throw throwable;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.qos.server.handler;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.qos.command.CommandContext;
|
||||
import org.apache.dubbo.qos.command.CommandExecutor;
|
||||
|
|
@ -37,6 +37,9 @@ import io.netty.handler.codec.http.HttpRequest;
|
|||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.handler.codec.http.HttpVersion;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_COMMAND_NOT_FOUND;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* Parse HttpRequest for uri and parameters
|
||||
* <p>
|
||||
|
|
@ -50,7 +53,7 @@ import io.netty.handler.codec.http.HttpVersion;
|
|||
*/
|
||||
public class HttpProcessHandler extends SimpleChannelInboundHandler<HttpRequest> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(HttpProcessHandler.class);
|
||||
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(HttpProcessHandler.class);
|
||||
private CommandExecutor commandExecutor;
|
||||
|
||||
public HttpProcessHandler(FrameworkModel frameworkModel) {
|
||||
|
|
@ -59,7 +62,7 @@ public class HttpProcessHandler extends SimpleChannelInboundHandler<HttpRequest>
|
|||
|
||||
private static FullHttpResponse http(int httpCode, String result) {
|
||||
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.valueOf(httpCode)
|
||||
, Unpooled.wrappedBuffer(result.getBytes()));
|
||||
, Unpooled.wrappedBuffer(result.getBytes()));
|
||||
HttpHeaders httpHeaders = response.headers();
|
||||
httpHeaders.set(HttpHeaderNames.CONTENT_TYPE, "text/plain");
|
||||
httpHeaders.set(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());
|
||||
|
|
@ -79,7 +82,7 @@ public class HttpProcessHandler extends SimpleChannelInboundHandler<HttpRequest>
|
|||
CommandContext commandContext = HttpCommandDecoder.decode(msg);
|
||||
// return 404 when fail to construct command context
|
||||
if (commandContext == null) {
|
||||
log.warn("can not found commandContext, url: " + msg.uri());
|
||||
log.warn(QOS_UNEXPECTED_EXCEPTION, "", "", "can not found commandContext, url: " + msg.uri());
|
||||
FullHttpResponse response = http404();
|
||||
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
|
||||
} else {
|
||||
|
|
@ -90,11 +93,11 @@ public class HttpProcessHandler extends SimpleChannelInboundHandler<HttpRequest>
|
|||
FullHttpResponse response = http(httpCode, result);
|
||||
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
|
||||
} catch (NoSuchCommandException ex) {
|
||||
log.error("can not find command: " + commandContext, ex);
|
||||
log.error(QOS_COMMAND_NOT_FOUND, "", "", "can not find command: " + commandContext, ex);
|
||||
FullHttpResponse response = http404();
|
||||
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
|
||||
} catch (Exception qosEx) {
|
||||
log.error("execute commandContext: " + commandContext + " got exception", qosEx);
|
||||
log.error(QOS_UNEXPECTED_EXCEPTION, "", "", "execute commandContext: " + commandContext + " got exception", qosEx);
|
||||
FullHttpResponse response = http(500, qosEx.getMessage());
|
||||
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.qos.server.handler;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.qos.command.CommandContext;
|
||||
|
|
@ -31,12 +31,15 @@ import io.netty.channel.ChannelFutureListener;
|
|||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_COMMAND_NOT_FOUND;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.QOS_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* Telnet process handler
|
||||
*/
|
||||
public class TelnetProcessHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TelnetProcessHandler.class);
|
||||
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(TelnetProcessHandler.class);
|
||||
private final CommandExecutor commandExecutor;
|
||||
|
||||
public TelnetProcessHandler(FrameworkModel frameworkModel) {
|
||||
|
|
@ -62,11 +65,11 @@ public class TelnetProcessHandler extends SimpleChannelInboundHandler<String> {
|
|||
} catch (NoSuchCommandException ex) {
|
||||
ctx.writeAndFlush(msg + " :no such command");
|
||||
ctx.writeAndFlush(QosConstants.BR_STR + QosProcessHandler.PROMPT);
|
||||
log.error("can not found command " + commandContext, ex);
|
||||
log.error(QOS_COMMAND_NOT_FOUND, "", "", "can not found command " + commandContext, ex);
|
||||
} catch (Exception ex) {
|
||||
ctx.writeAndFlush(msg + " :fail to execute commandContext by " + ex.getMessage());
|
||||
ctx.writeAndFlush(QosConstants.BR_STR + QosProcessHandler.PROMPT);
|
||||
log.error("execute commandContext got exception " + commandContext, ex);
|
||||
log.error(QOS_UNEXPECTED_EXCEPTION, "", "", "execute commandContext got exception " + commandContext, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_SOCKET_EXCEPTION;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_KEY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.OVERRIDE_PROTOCOL;
|
||||
|
|
@ -122,7 +123,7 @@ public class MulticastRegistry extends FailbackRegistry {
|
|||
Arrays.fill(buf, (byte) 0);
|
||||
} catch (Throwable e) {
|
||||
if (!multicastSocket.isClosed()) {
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.error(REGISTRY_SOCKET_EXCEPTION, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +139,7 @@ public class MulticastRegistry extends FailbackRegistry {
|
|||
try {
|
||||
clean(); // Remove the expired
|
||||
} catch (Throwable t) { // Defensive fault tolerance
|
||||
logger.error("Unexpected exception occur at clean expired provider, cause: " + t.getMessage(), t);
|
||||
logger.error(REGISTRY_SOCKET_EXCEPTION, "", "", "Unexpected exception occur at clean expired provider, cause: " + t.getMessage(), t);
|
||||
}
|
||||
}, cleanPeriod, cleanPeriod, TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
|
|
@ -151,10 +152,10 @@ public class MulticastRegistry extends FailbackRegistry {
|
|||
String message = "Invalid multicast address " + multicastAddress;
|
||||
if (multicastAddress instanceof Inet4Address) {
|
||||
throw new IllegalArgumentException(message + ", " +
|
||||
"ipv4 multicast address scope: 224.0.0.0 - 239.255.255.255.");
|
||||
"ipv4 multicast address scope: 224.0.0.0 - 239.255.255.255.");
|
||||
} else {
|
||||
throw new IllegalArgumentException(message + ", " + "ipv6 multicast address must start with ff, " +
|
||||
"for example: ff01::1");
|
||||
"for example: ff01::1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -168,7 +169,7 @@ public class MulticastRegistry extends FailbackRegistry {
|
|||
for (URL url : new HashSet<URL>(providers)) {
|
||||
if (isExpired(url)) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Clean expired provider " + url);
|
||||
logger.warn(REGISTRY_SOCKET_EXCEPTION, "", "", "Clean expired provider " + url);
|
||||
}
|
||||
doUnregister(url);
|
||||
}
|
||||
|
|
@ -213,7 +214,7 @@ public class MulticastRegistry extends FailbackRegistry {
|
|||
if (UrlUtils.isMatch(url, u)) {
|
||||
String host = remoteAddress != null && remoteAddress.getAddress() != null ? remoteAddress.getAddress().getHostAddress() : url.getIp();
|
||||
if (url.getParameter("unicast", true) // Whether the consumer's machine has only one process
|
||||
&& !NetUtils.getLocalHost().equals(host)) { // Multiple processes in the same machine cannot be unicast with unicast or there will be only one process receiving information
|
||||
&& !NetUtils.getLocalHost().equals(host)) { // Multiple processes in the same machine cannot be unicast with unicast or there will be only one process receiving information
|
||||
unicast(REGISTER + " " + u.toFullString(), host);
|
||||
} else {
|
||||
multicast(REGISTER + " " + u.toFullString());
|
||||
|
|
@ -301,13 +302,13 @@ public class MulticastRegistry extends FailbackRegistry {
|
|||
try {
|
||||
ExecutorUtil.cancelScheduledFuture(cleanFuture);
|
||||
} catch (Throwable t) {
|
||||
logger.warn(t.getMessage(), t);
|
||||
logger.warn(REGISTRY_SOCKET_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
try {
|
||||
multicastSocket.leaveGroup(multicastAddress);
|
||||
multicastSocket.close();
|
||||
} catch (Throwable t) {
|
||||
logger.warn(t.getMessage(), t);
|
||||
logger.warn(REGISTRY_SOCKET_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
ExecutorUtil.gracefulShutdown(cleanExecutor, cleanPeriod);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ 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.PROVIDER_SIDE;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_NACOS_EXCEPTION;
|
||||
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.CONSUMERS_CATEGORY;
|
||||
|
|
@ -279,7 +280,7 @@ public class NacosRegistry extends FailbackRegistry {
|
|||
} else {
|
||||
Map<NotifyListener, NacosAggregateListener> listenerMap = originToAggregateListener.get(url);
|
||||
if (listenerMap == null) {
|
||||
logger.warn(String.format("No aggregate listener found for url %s, this service might have already been unsubscribed.", url));
|
||||
logger.warn(REGISTRY_NACOS_EXCEPTION, "", "", String.format("No aggregate listener found for url %s, this service might have already been unsubscribed.", url));
|
||||
return;
|
||||
}
|
||||
NacosAggregateListener nacosAggregateListener = listenerMap.remove(listener);
|
||||
|
|
@ -291,7 +292,7 @@ public class NacosRegistry extends FailbackRegistry {
|
|||
NacosInstanceManageUtil.removeCorrespondingServiceNames(serviceName);
|
||||
}
|
||||
} catch (NacosException e) {
|
||||
logger.error("Failed to unsubscribe " + url + " to nacos " + getUrl() + ", cause: " + e.getMessage(), e);
|
||||
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", "Failed to unsubscribe " + url + " to nacos " + getUrl() + ", cause: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (listenerMap.isEmpty()) {
|
||||
|
|
@ -353,7 +354,7 @@ public class NacosRegistry extends FailbackRegistry {
|
|||
try {
|
||||
Set<String> serviceNames = new LinkedHashSet<>();
|
||||
serviceNames.addAll(namingService.getServicesOfServer(1, Integer.MAX_VALUE,
|
||||
getUrl().getGroup(Constants.DEFAULT_GROUP)).getData()
|
||||
getUrl().getGroup(Constants.DEFAULT_GROUP)).getData()
|
||||
.stream()
|
||||
.filter(this::isConformRules)
|
||||
.map(NacosServiceName::new)
|
||||
|
|
@ -534,7 +535,7 @@ public class NacosRegistry extends FailbackRegistry {
|
|||
List<URL> urls = buildURLs(consumerURL, instances);
|
||||
// Nacos does not support configurators and routers from registry, so all notifications are of providers type.
|
||||
if (urls.size() == 0 && !getUrl().getParameter(ENABLE_EMPTY_PROTECTION_KEY, true)) {
|
||||
logger.warn("Received empty url address list and empty protection is disabled, will clear current available addresses");
|
||||
logger.warn(REGISTRY_NACOS_EXCEPTION, "", "", "Received empty url address list and empty protection is disabled, will clear current available addresses");
|
||||
URL empty = URLBuilder.from(consumerURL)
|
||||
.setProtocol(EMPTY_PROTOCOL)
|
||||
.addParameter(CATEGORY_KEY, DEFAULT_CATEGORY)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.apache.dubbo.registry.nacos;
|
|||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.config.ConfigurationUtils;
|
||||
import org.apache.dubbo.common.function.ThrowableFunction;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.ConcurrentHashSet;
|
||||
import org.apache.dubbo.registry.client.AbstractServiceDiscovery;
|
||||
|
|
@ -44,6 +44,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_NACOS_EXCEPTION;
|
||||
import static org.apache.dubbo.common.function.ThrowableConsumer.execute;
|
||||
import static org.apache.dubbo.registry.nacos.util.NacosNamingServiceUtils.createNamingService;
|
||||
import static org.apache.dubbo.registry.nacos.util.NacosNamingServiceUtils.getGroup;
|
||||
|
|
@ -57,7 +58,7 @@ import static org.apache.dubbo.registry.nacos.util.NacosNamingServiceUtils.toIns
|
|||
*/
|
||||
public class NacosServiceDiscovery extends AbstractServiceDiscovery {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
|
||||
|
||||
private final String group;
|
||||
|
||||
|
|
@ -72,7 +73,7 @@ public class NacosServiceDiscovery extends AbstractServiceDiscovery {
|
|||
this.namingService = createNamingService(registryURL);
|
||||
// backward compatibility for 3.0.x
|
||||
this.group = Boolean.parseBoolean(ConfigurationUtils.getProperty(applicationModel, NACOS_SD_USE_DEFAULT_GROUP_KEY, "false")) ?
|
||||
DEFAULT_GROUP: getGroup(registryURL);
|
||||
DEFAULT_GROUP : getGroup(registryURL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -132,7 +133,7 @@ public class NacosServiceDiscovery extends AbstractServiceDiscovery {
|
|||
namingService.subscribe(serviceName, group, nacosEventListener);
|
||||
eventListeners.put(serviceName, nacosEventListener);
|
||||
} catch (NacosException e) {
|
||||
logger.error("add nacos service instances changed listener fail ", e);
|
||||
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", "add nacos service instances changed listener fail ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -152,7 +153,7 @@ public class NacosServiceDiscovery extends AbstractServiceDiscovery {
|
|||
try {
|
||||
namingService.unsubscribe(serviceName, group, nacosEventListener);
|
||||
} catch (NacosException e) {
|
||||
logger.error("remove nacos service instances changed listener fail ", e);
|
||||
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", "remove nacos service instances changed listener fail ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import static com.alibaba.nacos.api.PropertyKeyConst.USERNAME;
|
|||
import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP;
|
||||
import static com.alibaba.nacos.client.naming.utils.UtilAndComs.NACOS_NAMING_LOG_NAME;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_NACOS_EXCEPTION;
|
||||
import static org.apache.dubbo.common.constants.RemotingConstants.BACKUP_KEY;
|
||||
import static org.apache.dubbo.common.utils.StringConstantFieldValuePredicate.of;
|
||||
|
||||
|
|
@ -119,7 +120,7 @@ public class NacosNamingServiceUtils {
|
|||
namingService = NacosFactory.createNamingService(nacosProperties);
|
||||
} catch (NacosException e) {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error(e.getErrMsg(), e);
|
||||
logger.error(REGISTRY_NACOS_EXCEPTION, "", "", e.getErrMsg(), e);
|
||||
}
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
|
@ -157,10 +158,10 @@ public class NacosNamingServiceUtils {
|
|||
Map<String, String> parameters = url.getParameters(of(PropertyKeyConst.class));
|
||||
// Put all parameters
|
||||
properties.putAll(parameters);
|
||||
if (StringUtils.isNotEmpty(url.getUsername())){
|
||||
if (StringUtils.isNotEmpty(url.getUsername())) {
|
||||
properties.put(USERNAME, url.getUsername());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(url.getPassword())){
|
||||
if (StringUtils.isNotEmpty(url.getPassword())) {
|
||||
properties.put(PASSWORD, url.getPassword());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.CHECK_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMERS_CATEGORY;
|
||||
import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_CATEGORY;
|
||||
|
|
@ -87,20 +88,20 @@ public class ZookeeperRegistry extends CacheableFailbackRegistry {
|
|||
|
||||
this.zkClient.addStateListener((state) -> {
|
||||
if (state == StateListener.RECONNECTED) {
|
||||
logger.warn("Trying to fetch the latest urls, in case there are provider changes during connection loss.\n" +
|
||||
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "Trying to fetch the latest urls, in case there are provider changes during connection loss.\n" +
|
||||
" Since ephemeral ZNode will not get deleted for a connection lose, " +
|
||||
"there's no need to re-register url of this instance.");
|
||||
ZookeeperRegistry.this.fetchLatestAddresses();
|
||||
} else if (state == StateListener.NEW_SESSION_CREATED) {
|
||||
logger.warn("Trying to re-register urls and re-subscribe listeners of this instance to registry...");
|
||||
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "Trying to re-register urls and re-subscribe listeners of this instance to registry...");
|
||||
|
||||
try {
|
||||
ZookeeperRegistry.this.recover();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.error(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", e.getMessage(), e);
|
||||
}
|
||||
} else if (state == StateListener.SESSION_LOST) {
|
||||
logger.warn("Url of this instance will be deleted from registry soon. " +
|
||||
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "Url of this instance will be deleted from registry soon. " +
|
||||
"Dubbo client will try to re-register once a new session is created.");
|
||||
} else if (state == StateListener.SUSPENDED) {
|
||||
|
||||
|
|
@ -360,7 +361,7 @@ public class ZookeeperRegistry extends CacheableFailbackRegistry {
|
|||
|
||||
/**
|
||||
* Triggered when children get changed. It will be invoked by implementation of CuratorWatcher.
|
||||
*
|
||||
* <p>
|
||||
* 'org.apache.dubbo.remoting.zookeeper.curator5.Curator5ZookeeperClient.CuratorWatcherImpl' (Curator 5)
|
||||
*/
|
||||
private class RegistryChildListenerImpl implements ChildListener {
|
||||
|
|
@ -382,7 +383,7 @@ public class ZookeeperRegistry extends CacheableFailbackRegistry {
|
|||
try {
|
||||
latch.await();
|
||||
} catch (InterruptedException e) {
|
||||
logger.warn("Zookeeper children listener thread was interrupted unexpectedly, may cause race condition with the main thread.");
|
||||
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "Zookeeper children listener thread was interrupted unexpectedly, may cause race condition with the main thread.");
|
||||
}
|
||||
|
||||
notifier.notify(path, children);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.apache.dubbo.registry.zookeeper;
|
|||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.function.ThrowableConsumer;
|
||||
import org.apache.dubbo.common.function.ThrowableFunction;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.registry.client.AbstractServiceDiscovery;
|
||||
import org.apache.dubbo.registry.client.ServiceDiscovery;
|
||||
|
|
@ -40,6 +40,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION;
|
||||
import static org.apache.dubbo.common.function.ThrowableFunction.execute;
|
||||
import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkUtils.build;
|
||||
import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkUtils.buildCuratorFramework;
|
||||
|
|
@ -55,7 +56,7 @@ import static org.apache.dubbo.rpc.RpcException.REGISTRY_EXCEPTION;
|
|||
*/
|
||||
public class ZookeeperServiceDiscovery extends AbstractServiceDiscovery {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
|
||||
|
||||
public static final String DEFAULT_GROUP = "/services";
|
||||
|
||||
|
|
@ -165,7 +166,7 @@ public class ZookeeperServiceDiscovery extends AbstractServiceDiscovery {
|
|||
} catch (KeeperException.NoNodeException e) {
|
||||
// ignored
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error(e.getMessage());
|
||||
logger.error(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", e.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e.getMessage(), e);
|
||||
|
|
@ -189,7 +190,7 @@ public class ZookeeperServiceDiscovery extends AbstractServiceDiscovery {
|
|||
watcher.setLatch(latch);
|
||||
curatorFramework.getChildren().usingWatcher(watcher).forPath(path);
|
||||
} catch (Exception e) {
|
||||
logger.error("Trying to recover from new zkClient session failed, path is " + path + ", error msg: " + e.getMessage());
|
||||
logger.error(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "Trying to recover from new zkClient session failed, path is " + path + ", error msg: " + e.getMessage());
|
||||
}
|
||||
|
||||
List<ServiceInstance> instances = this.getInstances(watcher.getServiceName());
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ import static org.apache.curator.x.discovery.ServiceInstance.builder;
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SESSION_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION;
|
||||
import static org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery.DEFAULT_GROUP;
|
||||
import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkParams.BASE_SLEEP_TIME;
|
||||
import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkParams.BLOCK_UNTIL_CONNECTED_UNIT;
|
||||
|
|
@ -120,7 +121,7 @@ public abstract class CuratorFrameworkUtils {
|
|||
|
||||
|
||||
public static List<ServiceInstance> build(URL registryUrl, Collection<org.apache.curator.x.discovery.ServiceInstance<ZookeeperInstance>> instances) {
|
||||
return instances.stream().map((i)->build(registryUrl, i)).collect(Collectors.toList());
|
||||
return instances.stream().map((i) -> build(registryUrl, i)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static ServiceInstance build(URL registryUrl, org.apache.curator.x.discovery.ServiceInstance<ZookeeperInstance> instance) {
|
||||
|
|
@ -192,24 +193,24 @@ public abstract class CuratorFrameworkUtils {
|
|||
try {
|
||||
sessionId = client.getZookeeperClient().getZooKeeper().getSessionId();
|
||||
} catch (Exception e) {
|
||||
logger.warn("Curator client state changed, but failed to get the related zk session instance.");
|
||||
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "Curator client state changed, but failed to get the related zk session instance.");
|
||||
}
|
||||
|
||||
if (state == ConnectionState.LOST) {
|
||||
logger.warn("Curator zookeeper session " + Long.toHexString(lastSessionId) + " expired.");
|
||||
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "Curator zookeeper session " + Long.toHexString(lastSessionId) + " expired.");
|
||||
} else if (state == ConnectionState.SUSPENDED) {
|
||||
logger.warn("Curator zookeeper connection of session " + Long.toHexString(sessionId) + " timed out. " +
|
||||
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "Curator zookeeper connection of session " + Long.toHexString(sessionId) + " timed out. " +
|
||||
"connection timeout value is " + timeout + ", session expire timeout value is " + sessionExpireMs);
|
||||
} else if (state == ConnectionState.CONNECTED) {
|
||||
lastSessionId = sessionId;
|
||||
logger.info("Curator zookeeper client instance initiated successfully, session id is " + Long.toHexString(sessionId));
|
||||
} else if (state == ConnectionState.RECONNECTED) {
|
||||
if (lastSessionId == sessionId && sessionId != UNKNOWN_SESSION_ID) {
|
||||
logger.warn("Curator zookeeper connection recovered from connection lose, " +
|
||||
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "Curator zookeeper connection recovered from connection lose, " +
|
||||
"reuse the old session " + Long.toHexString(sessionId));
|
||||
serviceDiscovery.recover();
|
||||
} else {
|
||||
logger.warn("New session created after old session lost, " +
|
||||
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", "New session created after old session lost, " +
|
||||
"old session " + Long.toHexString(lastSessionId) + ", new session " + Long.toHexString(sessionId));
|
||||
lastSessionId = sessionId;
|
||||
serviceDiscovery.recover();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.remoting;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
|
|
@ -26,12 +26,14 @@ import org.apache.dubbo.rpc.model.ScopeModelInitializer;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_DESTROY_ZOOKEEPER;
|
||||
|
||||
/**
|
||||
* Scope model initializer for remoting-api
|
||||
*/
|
||||
public class RemotingScopeModelInitializer implements ScopeModelInitializer {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RemotingScopeModelInitializer.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(RemotingScopeModelInitializer.class);
|
||||
|
||||
@Override
|
||||
public void initializeFrameworkModel(FrameworkModel frameworkModel) {
|
||||
|
|
@ -48,7 +50,7 @@ public class RemotingScopeModelInitializer implements ScopeModelInitializer {
|
|||
zkTransporter.destroy();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Error encountered while destroying ZookeeperTransporter: " + e.getMessage(), e);
|
||||
logger.error(TRANSPORT_FAILED_DESTROY_ZOOKEEPER, "", "", "Error encountered while destroying ZookeeperTransporter: " + e.getMessage(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.remoting.api;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
|
|
@ -29,9 +29,11 @@ import io.netty.util.AttributeKey;
|
|||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
public class ConnectionHandler extends ChannelInboundHandlerAdapter {
|
||||
private static final Logger log = LoggerFactory.getLogger(ConnectionHandler.class);
|
||||
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(ConnectionHandler.class);
|
||||
private static final AttributeKey<Boolean> GO_AWAY_KEY = AttributeKey.valueOf("dubbo_channel_goaway");
|
||||
private final Connection connection;
|
||||
|
||||
|
|
@ -68,7 +70,7 @@ public class ConnectionHandler extends ChannelInboundHandlerAdapter {
|
|||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
log.warn(String.format("Channel error:%s", ctx.channel()), cause);
|
||||
log.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", String.format("Channel error:%s", ctx.channel()), cause);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.api;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
|
@ -29,10 +29,12 @@ import io.netty.handler.ssl.SslHandshakeCompletionEvent;
|
|||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
|
||||
|
||||
public class SslClientTlsHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SslClientTlsHandler.class);
|
||||
public class SslClientTlsHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SslClientTlsHandler.class);
|
||||
|
||||
private final SslContext sslContext;
|
||||
|
||||
|
|
@ -59,7 +61,7 @@ public class SslClientTlsHandler extends ChannelInboundHandlerAdapter {
|
|||
logger.info("TLS negotiation succeed with session: " + session);
|
||||
ctx.pipeline().remove(this);
|
||||
} else {
|
||||
logger.error("TLS negotiation failed when trying to accept new connection.", handshakeEvent.cause());
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "TLS negotiation failed when trying to accept new connection.", handshakeEvent.cause());
|
||||
ctx.fireExceptionCaught(handshakeEvent.cause());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.api;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.config.SslConfig;
|
||||
import org.apache.dubbo.config.context.ConfigManager;
|
||||
|
|
@ -34,9 +34,11 @@ import java.io.InputStream;
|
|||
import java.security.Provider;
|
||||
import java.security.Security;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CLOSE_STREAM;
|
||||
|
||||
public class SslContexts {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SslContexts.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SslContexts.class);
|
||||
|
||||
public static SslContext buildServerSslContext(URL url) {
|
||||
ConfigManager globalConfigManager = url.getOrDefaultApplicationModel().getApplicationConfigManager();
|
||||
|
|
@ -128,8 +130,8 @@ public class SslContexts {
|
|||
return SslProvider.JDK;
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
"Could not find any valid TLS provider, please check your dependency or deployment environment, " +
|
||||
"usually netty-tcnative, Conscrypt, or Jetty NPN/ALPN is needed.");
|
||||
"Could not find any valid TLS provider, please check your dependency or deployment environment, " +
|
||||
"usually netty-tcnative, Conscrypt, or Jetty NPN/ALPN is needed.");
|
||||
}
|
||||
|
||||
private static boolean checkJdkProvider() {
|
||||
|
|
@ -144,7 +146,7 @@ public class SslContexts {
|
|||
try {
|
||||
stream.close();
|
||||
} catch (IOException e) {
|
||||
logger.warn("Failed to close a stream.", e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE_STREAM, "", "", "Failed to close a stream.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.api;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
|
@ -31,8 +31,10 @@ import io.netty.handler.ssl.SslHandshakeCompletionEvent;
|
|||
import javax.net.ssl.SSLSession;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
|
||||
|
||||
public class SslServerTlsHandler extends ByteToMessageDecoder {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SslServerTlsHandler.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SslServerTlsHandler.class);
|
||||
|
||||
private final SslContext sslContext;
|
||||
private final boolean detectSsl;
|
||||
|
|
@ -57,7 +59,7 @@ public class SslServerTlsHandler extends ByteToMessageDecoder {
|
|||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
logger.error("TLS negotiation failed when trying to accept new connection.", cause);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "TLS negotiation failed when trying to accept new connection.", cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -70,7 +72,7 @@ public class SslServerTlsHandler extends ByteToMessageDecoder {
|
|||
// Remove after handshake success.
|
||||
ctx.pipeline().remove(this);
|
||||
} else {
|
||||
logger.error("TLS negotiation failed when trying to accept new connection.", handshakeEvent.cause());
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "TLS negotiation failed when trying to accept new connection.", handshakeEvent.cause());
|
||||
ctx.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.exchange;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.remoting.ChannelHandler;
|
||||
import org.apache.dubbo.remoting.RemotingException;
|
||||
|
|
@ -29,9 +29,11 @@ import java.util.ArrayList;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_ERROR_CLOSE_SERVER;
|
||||
|
||||
public class PortUnificationExchanger {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PortUnificationExchanger.class);
|
||||
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(PortUnificationExchanger.class);
|
||||
private static final ConcurrentMap<String, RemotingServer> servers = new ConcurrentHashMap<>();
|
||||
|
||||
public static RemotingServer bind(URL url, ChannelHandler handler) {
|
||||
|
|
@ -60,7 +62,7 @@ public class PortUnificationExchanger {
|
|||
try {
|
||||
server.close();
|
||||
} catch (Throwable throwable) {
|
||||
log.error("Close all port unification server failed", throwable);
|
||||
log.error(PROTOCOL_ERROR_CLOSE_SERVER, "", "", "Close all port unification server failed", throwable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.apache.dubbo.common.Version;
|
|||
import org.apache.dubbo.common.config.ConfigurationUtils;
|
||||
import org.apache.dubbo.common.io.Bytes;
|
||||
import org.apache.dubbo.common.io.StreamUtils;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.serialize.Cleanable;
|
||||
import org.apache.dubbo.common.serialize.ObjectInput;
|
||||
|
|
@ -43,6 +43,10 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_EXCEED_PAYLOAD_LIMIT;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_RESPONSE;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_SKIP_UNUSED_STREAM;
|
||||
|
||||
/**
|
||||
* ExchangeCodec.
|
||||
*/
|
||||
|
|
@ -59,7 +63,7 @@ public class ExchangeCodec extends TelnetCodec {
|
|||
protected static final byte FLAG_TWOWAY = (byte) 0x40;
|
||||
protected static final byte FLAG_EVENT = (byte) 0x20;
|
||||
protected static final int SERIALIZATION_MASK = 0x1f;
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExchangeCodec.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ExchangeCodec.class);
|
||||
|
||||
public Short getMagicCode() {
|
||||
return MAGIC;
|
||||
|
|
@ -88,7 +92,7 @@ public class ExchangeCodec extends TelnetCodec {
|
|||
protected Object decode(Channel channel, ChannelBuffer buffer, int readable, byte[] header) throws IOException {
|
||||
// check magic number.
|
||||
if (readable > 0 && header[0] != MAGIC_HIGH
|
||||
|| readable > 1 && header[1] != MAGIC_LOW) {
|
||||
|| readable > 1 && header[1] != MAGIC_LOW) {
|
||||
int length = header.length;
|
||||
if (header.length < readable) {
|
||||
header = Bytes.copyOf(header, readable);
|
||||
|
|
@ -132,11 +136,11 @@ public class ExchangeCodec extends TelnetCodec {
|
|||
if (is.available() > 0) {
|
||||
try {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Skip input stream " + is.available());
|
||||
logger.warn(TRANSPORT_SKIP_UNUSED_STREAM, "", "", "Skip input stream " + is.available());
|
||||
}
|
||||
StreamUtils.skipUnusedStream(is);
|
||||
} catch (IOException e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_SKIP_UNUSED_STREAM, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -298,10 +302,10 @@ public class ExchangeCodec extends TelnetCodec {
|
|||
|
||||
// encode response data or error message.
|
||||
if (status == Response.OK) {
|
||||
if(res.isHeartbeat()){
|
||||
if (res.isHeartbeat()) {
|
||||
// heartbeat response data is always null
|
||||
bos.write(CodecSupport.getNullBytesOf(serialization));
|
||||
}else {
|
||||
} else {
|
||||
ObjectOutput out = serialization.serialize(channel.getUrl(), bos);
|
||||
if (res.isEvent()) {
|
||||
encodeEventData(channel, out, res.getResult());
|
||||
|
|
@ -341,23 +345,23 @@ public class ExchangeCodec extends TelnetCodec {
|
|||
r.setStatus(Response.BAD_RESPONSE);
|
||||
|
||||
if (t instanceof ExceedPayloadLimitException) {
|
||||
logger.warn(t.getMessage(), t);
|
||||
logger.warn(TRANSPORT_EXCEED_PAYLOAD_LIMIT, "", "", t.getMessage(), t);
|
||||
try {
|
||||
r.setErrorMessage(t.getMessage());
|
||||
channel.send(r);
|
||||
return;
|
||||
} catch (RemotingException e) {
|
||||
logger.warn("Failed to send bad_response info back: " + t.getMessage() + ", cause: " + e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_RESPONSE, "", "", "Failed to send bad_response info back: " + t.getMessage() + ", cause: " + e.getMessage(), e);
|
||||
}
|
||||
} else {
|
||||
// FIXME log error message in Codec and handle in caught() of IoHanndler?
|
||||
logger.warn("Fail to encode response: " + res + ", send bad_response info instead, cause: " + t.getMessage(), t);
|
||||
logger.warn(TRANSPORT_FAILED_RESPONSE, "", "", "Fail to encode response: " + res + ", send bad_response info instead, cause: " + t.getMessage(), t);
|
||||
try {
|
||||
r.setErrorMessage("Failed to send response: " + res + ", cause: " + StringUtils.toString(t));
|
||||
channel.send(r);
|
||||
return;
|
||||
} catch (RemotingException e) {
|
||||
logger.warn("Failed to send bad_response info back: " + res + ", cause: " + e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_RESPONSE, "", "", "Failed to send bad_response info back: " + res + ", cause: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -493,7 +497,7 @@ public class ExchangeCodec extends TelnetCodec {
|
|||
}
|
||||
res.setStatus(Response.CLIENT_ERROR);
|
||||
String errorMsg = "Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel;
|
||||
logger.error(errorMsg);
|
||||
logger.error(TRANSPORT_EXCEED_PAYLOAD_LIMIT, "", "", errorMsg);
|
||||
res.setErrorMessage(errorMsg);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.remoting.exchange.support;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.resource.GlobalResourceInitializer;
|
||||
import org.apache.dubbo.common.threadpool.ThreadlessExecutor;
|
||||
|
|
@ -41,13 +41,14 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_TIMEOUT_SERVER;
|
||||
|
||||
/**
|
||||
* DefaultFuture.
|
||||
*/
|
||||
public class DefaultFuture extends CompletableFuture<Object> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DefaultFuture.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(DefaultFuture.class);
|
||||
|
||||
/**
|
||||
* in-flight channels
|
||||
|
|
@ -184,11 +185,11 @@ public class DefaultFuture extends CompletableFuture<Object> {
|
|||
}
|
||||
future.doReceived(response);
|
||||
} else {
|
||||
logger.warn("The timeout response finally returned at "
|
||||
+ (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()))
|
||||
+ ", response status is " + response.getStatus()
|
||||
+ (channel == null ? "" : ", channel: " + channel.getLocalAddress()
|
||||
+ " -> " + channel.getRemoteAddress()) + ", please check provider side for detailed result.");
|
||||
logger.warn(PROTOCOL_TIMEOUT_SERVER, "", "", "The timeout response finally returned at "
|
||||
+ (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()))
|
||||
+ ", response status is " + response.getStatus()
|
||||
+ (channel == null ? "" : ", channel: " + channel.getLocalAddress()
|
||||
+ " -> " + channel.getRemoteAddress()) + ", please check provider side for detailed result.");
|
||||
}
|
||||
} finally {
|
||||
CHANNELS.remove(response.getId());
|
||||
|
|
@ -229,7 +230,7 @@ public class DefaultFuture extends CompletableFuture<Object> {
|
|||
ThreadlessExecutor threadlessExecutor = (ThreadlessExecutor) executor;
|
||||
if (threadlessExecutor.isWaiting()) {
|
||||
threadlessExecutor.notifyReturn(new IllegalStateException("The result has returned, but the biz thread is still waiting" +
|
||||
" which is not an expected state, interrupt the thread manually by returning an exception."));
|
||||
" which is not an expected state, interrupt the thread manually by returning an exception."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -261,14 +262,14 @@ public class DefaultFuture extends CompletableFuture<Object> {
|
|||
private String getTimeoutMessage(boolean scan) {
|
||||
long nowTimestamp = System.currentTimeMillis();
|
||||
return (sent > 0 ? "Waiting server-side response timeout" : "Sending request timeout in client-side")
|
||||
+ (scan ? " by scan timer" : "") + ". start time: "
|
||||
+ (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date(start))) + ", end time: "
|
||||
+ (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date(nowTimestamp))) + ","
|
||||
+ (sent > 0 ? " client elapsed: " + (sent - start)
|
||||
+ " ms, server elapsed: " + (nowTimestamp - sent)
|
||||
: " elapsed: " + (nowTimestamp - start)) + " ms, timeout: "
|
||||
+ timeout + " ms, request: " + (logger.isDebugEnabled() ? request : request.copyWithoutData()) + ", channel: " + channel.getLocalAddress()
|
||||
+ " -> " + channel.getRemoteAddress();
|
||||
+ (scan ? " by scan timer" : "") + ". start time: "
|
||||
+ (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date(start))) + ", end time: "
|
||||
+ (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date(nowTimestamp))) + ","
|
||||
+ (sent > 0 ? " client elapsed: " + (sent - start)
|
||||
+ " ms, server elapsed: " + (nowTimestamp - sent)
|
||||
: " elapsed: " + (nowTimestamp - start)) + " ms, timeout: "
|
||||
+ timeout + " ms, request: " + (logger.isDebugEnabled() ? request : request.copyWithoutData()) + ", channel: " + channel.getLocalAddress()
|
||||
+ " -> " + channel.getRemoteAddress();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,16 +17,19 @@
|
|||
|
||||
package org.apache.dubbo.remoting.exchange.support.header;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.remoting.Channel;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_RESPONSE;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CLOSE;
|
||||
|
||||
/**
|
||||
* CloseTimerTask
|
||||
*/
|
||||
public class CloseTimerTask extends AbstractTimerTask {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CloseTimerTask.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(CloseTimerTask.class);
|
||||
|
||||
private final int idleTimeout;
|
||||
|
||||
|
|
@ -43,12 +46,12 @@ public class CloseTimerTask extends AbstractTimerTask {
|
|||
Long now = now();
|
||||
// check ping & pong at server
|
||||
if ((lastRead != null && now - lastRead > idleTimeout)
|
||||
|| (lastWrite != null && now - lastWrite > idleTimeout)) {
|
||||
logger.warn("Close channel " + channel + ", because idleCheck timeout: " + idleTimeout + "ms");
|
||||
|| (lastWrite != null && now - lastWrite > idleTimeout)) {
|
||||
logger.warn(PROTOCOL_FAILED_RESPONSE, "", "", "Close channel " + channel + ", because idleCheck timeout: " + idleTimeout + "ms");
|
||||
channel.close();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.warn("Exception when close remote channel " + channel.getRemoteAddress(), t);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", "Exception when close remote channel " + channel.getRemoteAddress(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.remoting.exchange.support.header;
|
|||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.Version;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.remoting.Channel;
|
||||
import org.apache.dubbo.remoting.ChannelHandler;
|
||||
|
|
@ -35,13 +35,14 @@ import java.util.concurrent.ExecutorService;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CLOSE;
|
||||
|
||||
/**
|
||||
* ExchangeReceiver
|
||||
*/
|
||||
final class HeaderExchangeChannel implements ExchangeChannel {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HeaderExchangeChannel.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(HeaderExchangeChannel.class);
|
||||
|
||||
private static final String CHANNEL_KEY = HeaderExchangeChannel.class.getName() + ".CHANNEL";
|
||||
|
||||
|
|
@ -93,8 +94,8 @@ final class HeaderExchangeChannel implements ExchangeChannel {
|
|||
throw new RemotingException(this.getLocalAddress(), null, "Failed to send message " + message + ", cause: The channel " + this + " is closed!");
|
||||
}
|
||||
if (message instanceof Request
|
||||
|| message instanceof Response
|
||||
|| message instanceof String) {
|
||||
|| message instanceof Response
|
||||
|| message instanceof String) {
|
||||
channel.send(message, sent);
|
||||
} else {
|
||||
Request request = new Request();
|
||||
|
|
@ -156,7 +157,7 @@ final class HeaderExchangeChannel implements ExchangeChannel {
|
|||
DefaultFuture.closeChannel(channel);
|
||||
channel.close();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -169,11 +170,11 @@ final class HeaderExchangeChannel implements ExchangeChannel {
|
|||
if (timeout > 0) {
|
||||
long start = System.currentTimeMillis();
|
||||
while (DefaultFuture.hasFuture(channel)
|
||||
&& System.currentTimeMillis() - start < timeout) {
|
||||
&& System.currentTimeMillis() - start < timeout) {
|
||||
try {
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.exchange.support.header;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -37,6 +37,8 @@ import java.net.InetSocketAddress;
|
|||
import java.util.concurrent.CompletionStage;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.READONLY_EVENT;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_RESPONSE;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNSUPPORTED_MESSAGE;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -44,7 +46,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.READONLY_EVENT;
|
|||
*/
|
||||
public class HeaderExchangeHandler implements ChannelHandlerDelegate {
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(HeaderExchangeHandler.class);
|
||||
protected static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(HeaderExchangeHandler.class);
|
||||
|
||||
private final ExchangeHandler handler;
|
||||
|
||||
|
|
@ -65,8 +67,8 @@ public class HeaderExchangeHandler implements ChannelHandlerDelegate {
|
|||
InetSocketAddress address = channel.getRemoteAddress();
|
||||
URL url = channel.getUrl();
|
||||
return url.getPort() == address.getPort() &&
|
||||
NetUtils.filterLocalHost(url.getIp())
|
||||
.equals(NetUtils.filterLocalHost(address.getAddress().getHostAddress()));
|
||||
NetUtils.filterLocalHost(url.getIp())
|
||||
.equals(NetUtils.filterLocalHost(address.getAddress().getHostAddress()));
|
||||
}
|
||||
|
||||
void handlerEvent(Channel channel, Request req) throws RemotingException {
|
||||
|
|
@ -109,7 +111,7 @@ public class HeaderExchangeHandler implements ChannelHandlerDelegate {
|
|||
}
|
||||
channel.send(res);
|
||||
} catch (RemotingException e) {
|
||||
logger.warn("Send result to consumer failed, channel is " + channel + ", msg is " + e);
|
||||
logger.warn(TRANSPORT_FAILED_RESPONSE, "", "", "Send result to consumer failed, channel is " + channel + ", msg is " + e);
|
||||
}
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
|
|
@ -157,7 +159,7 @@ public class HeaderExchangeHandler implements ChannelHandlerDelegate {
|
|||
throw (RemotingException) exception;
|
||||
} else {
|
||||
throw new RemotingException(channel.getLocalAddress(), channel.getRemoteAddress(),
|
||||
exception.getMessage(), exception);
|
||||
exception.getMessage(), exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -182,7 +184,7 @@ public class HeaderExchangeHandler implements ChannelHandlerDelegate {
|
|||
} else if (message instanceof String) {
|
||||
if (isClientSide(channel)) {
|
||||
Exception e = new Exception("Dubbo client can not supported string message: " + message + " in channel: " + channel + ", url: " + channel.getUrl());
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.error(TRANSPORT_UNSUPPORTED_MESSAGE, "", "", e.getMessage(), e);
|
||||
} else {
|
||||
String echo = handler.telnet(channel, (String) message);
|
||||
if (StringUtils.isNotEmpty(echo)) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.remoting.exchange.support.header;
|
|||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.Version;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.resource.GlobalResourceInitializer;
|
||||
import org.apache.dubbo.common.timer.HashedWheelTimer;
|
||||
|
|
@ -44,6 +44,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
|
||||
import static java.util.Collections.unmodifiableCollection;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.READONLY_EVENT;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CLOSE;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_RESPONSE;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
|
||||
import static org.apache.dubbo.remoting.Constants.HEARTBEAT_CHECK_TICK;
|
||||
import static org.apache.dubbo.remoting.Constants.LEAST_HEARTBEAT_DURATION;
|
||||
import static org.apache.dubbo.remoting.Constants.TICKS_PER_WHEEL;
|
||||
|
|
@ -55,7 +58,7 @@ import static org.apache.dubbo.remoting.utils.UrlUtils.getIdleTimeout;
|
|||
*/
|
||||
public class HeaderExchangeServer implements ExchangeServer {
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
protected final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
|
||||
|
||||
private final RemotingServer server;
|
||||
|
||||
|
|
@ -111,7 +114,7 @@ public class HeaderExchangeServer implements ExchangeServer {
|
|||
try {
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -141,7 +144,7 @@ public class HeaderExchangeServer implements ExchangeServer {
|
|||
// ignore ClosedChannelException which means the connection has been closed.
|
||||
continue;
|
||||
}
|
||||
logger.warn("send cannot write message error.", e);
|
||||
logger.warn(TRANSPORT_FAILED_RESPONSE, "", "", "send cannot write message error.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -218,7 +221,7 @@ public class HeaderExchangeServer implements ExchangeServer {
|
|||
startIdleCheckTask(url);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -232,7 +235,7 @@ public class HeaderExchangeServer implements ExchangeServer {
|
|||
public void send(Object message) throws RemotingException {
|
||||
if (closed.get()) {
|
||||
throw new RemotingException(this.getLocalAddress(), null, "Failed to send message " + message
|
||||
+ ", cause: The server " + getLocalAddress() + " is closed!");
|
||||
+ ", cause: The server " + getLocalAddress() + " is closed!");
|
||||
}
|
||||
server.send(message);
|
||||
}
|
||||
|
|
@ -241,7 +244,7 @@ public class HeaderExchangeServer implements ExchangeServer {
|
|||
public void send(Object message, boolean sent) throws RemotingException {
|
||||
if (closed.get()) {
|
||||
throw new RemotingException(this.getLocalAddress(), null, "Failed to send message " + message
|
||||
+ ", cause: The server " + getLocalAddress() + " is closed!");
|
||||
+ ", cause: The server " + getLocalAddress() + " is closed!");
|
||||
}
|
||||
server.send(message, sent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,19 +18,20 @@
|
|||
package org.apache.dubbo.remoting.exchange.support.header;
|
||||
|
||||
import org.apache.dubbo.common.Version;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.remoting.Channel;
|
||||
import org.apache.dubbo.remoting.exchange.Request;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.HEARTBEAT_EVENT;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_RESPONSE;
|
||||
|
||||
/**
|
||||
* HeartbeatTimerTask
|
||||
*/
|
||||
public class HeartbeatTimerTask extends AbstractTimerTask {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HeartbeatTimerTask.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(HeartbeatTimerTask.class);
|
||||
|
||||
private final int heartbeat;
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ public class HeartbeatTimerTask extends AbstractTimerTask {
|
|||
Long lastWrite = lastWrite(channel);
|
||||
Long now = now();
|
||||
if ((lastRead != null && now - lastRead > heartbeat)
|
||||
|| (lastWrite != null && now - lastWrite > heartbeat)) {
|
||||
|| (lastWrite != null && now - lastWrite > heartbeat)) {
|
||||
Request req = new Request();
|
||||
req.setVersion(Version.getProtocolVersion());
|
||||
req.setTwoWay(true);
|
||||
|
|
@ -54,12 +55,12 @@ public class HeartbeatTimerTask extends AbstractTimerTask {
|
|||
channel.send(req);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Send heartbeat to remote channel " + channel.getRemoteAddress()
|
||||
+ ", cause: The channel has no data-transmission exceeds a heartbeat period: "
|
||||
+ heartbeat + "ms");
|
||||
+ ", cause: The channel has no data-transmission exceeds a heartbeat period: "
|
||||
+ heartbeat + "ms");
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.warn("Exception when heartbeat to remote channel " + channel.getRemoteAddress(), t);
|
||||
logger.warn(TRANSPORT_FAILED_RESPONSE, "", "", "Exception when heartbeat to remote channel " + channel.getRemoteAddress(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,17 +17,20 @@
|
|||
|
||||
package org.apache.dubbo.remoting.exchange.support.header;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.remoting.Channel;
|
||||
import org.apache.dubbo.remoting.Client;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_RECONNECT;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* ReconnectTimerTask
|
||||
*/
|
||||
public class ReconnectTimerTask extends AbstractTimerTask {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ReconnectTimerTask.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ReconnectTimerTask.class);
|
||||
|
||||
private final int idleTimeout;
|
||||
|
||||
|
|
@ -48,20 +51,20 @@ public class ReconnectTimerTask extends AbstractTimerTask {
|
|||
logger.info("Initial connection to " + channel);
|
||||
((Client) channel).reconnect();
|
||||
} catch (Exception e) {
|
||||
logger.error("Fail to connect to " + channel, e);
|
||||
logger.error(TRANSPORT_FAILED_RECONNECT, "", "", "Fail to connect to" + channel, e);
|
||||
}
|
||||
// check pong at client
|
||||
// check pong at client
|
||||
} else if (lastRead != null && now - lastRead > idleTimeout) {
|
||||
logger.warn("Reconnect to channel " + channel + ", because heartbeat read idle time out: "
|
||||
+ idleTimeout + "ms");
|
||||
logger.warn(TRANSPORT_FAILED_RECONNECT, "", "", "Reconnect to channel " + channel + ", because heartbeat read idle time out: "
|
||||
+ idleTimeout + "ms");
|
||||
try {
|
||||
((Client) channel).reconnect();
|
||||
} catch (Exception e) {
|
||||
logger.error(channel + "reconnect failed during idle time.", e);
|
||||
logger.error(TRANSPORT_FAILED_RECONNECT, "", "", channel + "reconnect failed during idle time.", e);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.warn("Exception when reconnect to remote channel " + channel.getRemoteAddress(), t);
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "Exception when reconnect to remote channel " + channel.getRemoteAddress(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.telnet.codec;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
|
|
@ -33,6 +33,7 @@ import java.util.Arrays;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNSUPPORTED_CHARSET;
|
||||
import static org.apache.dubbo.remoting.Constants.CHARSET_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.DEFAULT_CHARSET;
|
||||
|
||||
|
|
@ -41,7 +42,7 @@ import static org.apache.dubbo.remoting.Constants.DEFAULT_CHARSET;
|
|||
*/
|
||||
public class TelnetCodec extends TransportCodec {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TelnetCodec.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(TelnetCodec.class);
|
||||
|
||||
private static final String HISTORY_LIST_KEY = "telnet.history.list";
|
||||
|
||||
|
|
@ -52,13 +53,13 @@ public class TelnetCodec extends TransportCodec {
|
|||
private static final byte[] DOWN = new byte[]{27, 91, 66};
|
||||
|
||||
private static final List<?> ENTER = Arrays.asList(
|
||||
new byte[]{'\r', '\n'} /* Windows Enter */,
|
||||
new byte[]{'\n'} /* Linux Enter */);
|
||||
new byte[]{'\r', '\n'} /* Windows Enter */,
|
||||
new byte[]{'\n'} /* Linux Enter */);
|
||||
|
||||
private static final List<?> EXIT = Arrays.asList(
|
||||
new byte[]{3} /* Windows Ctrl+C */,
|
||||
new byte[]{-1, -12, -1, -3, 6} /* Linux Ctrl+C */,
|
||||
new byte[]{-1, -19, -1, -3, 6} /* Linux Pause */);
|
||||
new byte[]{3} /* Windows Ctrl+C */,
|
||||
new byte[]{-1, -12, -1, -3, 6} /* Linux Ctrl+C */,
|
||||
new byte[]{-1, -19, -1, -3, 6} /* Linux Pause */);
|
||||
|
||||
private static Charset getCharset(Channel channel) {
|
||||
if (channel != null) {
|
||||
|
|
@ -67,7 +68,7 @@ public class TelnetCodec extends TransportCodec {
|
|||
try {
|
||||
return Charset.forName((String) attribute);
|
||||
} catch (Throwable t) {
|
||||
logger.warn(t.getMessage(), t);
|
||||
logger.warn(TRANSPORT_UNSUPPORTED_CHARSET, "", "", t.getMessage(), t);
|
||||
}
|
||||
} else if (attribute instanceof Charset) {
|
||||
return (Charset) attribute;
|
||||
|
|
@ -79,7 +80,7 @@ public class TelnetCodec extends TransportCodec {
|
|||
try {
|
||||
return Charset.forName(parameter);
|
||||
} catch (Throwable t) {
|
||||
logger.warn(t.getMessage(), t);
|
||||
logger.warn(TRANSPORT_UNSUPPORTED_CHARSET, "", "", t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -87,7 +88,7 @@ public class TelnetCodec extends TransportCodec {
|
|||
try {
|
||||
return Charset.forName(DEFAULT_CHARSET);
|
||||
} catch (Throwable t) {
|
||||
logger.warn(t.getMessage(), t);
|
||||
logger.warn(TRANSPORT_UNSUPPORTED_CHARSET, "", "", t.getMessage(), t);
|
||||
}
|
||||
return Charset.defaultCharset();
|
||||
}
|
||||
|
|
@ -115,7 +116,7 @@ public class TelnetCodec extends TransportCodec {
|
|||
i = i + 2;
|
||||
}
|
||||
} else if (b == -1 && i < message.length - 2
|
||||
&& (message[i + 1] == -3 || message[i + 1] == -5)) { // handshake
|
||||
&& (message[i + 1] == -3 || message[i + 1] == -5)) { // handshake
|
||||
i = i + 2;
|
||||
} else {
|
||||
copy[index++] = message[i];
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.remoting.transport;
|
|||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.Version;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.threadpool.manager.ExecutorRepository;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
|
|
@ -38,6 +38,8 @@ import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_CLIENT_T
|
|||
import static org.apache.dubbo.common.constants.CommonConstants.THREADPOOL_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.LAZY_CONNECT_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CLOSE;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CONNECT_PROVIDER;
|
||||
|
||||
/**
|
||||
* AbstractClient
|
||||
|
|
@ -46,7 +48,7 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client
|
|||
|
||||
protected static final String CLIENT_THREAD_POOL_NAME = "DubboClientHandler";
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractClient.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractClient.class);
|
||||
|
||||
private final Lock connectLock = new ReentrantLock();
|
||||
|
||||
|
|
@ -80,7 +82,7 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client
|
|||
// If lazy connect client fails to establish a connection, the client instance will still be created,
|
||||
// and the reconnection will be initiated by ReconnectTask, so there is no need to throw an exception
|
||||
if (url.getParameter(LAZY_CONNECT_KEY, false)) {
|
||||
logger.warn("Failed to start " + getClass().getSimpleName() + " " + NetUtils.getLocalAddress() +
|
||||
logger.warn(TRANSPORT_FAILED_CONNECT_PROVIDER, "", "", "Failed to start " + getClass().getSimpleName() + " " + NetUtils.getLocalAddress() +
|
||||
" connect to the server " + getRemoteAddress() +
|
||||
" (the connection request is initiated by lazy connect client, ignore and retry later!), cause: " +
|
||||
t.getMessage(), t);
|
||||
|
|
@ -91,7 +93,7 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client
|
|||
close();
|
||||
throw t;
|
||||
} else {
|
||||
logger.warn("Failed to start " + getClass().getSimpleName() + " " + NetUtils.getLocalAddress()
|
||||
logger.warn(TRANSPORT_FAILED_CONNECT_PROVIDER, "", "", "Failed to start " + getClass().getSimpleName() + " " + NetUtils.getLocalAddress()
|
||||
+ " connect to the server " + getRemoteAddress() + " (check == false, ignore and retry later!), cause: " + t.getMessage(), t);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
|
|
@ -210,7 +212,7 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client
|
|||
}
|
||||
|
||||
if (isClosed() || isClosing()) {
|
||||
logger.warn("No need to connect to server " + getRemoteAddress() + " from " + getClass().getSimpleName() + " "
|
||||
logger.warn(TRANSPORT_FAILED_CONNECT_PROVIDER, "", "", "No need to connect to server " + getRemoteAddress() + " from " + getClass().getSimpleName() + " "
|
||||
+ NetUtils.getLocalHost() + " using dubbo version " + Version.getVersion() + ", cause: client status is closed or closing.");
|
||||
return;
|
||||
}
|
||||
|
|
@ -252,12 +254,12 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client
|
|||
channel.close();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
doDisConnect();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
} finally {
|
||||
connectLock.unlock();
|
||||
|
|
@ -278,33 +280,33 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client
|
|||
@Override
|
||||
public void close() {
|
||||
if (isClosed()) {
|
||||
logger.warn("No need to close connection to server " + getRemoteAddress() + " from " + getClass().getSimpleName() + " " + NetUtils.getLocalHost() + " using dubbo version " + Version.getVersion() + ", cause: the client status is closed.");
|
||||
logger.warn(TRANSPORT_FAILED_CONNECT_PROVIDER, "", "", "No need to close connection to server " + getRemoteAddress() + " from " + getClass().getSimpleName() + " " + NetUtils.getLocalHost() + " using dubbo version " + Version.getVersion() + ", cause: the client status is closed.");
|
||||
return;
|
||||
}
|
||||
|
||||
connectLock.lock();
|
||||
try {
|
||||
if (isClosed()) {
|
||||
logger.warn("No need to close connection to server " + getRemoteAddress() + " from " + getClass().getSimpleName() + " " + NetUtils.getLocalHost() + " using dubbo version " + Version.getVersion() + ", cause: the client status is closed.");
|
||||
logger.warn(TRANSPORT_FAILED_CONNECT_PROVIDER, "", "", "No need to close connection to server " + getRemoteAddress() + " from " + getClass().getSimpleName() + " " + NetUtils.getLocalHost() + " using dubbo version " + Version.getVersion() + ", cause: the client status is closed.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
super.close();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
disconnect();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
doClose();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.transport;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.serialize.Serialization;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
|
|
@ -33,13 +33,14 @@ import java.io.IOException;
|
|||
import java.net.InetSocketAddress;
|
||||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_EXCEED_PAYLOAD_LIMIT;
|
||||
|
||||
/**
|
||||
* AbstractCodec
|
||||
*/
|
||||
public abstract class AbstractCodec implements Codec2, ScopeModelAware {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractCodec.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractCodec.class);
|
||||
|
||||
private static final String CLIENT_SIDE = "client";
|
||||
|
||||
|
|
@ -56,8 +57,8 @@ public abstract class AbstractCodec implements Codec2, ScopeModelAware {
|
|||
boolean overPayload = isOverPayload(payload, size);
|
||||
if (overPayload) {
|
||||
ExceedPayloadLimitException e = new ExceedPayloadLimitException(
|
||||
"Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel);
|
||||
logger.error(e);
|
||||
"Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel);
|
||||
logger.error(TRANSPORT_EXCEED_PAYLOAD_LIMIT, "", "", e.getMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.remoting.transport;
|
|||
|
||||
import org.apache.dubbo.common.Resetable;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.StringUtils;
|
||||
import org.apache.dubbo.remoting.ChannelHandler;
|
||||
|
|
@ -28,6 +28,7 @@ import org.apache.dubbo.remoting.Constants;
|
|||
import org.apache.dubbo.remoting.transport.codec.CodecAdapter;
|
||||
import org.apache.dubbo.rpc.model.FrameworkModel;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
|
||||
import static org.apache.dubbo.rpc.model.ScopeModelUtil.getFrameworkModel;
|
||||
|
||||
/**
|
||||
|
|
@ -35,7 +36,7 @@ import static org.apache.dubbo.rpc.model.ScopeModelUtil.getFrameworkModel;
|
|||
*/
|
||||
public abstract class AbstractEndpoint extends AbstractPeer implements Resetable {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractEndpoint.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractEndpoint.class);
|
||||
|
||||
private Codec2 codec;
|
||||
|
||||
|
|
@ -56,10 +57,10 @@ public abstract class AbstractEndpoint extends AbstractPeer implements Resetable
|
|||
FrameworkModel frameworkModel = getFrameworkModel(url.getScopeModel());
|
||||
if (frameworkModel.getExtensionLoader(Codec2.class).hasExtension(codecName)) {
|
||||
return frameworkModel.getExtensionLoader(Codec2.class).getExtension(codecName);
|
||||
} else if(frameworkModel.getExtensionLoader(Codec.class).hasExtension(codecName)){
|
||||
} else if (frameworkModel.getExtensionLoader(Codec.class).hasExtension(codecName)) {
|
||||
return new CodecAdapter(frameworkModel.getExtensionLoader(Codec.class)
|
||||
.getExtension(codecName));
|
||||
}else {
|
||||
} else {
|
||||
return frameworkModel.getExtensionLoader(Codec2.class).getExtension("default");
|
||||
}
|
||||
}
|
||||
|
|
@ -79,7 +80,7 @@ public abstract class AbstractEndpoint extends AbstractPeer implements Resetable
|
|||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -87,7 +88,7 @@ public abstract class AbstractEndpoint extends AbstractPeer implements Resetable
|
|||
this.codec = getChannelCodec(url);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.transport;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.threadpool.manager.ExecutorRepository;
|
||||
import org.apache.dubbo.common.utils.ConcurrentHashSet;
|
||||
|
|
@ -36,6 +36,7 @@ import java.util.concurrent.ExecutorService;
|
|||
|
||||
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.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
|
||||
import static org.apache.dubbo.remoting.Constants.ACCEPTS_KEY;
|
||||
import static org.apache.dubbo.remoting.Constants.DEFAULT_ACCEPTS;
|
||||
|
||||
|
|
@ -45,7 +46,7 @@ import static org.apache.dubbo.remoting.Constants.DEFAULT_ACCEPTS;
|
|||
public abstract class AbstractServer extends AbstractEndpoint implements RemotingServer {
|
||||
|
||||
protected static final String SERVER_THREAD_POOL_NAME = "DubboServerHandler";
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractServer.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractServer.class);
|
||||
private Set<ExecutorService> executors = new ConcurrentHashSet<>();
|
||||
private InetSocketAddress localAddress;
|
||||
private InetSocketAddress bindAddress;
|
||||
|
|
@ -72,7 +73,7 @@ public abstract class AbstractServer extends AbstractEndpoint implements Remotin
|
|||
}
|
||||
} catch (Throwable t) {
|
||||
throw new RemotingException(url.toInetSocketAddress(), null, "Failed to bind " + getClass().getSimpleName()
|
||||
+ " on " + bindAddress + ", cause: " + t.getMessage(), t);
|
||||
+ " on " + bindAddress + ", cause: " + t.getMessage(), t);
|
||||
}
|
||||
executors.add(executorRepository.createExecutorIfAbsent(url));
|
||||
}
|
||||
|
|
@ -95,7 +96,7 @@ public abstract class AbstractServer extends AbstractEndpoint implements Remotin
|
|||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
|
||||
ExecutorService executor = executorRepository.createExecutorIfAbsent(url);
|
||||
|
|
@ -127,13 +128,13 @@ public abstract class AbstractServer extends AbstractEndpoint implements Remotin
|
|||
try {
|
||||
super.close();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
doClose();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -162,13 +163,13 @@ public abstract class AbstractServer extends AbstractEndpoint implements Remotin
|
|||
public void connected(Channel ch) throws RemotingException {
|
||||
// If the server has entered the shutdown process, reject any new connection
|
||||
if (this.isClosing() || this.isClosed()) {
|
||||
logger.warn("Close new channel " + ch + ", cause: server is closing or has been closed. For example, receive a new connect request while in shutdown process.");
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "Close new channel " + ch + ", cause: server is closing or has been closed. For example, receive a new connect request while in shutdown process.");
|
||||
ch.close();
|
||||
return;
|
||||
}
|
||||
|
||||
if (accepts > 0 && getChannels().size() > accepts) {
|
||||
logger.error("Close channel " + ch + ", cause: The server " + ch.getLocalAddress() + " connections greater than max config " + accepts);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "Close channel " + ch + ", cause: The server " + ch.getLocalAddress() + " connections greater than max config " + accepts);
|
||||
ch.close();
|
||||
return;
|
||||
}
|
||||
|
|
@ -179,7 +180,7 @@ public abstract class AbstractServer extends AbstractEndpoint implements Remotin
|
|||
public void disconnected(Channel ch) throws RemotingException {
|
||||
Collection<Channel> channels = getChannels();
|
||||
if (channels.isEmpty()) {
|
||||
logger.warn("All clients has disconnected from " + ch.getLocalAddress() + ". You can graceful shutdown now.");
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "All clients has disconnected from " + ch.getLocalAddress() + ". You can graceful shutdown now.");
|
||||
}
|
||||
super.disconnected(ch);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.dubbo.remoting.transport;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.remoting.Channel;
|
||||
|
|
@ -26,12 +26,14 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* ChannelListenerDispatcher
|
||||
*/
|
||||
public class ChannelHandlerDispatcher implements ChannelHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChannelHandlerDispatcher.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ChannelHandlerDispatcher.class);
|
||||
|
||||
private final Collection<ChannelHandler> channelHandlers = new CopyOnWriteArraySet<>();
|
||||
|
||||
|
|
@ -68,7 +70,7 @@ public class ChannelHandlerDispatcher implements ChannelHandler {
|
|||
try {
|
||||
listener.connected(channel);
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -79,7 +81,7 @@ public class ChannelHandlerDispatcher implements ChannelHandler {
|
|||
try {
|
||||
listener.disconnected(channel);
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -90,7 +92,7 @@ public class ChannelHandlerDispatcher implements ChannelHandler {
|
|||
try {
|
||||
listener.sent(channel, message);
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -101,7 +103,7 @@ public class ChannelHandlerDispatcher implements ChannelHandler {
|
|||
try {
|
||||
listener.received(channel, message);
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -112,7 +114,7 @@ public class ChannelHandlerDispatcher implements ChannelHandler {
|
|||
try {
|
||||
listener.caught(channel, exception);
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.apache.dubbo.remoting.transport;
|
|||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.serialize.ObjectInput;
|
||||
import org.apache.dubbo.common.serialize.ObjectOutput;
|
||||
|
|
@ -41,9 +41,10 @@ import java.util.Set;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.apache.dubbo.common.BaseServiceMetadata.keyWithoutGroup;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_SERIALIZATION;
|
||||
|
||||
public class CodecSupport {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CodecSupport.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(CodecSupport.class);
|
||||
private static Map<Byte, Serialization> ID_SERIALIZATION_MAP = new HashMap<Byte, Serialization>();
|
||||
private static Map<Byte, String> ID_SERIALIZATIONNAME_MAP = new HashMap<Byte, String>();
|
||||
private static Map<String, Byte> SERIALIZATIONNAME_ID_MAP = new HashMap<String, Byte>();
|
||||
|
|
@ -59,10 +60,10 @@ public class CodecSupport {
|
|||
Serialization serialization = extensionLoader.getExtension(name);
|
||||
byte idByte = serialization.getContentTypeId();
|
||||
if (ID_SERIALIZATION_MAP.containsKey(idByte)) {
|
||||
logger.error("Serialization extension " + serialization.getClass().getName()
|
||||
+ " has duplicate id to Serialization extension "
|
||||
+ ID_SERIALIZATION_MAP.get(idByte).getClass().getName()
|
||||
+ ", ignore this Serialization extension");
|
||||
logger.error(TRANSPORT_FAILED_SERIALIZATION, "", "", "Serialization extension " + serialization.getClass().getName()
|
||||
+ " has duplicate id to Serialization extension "
|
||||
+ ID_SERIALIZATION_MAP.get(idByte).getClass().getName()
|
||||
+ ", ignore this Serialization extension");
|
||||
continue;
|
||||
}
|
||||
ID_SERIALIZATION_MAP.put(idByte, serialization);
|
||||
|
|
@ -84,7 +85,7 @@ public class CodecSupport {
|
|||
|
||||
public static Serialization getSerialization(URL url) {
|
||||
return url.getOrDefaultFrameworkModel().getExtensionLoader(Serialization.class).getExtension(
|
||||
url.getParameter(Constants.SERIALIZATION_KEY, DefaultSerializationSelector.getDefaultRemotingSerialization()));
|
||||
url.getParameter(Constants.SERIALIZATION_KEY, DefaultSerializationSelector.getDefaultRemotingSerialization()));
|
||||
}
|
||||
|
||||
public static Serialization getSerialization(URL url, Byte id) throws IOException {
|
||||
|
|
@ -119,7 +120,7 @@ public class CodecSupport {
|
|||
nullBytes = baos.toByteArray();
|
||||
baos.close();
|
||||
} catch (Exception e) {
|
||||
logger.warn("Serialization extension " + s.getClass().getName() + " not support serializing null object, return an empty bytes instead.");
|
||||
logger.warn(TRANSPORT_FAILED_SERIALIZATION, "", "", "Serialization extension " + s.getClass().getName() + " not support serializing null object, return an empty bytes instead.");
|
||||
}
|
||||
return nullBytes;
|
||||
});
|
||||
|
|
@ -175,7 +176,7 @@ public class CodecSupport {
|
|||
match = true;
|
||||
}
|
||||
}
|
||||
if(!match) {
|
||||
if (!match) {
|
||||
throw new IOException("Unexpected serialization id:" + id + " received from network, please check if the peer send the right id.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.apache.dubbo.remoting.transport;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.remoting.Channel;
|
||||
import org.apache.dubbo.remoting.ChannelHandler;
|
||||
|
|
@ -26,9 +26,11 @@ import org.apache.dubbo.remoting.RemotingException;
|
|||
import org.apache.dubbo.remoting.exchange.Request;
|
||||
import org.apache.dubbo.remoting.exchange.Response;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_DECODE;
|
||||
|
||||
public class DecodeHandler extends AbstractChannelHandlerDelegate {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DecodeHandler.class);
|
||||
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(DecodeHandler.class);
|
||||
|
||||
public DecodeHandler(ChannelHandler handler) {
|
||||
super(handler);
|
||||
|
|
@ -63,7 +65,7 @@ public class DecodeHandler extends AbstractChannelHandlerDelegate {
|
|||
}
|
||||
} catch (Throwable e) {
|
||||
if (log.isWarnEnabled()) {
|
||||
log.warn("Call Decodeable.decode failed: " + e.getMessage(), e);
|
||||
log.warn(TRANSPORT_FAILED_DECODE, "", "", "Call Decodeable.decode failed: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,19 +16,21 @@
|
|||
*/
|
||||
package org.apache.dubbo.remoting.transport;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.remoting.Channel;
|
||||
import org.apache.dubbo.remoting.ChannelHandler;
|
||||
import org.apache.dubbo.remoting.RemotingException;
|
||||
import org.apache.dubbo.remoting.exchange.support.MultiMessage;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* @see MultiMessage
|
||||
*/
|
||||
public class MultiMessageHandler extends AbstractChannelHandlerDelegate {
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(MultiMessageHandler.class);
|
||||
protected static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(MultiMessageHandler.class);
|
||||
|
||||
public MultiMessageHandler(ChannelHandler handler) {
|
||||
super(handler);
|
||||
|
|
@ -43,11 +45,11 @@ public class MultiMessageHandler extends AbstractChannelHandlerDelegate {
|
|||
try {
|
||||
handler.received(channel, obj);
|
||||
} catch (Throwable t) {
|
||||
logger.error("MultiMessageHandler received fail.", t);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "MultiMessageHandler received fail.", t);
|
||||
try {
|
||||
handler.caught(channel, t);
|
||||
} catch (Throwable t1) {
|
||||
logger.error("MultiMessageHandler caught fail.", t1);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "MultiMessageHandler caught fail.", t1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,16 @@
|
|||
*/
|
||||
package org.apache.dubbo.remoting.transport.dispatcher;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.threadlocal.InternalThreadLocal;
|
||||
import org.apache.dubbo.remoting.Channel;
|
||||
import org.apache.dubbo.remoting.ChannelHandler;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
|
||||
|
||||
public class ChannelEventRunnable implements Runnable {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChannelEventRunnable.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ChannelEventRunnable.class);
|
||||
|
||||
private final ChannelHandler handler;
|
||||
private final Channel channel;
|
||||
|
|
@ -58,43 +60,43 @@ public class ChannelEventRunnable implements Runnable {
|
|||
try {
|
||||
handler.received(channel, message);
|
||||
} catch (Exception e) {
|
||||
logger.warn("ChannelEventRunnable handle " + state + " operation error, channel is " + channel
|
||||
+ ", message is " + message, e);
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel
|
||||
+ ", message is " + message, e);
|
||||
}
|
||||
} else {
|
||||
switch (state) {
|
||||
case CONNECTED:
|
||||
try {
|
||||
handler.connected(channel);
|
||||
} catch (Exception e) {
|
||||
logger.warn("ChannelEventRunnable handle " + state + " operation error, channel is " + channel, e);
|
||||
}
|
||||
break;
|
||||
case DISCONNECTED:
|
||||
try {
|
||||
handler.disconnected(channel);
|
||||
} catch (Exception e) {
|
||||
logger.warn("ChannelEventRunnable handle " + state + " operation error, channel is " + channel, e);
|
||||
}
|
||||
break;
|
||||
case SENT:
|
||||
try {
|
||||
handler.sent(channel, message);
|
||||
} catch (Exception e) {
|
||||
logger.warn("ChannelEventRunnable handle " + state + " operation error, channel is " + channel
|
||||
case CONNECTED:
|
||||
try {
|
||||
handler.connected(channel);
|
||||
} catch (Exception e) {
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel, e);
|
||||
}
|
||||
break;
|
||||
case DISCONNECTED:
|
||||
try {
|
||||
handler.disconnected(channel);
|
||||
} catch (Exception e) {
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel, e);
|
||||
}
|
||||
break;
|
||||
case SENT:
|
||||
try {
|
||||
handler.sent(channel, message);
|
||||
} catch (Exception e) {
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel
|
||||
+ ", message is " + message, e);
|
||||
}
|
||||
break;
|
||||
case CAUGHT:
|
||||
try {
|
||||
handler.caught(channel, exception);
|
||||
} catch (Exception e) {
|
||||
logger.warn("ChannelEventRunnable handle " + state + " operation error, channel is " + channel
|
||||
}
|
||||
break;
|
||||
case CAUGHT:
|
||||
try {
|
||||
handler.caught(channel, exception);
|
||||
} catch (Exception e) {
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel
|
||||
+ ", message is: " + message + ", exception is " + exception, e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
logger.warn("unknown state: " + state + ", message is " + message);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "unknown state: " + state + ", message is " + message);
|
||||
}
|
||||
}
|
||||
InternalThreadLocal.removeAll();
|
||||
|
|
@ -102,8 +104,6 @@ public class ChannelEventRunnable implements Runnable {
|
|||
|
||||
/**
|
||||
* ChannelState
|
||||
*
|
||||
*
|
||||
*/
|
||||
public enum ChannelState {
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.transport.dispatcher;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.resource.GlobalResourcesRepository;
|
||||
import org.apache.dubbo.common.threadpool.manager.ExecutorRepository;
|
||||
|
|
@ -34,7 +34,7 @@ import java.util.concurrent.ExecutorService;
|
|||
|
||||
public class WrappedChannelHandler implements ChannelHandlerDelegate {
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(WrappedChannelHandler.class);
|
||||
protected static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(WrappedChannelHandler.class);
|
||||
|
||||
protected final ChannelHandler handler;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_THREAD_NAME;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_CONNECTION_LIMIT_EXCEED;
|
||||
import static org.apache.dubbo.remoting.Constants.CONNECT_QUEUE_CAPACITY;
|
||||
import static org.apache.dubbo.remoting.Constants.CONNECT_QUEUE_WARNING_SIZE;
|
||||
import static org.apache.dubbo.remoting.Constants.DEFAULT_CONNECT_QUEUE_WARNING_SIZE;
|
||||
|
|
@ -49,10 +50,10 @@ public class ConnectionOrderedChannelHandler extends WrappedChannelHandler {
|
|||
super(handler, url);
|
||||
String threadName = url.getParameter(THREAD_NAME_KEY, DEFAULT_THREAD_NAME);
|
||||
connectionExecutor = new ThreadPoolExecutor(1, 1,
|
||||
0L, TimeUnit.MILLISECONDS,
|
||||
0L, TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue<>(url.getPositiveParameter(CONNECT_QUEUE_CAPACITY, Integer.MAX_VALUE)),
|
||||
new NamedThreadFactory(threadName, true),
|
||||
new AbortPolicyWithReport(threadName, url)
|
||||
new NamedThreadFactory(threadName, true),
|
||||
new AbortPolicyWithReport(threadName, url)
|
||||
); // FIXME There's no place to release connectionExecutor!
|
||||
queueWarningLimit = url.getParameter(CONNECT_QUEUE_WARNING_SIZE, DEFAULT_CONNECT_QUEUE_WARNING_SIZE);
|
||||
}
|
||||
|
|
@ -103,7 +104,7 @@ public class ConnectionOrderedChannelHandler extends WrappedChannelHandler {
|
|||
|
||||
private void checkQueueLength() {
|
||||
if (connectionExecutor.getQueue().size() > queueWarningLimit) {
|
||||
logger.warn(new IllegalThreadStateException("connectionordered channel handler queue size: " + connectionExecutor.getQueue().size() + " exceed the warning limit number :" + queueWarningLimit));
|
||||
logger.warn(TRANSPORT_CONNECTION_LIMIT_EXCEED, "", "", "connectionordered channel handler queue size: " + connectionExecutor.getQueue().size() + " exceed the warning limit number :" + queueWarningLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.remoting.zookeeper;
|
|||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.config.configcenter.ConfigItem;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.ConcurrentHashSet;
|
||||
|
||||
|
|
@ -29,9 +29,11 @@ import java.util.concurrent.ConcurrentMap;
|
|||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION;
|
||||
|
||||
public abstract class AbstractZookeeperClient<TargetDataListener, TargetChildListener> implements ZookeeperClient {
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(AbstractZookeeperClient.class);
|
||||
protected static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractZookeeperClient.class);
|
||||
|
||||
// may hang up to wait name resolution up to 10s
|
||||
protected int DEFAULT_CONNECTION_TIMEOUT_MS = 30 * 1000;
|
||||
|
|
@ -159,7 +161,7 @@ public abstract class AbstractZookeeperClient<TargetDataListener, TargetChildLis
|
|||
try {
|
||||
doClose();
|
||||
} catch (Throwable t) {
|
||||
logger.warn(t.getMessage(), t);
|
||||
logger.warn(REGISTRY_ZOOKEEPER_EXCEPTION, "", "", t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.http.jetty;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.remoting.Constants;
|
||||
|
|
@ -35,10 +35,11 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_THREADS;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_STOP_HTTP_SERVER;
|
||||
|
||||
public class JettyHttpServer extends AbstractHttpServer {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(JettyHttpServer.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(JettyHttpServer.class);
|
||||
|
||||
private Server server;
|
||||
|
||||
|
|
@ -86,7 +87,7 @@ public class JettyHttpServer extends AbstractHttpServer {
|
|||
server.start();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Failed to start jetty server on " + url.getParameter(Constants.BIND_IP_KEY) + ":" + url.getParameter(Constants.BIND_PORT_KEY) + ", cause: "
|
||||
+ e.getMessage(), e);
|
||||
+ e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +102,7 @@ public class JettyHttpServer extends AbstractHttpServer {
|
|||
try {
|
||||
server.stop();
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(COMMON_FAILED_STOP_HTTP_SERVER, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,32 +16,35 @@
|
|||
*/
|
||||
package org.apache.dubbo.remoting.http.jetty;
|
||||
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import org.eclipse.jetty.util.log.AbstractLogger;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
|
||||
|
||||
/**
|
||||
* logger adapter for jetty
|
||||
*/
|
||||
public class JettyLoggerAdapter extends AbstractLogger {
|
||||
protected String name;
|
||||
|
||||
private final org.apache.dubbo.common.logger.Logger logger;
|
||||
private final ErrorTypeAwareLogger logger;
|
||||
|
||||
private static boolean debugEnabled = false;
|
||||
|
||||
public JettyLoggerAdapter(){
|
||||
public JettyLoggerAdapter() {
|
||||
this("org.apache.dubbo.remoting.http.jetty");
|
||||
}
|
||||
|
||||
public JettyLoggerAdapter(Class<?> clazz){
|
||||
public JettyLoggerAdapter(Class<?> clazz) {
|
||||
this(clazz.getName());
|
||||
}
|
||||
|
||||
public JettyLoggerAdapter(String name) {
|
||||
this.name = name;
|
||||
this.logger = LoggerFactory.getLogger(name);
|
||||
this.logger = LoggerFactory.getErrorTypeAwareLogger(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -56,42 +59,42 @@ public class JettyLoggerAdapter extends AbstractLogger {
|
|||
|
||||
@Override
|
||||
public void warn(String msg, Object... objects) {
|
||||
if (logger.isWarnEnabled()){
|
||||
logger.warn(this.format(msg, objects));
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", this.format(msg, objects));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Throwable throwable) {
|
||||
if (logger.isWarnEnabled()){
|
||||
logger.warn(throwable);
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", throwable.getMessage(), throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String msg, Throwable throwable) {
|
||||
if (logger.isWarnEnabled()){
|
||||
logger.warn(msg, throwable);
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", msg, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String msg, Object... objects) {
|
||||
if (logger.isInfoEnabled()){
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info(this.format(msg, objects));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Throwable throwable) {
|
||||
if (logger.isInfoEnabled()){
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String msg, Throwable throwable) {
|
||||
if (logger.isInfoEnabled()){
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info(msg, throwable);
|
||||
}
|
||||
}
|
||||
|
|
@ -108,29 +111,29 @@ public class JettyLoggerAdapter extends AbstractLogger {
|
|||
|
||||
@Override
|
||||
public void debug(String msg, Object... objects) {
|
||||
if (debugEnabled && logger.isDebugEnabled()){
|
||||
if (debugEnabled && logger.isDebugEnabled()) {
|
||||
logger.debug(this.format(msg, objects));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Throwable throwable) {
|
||||
if (debugEnabled && logger.isDebugEnabled()){
|
||||
if (debugEnabled && logger.isDebugEnabled()) {
|
||||
logger.debug(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String msg, Throwable throwable) {
|
||||
if (debugEnabled && logger.isDebugEnabled()){
|
||||
if (debugEnabled && logger.isDebugEnabled()) {
|
||||
logger.debug(msg, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignore(Throwable throwable) {
|
||||
if (logger.isWarnEnabled()){
|
||||
logger.warn("IGNORED EXCEPTION ", throwable);
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn(COMMON_UNEXPECTED_EXCEPTION, "", "", "IGNORED EXCEPTION ", throwable);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.http.tomcat;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.remoting.http.HttpHandler;
|
||||
import org.apache.dubbo.remoting.http.servlet.DispatcherServlet;
|
||||
|
|
@ -33,11 +33,12 @@ import java.io.File;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_THREADS;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_STOP_HTTP_SERVER;
|
||||
import static org.apache.dubbo.remoting.Constants.ACCEPTS_KEY;
|
||||
|
||||
public class TomcatHttpServer extends AbstractHttpServer {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TomcatHttpServer.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(TomcatHttpServer.class);
|
||||
|
||||
private final Tomcat tomcat;
|
||||
|
||||
|
|
@ -91,7 +92,7 @@ public class TomcatHttpServer extends AbstractHttpServer {
|
|||
// close port by destroy()
|
||||
tomcat.destroy();
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(COMMON_FAILED_STOP_HTTP_SERVER, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.http.jetty;
|
|||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.support.FailsafeErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.url.component.ServiceConfigURL;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.remoting.Constants;
|
||||
|
|
@ -70,7 +71,7 @@ public class JettyLoggerAdapterTest {
|
|||
|
||||
Field loggerField = clazz.getDeclaredField("logger");
|
||||
loggerField.setAccessible(true);
|
||||
loggerField.set(jettyLoggerAdapter, successLogger);
|
||||
loggerField.set(jettyLoggerAdapter, new FailsafeErrorTypeAwareLogger(successLogger));
|
||||
jettyLoggerAdapter.setDebugEnabled(true);
|
||||
|
||||
when(successLogger.isDebugEnabled()).thenReturn(true);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.transport.netty;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.remoting.ChannelHandler;
|
||||
import org.apache.dubbo.remoting.RemotingException;
|
||||
|
|
@ -33,13 +33,14 @@ import java.util.concurrent.ConcurrentMap;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CLOSE;
|
||||
|
||||
/**
|
||||
* NettyChannel.
|
||||
*/
|
||||
final class NettyChannel extends AbstractChannel {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NettyChannel.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(NettyChannel.class);
|
||||
|
||||
private static final ConcurrentMap<org.jboss.netty.channel.Channel, NettyChannel> CHANNEL_MAP = new ConcurrentHashMap<org.jboss.netty.channel.Channel, NettyChannel>();
|
||||
|
||||
|
|
@ -115,7 +116,7 @@ final class NettyChannel extends AbstractChannel {
|
|||
|
||||
if (!success) {
|
||||
throw new RemotingException(this, "Failed to send message " + PayloadDropper.getRequestWithoutData(message) + " to " + getRemoteAddress()
|
||||
+ "in timeout(" + timeout + "ms) limit");
|
||||
+ "in timeout(" + timeout + "ms) limit");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,17 +125,17 @@ final class NettyChannel extends AbstractChannel {
|
|||
try {
|
||||
super.close();
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
removeChannelIfDisconnected(channel);
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
attributes.clear();
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
if (logger.isInfoEnabled()) {
|
||||
|
|
@ -142,7 +143,7 @@ final class NettyChannel extends AbstractChannel {
|
|||
}
|
||||
channel.close();
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_CLIENT_CONNECT_TIMEOUT;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CONNECT_PROVIDER;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_DISCONNECT_PROVIDER;
|
||||
|
||||
/**
|
||||
* NettyClient.
|
||||
|
|
@ -52,8 +53,8 @@ public class NettyClient extends AbstractClient {
|
|||
// ChannelFactory's closure has a DirectMemory leak, using static to avoid
|
||||
// https://issues.jboss.org/browse/NETTY-424
|
||||
private static final ChannelFactory CHANNEL_FACTORY = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(new NamedThreadFactory("NettyClientBoss", true)),
|
||||
Executors.newCachedThreadPool(new NamedThreadFactory("NettyClientWorker", true)),
|
||||
Constants.DEFAULT_IO_THREADS);
|
||||
Executors.newCachedThreadPool(new NamedThreadFactory("NettyClientWorker", true)),
|
||||
Constants.DEFAULT_IO_THREADS);
|
||||
private ClientBootstrap bootstrap;
|
||||
|
||||
private volatile Channel channel; // volatile, please copy reference to use
|
||||
|
|
@ -127,7 +128,7 @@ public class NettyClient extends AbstractClient {
|
|||
Throwable cause = future.getCause();
|
||||
|
||||
RemotingException remotingException = new RemotingException(this, "client(url: " + getUrl() + ") failed to connect to server "
|
||||
+ getRemoteAddress() + ", error message is:" + cause.getMessage(), cause);
|
||||
+ getRemoteAddress() + ", error message is:" + cause.getMessage(), cause);
|
||||
|
||||
// 6-1 - Failed to connect to provider server by other reason.
|
||||
logger.error(TRANSPORT_FAILED_CONNECT_PROVIDER, "network disconnected", "", "Failed to connect to provider server by other reason.", cause);
|
||||
|
|
@ -136,9 +137,9 @@ public class NettyClient extends AbstractClient {
|
|||
} else {
|
||||
|
||||
RemotingException remotingException = new RemotingException(this, "client(url: " + getUrl() + ") failed to connect to server "
|
||||
+ getRemoteAddress() + " client-side timeout "
|
||||
+ getConnectTimeout() + "ms (elapsed: " + (System.currentTimeMillis() - start) + "ms) from netty client "
|
||||
+ NetUtils.getLocalHost() + " using dubbo version " + Version.getVersion());
|
||||
+ getRemoteAddress() + " client-side timeout "
|
||||
+ getConnectTimeout() + "ms (elapsed: " + (System.currentTimeMillis() - start) + "ms) from netty client "
|
||||
+ NetUtils.getLocalHost() + " using dubbo version " + Version.getVersion());
|
||||
|
||||
// 6-2 - Client-side timeout.
|
||||
logger.error(TRANSPORT_CLIENT_CONNECT_TIMEOUT, "provider crash", "", "Client-side timeout.", remotingException);
|
||||
|
|
@ -157,7 +158,7 @@ public class NettyClient extends AbstractClient {
|
|||
try {
|
||||
NettyChannel.removeChannelIfDisconnected(channel);
|
||||
} catch (Throwable t) {
|
||||
logger.warn(t.getMessage());
|
||||
logger.warn(TRANSPORT_FAILED_DISCONNECT_PROVIDER, "", "", t.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,13 +16,15 @@
|
|||
*/
|
||||
package org.apache.dubbo.remoting.transport.netty;
|
||||
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
|
||||
import org.jboss.netty.logging.AbstractInternalLogger;
|
||||
import org.jboss.netty.logging.InternalLogger;
|
||||
import org.jboss.netty.logging.InternalLoggerFactory;
|
||||
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
|
||||
|
||||
final class NettyHelper {
|
||||
|
||||
public static void setNettyLoggerFactory() {
|
||||
|
|
@ -36,15 +38,15 @@ final class NettyHelper {
|
|||
|
||||
@Override
|
||||
public InternalLogger newInstance(String name) {
|
||||
return new DubboLogger(LoggerFactory.getLogger(name));
|
||||
return new DubboLogger(LoggerFactory.getErrorTypeAwareLogger(name));
|
||||
}
|
||||
}
|
||||
|
||||
static class DubboLogger extends AbstractInternalLogger {
|
||||
|
||||
private Logger logger;
|
||||
private ErrorTypeAwareLogger logger;
|
||||
|
||||
DubboLogger(Logger logger) {
|
||||
DubboLogger(ErrorTypeAwareLogger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
|
|
@ -90,22 +92,22 @@ final class NettyHelper {
|
|||
|
||||
@Override
|
||||
public void warn(String msg) {
|
||||
logger.warn(msg);
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String msg, Throwable cause) {
|
||||
logger.warn(msg, cause);
|
||||
logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", msg, cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String msg) {
|
||||
logger.error(msg);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String msg, Throwable cause) {
|
||||
logger.error(msg, cause);
|
||||
logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", msg, cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.dubbo.remoting.transport.netty;
|
||||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.logger.Logger;
|
||||
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
|
||||
import org.apache.dubbo.common.logger.LoggerFactory;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.apache.dubbo.common.utils.ExecutorUtil;
|
||||
|
|
@ -47,6 +47,7 @@ import java.util.concurrent.Executors;
|
|||
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.BACKLOG_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.IO_THREADS_KEY;
|
||||
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CLOSE;
|
||||
import static org.apache.dubbo.remoting.Constants.EVENT_LOOP_BOSS_POOL_NAME;
|
||||
import static org.apache.dubbo.remoting.Constants.EVENT_LOOP_WORKER_POOL_NAME;
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ import static org.apache.dubbo.remoting.Constants.EVENT_LOOP_WORKER_POOL_NAME;
|
|||
*/
|
||||
public class NettyServer extends AbstractServer implements RemotingServer {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NettyServer.class);
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(NettyServer.class);
|
||||
|
||||
private Map<String, Channel> channels; // <ip:port, channel>
|
||||
|
||||
|
|
@ -109,7 +110,7 @@ public class NettyServer extends AbstractServer implements RemotingServer {
|
|||
channel.close();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
Collection<org.apache.dubbo.remoting.Channel> channels = getChannels();
|
||||
|
|
@ -118,12 +119,12 @@ public class NettyServer extends AbstractServer implements RemotingServer {
|
|||
try {
|
||||
channel.close();
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
if (bootstrap != null) {
|
||||
|
|
@ -131,14 +132,14 @@ public class NettyServer extends AbstractServer implements RemotingServer {
|
|||
bootstrap.releaseExternalResources();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
if (channels != null) {
|
||||
channels.clear();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
logger.warn(TRANSPORT_FAILED_CLOSE, "", "", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue