3.1-Error code is managed with constants (#10771) (#10837)

This commit is contained in:
cnjxzhao 2022-10-27 10:40:13 +08:00 committed by GitHub
parent 6f35df41b5
commit 6ed4cc2457
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 155 additions and 104 deletions

View File

@ -37,6 +37,10 @@ public interface LoggerCodeConstants {
String COMMON_CLASS_NOT_FOUND = "0-7";
String COMMON_FAILED_REFLECT = "0-8";
String COMMON_FAILED_NOTIFY_EVENT = "0-9";
// registry module
String REGISTRY_ADDRESS_INVALID = "1-1";
@ -150,6 +154,16 @@ public interface LoggerCodeConstants {
// proxy module
String PROXY_FAILED_CONVERT_URL = "3-1";
String PROXY_FAILED_EXPORT_SERVICE = "3-2";
String PROXY_FAILED_JAVASSIST = "3-3";
String PROXY_TIMEOUT_REQUEST = "3-4";
String PROXY_ERROR_ASYNC_RESPONSE = "3-5";
String PROXY_UNSUPPORTED_INVOKER = "3-6";
// protocol module
String PROTOCOL_UNSUPPORTED = "4-1";
@ -185,6 +199,12 @@ public interface LoggerCodeConstants {
String PROTOCOL_FAILED_DESTROY_INVOKER = "4-17";
String PROTOCOL_FAILED_LOAD_MODEL = "4-18";
String PROTOCOL_INCORRECT_PARAMETER_VALUES = "4-19";
String PROTOCOL_FAILED_DECODE = "4-20";
// config module
String CONFIG_FAILED_CONNECT_REGISTRY = "5-1";

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.rpc;
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 org.apache.dubbo.common.threadpool.ThreadlessExecutor;
import org.apache.dubbo.rpc.model.ConsumerMethodModel;
@ -33,6 +33,7 @@ import java.util.function.BiConsumer;
import java.util.function.Function;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_ASYNC_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_ERROR_ASYNC_RESPONSE;
import static org.apache.dubbo.common.utils.ReflectUtils.defaultReturn;
/**
@ -50,7 +51,7 @@ import static org.apache.dubbo.common.utils.ReflectUtils.defaultReturn;
* for compatibility consideration. Because many legacy {@link Filter} implementation are most possibly to call getValue directly.
*/
public class AsyncRpcResult implements Result {
private static final Logger logger = LoggerFactory.getLogger(AsyncRpcResult.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AsyncRpcResult.class);
/**
* RpcContext may already have been changed when callback happens, it happens when the same thread is used to execute another RPC call.
@ -95,7 +96,7 @@ public class AsyncRpcResult implements Result {
/**
* CompletableFuture can only be completed once, so try to update the result of one completed CompletableFuture will
* have no effect. To avoid this problem, we check the complete status of this future before update its value.
*
* <p>
* But notice that trying to give an uncompleted CompletableFuture a new specified value may face a race condition,
* because the background thread watching the real result will also change the status of this CompletableFuture.
* The result is you may lose the value you expected to set.
@ -114,7 +115,7 @@ public class AsyncRpcResult implements Result {
}
} catch (Exception e) {
// This should not happen in normal request process;
logger.error("Got exception when trying to fetch the underlying result from AsyncRpcResult.");
logger.error(PROXY_ERROR_ASYNC_RESPONSE, "", "", "Got exception when trying to fetch the underlying result from AsyncRpcResult.");
throw new RpcException(e);
}
}
@ -136,7 +137,7 @@ public class AsyncRpcResult implements Result {
}
} catch (Exception e) {
// This should not happen in normal request process;
logger.error("Got exception when trying to fetch the underlying result from AsyncRpcResult.");
logger.error(PROXY_ERROR_ASYNC_RESPONSE, "", "", "Got exception when trying to fetch the underlying result from AsyncRpcResult.");
throw new RpcException(e);
}
}
@ -161,7 +162,7 @@ public class AsyncRpcResult implements Result {
}
} catch (Exception e) {
// This should not happen in normal request process;
logger.error("Got exception when trying to fetch the underlying result from AsyncRpcResult.");
logger.error(PROXY_ERROR_ASYNC_RESPONSE, "", "", "Got exception when trying to fetch the underlying result from AsyncRpcResult.");
throw new RpcException(e);
}

View File

@ -17,15 +17,17 @@
package org.apache.dubbo.rpc;
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;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_NOTIFY_EVENT;
public class ExecutableListener implements Runnable {
private static final Logger log = LoggerFactory.getLogger(ExecutableListener.class);
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(ExecutableListener.class);
private final Executor executor;
private final CancellationListener listener;
@ -46,7 +48,7 @@ public class ExecutableListener implements Runnable {
try {
executor.execute(this);
} catch (Throwable t) {
log.warn("Exception notifying context listener", t);
log.warn(COMMON_FAILED_NOTIFY_EVENT, "", "", "Exception notifying context listener", t);
}
}

View File

@ -17,11 +17,12 @@
package org.apache.dubbo.rpc.listener;
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.rpc.Invoker;
import org.apache.dubbo.rpc.RpcException;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_UNSUPPORTED_INVOKER;
import static org.apache.dubbo.rpc.Constants.DEPRECATED_KEY;
/**
@ -30,12 +31,12 @@ import static org.apache.dubbo.rpc.Constants.DEPRECATED_KEY;
@Activate(DEPRECATED_KEY)
public class DeprecatedInvokerListener extends InvokerListenerAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(DeprecatedInvokerListener.class);
private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(DeprecatedInvokerListener.class);
@Override
public void referred(Invoker<?> invoker) throws RpcException {
if (invoker.getUrl().getParameter(DEPRECATED_KEY, false)) {
LOGGER.error("The service " + invoker.getInterface().getName() + " is DEPRECATED! Declare from " + invoker.getUrl());
LOGGER.error(PROXY_UNSUPPORTED_INVOKER,"","","The service " + invoker.getInterface().getName() + " is DEPRECATED! Declare from " + invoker.getUrl());
}
}

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.rpc.listener;
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.rpc.Exporter;
@ -26,12 +26,14 @@ import org.apache.dubbo.rpc.Invoker;
import java.util.List;
import java.util.function.Consumer;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_NOTIFY_EVENT;
/**
* ListenerExporter
*/
public class ListenerExporterWrapper<T> implements Exporter<T> {
private static final Logger logger = LoggerFactory.getLogger(ListenerExporterWrapper.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ListenerExporterWrapper.class);
private final Exporter<T> exporter;
@ -68,7 +70,7 @@ public class ListenerExporterWrapper<T> implements Exporter<T> {
try {
consumer.accept(listener);
} catch (RuntimeException t) {
logger.error(t.getMessage(), t);
logger.error(COMMON_FAILED_NOTIFY_EVENT, "", "", t.getMessage(), t);
exception = t;
}
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.listener;
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.rpc.Invocation;
@ -34,7 +34,7 @@ import java.util.function.Consumer;
*/
public class ListenerInvokerWrapper<T> implements Invoker<T> {
private static final Logger logger = LoggerFactory.getLogger(ListenerInvokerWrapper.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ListenerInvokerWrapper.class);
private final Invoker<T> invoker;

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.rpc.protocol;
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.Exporter;
import org.apache.dubbo.rpc.Invoker;
@ -26,7 +26,7 @@ import org.apache.dubbo.rpc.Invoker;
*/
public abstract class AbstractExporter<T> implements Exporter<T> {
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
private final Invoker<T> invoker;

View File

@ -45,6 +45,7 @@ import java.util.concurrent.ConcurrentHashMap;
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.OPTIMIZER_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_DESTROY_INVOKER;
/**
* abstract ProtocolSupport.
@ -107,13 +108,13 @@ public abstract class AbstractProtocol implements Protocol, ScopeModelAware {
}
invoker.destroy();
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
logger.warn(PROTOCOL_FAILED_DESTROY_INVOKER, "", "", t.getMessage(), t);
}
}
}
invokers.clear();
exporterMap.forEach((key, exporter)-> {
exporterMap.forEach((key, exporter) -> {
if (exporter != null) {
try {
if (logger.isInfoEnabled()) {
@ -121,7 +122,7 @@ public abstract class AbstractProtocol implements Protocol, ScopeModelAware {
}
exporter.unexport();
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
logger.warn(PROTOCOL_FAILED_DESTROY_INVOKER, "", "", t.getMessage(), t);
}
}
});

View File

@ -44,6 +44,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
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.PROTOCOL_UNSUPPORTED;
/**
* AbstractProxyProtocol
@ -95,7 +96,7 @@ public abstract class AbstractProxyProtocol extends AbstractProtocol {
try {
runnable.run();
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
logger.warn(PROTOCOL_UNSUPPORTED, "", "", t.getMessage(), t);
}
}
}

View File

@ -16,7 +16,7 @@
*/
package org.apache.dubbo.rpc.proxy;
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.ReflectUtils;
@ -34,6 +34,7 @@ import java.util.Arrays;
import java.util.LinkedHashSet;
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_UNSUPPORTED_INVOKER;
import static org.apache.dubbo.rpc.Constants.INTERFACES;
/**
@ -44,7 +45,7 @@ public abstract class AbstractProxyFactory implements ProxyFactory {
EchoService.class, Destroyable.class
};
private static final Logger logger = LoggerFactory.getLogger(AbstractProxyFactory.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractProxyFactory.class);
@Override
public <T> T getProxy(Invoker<T> invoker) throws RpcException {
@ -98,7 +99,7 @@ public abstract class AbstractProxyFactory implements ProxyFactory {
}
interfaces.remove(invoker.getInterface());
logger.error("Error occur when creating proxy. Invoker is in generic mode. Trying to create proxy without real interface class.", t);
logger.error(PROXY_UNSUPPORTED_INVOKER, "", "", "Error occur when creating proxy. Invoker is in generic mode. Trying to create proxy without real interface class.", t);
return getProxy(invoker, interfaces.toArray(new Class<?>[0]));
} else {
throw t;

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.proxy;
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.profiler.Profiler;
import org.apache.dubbo.common.profiler.ProfilerEntry;
@ -36,12 +36,13 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_ASYNC_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_ERROR_ASYNC_RESPONSE;
/**
* This Invoker works on provider side, delegates RPC to interface implementation.
*/
public abstract class AbstractProxyInvoker<T> implements Invoker<T> {
Logger logger = LoggerFactory.getLogger(AbstractProxyInvoker.class);
ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(AbstractProxyInvoker.class);
private final T proxy;
@ -127,7 +128,7 @@ public abstract class AbstractProxyInvoker<T> implements Invoker<T> {
return new AsyncRpcResult(appResponseFuture, invocation);
} catch (InvocationTargetException e) {
if (RpcContext.getServiceContext().isAsyncStarted() && !RpcContext.getServiceContext().stopAsync()) {
logger.error("Provider async started, but got an exception from the original method, cannot write the exception back to consumer because an async result may have returned the new thread.", e);
logger.error(PROXY_ERROR_ASYNC_RESPONSE, "", "", "Provider async started, but got an exception from the original method, cannot write the exception back to consumer because an async result may have returned the new thread.", e);
}
return AsyncRpcResult.newDefaultAsyncResult(null, e.getTargetException(), invocation);
} catch (Throwable e) {

View File

@ -18,7 +18,7 @@
package org.apache.dubbo.rpc.proxy;
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.profiler.Profiler;
import org.apache.dubbo.common.profiler.ProfilerEntry;
@ -29,9 +29,10 @@ import org.apache.dubbo.rpc.RpcServiceContext;
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.PROXY_TIMEOUT_REQUEST;
public class InvocationUtil {
private static final Logger logger = LoggerFactory.getLogger(InvokerInvocationHandler.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(InvokerInvocationHandler.class);
public static Object invoke(Invoker<?> invoker, RpcInvocation rpcInvocation) throws Throwable {
URL url = invoker.getUrl();
@ -71,7 +72,7 @@ public class InvocationUtil {
attachment.append(entry.getKey()).append("=").append(entry.getValue()).append(";\n");
});
logger.warn(String.format(
logger.warn(PROXY_TIMEOUT_REQUEST, "", "", String.format(
"[Dubbo-Consumer] execute service %s#%s cost %d.%06d ms, this invocation almost (maybe already) timeout. Timeout: %dms\n" + "invocation context:\n%s" + "thread info: \n%s",
rpcInvocation.getProtocolServiceKey(),
rpcInvocation.getMethodName(),

View File

@ -29,6 +29,8 @@ import org.apache.dubbo.rpc.proxy.jdk.JdkProxyFactory;
import java.util.Arrays;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_FAILED_JAVASSIST;
/**
* JavassistRpcProxyFactory
*/
@ -45,13 +47,13 @@ public class JavassistProxyFactory extends AbstractProxyFactory {
// try fall back to JDK proxy factory
try {
T proxy = jdkProxyFactory.getProxy(invoker, interfaces);
logger.error("Failed to generate proxy by Javassist failed. Fallback to use JDK proxy success. " +
logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate proxy by Javassist failed. Fallback to use JDK proxy success. " +
"Interfaces: " + Arrays.toString(interfaces), fromJavassist);
return proxy;
} catch (Throwable fromJdk) {
logger.error("Failed to generate proxy by Javassist failed. Fallback to use JDK proxy is also failed. " +
logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate proxy by Javassist failed. Fallback to use JDK proxy is also failed. " +
"Interfaces: " + Arrays.toString(interfaces) + " Javassist Error.", fromJavassist);
logger.error("Failed to generate proxy by Javassist failed. Fallback to use JDK proxy is also failed. " +
logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate proxy by Javassist failed. Fallback to use JDK proxy is also failed. " +
"Interfaces: " + Arrays.toString(interfaces) + " JDK Error.", fromJdk);
throw fromJavassist;
}
@ -75,14 +77,14 @@ public class JavassistProxyFactory extends AbstractProxyFactory {
// try fall back to JDK proxy factory
try {
Invoker<T> invoker = jdkProxyFactory.getInvoker(proxy, type, url);
logger.error("Failed to generate invoker by Javassist failed. Fallback to use JDK proxy success. " +
logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate invoker by Javassist failed. Fallback to use JDK proxy success. " +
"Interfaces: " + type, fromJavassist);
// log out error
return invoker;
} catch (Throwable fromJdk) {
logger.error("Failed to generate invoker by Javassist failed. Fallback to use JDK proxy is also failed. " +
logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate invoker by Javassist failed. Fallback to use JDK proxy is also failed. " +
"Interfaces: " + type + " Javassist Error.", fromJavassist);
logger.error("Failed to generate invoker by Javassist failed. Fallback to use JDK proxy is also failed. " +
logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate invoker by Javassist failed. Fallback to use JDK proxy is also failed. " +
"Interfaces: " + type + " JDK Error.", fromJdk);
throw fromJavassist;
}

View File

@ -20,7 +20,7 @@ import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.bytecode.Wrapper;
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.NetUtils;
@ -36,6 +36,7 @@ import org.apache.dubbo.rpc.service.GenericService;
import java.lang.reflect.Constructor;
import static org.apache.dubbo.common.constants.CommonConstants.STUB_EVENT_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_FAILED_EXPORT_SERVICE;
import static org.apache.dubbo.rpc.Constants.DEFAULT_STUB_EVENT;
import static org.apache.dubbo.rpc.Constants.IS_SERVER_KEY;
import static org.apache.dubbo.rpc.Constants.LOCAL_KEY;
@ -47,7 +48,7 @@ import static org.apache.dubbo.rpc.Constants.STUB_KEY;
*/
public class StubProxyFactoryWrapper implements ProxyFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(StubProxyFactoryWrapper.class);
private static final ErrorTypeAwareLogger LOGGER = LoggerFactory.getErrorTypeAwareLogger(StubProxyFactoryWrapper.class);
private final ProxyFactory proxyFactory;
@ -92,14 +93,14 @@ public class StubProxyFactoryWrapper implements ProxyFactory {
try {
export(proxy, invoker.getInterface(), urlBuilder.build());
} catch (Exception e) {
LOGGER.error("export a stub service error.", e);
LOGGER.error(PROXY_FAILED_EXPORT_SERVICE, "", "", "export a stub service error.", e);
}
}
} catch (NoSuchMethodException e) {
throw new IllegalStateException("No such constructor \"public " + stubClass.getSimpleName() + "(" + serviceType.getName() + ")\" in stub implementation class " + stubClass.getName(), e);
}
} catch (Throwable t) {
LOGGER.error("Failed to create stub implementation class " + stub + " in consumer " + NetUtils.getLocalHost() + " use dubbo version " + Version.getVersion() + ", cause: " + t.getMessage(), t);
LOGGER.error(PROXY_FAILED_EXPORT_SERVICE, "", "", "Failed to create stub implementation class " + stub + " in consumer " + NetUtils.getLocalHost() + " use dubbo version " + Version.getVersion() + ", cause: " + t.getMessage(), t);
// ignore
}
}

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.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.ReflectUtils;
import org.apache.dubbo.common.utils.StringUtils;
@ -38,6 +38,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.GENERIC_PARAMETE
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_ATTACHMENT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_ATTACHMENT_KEY_LOWER;
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_FAILED_REFLECT;
import static org.apache.dubbo.rpc.Constants.$ECHO;
import static org.apache.dubbo.rpc.Constants.$ECHO_PARAMETER_DESC;
import static org.apache.dubbo.rpc.Constants.ASYNC_KEY;
@ -50,15 +51,15 @@ import static org.apache.dubbo.rpc.Constants.RETURN_KEY;
*/
public class RpcUtils {
private static final Logger logger = LoggerFactory.getLogger(RpcUtils.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(RpcUtils.class);
private static final AtomicLong INVOKE_ID = new AtomicLong(0);
public static Class<?> getReturnType(Invocation invocation) {
try {
if (invocation != null && invocation.getInvoker() != null
&& invocation.getInvoker().getUrl() != null
&& invocation.getInvoker().getInterface() != GenericService.class
&& !invocation.getMethodName().startsWith("$")) {
&& invocation.getInvoker().getUrl() != null
&& invocation.getInvoker().getInterface() != GenericService.class
&& !invocation.getMethodName().startsWith("$")) {
String service = invocation.getInvoker().getUrl().getServiceInterface();
if (StringUtils.isNotEmpty(service)) {
Method method = getMethodByService(invocation, service);
@ -66,7 +67,7 @@ public class RpcUtils {
}
}
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
logger.warn(COMMON_FAILED_REFLECT, "", "", t.getMessage(), t);
}
return null;
}
@ -74,9 +75,9 @@ public class RpcUtils {
public static Type[] getReturnTypes(Invocation invocation) {
try {
if (invocation != null && invocation.getInvoker() != null
&& invocation.getInvoker().getUrl() != null
&& invocation.getInvoker().getInterface() != GenericService.class
&& !invocation.getMethodName().startsWith("$")) {
&& invocation.getInvoker().getUrl() != null
&& invocation.getInvoker().getInterface() != GenericService.class
&& !invocation.getMethodName().startsWith("$")) {
String service = invocation.getInvoker().getUrl().getServiceInterface();
if (StringUtils.isNotEmpty(service)) {
Method method = getMethodByService(invocation, service);
@ -84,7 +85,7 @@ public class RpcUtils {
}
}
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
logger.warn(COMMON_FAILED_REFLECT, "", "", t.getMessage(), t);
}
return null;
}
@ -120,9 +121,9 @@ public class RpcUtils {
public static String getMethodName(Invocation invocation) {
if ($INVOKE.equals(invocation.getMethodName())
&& invocation.getArguments() != null
&& invocation.getArguments().length > 0
&& invocation.getArguments()[0] instanceof String) {
&& invocation.getArguments() != null
&& invocation.getArguments().length > 0
&& invocation.getArguments()[0] instanceof String) {
return (String) invocation.getArguments()[0];
}
return invocation.getMethodName();
@ -130,9 +131,9 @@ public class RpcUtils {
public static Object[] getArguments(Invocation invocation) {
if ($INVOKE.equals(invocation.getMethodName())
&& invocation.getArguments() != null
&& invocation.getArguments().length > 2
&& invocation.getArguments()[2] instanceof Object[]) {
&& invocation.getArguments() != null
&& invocation.getArguments().length > 2
&& invocation.getArguments()[2] instanceof Object[]) {
return (Object[]) invocation.getArguments()[2];
}
return invocation.getArguments();
@ -140,9 +141,9 @@ public class RpcUtils {
public static Class<?>[] getParameterTypes(Invocation invocation) {
if ($INVOKE.equals(invocation.getMethodName())
&& invocation.getArguments() != null
&& invocation.getArguments().length > 1
&& invocation.getArguments()[1] instanceof String[]) {
&& invocation.getArguments() != null
&& invocation.getArguments().length > 1
&& invocation.getArguments()[1] instanceof String[]) {
String[] types = (String[]) invocation.getArguments()[1];
if (types == null) {
return new Class<?>[0];
@ -228,7 +229,7 @@ public class RpcUtils {
private static Method getMethodByService(Invocation invocation, String service) throws NoSuchMethodException {
Class<?> invokerInterface = invocation.getInvoker().getInterface();
Class<?> cls = invokerInterface != null ? ReflectUtils.forName(invokerInterface.getClassLoader(), service)
: ReflectUtils.forName(service);
: ReflectUtils.forName(service);
Method method = cls.getMethod(invocation.getMethodName(), invocation.getParameterTypes());
if (method.getReturnType() == void.class) {
return null;
@ -239,7 +240,7 @@ public class RpcUtils {
public static long getTimeout(Invocation invocation, long defaultTimeout) {
long timeout = defaultTimeout;
Object genericTimeout = invocation.getObjectAttachmentWithoutConvert(TIMEOUT_ATTACHMENT_KEY);
if(genericTimeout == null) {
if (genericTimeout == null) {
genericTimeout = invocation.getObjectAttachmentWithoutConvert(TIMEOUT_ATTACHMENT_KEY_LOWER);
}
if (genericTimeout != null) {

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.BaseServiceMetadata;
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.url.component.ServiceConfigURL;
import org.apache.dubbo.common.utils.ClassUtils;
@ -52,6 +52,9 @@ import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_DESTROY_INVOKER;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_LOAD_MODEL;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_INCORRECT_PARAMETER_VALUES;
import static org.apache.dubbo.rpc.Constants.IS_SERVER_KEY;
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_KEY;
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.CALLBACK_SERVICE_PROXY_KEY;
@ -62,7 +65,7 @@ import static org.apache.dubbo.rpc.protocol.dubbo.Constants.IS_CALLBACK_SERVICE;
* callback service helper
*/
public class CallbackServiceCodec {
private static final Logger logger = LoggerFactory.getLogger(CallbackServiceCodec.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(CallbackServiceCodec.class);
private static final byte CALLBACK_NONE = 0x0;
private static final byte CALLBACK_CREATE = 0x1;
@ -149,7 +152,7 @@ public class CallbackServiceCodec {
if (inv.getServiceModel() == null) {
//TODO should get scope model from url?
moduleModel = ApplicationModel.defaultModel().getDefaultModule();
logger.error("Unable to get Service Model from Invocation. Please check if your invocation failed! " +
logger.error(PROTOCOL_FAILED_LOAD_MODEL, "", "", "Unable to get Service Model from Invocation. Please check if your invocation failed! " +
"This error only happen in UT cases! Invocation:" + inv);
} else {
moduleModel = inv.getServiceModel().getModuleModel();
@ -229,7 +232,7 @@ public class CallbackServiceCodec {
}
invoker.destroy();
} catch (Exception e) {
logger.error(e.getMessage(), e);
logger.error(PROTOCOL_FAILED_DESTROY_INVOKER, "", "", e.getMessage(), e);
}
// cancel refer, directly remove from the map
channel.removeAttribute(proxyCacheKey);
@ -283,7 +286,7 @@ public class CallbackServiceCodec {
}
channel.setAttribute(countkey, count);
} catch (Exception e) {
logger.error(e.getMessage(), e);
logger.error(PROTOCOL_INCORRECT_PARAMETER_VALUES, "", "", e.getMessage(), e);
}
}
@ -297,7 +300,7 @@ public class CallbackServiceCodec {
}
channel.setAttribute(countkey, count);
} catch (Exception e) {
logger.error(e.getMessage(), e);
logger.error(PROTOCOL_INCORRECT_PARAMETER_VALUES, "", "", e.getMessage(), e);
}
}
@ -337,7 +340,7 @@ public class CallbackServiceCodec {
try {
return referOrDestroyCallbackService(channel, url, pts[paraIndex], inv, Integer.parseInt(inv.getAttachment(INV_ATT_CALLBACK_KEY + paraIndex)), true);
} catch (Exception e) {
logger.error(e.getMessage(), e);
logger.error(PROTOCOL_FAILED_DESTROY_INVOKER, "", "", e.getMessage(), e);
throw new IOException(StringUtils.toString(e));
}
case CallbackServiceCodec.CALLBACK_DESTROY:

View File

@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.protocol.dubbo;
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;
@ -52,12 +52,13 @@ import static org.apache.dubbo.common.constants.CommonConstants.DUBBO_VERSION_KE
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_DECODE;
import static org.apache.dubbo.rpc.Constants.SERIALIZATION_ID_KEY;
import static org.apache.dubbo.rpc.Constants.SERIALIZATION_SECURITY_CHECK_KEY;
public class DecodeableRpcInvocation extends RpcInvocation implements Codec, Decodeable {
private static final Logger log = LoggerFactory.getLogger(DecodeableRpcInvocation.class);
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(DecodeableRpcInvocation.class);
private Channel channel;
@ -92,7 +93,7 @@ public class DecodeableRpcInvocation extends RpcInvocation implements Codec, Dec
decode(channel, inputStream);
} catch (Throwable e) {
if (log.isWarnEnabled()) {
log.warn("Decode rpc invocation failed: " + e.getMessage(), e);
log.warn(PROTOCOL_FAILED_DECODE, "", "", "Decode rpc invocation failed: " + e.getMessage(), e);
}
request.setBroken(true);
request.setData(e);

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.config.Configuration;
import org.apache.dubbo.common.config.ConfigurationUtils;
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;
@ -40,12 +40,13 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Type;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_DECODE;
import static org.apache.dubbo.rpc.Constants.SERIALIZATION_ID_KEY;
import static org.apache.dubbo.rpc.Constants.SERIALIZATION_SECURITY_CHECK_KEY;
public class DecodeableRpcResult extends AppResponse implements Codec, Decodeable {
private static final Logger log = LoggerFactory.getLogger(DecodeableRpcResult.class);
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(DecodeableRpcResult.class);
private Channel channel;
@ -87,7 +88,7 @@ public class DecodeableRpcResult extends AppResponse implements Codec, Decodeabl
Thread.currentThread().setContextClassLoader(invocation.getServiceModel().getClassLoader());
}
ObjectInput in = CodecSupport.getSerialization(channel.getUrl(), serializationType)
.deserialize(channel.getUrl(), input);
.deserialize(channel.getUrl(), input);
byte flag = in.readByte();
switch (flag) {
@ -138,7 +139,7 @@ public class DecodeableRpcResult extends AppResponse implements Codec, Decodeabl
decode(channel, inputStream);
} catch (Throwable e) {
if (log.isWarnEnabled()) {
log.warn("Decode rpc result failed: " + e.getMessage(), e);
log.warn(PROTOCOL_FAILED_DECODE, "", "", "Decode rpc result failed: " + e.getMessage(), e);
}
response.setStatus(Response.CLIENT_ERROR);
response.setErrorMessage(StringUtils.toString(e));

View File

@ -19,7 +19,7 @@ package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.io.Bytes;
import org.apache.dubbo.common.io.UnsafeByteArrayInputStream;
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;
@ -44,6 +44,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.DUBBO_VERSION_KE
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_DECODE;
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.DECODE_IN_IO_THREAD_KEY;
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.DEFAULT_DECODE_IN_IO_THREAD;
@ -62,7 +63,7 @@ public class DubboCodec extends ExchangeCodec {
public static final byte RESPONSE_NULL_VALUE_WITH_ATTACHMENTS = 5;
public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
public static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
private static final Logger log = LoggerFactory.getLogger(DubboCodec.class);
private static final ErrorTypeAwareLogger log = LoggerFactory.getErrorTypeAwareLogger(DubboCodec.class);
private CallbackServiceCodec callbackServiceCodec;
private FrameworkModel frameworkModel;
@ -101,12 +102,12 @@ public class DubboCodec extends ExchangeCodec {
DecodeableRpcResult result;
if (channel.getUrl().getParameter(DECODE_IN_IO_THREAD_KEY, DEFAULT_DECODE_IN_IO_THREAD)) {
result = new DecodeableRpcResult(channel, res, is,
(Invocation) getRequestData(id), proto);
(Invocation) getRequestData(id), proto);
result.decode();
} else {
result = new DecodeableRpcResult(channel, res,
new UnsafeByteArrayInputStream(readMessageData(is)),
(Invocation) getRequestData(id), proto);
new UnsafeByteArrayInputStream(readMessageData(is)),
(Invocation) getRequestData(id), proto);
}
data = result;
}
@ -117,7 +118,7 @@ public class DubboCodec extends ExchangeCodec {
}
} catch (Throwable t) {
if (log.isWarnEnabled()) {
log.warn("Decode response failed: " + t.getMessage(), t);
log.warn(PROTOCOL_FAILED_DECODE, "", "", "Decode response failed: " + t.getMessage(), t);
}
res.setStatus(Response.CLIENT_ERROR);
res.setErrorMessage(StringUtils.toString(t));
@ -149,7 +150,7 @@ public class DubboCodec extends ExchangeCodec {
inv.decode();
} else {
inv = new DecodeableRpcInvocation(frameworkModel, channel, req,
new UnsafeByteArrayInputStream(readMessageData(is)), proto);
new UnsafeByteArrayInputStream(readMessageData(is)), proto);
}
data = inv;
}

View File

@ -52,6 +52,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_ATTACHME
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.TIME_COUNTDOWN_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_ERROR_CLOSE_CLIENT;
import static org.apache.dubbo.rpc.Constants.TOKEN_KEY;
/**
@ -181,7 +182,7 @@ public class DubboInvoker<T> extends AbstractInvoker<T> {
client.close(serverShutdownTimeout);
}
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
logger.warn(PROTOCOL_ERROR_CLOSE_CLIENT, "", "", t.getMessage(), t);
}
}

View File

@ -66,6 +66,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.LAZY_CONNECT_KEY
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.STUB_EVENT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_ERROR_CLOSE_CLIENT;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_ERROR_CLOSE_SERVER;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_REFER_INVOKER;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_UNSUPPORTED;
import static org.apache.dubbo.remoting.Constants.CHANNEL_READONLYEVENT_SENT_KEY;
import static org.apache.dubbo.remoting.Constants.CLIENT_KEY;
import static org.apache.dubbo.remoting.Constants.CODEC_KEY;
@ -141,7 +145,7 @@ public class DubboProtocol extends AbstractProtocol {
}
}
if (!hasMethod) {
logger.warn(new IllegalStateException("The methodName " + inv.getMethodName()
logger.warn(PROTOCOL_FAILED_REFER_INVOKER, "", "", new IllegalStateException("The methodName " + inv.getMethodName()
+ " not found in callback service interface ,invoke will be ignored."
+ " please update the api interface. url is:"
+ invoker.getUrl()) + " ,invocation is :" + inv);
@ -185,7 +189,7 @@ public class DubboProtocol extends AbstractProtocol {
}
received(channel, invocation);
} catch (Throwable t) {
logger.warn("Failed to invoke event method " + invocation.getMethodName() + "(), cause: " + t.getMessage(), t);
logger.warn(PROTOCOL_FAILED_REFER_INVOKER, "", "", "Failed to invoke event method " + invocation.getMethodName() + "(), cause: " + t.getMessage(), t);
}
}
}
@ -316,8 +320,8 @@ public class DubboProtocol extends AbstractProtocol {
String stubServiceMethods = url.getParameter(STUB_EVENT_METHODS_KEY);
if (stubServiceMethods == null || stubServiceMethods.length() == 0) {
if (logger.isWarnEnabled()) {
logger.warn(new IllegalStateException("consumer [" + url.getParameter(INTERFACE_KEY) +
"], has set stub proxy support event ,but no stub methods founded."));
logger.warn(PROTOCOL_UNSUPPORTED, "", "", "consumer [" + url.getParameter(INTERFACE_KEY) +
"], has set stub proxy support event ,but no stub methods founded.");
}
}
@ -636,7 +640,7 @@ public class DubboProtocol extends AbstractProtocol {
server.close(getServerShutdownTimeout(protocolServer));
} catch (Throwable t) {
logger.warn("Close dubbo server [" + server.getLocalAddress() + "] failed: " + t.getMessage(), t);
logger.warn(PROTOCOL_ERROR_CLOSE_SERVER, "", "", "Close dubbo server [" + server.getLocalAddress() + "] failed: " + t.getMessage(), t);
}
}
serverMap.clear();
@ -685,7 +689,7 @@ public class DubboProtocol extends AbstractProtocol {
*/
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
logger.warn(PROTOCOL_ERROR_CLOSE_CLIENT, "", "", t.getMessage(), t);
}
}

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.Parameters;
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.ChannelHandler;
@ -36,6 +36,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import static org.apache.dubbo.common.constants.CommonConstants.LAZY_CONNECT_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_REQUEST;
import static org.apache.dubbo.remoting.Constants.SEND_RECONNECT_KEY;
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.DEFAULT_LAZY_REQUEST_WITH_WARNING;
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.LAZY_REQUEST_WITH_WARNING_KEY;
@ -46,7 +47,7 @@ import static org.apache.dubbo.rpc.protocol.dubbo.Constants.LAZY_REQUEST_WITH_WA
@SuppressWarnings("deprecation")
final class LazyConnectExchangeClient implements ExchangeClient {
private final static Logger logger = LoggerFactory.getLogger(LazyConnectExchangeClient.class);
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(LazyConnectExchangeClient.class);
private final boolean requestWithWarning;
private final URL url;
private final ExchangeHandler requestHandler;
@ -130,7 +131,7 @@ final class LazyConnectExchangeClient implements ExchangeClient {
private void warning() {
if (requestWithWarning) {
if (warningCount.get() % warningPeriod == 0) {
logger.warn(url.getAddress() + " " + url.getServiceKey() + " safe guard client , should not be called ,must have a bug.");
logger.warn(PROTOCOL_FAILED_REQUEST, "", "", url.getAddress() + " " + url.getServiceKey() + " safe guard client , should not be called ,must have a bug.");
}
warningCount.incrementAndGet();
}

View File

@ -19,7 +19,7 @@ package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.Parameters;
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;
@ -32,6 +32,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_SERVER_SHUTDOWN_TIMEOUT;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_REQUEST;
/**
* dubbo protocol support class.
@ -39,7 +40,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_SERVER_S
@SuppressWarnings("deprecation")
final class ReferenceCountExchangeClient implements ExchangeClient {
private final static Logger logger = LoggerFactory.getLogger(ReferenceCountExchangeClient.class);
private final static ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ReferenceCountExchangeClient.class);
private final URL url;
private final AtomicInteger referenceCount = new AtomicInteger(0);
private final AtomicInteger disconnectCount = new AtomicInteger(0);
@ -199,7 +200,7 @@ final class ReferenceCountExchangeClient implements ExchangeClient {
private void replaceWithLazyClient() {
// start warning at second replaceWithLazyClient()
if (disconnectCount.getAndIncrement() % warningPeriod == 1) {
logger.warn(url.getAddress() + " " + url.getServiceKey() + " safe guard client , should not be called ,must have a bug.");
logger.warn(PROTOCOL_FAILED_REQUEST, "", "", url.getAddress() + " " + url.getServiceKey() + " safe guard client , should not be called ,must have a bug.");
}
// the order of judgment in the if statement cannot be changed.

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.rpc.protocol.dubbo.filter;
import org.apache.dubbo.common.constants.CommonConstants;
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.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
@ -33,6 +33,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import static org.apache.dubbo.common.constants.CommonConstants.$INVOKE;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_REQUEST;
import static org.apache.dubbo.rpc.protocol.dubbo.Constants.ASYNC_METHOD_INFO;
/**
@ -41,7 +42,7 @@ import static org.apache.dubbo.rpc.protocol.dubbo.Constants.ASYNC_METHOD_INFO;
@Activate(group = CommonConstants.CONSUMER)
public class FutureFilter implements ClusterFilter, ClusterFilter.Listener {
protected static final Logger logger = LoggerFactory.getLogger(FutureFilter.class);
protected static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(FutureFilter.class);
@Override
public Result invoke(final Invoker<?> invoker, final Invocation invocation) throws RpcException {
@ -179,10 +180,10 @@ public class FutureFilter implements ClusterFilter, ClusterFilter.Listener {
}
onthrowMethod.invoke(onthrowInst, params);
} catch (Throwable e) {
logger.error(invocation.getMethodName() + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), e);
logger.error(PROTOCOL_FAILED_REQUEST, "", "", invocation.getMethodName() + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), e);
}
} else {
logger.error(invocation.getMethodName() + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), exception);
logger.error(PROTOCOL_FAILED_REQUEST, "", "", invocation.getMethodName() + ".call back method invoke error . callback method :" + onthrowMethod + ", url:" + invoker.getUrl(), exception);
}
}

View File

@ -18,7 +18,7 @@ package org.apache.dubbo.rpc.protocol.dubbo.filter;
import org.apache.dubbo.common.constants.CommonConstants;
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.utils.CollectionUtils;
import org.apache.dubbo.common.utils.ConcurrentHashSet;
@ -39,13 +39,15 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_PARSE;
/**
* TraceFilter
*/
@Activate(group = CommonConstants.PROVIDER)
public class TraceFilter implements Filter {
private static final Logger logger = LoggerFactory.getLogger(TraceFilter.class);
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(TraceFilter.class);
private static final String TRACE_MAX = "trace.max";
@ -113,7 +115,7 @@ public class TraceFilter implements Filter {
}
} catch (Throwable e) {
channels.remove(channel);
logger.warn(e.getMessage(), e);
logger.warn(PROTOCOL_FAILED_PARSE, "", "", e.getMessage(), e);
}
} else {
channels.remove(channel);