This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.1 by this push:
new 6f35df41b5 Error code is managed with constants (#10771) (#10830)
6f35df41b5 is described below
commit 6f35df41b50efd56fb1232efc2bb877a3fb01761
Author: cnjxzhao <[email protected]>
AuthorDate: Wed Oct 26 10:26:46 2022 +0800
Error code is managed with constants (#10771) (#10830)
---
.../common/constants/LoggerCodeConstants.java | 48 ++++++++++++++++++++++
.../apache/dubbo/rpc/protocol/AbstractInvoker.java | 7 ++--
.../dubbo/rpc/protocol/AbstractProtocol.java | 4 +-
.../dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java | 29 ++++++-------
.../protocol/injvm/DefaultParamDeepCopyUtil.java | 10 +++--
.../rpc/protocol/rest/ReferenceCountedClient.java | 8 ++--
.../dubbo/rpc/protocol/rest/RestProtocol.java | 12 +++---
.../dubbo/rpc/protocol/tri/TripleInvoker.java | 34 +++++++--------
.../rpc/protocol/tri/call/AbstractServerCall.java | 19 +++++----
.../tri/call/AbstractServerCallListener.java | 8 ++--
.../rpc/protocol/tri/call/TripleClientCall.java | 24 ++++++-----
.../rpc/protocol/tri/service/TriHealthImpl.java | 10 +++--
.../dubbo/rpc/protocol/tri/stream/StreamUtils.java | 11 ++---
.../tri/transport/AbstractH2TransportListener.java | 8 ++--
.../TripleHttp2ClientResponseHandler.java | 10 +++--
.../transport/TripleHttp2FrameServerHandler.java | 10 +++--
.../transport/TripleServerConnectionHandler.java | 9 ++--
.../common/serialize/java/JavaSerialization.java | 9 ++--
.../nativejava/NativeJavaSerialization.java | 9 ++--
.../CompatibleOnEnabledEndpointCondition.java | 8 ++--
.../dubbo/registry/xds/XdsServiceDiscovery.java | 13 +++---
.../registry/xds/XdsServiceDiscoveryFactory.java | 10 +++--
.../xds/istio/IstioCitadelCertificateSigner.java | 16 +++++---
.../apache/dubbo/registry/xds/istio/IstioEnv.java | 11 ++---
.../apache/dubbo/registry/xds/util/XdsChannel.java | 16 ++++----
.../xds/util/protocol/AbstractProtocol.java | 14 ++++---
.../xds/util/protocol/impl/EdsProtocol.java | 8 ++--
.../xds/util/protocol/impl/LdsProtocol.java | 10 +++--
.../xds/util/protocol/impl/RdsProtocol.java | 8 ++--
29 files changed, 248 insertions(+), 145 deletions(-)
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/LoggerCodeConstants.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/LoggerCodeConstants.java
index 8d5c0d6873..c8d4cf9543 100644
---
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/LoggerCodeConstants.java
+++
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/LoggerCodeConstants.java
@@ -35,6 +35,8 @@ public interface LoggerCodeConstants {
String COMMON_THREAD_INTERRUPTED_EXCEPTION = "0-6";
+ String COMMON_CLASS_NOT_FOUND = "0-7";
+
// registry module
String REGISTRY_ADDRESS_INVALID = "1-1";
@@ -86,6 +88,24 @@ public interface LoggerCodeConstants {
String REGISTRY_FAILED_STOP_ZOOKEEPER = "1-25";
+ String REGISTRY_FAILED_GENERATE_CERT_ISTIO = "1-26";
+
+ String REGISTRY_FAILED_GENERATE_KEY_ISTIO = "1-27";
+
+ String REGISTRY_RECEIVE_ERROR_MSG_ISTIO = "1-28";
+
+ String REGISTRY_ERROR_READ_FILE_ISTIO = "1-29";
+
+ String REGISTRY_ERROR_REQUEST_XDS = "1-30";
+
+ String REGISTRY_ERROR_RESPONSE_XDS = "1-31";
+
+ String REGISTRY_ERROR_CREATE_CHANNEL_XDS = "1-32";
+
+ String REGISTRY_ERROR_INITIALIZE_XDS = "1-33";
+
+ String REGISTRY_ERROR_PARSING_XDS = "1-34";
+
// cluster module
String CLUSTER_FAILED_SITE_SELECTION = "2-1";
@@ -137,6 +157,34 @@ public interface LoggerCodeConstants {
String PROTOCOL_FAILED_REFER_INVOKER = "4-3";
+ String PROTOCOL_UNSAFE_SERIALIZATION = "4-4";
+
+ String PROTOCOL_FAILED_CLOSE_STREAM = "4-5";
+
+ String PROTOCOL_ERROR_DESERIALIZE = "4-6";
+
+ String PROTOCOL_ERROR_CLOSE_CLIENT = "4-7";
+
+ String PROTOCOL_ERROR_CLOSE_SERVER = "4-8";
+
+ String PROTOCOL_FAILED_PARSE = "4-9";
+
+ String PROTOCOL_FAILED_SERIALIZE_TRIPLE = "4-10";
+
+ String PROTOCOL_FAILED_REQUEST = "4-11";
+
+ String PROTOCOL_FAILED_CREATE_STREAM_TRIPLE = "4-12";
+
+ String PROTOCOL_TIMEOUT_SERVER = "4-13";
+
+ String PROTOCOL_FAILED_RESPONSE = "4-14";
+
+ String PROTOCOL_STREAM_LISTENER = "4-15";
+
+ String PROTOCOL_CLOSED_SERVER = "4-16";
+
+ String PROTOCOL_FAILED_DESTROY_INVOKER = "4-17";
+
// config module
String CONFIG_FAILED_CONNECT_REGISTRY = "5-1";
diff --git
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractInvoker.java
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractInvoker.java
index be560156d5..ee04a1ded8 100644
---
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractInvoker.java
+++
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractInvoker.java
@@ -20,7 +20,7 @@ import org.apache.dubbo.common.Node;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
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.serialize.support.DefaultSerializationSelector;
import org.apache.dubbo.common.threadpool.ThreadlessExecutor;
@@ -51,6 +51,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_REQUEST;
import static org.apache.dubbo.remoting.Constants.SERIALIZATION_KEY;
import static org.apache.dubbo.rpc.Constants.SERIALIZATION_ID_KEY;
@@ -59,7 +60,7 @@ import static
org.apache.dubbo.rpc.Constants.SERIALIZATION_ID_KEY;
*/
public abstract class AbstractInvoker<T> implements Invoker<T> {
- protected static final Logger logger =
LoggerFactory.getLogger(AbstractInvoker.class);
+ protected static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(AbstractInvoker.class);
/**
* Service interface type
@@ -169,7 +170,7 @@ public abstract class AbstractInvoker<T> implements
Invoker<T> {
public Result invoke(Invocation inv) throws RpcException {
// if invoker is destroyed due to address refresh from registry, let's
allow the current invoke to proceed
if (isDestroyed()) {
- logger.warn("Invoker for service " + this + " on consumer " +
NetUtils.getLocalHost() + " is destroyed, "
+ logger.warn(PROTOCOL_FAILED_REQUEST, "", "", "Invoker for service
" + this + " on consumer " + NetUtils.getLocalHost() + " is destroyed, "
+ ", dubbo version is " + Version.getVersion() + ", this
invoker should not be used any longer");
}
diff --git
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java
index 5278c35c6e..abd3d4ae23 100644
---
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java
+++
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractProtocol.java
@@ -18,7 +18,7 @@ package org.apache.dubbo.rpc.protocol;
import org.apache.dubbo.common.URL;
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.support.SerializableClassRegistry;
import org.apache.dubbo.common.serialize.support.SerializationOptimizer;
@@ -51,7 +51,7 @@ import static
org.apache.dubbo.common.constants.CommonConstants.OPTIMIZER_KEY;
*/
public abstract class AbstractProtocol implements Protocol, ScopeModelAware {
- protected final Logger logger = LoggerFactory.getLogger(getClass());
+ protected final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(getClass());
protected final Map<String, Exporter<?>> exporterMap = new
ConcurrentHashMap<>();
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java
index 314d1d7c29..a0685b2da7 100644
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java
+++
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java
@@ -18,7 +18,7 @@ package org.apache.dubbo.rpc.protocol.grpc;
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.threadpool.ThreadPool;
import org.apache.dubbo.common.utils.CollectionUtils;
@@ -50,6 +50,7 @@ import java.util.Set;
import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
import static
org.apache.dubbo.common.constants.CommonConstants.SSL_ENABLED_KEY;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_CLOSE_STREAM;
import static org.apache.dubbo.remoting.Constants.DISPATCHER_KEY;
import static org.apache.dubbo.rpc.Constants.EXECUTES_KEY;
import static
org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.CLIENT_INTERCEPTORS;
@@ -65,7 +66,7 @@ import static
org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.TRANSPORT_FILTERS
*/
public class GrpcOptionsUtils {
- private static final Logger logger =
LoggerFactory.getLogger(GrpcOptionsUtils.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(GrpcOptionsUtils.class);
static ServerBuilder buildServerBuilder(URL url, NettyServerBuilder
builder) {
@@ -95,14 +96,14 @@ public class GrpcOptionsUtils {
// server interceptors
List<ServerInterceptor> serverInterceptors =
url.getOrDefaultFrameworkModel().getExtensionLoader(ServerInterceptor.class)
- .getActivateExtension(url, SERVER_INTERCEPTORS, PROVIDER_SIDE);
+ .getActivateExtension(url, SERVER_INTERCEPTORS, PROVIDER_SIDE);
for (ServerInterceptor serverInterceptor : serverInterceptors) {
builder.intercept(serverInterceptor);
}
// server filters
List<ServerTransportFilter> transportFilters =
url.getOrDefaultFrameworkModel().getExtensionLoader(ServerTransportFilter.class)
- .getActivateExtension(url, TRANSPORT_FILTERS, PROVIDER_SIDE);
+ .getActivateExtension(url, TRANSPORT_FILTERS, PROVIDER_SIDE);
for (ServerTransportFilter transportFilter : transportFilters) {
builder.addTransportFilter(transportFilter.grpcTransportFilter());
}
@@ -116,8 +117,8 @@ public class GrpcOptionsUtils {
// Give users the chance to customize ServerBuilder
return getConfigurator()
- .map(configurator ->
configurator.configureServerBuilder(builder, url))
- .orElse(builder);
+ .map(configurator -> configurator.configureServerBuilder(builder,
url))
+ .orElse(builder);
}
static ManagedChannel buildManagedChannel(URL url) {
@@ -135,15 +136,15 @@ public class GrpcOptionsUtils {
// client interceptors
List<io.grpc.ClientInterceptor> interceptors = new ArrayList<>(
url.getOrDefaultFrameworkModel().getExtensionLoader(ClientInterceptor.class)
- .getActivateExtension(url, CLIENT_INTERCEPTORS,
CONSUMER_SIDE)
+ .getActivateExtension(url, CLIENT_INTERCEPTORS, CONSUMER_SIDE)
);
builder.intercept(interceptors);
return getConfigurator()
- .map(configurator ->
configurator.configureChannelBuilder(builder, url))
- .orElse(builder)
- .build();
+ .map(configurator -> configurator.configureChannelBuilder(builder,
url))
+ .orElse(builder)
+ .build();
}
static CallOptions buildCallOptions(URL url) {
@@ -152,8 +153,8 @@ public class GrpcOptionsUtils {
// .withDeadline(Deadline.after(url.getParameter(TIMEOUT_KEY,
DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS));
CallOptions callOptions = CallOptions.DEFAULT;
return getConfigurator()
- .map(configurator ->
configurator.configureCallOptions(callOptions, url))
- .orElse(callOptions);
+ .map(configurator ->
configurator.configureCallOptions(callOptions, url))
+ .orElse(callOptions);
}
private static SslContext buildServerSslContext(URL url) {
@@ -236,7 +237,7 @@ public class GrpcOptionsUtils {
private static Optional<GrpcConfigurator> getConfigurator() {
// Give users the chance to customize ServerBuilder
Set<GrpcConfigurator> configurators =
ExtensionLoader.getExtensionLoader(GrpcConfigurator.class)
- .getSupportedExtensionInstances();
+ .getSupportedExtensionInstances();
if (CollectionUtils.isNotEmpty(configurators)) {
return Optional.of(configurators.iterator().next());
}
@@ -250,7 +251,7 @@ public class GrpcOptionsUtils {
try {
stream.close();
} catch (IOException e) {
- logger.warn("Failed to close a stream.", e);
+ logger.warn(PROTOCOL_FAILED_CLOSE_STREAM, "", "", "Failed to close
a stream.", e);
}
}
}
diff --git
a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/DefaultParamDeepCopyUtil.java
b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/DefaultParamDeepCopyUtil.java
index 232b586031..455e77b573 100644
---
a/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/DefaultParamDeepCopyUtil.java
+++
b/dubbo-rpc/dubbo-rpc-injvm/src/main/java/org/apache/dubbo/rpc/protocol/injvm/DefaultParamDeepCopyUtil.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.protocol.injvm;
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.ObjectInput;
import org.apache.dubbo.common.serialize.ObjectOutput;
@@ -29,8 +29,10 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_ERROR_DESERIALIZE;
+
public class DefaultParamDeepCopyUtil implements ParamDeepCopyUtil {
- private static final Logger logger =
LoggerFactory.getLogger(DefaultParamDeepCopyUtil.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(DefaultParamDeepCopyUtil.class);
public final static String NAME = "default";
@@ -49,11 +51,11 @@ public class DefaultParamDeepCopyUtil implements
ParamDeepCopyUtil {
ObjectInput objectInput = serialization.deserialize(url,
inputStream);
return objectInput.readObject(targetClass);
} catch (ClassNotFoundException | IOException e) {
- logger.error("Unable to deep copy parameter to target class.",
e);
+ logger.error(PROTOCOL_ERROR_DESERIALIZE, "", "", "Unable to
deep copy parameter to target class.", e);
}
} catch (Throwable e) {
- logger.error("Unable to deep copy parameter to target class.", e);
+ logger.error(PROTOCOL_ERROR_DESERIALIZE, "", "", "Unable to deep
copy parameter to target class.", e);
}
diff --git
a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/ReferenceCountedClient.java
b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/ReferenceCountedClient.java
index e3c15debe4..393a6d6c34 100644
---
a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/ReferenceCountedClient.java
+++
b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/ReferenceCountedClient.java
@@ -16,14 +16,16 @@
*/
package org.apache.dubbo.rpc.protocol.rest;
-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.reference.ReferenceCountedResource;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_ERROR_CLOSE_CLIENT;
+
public class ReferenceCountedClient extends ReferenceCountedResource {
- private static final Logger logger =
LoggerFactory.getLogger(ReferenceCountedClient.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(ReferenceCountedClient.class);
private final ResteasyClient resteasyClient;
@@ -44,7 +46,7 @@ public class ReferenceCountedClient extends
ReferenceCountedResource {
try {
resteasyClient.close();
} catch (Exception e) {
- logger.error("Close resteasy client error", e);
+ logger.error(PROTOCOL_ERROR_CLOSE_CLIENT, "", "", "Close resteasy
client error", e);
}
}
}
diff --git
a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java
b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java
index 267fcb18f0..f38b0139c0 100644
---
a/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java
+++
b/dubbo-rpc/dubbo-rpc-rest/src/main/java/org/apache/dubbo/rpc/protocol/rest/RestProtocol.java
@@ -51,6 +51,8 @@ import static
org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATT
import static
org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_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.remoting.Constants.CONNECTIONS_KEY;
import static org.apache.dubbo.remoting.Constants.CONNECT_TIMEOUT_KEY;
import static org.apache.dubbo.remoting.Constants.DEFAULT_CONNECT_TIMEOUT;
@@ -103,14 +105,14 @@ public class RestProtocol extends AbstractProxyProtocol {
ServletContext servletContext =
ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT);
if (servletContext == null) {
throw new RpcException("No servlet context found. Since you
are using server='servlet', " +
- "make sure that you've configured " +
BootstrapListener.class.getName() + " in web.xml");
+ "make sure that you've configured " +
BootstrapListener.class.getName() + " in web.xml");
}
String webappPath = servletContext.getContextPath();
if (StringUtils.isNotEmpty(webappPath)) {
webappPath = webappPath.substring(1);
if (!contextPath.startsWith(webappPath)) {
throw new RpcException("Since you are using
server='servlet', " +
- "make sure that the 'contextpath' property starts
with the path of external webapp");
+ "make sure that the 'contextpath' property starts with
the path of external webapp");
}
contextPath = contextPath.substring(webappPath.length());
if (contextPath.startsWith("/")) {
@@ -230,7 +232,7 @@ public class RestProtocol extends AbstractProxyProtocol {
}
entry.getValue().close();
} catch (Throwable t) {
- logger.warn("Error closing rest server", t);
+ logger.warn(PROTOCOL_ERROR_CLOSE_SERVER, "", "", "Error
closing rest server", t);
}
}
serverMap.clear();
@@ -243,7 +245,7 @@ public class RestProtocol extends AbstractProxyProtocol {
// destroy directly regardless of the current reference count.
client.destroy();
} catch (Throwable t) {
- logger.warn("Error closing rest client", t);
+ logger.warn(PROTOCOL_ERROR_CLOSE_CLIENT, "", "", "Error
closing rest client", t);
}
}
clients.clear();
@@ -280,7 +282,7 @@ public class RestProtocol extends AbstractProxyProtocol {
connectionMonitor.destroyManager(url);
}
} catch (Exception e) {
- logger.warn("Failed to close unused resources in rest protocol.
interfaceName [" + url.getServiceInterface() + "]", e);
+ logger.warn(PROTOCOL_ERROR_CLOSE_CLIENT, "", "", "Failed to close
unused resources in rest protocol. interfaceName [" + url.getServiceInterface()
+ "]", e);
}
}
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java
index 63df5735a6..db6ed19911 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleInvoker.java
@@ -19,7 +19,7 @@ package org.apache.dubbo.rpc.protocol.tri;
import org.apache.dubbo.common.URL;
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.stream.StreamObserver;
import org.apache.dubbo.remoting.api.Connection;
@@ -65,6 +65,8 @@ import static
org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
import static
org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_ATTACHMENT_KEY;
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.LoggerCodeConstants.PROTOCOL_FAILED_DESTROY_INVOKER;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_REQUEST;
import static org.apache.dubbo.rpc.Constants.TOKEN_KEY;
/**
@@ -72,7 +74,7 @@ import static org.apache.dubbo.rpc.Constants.TOKEN_KEY;
*/
public class TripleInvoker<T> extends AbstractInvoker<T> {
- private static final Logger LOGGER =
LoggerFactory.getLogger(TripleInvoker.class);
+ private static final ErrorTypeAwareLogger LOGGER =
LoggerFactory.getErrorTypeAwareLogger(TripleInvoker.class);
private final Connection connection;
@@ -82,11 +84,11 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
private final String acceptEncodings;
public TripleInvoker(Class<T> serviceType,
- URL url,
- String acceptEncodings,
- ConnectionManager connectionManager,
- Set<Invoker<?>> invokers,
- ExecutorService streamExecutor) {
+ URL url,
+ String acceptEncodings,
+ ConnectionManager connectionManager,
+ Set<Invoker<?>> invokers,
+ ExecutorService streamExecutor) {
super(serviceType, url, new String[]{INTERFACE_KEY, GROUP_KEY,
TOKEN_KEY});
this.invokers = invokers;
this.connection = connectionManager.connect(url);
@@ -104,7 +106,7 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
if (!connection.isAvailable()) {
CompletableFuture<AppResponse> future = new CompletableFuture<>();
RpcException exception = TriRpcStatus.UNAVAILABLE.withDescription(
- String.format("upstream %s is unavailable",
getUrl().getAddress()))
+ String.format("upstream %s is unavailable",
getUrl().getAddress()))
.asException();
future.completeExceptionally(exception);
return new AsyncRpcResult(future, invocation);
@@ -143,7 +145,7 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
try {
call.cancelByLocal(e);
} catch (Throwable t1) {
- LOGGER.error("Cancel triple request failed", t1);
+ LOGGER.error(PROTOCOL_FAILED_REQUEST, "", "", "Cancel triple
request failed", t1);
}
CompletableFuture<AppResponse> future = new CompletableFuture<>();
future.completeExceptionally(e);
@@ -152,7 +154,7 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
}
AsyncRpcResult invokeServerStream(MethodDescriptor methodDescriptor,
Invocation invocation,
- ClientCall call) {
+ ClientCall call) {
RequestMetadata request = createRequest(methodDescriptor, invocation,
null);
StreamObserver<Object> responseObserver = (StreamObserver<Object>)
invocation.getArguments()[1];
final StreamObserver<Object> requestObserver = streamCall(call,
request, responseObserver);
@@ -162,7 +164,7 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
}
AsyncRpcResult invokeBiOrClientStream(MethodDescriptor methodDescriptor,
Invocation invocation,
- ClientCall call) {
+ ClientCall call) {
final AsyncRpcResult result;
RequestMetadata request = createRequest(methodDescriptor, invocation,
null);
StreamObserver<Object> responseObserver = (StreamObserver<Object>)
invocation.getArguments()[0];
@@ -173,8 +175,8 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
}
StreamObserver<Object> streamCall(ClientCall call,
- RequestMetadata metadata,
- StreamObserver<Object> responseObserver) {
+ RequestMetadata metadata,
+ StreamObserver<Object> responseObserver)
{
ObserverToClientCallListenerAdapter listener = new
ObserverToClientCallListenerAdapter(
responseObserver);
StreamObserver<Object> streamObserver = call.start(metadata, listener);
@@ -190,7 +192,7 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
}
AsyncRpcResult invokeUnary(MethodDescriptor methodDescriptor, Invocation
invocation,
- ClientCall call) {
+ ClientCall call) {
ExecutorService callbackExecutor = getCallbackExecutor(getUrl(),
invocation);
int timeout = calculateTimeout(invocation, invocation.getMethodName());
@@ -227,7 +229,7 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
}
RequestMetadata createRequest(MethodDescriptor methodDescriptor,
Invocation invocation,
- Integer timeout) {
+ Integer timeout) {
final String methodName = RpcUtils.getMethodName(invocation);
Objects.requireNonNull(methodDescriptor,
"MethodDescriptor not found for" + methodName + " params:" +
Arrays.toString(
@@ -289,7 +291,7 @@ public class TripleInvoker<T> extends AbstractInvoker<T> {
try {
connection.release();
} catch (Throwable t) {
- logger.warn(t.getMessage(), t);
+ logger.warn(PROTOCOL_FAILED_DESTROY_INVOKER, "", "",
t.getMessage(), t);
}
} finally {
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCall.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCall.java
index 76b1fb39f7..ca4d849ab4 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCall.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCall.java
@@ -18,7 +18,7 @@
package org.apache.dubbo.rpc.protocol.tri.call;
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.rpc.CancellationContext;
@@ -50,10 +50,15 @@ import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_CREATE_STREAM_TRIPLE;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_PARSE;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_SERIALIZE_TRIPLE;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_REQUEST;
+
public abstract class AbstractServerCall implements ServerCall,
ServerStream.Listener {
public static final String REMOTE_ADDRESS_KEY = "tri.remote.address";
- private static final Logger LOGGER =
LoggerFactory.getLogger(AbstractServerCall.class);
+ private static final ErrorTypeAwareLogger LOGGER =
LoggerFactory.getErrorTypeAwareLogger(AbstractServerCall.class);
public final Invoker<?> invoker;
public final FrameworkModel frameworkModel;
@@ -141,7 +146,7 @@ public abstract class AbstractServerCall implements
ServerCall, ServerStream.Lis
} catch (Throwable e) {
close(TriRpcStatus.INTERNAL.withDescription("Serialize response
failed")
.withCause(e), null);
- LOGGER.error(String.format("Serialize triple response failed,
service=%s method=%s",
+
LOGGER.error(PROTOCOL_FAILED_SERIALIZE_TRIPLE,"","",String.format("Serialize
triple response failed, service=%s method=%s",
serviceName, methodName), e);
return;
}
@@ -183,7 +188,7 @@ public abstract class AbstractServerCall implements
ServerCall, ServerStream.Lis
final TriRpcStatus status =
TriRpcStatus.UNKNOWN.withDescription("Server error")
.withCause(t);
close(status, null);
- LOGGER.error("Process request failed. service=" + serviceName +
+ LOGGER.error(PROTOCOL_FAILED_REQUEST,"","","Process request
failed. service=" + serviceName +
" method=" + methodName, t);
} finally {
ClassLoadUtil.switchContextLoader(tccl);
@@ -229,7 +234,7 @@ public abstract class AbstractServerCall implements
ServerCall, ServerStream.Lis
this.timeout = parseTimeoutToMills(timeout);
}
} catch (Throwable t) {
- LOGGER.warn(String.format("Failed to parse request timeout set
from:%s, service=%s "
+ LOGGER.warn(PROTOCOL_FAILED_PARSE, "", "", String.format("Failed
to parse request timeout set from:%s, service=%s "
+ "method=%s", timeout, serviceDescriptor.getInterfaceName(),
methodName));
}
if (null !=
requestMetadata.get(TripleHeaderEnum.CONSUMER_APP_NAME_KEY.getHeader())) {
@@ -348,7 +353,7 @@ public abstract class AbstractServerCall implements
ServerCall, ServerStream.Lis
}
closed = true;
stream.complete(status, null);
- LOGGER.error("Triple request error: service=" + serviceName + "
method" + methodName,
+ LOGGER.error(PROTOCOL_FAILED_REQUEST, "", "", "Triple request error:
service=" + serviceName + " method" + methodName,
status.asException());
}
@@ -383,7 +388,7 @@ public abstract class AbstractServerCall implements
ServerCall, ServerStream.Lis
}
return listener;
} catch (Throwable t) {
- LOGGER.error("Create triple stream failed", t);
+ LOGGER.error(PROTOCOL_FAILED_CREATE_STREAM_TRIPLE, "", "", "Create
triple stream failed", t);
responseErr(TriRpcStatus.INTERNAL.withDescription("Create stream
failed")
.withCause(t));
}
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java
index 7d9c422d05..98748e25f1 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/AbstractServerCallListener.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.protocol.tri.call;
-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.CancellationContext;
import org.apache.dubbo.rpc.Invoker;
@@ -30,9 +30,11 @@ import
org.apache.dubbo.rpc.protocol.tri.observer.ServerCallToObserverAdapter;
import java.net.InetSocketAddress;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_TIMEOUT_SERVER;
+
public abstract class AbstractServerCallListener implements
AbstractServerCall.Listener {
- private static final Logger LOGGER =
LoggerFactory.getLogger(AbstractServerCallListener.class);
+ private static final ErrorTypeAwareLogger LOGGER =
LoggerFactory.getErrorTypeAwareLogger(AbstractServerCallListener.class);
public final CancellationContext cancellationContext;
final RpcInvocation invocation;
final Invoker<?> invoker;
@@ -71,7 +73,7 @@ public abstract class AbstractServerCallListener implements
AbstractServerCall.L
}
final long cost = System.currentTimeMillis() - stInMillis;
if (responseObserver.isTimeout(cost)) {
- LOGGER.error(String.format(
+ LOGGER.error(PROTOCOL_TIMEOUT_SERVER, "", "",
String.format(
"Invoke timeout at server side, ignored to send
response. service=%s method=%s cost=%s",
invocation.getTargetServiceUniqueName(),
invocation.getMethodName(),
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/TripleClientCall.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/TripleClientCall.java
index b13af798cd..1792fc973e 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/TripleClientCall.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/call/TripleClientCall.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.protocol.tri.call;
-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.remoting.api.Connection;
@@ -45,9 +45,13 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_RESPONSE;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_SERIALIZE_TRIPLE;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_STREAM_LISTENER;
+
public class TripleClientCall implements ClientCall, ClientStream.Listener {
- private static final Logger LOGGER =
LoggerFactory.getLogger(TripleClientCall.class);
+ private static final ErrorTypeAwareLogger LOGGER =
LoggerFactory.getErrorTypeAwareLogger(TripleClientCall.class);
private final Connection connection;
private final Executor executor;
private final FrameworkModel frameworkModel;
@@ -60,7 +64,7 @@ public class TripleClientCall implements ClientCall,
ClientStream.Listener {
private boolean done;
public TripleClientCall(Connection connection, Executor executor,
- FrameworkModel frameworkModel) {
+ FrameworkModel frameworkModel) {
this.connection = connection;
this.executor = executor;
this.frameworkModel = frameworkModel;
@@ -71,7 +75,7 @@ public class TripleClientCall implements ClientCall,
ClientStream.Listener {
@Override
public void onMessage(byte[] message) {
if (done) {
- LOGGER.warn(
+ LOGGER.warn(PROTOCOL_STREAM_LISTENER, "", "",
"Received message from closed stream,connection=" + connection
+ " service="
+ requestMetadata.service + " method="
+ requestMetadata.method.getMethodName());
@@ -83,8 +87,8 @@ public class TripleClientCall implements ClientCall,
ClientStream.Listener {
} catch (Throwable t) {
cancelByLocal(TriRpcStatus.INTERNAL.withDescription("Deserialize
response failed")
.withCause(t).asException());
- LOGGER.error(String.format("Failed to deserialize triple response,
service=%s, method=%s,connection=%s",
- connection ,requestMetadata.service,
requestMetadata.method.getMethodName()),t);
+ LOGGER.error(PROTOCOL_FAILED_RESPONSE, "", "",
String.format("Failed to deserialize triple response, service=%s,
method=%s,connection=%s",
+ connection, requestMetadata.service,
requestMetadata.method.getMethodName()), t);
}
}
@@ -102,7 +106,7 @@ public class TripleClientCall implements ClientCall,
ClientStream.Listener {
@Override
public void onComplete(TriRpcStatus status, Map<String, Object>
attachments,
- Map<String, String> excludeHeaders) {
+ Map<String, String> excludeHeaders) {
if (done) {
return;
}
@@ -174,7 +178,7 @@ public class TripleClientCall implements ClientCall,
ClientStream.Listener {
// support others type but now only support this
}
} catch (Throwable t) {
- LOGGER.error("tran from grpc-status-details error", t);
+ LOGGER.error(PROTOCOL_FAILED_RESPONSE, "", "", "tran from
grpc-status-details error", t);
}
return map;
}
@@ -233,7 +237,7 @@ public class TripleClientCall implements ClientCall,
ClientStream.Listener {
}
});
} catch (Throwable t) {
- LOGGER.error(String.format("Serialize triple request failed,
service=%s method=%s",
+ LOGGER.error(PROTOCOL_FAILED_SERIALIZE_TRIPLE, "", "",
String.format("Serialize triple request failed, service=%s method=%s",
requestMetadata.service,
requestMetadata.method), t);
cancelByLocal(t);
@@ -266,7 +270,7 @@ public class TripleClientCall implements ClientCall,
ClientStream.Listener {
@Override
public StreamObserver<Object> start(RequestMetadata metadata,
- ClientCall.Listener responseListener) {
+ ClientCall.Listener responseListener) {
this.requestMetadata = metadata;
this.listener = responseListener;
this.stream = new TripleClientStream(frameworkModel, executor,
connection.getChannel(),
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/service/TriHealthImpl.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/service/TriHealthImpl.java
index 4f22c832e3..c21e78e1af 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/service/TriHealthImpl.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/service/TriHealthImpl.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.protocol.tri.service;
-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.rpc.RpcContext;
@@ -32,9 +32,11 @@ import java.util.IdentityHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_CLOSED_SERVER;
+
public class TriHealthImpl extends DubboHealthTriple.HealthImplBase {
- private static final Logger logger =
LoggerFactory.getLogger(TriHealthImpl.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(TriHealthImpl.class);
// Due to the latency of rpc calls, synchronization of the map does not
help with consistency.
// However, need use ConcurrentHashMap to allow concurrent reading by
check().
@@ -76,7 +78,7 @@ public class TriHealthImpl extends
DubboHealthTriple.HealthImplBase {
@Override
public void watch(HealthCheckRequest request,
- StreamObserver<HealthCheckResponse> responseObserver) {
+ StreamObserver<HealthCheckResponse> responseObserver) {
final String service = request.getService();
synchronized (watchLock) {
HealthCheckResponse.ServingStatus status = statusMap.get(service);
@@ -136,7 +138,7 @@ public class TriHealthImpl extends
DubboHealthTriple.HealthImplBase {
void enterTerminalState() {
synchronized (watchLock) {
if (terminal) {
- logger.warn("Already terminating", new RuntimeException());
+ logger.warn(PROTOCOL_CLOSED_SERVER, "", "", "Already
terminating", new RuntimeException());
return;
}
terminal = true;
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/StreamUtils.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/StreamUtils.java
index e0c6f61400..1270f421c4 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/StreamUtils.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/StreamUtils.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.protocol.tri.stream;
-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.rpc.TriRpcStatus;
@@ -35,9 +35,11 @@ import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_UNSUPPORTED;
+
public class StreamUtils {
- protected static final Logger LOGGER =
LoggerFactory.getLogger(StreamUtils.class);
+ protected static final ErrorTypeAwareLogger LOGGER =
LoggerFactory.getErrorTypeAwareLogger(StreamUtils.class);
private static final Base64.Decoder BASE64_DECODER = Base64.getDecoder();
private static final Base64.Encoder BASE64_ENCODER =
Base64.getEncoder().withoutPadding();
@@ -132,14 +134,13 @@ public class StreamUtils {
String str = encodeBase64ASCII((byte[]) v);
headers.set(key + TripleConstant.HEADER_BIN_SUFFIX, str);
} else {
- LOGGER.warn("Unsupported attachment k: " + key + " class: " +
v.getClass().getName());
+ LOGGER.warn(PROTOCOL_UNSUPPORTED, "", "", "Unsupported
attachment k: " + key + " class: " + v.getClass().getName());
}
} catch (Throwable t) {
- LOGGER.warn("Meet exception when convert single attachment key:" +
key + " value=" + v,
+ LOGGER.warn(PROTOCOL_UNSUPPORTED, "", "", "Meet exception when
convert single attachment key:" + key + " value=" + v,
t);
}
}
-
}
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/AbstractH2TransportListener.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/AbstractH2TransportListener.java
index d3bcc86a1b..2cf6caa001 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/AbstractH2TransportListener.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/AbstractH2TransportListener.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.protocol.tri.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.rpc.protocol.tri.TripleConstant;
import org.apache.dubbo.rpc.protocol.tri.TripleHeaderEnum;
@@ -29,9 +29,11 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_PARSE;
+
public abstract class AbstractH2TransportListener implements
H2TransportListener {
- private static final Logger LOGGER =
LoggerFactory.getLogger(AbstractH2TransportListener.class);
+ private static final ErrorTypeAwareLogger LOGGER =
LoggerFactory.getErrorTypeAwareLogger(AbstractH2TransportListener.class);
/**
* Parse metadata to a KV pairs map.
@@ -54,7 +56,7 @@ public abstract class AbstractH2TransportListener implements
H2TransportListener
byte[] value =
StreamUtils.decodeASCIIByte(header.getValue());
attachments.put(realKey, value);
} catch (Exception e) {
- LOGGER.error("Failed to parse response attachment key=" +
key, e);
+ LOGGER.error(PROTOCOL_FAILED_PARSE, "", "", "Failed to
parse response attachment key=" + key, e);
}
} else {
attachments.put(key, header.getValue().toString());
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleHttp2ClientResponseHandler.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleHttp2ClientResponseHandler.java
index 3fd99be7c6..19b35fd912 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleHttp2ClientResponseHandler.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleHttp2ClientResponseHandler.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.protocol.tri.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.rpc.TriRpcStatus;
@@ -30,10 +30,12 @@ import io.netty.handler.codec.http2.Http2HeadersFrame;
import io.netty.handler.codec.http2.Http2ResetFrame;
import io.netty.handler.codec.http2.Http2StreamFrame;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_SERIALIZE_TRIPLE;
+
public final class TripleHttp2ClientResponseHandler extends
SimpleChannelInboundHandler<Http2StreamFrame> {
- private static final Logger LOGGER = LoggerFactory.getLogger(
+ private static final ErrorTypeAwareLogger LOGGER =
LoggerFactory.getErrorTypeAwareLogger(
TripleHttp2ClientResponseHandler.class);
private final H2TransportListener transportListener;
@@ -70,7 +72,7 @@ public final class TripleHttp2ClientResponseHandler extends
}
private void onResetRead(ChannelHandlerContext ctx, Http2ResetFrame
resetFrame) {
- LOGGER.warn("Triple Client received remote reset errorCode=" +
resetFrame.errorCode());
+ LOGGER.warn(PROTOCOL_FAILED_SERIALIZE_TRIPLE, "", "", "Triple Client
received remote reset errorCode=" + resetFrame.errorCode());
transportListener.cancelByRemote(resetFrame.errorCode());
ctx.close();
}
@@ -85,7 +87,7 @@ public final class TripleHttp2ClientResponseHandler extends
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
final TriRpcStatus status = TriRpcStatus.INTERNAL
.withCause(cause);
- LOGGER.warn("Meet Exception on ClientResponseHandler, status code is:
" + status.code,
+ LOGGER.warn(PROTOCOL_FAILED_SERIALIZE_TRIPLE, "", "", "Meet Exception
on ClientResponseHandler, status code is: " + status.code,
cause);
transportListener.cancelByRemote(Http2Error.INTERNAL_ERROR.code());
ctx.close();
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleHttp2FrameServerHandler.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleHttp2FrameServerHandler.java
index 048d24644f..0bfe6c380c 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleHttp2FrameServerHandler.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleHttp2FrameServerHandler.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.protocol.tri.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.rpc.HeaderFilter;
import org.apache.dubbo.rpc.PathResolver;
@@ -38,13 +38,15 @@ import io.netty.util.ReferenceCounted;
import java.util.List;
import java.util.concurrent.Executor;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_RESPONSE;
+
public class TripleHttp2FrameServerHandler extends ChannelDuplexHandler {
private static final AttributeKey<TripleServerStream> SERVER_STREAM_KEY =
AttributeKey.valueOf(
"tri_server_stream");
- private static final Logger LOGGER = LoggerFactory.getLogger(
+ private static final ErrorTypeAwareLogger LOGGER =
LoggerFactory.getErrorTypeAwareLogger(
TripleHttp2FrameServerHandler.class);
private final PathResolver pathResolver;
private final FrameworkModel frameworkModel;
@@ -89,7 +91,7 @@ public class TripleHttp2FrameServerHandler extends
ChannelDuplexHandler {
public void onResetRead(ChannelHandlerContext ctx, Http2ResetFrame frame) {
final TripleServerStream tripleServerStream =
ctx.channel().attr(SERVER_STREAM_KEY)
.get();
- LOGGER.warn("Triple Server received remote reset errorCode=" +
frame.errorCode());
+ LOGGER.warn(PROTOCOL_FAILED_RESPONSE, "", "", "Triple Server received
remote reset errorCode=" + frame.errorCode());
if (tripleServerStream != null) {
tripleServerStream.transportObserver.cancelByRemote(frame.errorCode());
}
@@ -98,7 +100,7 @@ public class TripleHttp2FrameServerHandler extends
ChannelDuplexHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
throws Exception {
if (LOGGER.isWarnEnabled()) {
- LOGGER.warn("Exception in processing triple message", cause);
+ LOGGER.warn(PROTOCOL_FAILED_RESPONSE, "", "", "Exception in
processing triple message", cause);
}
TriRpcStatus status = TriRpcStatus.getStatus(cause,
"Provider's error:\n" + cause.getMessage());
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleServerConnectionHandler.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleServerConnectionHandler.java
index 97c23545ca..7aefff58fc 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleServerConnectionHandler.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/TripleServerConnectionHandler.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.rpc.protocol.tri.transport;
-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;
@@ -32,10 +32,11 @@ import java.net.SocketException;
import java.util.HashSet;
import java.util.Set;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_RESPONSE;
import static
org.apache.dubbo.rpc.protocol.tri.transport.GracefulShutdown.GRACEFUL_SHUTDOWN_PING;
public class TripleServerConnectionHandler extends Http2ChannelDuplexHandler {
- private static final Logger logger =
LoggerFactory.getLogger(TripleServerConnectionHandler.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(TripleServerConnectionHandler.class);
// Some exceptions are not very useful and add too much noise to the log
private static final Set<String> QUIET_EXCEPTIONS = new HashSet<>();
private static final Set<Class<?>> QUIET_EXCEPTIONS_CLASS = new
HashSet<>();
@@ -54,7 +55,7 @@ public class TripleServerConnectionHandler extends
Http2ChannelDuplexHandler {
if (((Http2PingFrame) msg).content() == GRACEFUL_SHUTDOWN_PING) {
if (gracefulShutdown == null) {
// this should never happen
- logger.warn("Received GRACEFUL_SHUTDOWN_PING Ack but
gracefulShutdown is null");
+ logger.warn(PROTOCOL_FAILED_RESPONSE, "", "", "Received
GRACEFUL_SHUTDOWN_PING Ack but gracefulShutdown is null");
} else {
gracefulShutdown.secondGoAwayAndClose(ctx);
}
@@ -86,7 +87,7 @@ public class TripleServerConnectionHandler extends
Http2ChannelDuplexHandler {
logger.debug(String.format("Channel:%s Error", ctx.channel()),
cause);
}
} else {
- logger.warn(String.format("Channel:%s Error", ctx.channel()),
cause);
+ logger.warn(PROTOCOL_FAILED_RESPONSE, "", "",
String.format("Channel:%s Error", ctx.channel()), cause);
}
ctx.close();
}
diff --git
a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java
b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java
index e166f33776..4626ece767 100644
---
a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java
+++
b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/java/JavaSerialization.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.common.serialize.java;
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.ObjectInput;
import org.apache.dubbo.common.serialize.ObjectOutput;
@@ -28,6 +28,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicBoolean;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_UNSAFE_SERIALIZATION;
import static
org.apache.dubbo.common.serialize.Constants.JAVA_SERIALIZATION_ID;
/**
@@ -38,7 +39,7 @@ import static
org.apache.dubbo.common.serialize.Constants.JAVA_SERIALIZATION_ID;
* </pre>
*/
public class JavaSerialization implements Serialization {
- private static final Logger logger =
LoggerFactory.getLogger(JavaSerialization.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(JavaSerialization.class);
private static final AtomicBoolean warn = new AtomicBoolean(false);
@Override
@@ -54,7 +55,7 @@ public class JavaSerialization implements Serialization {
@Override
public ObjectOutput serialize(URL url, OutputStream out) throws
IOException {
if (warn.compareAndSet(false, true)) {
- logger.error("Java serialization is unsafe. Dubbo Team do not
recommend anyone to use it." +
+ logger.error(PROTOCOL_UNSAFE_SERIALIZATION, "", "", "Java
serialization is unsafe. Dubbo Team do not recommend anyone to use it." +
"If you still want to use it, please follow [JEP
290](https://openjdk.java.net/jeps/290)" +
"to set serialization filter to prevent deserialization
leak.");
}
@@ -64,7 +65,7 @@ public class JavaSerialization implements Serialization {
@Override
public ObjectInput deserialize(URL url, InputStream is) throws IOException
{
if (warn.compareAndSet(false, true)) {
- logger.error("Java serialization is unsafe. Dubbo Team do not
recommend anyone to use it." +
+ logger.error(PROTOCOL_UNSAFE_SERIALIZATION, "", "", "Java
serialization is unsafe. Dubbo Team do not recommend anyone to use it." +
"If you still want to use it, please follow [JEP
290](https://openjdk.java.net/jeps/290)" +
"to set serialization filter to prevent deserialization
leak.");
}
diff --git
a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java
b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java
index 854fb0e26f..2e6e493b91 100644
---
a/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java
+++
b/dubbo-serialization/dubbo-serialization-jdk/src/main/java/org/apache/dubbo/common/serialize/nativejava/NativeJavaSerialization.java
@@ -18,7 +18,7 @@
package org.apache.dubbo.common.serialize.nativejava;
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.ObjectInput;
import org.apache.dubbo.common.serialize.ObjectOutput;
@@ -30,6 +30,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicBoolean;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_UNSAFE_SERIALIZATION;
import static
org.apache.dubbo.common.serialize.Constants.NATIVE_JAVA_SERIALIZATION_ID;
/**
@@ -40,7 +41,7 @@ import static
org.apache.dubbo.common.serialize.Constants.NATIVE_JAVA_SERIALIZAT
* </pre>
*/
public class NativeJavaSerialization implements Serialization {
- private static final Logger logger =
LoggerFactory.getLogger(JavaSerialization.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(JavaSerialization.class);
private static final AtomicBoolean warn = new AtomicBoolean(false);
@Override
@@ -56,7 +57,7 @@ public class NativeJavaSerialization implements Serialization
{
@Override
public ObjectOutput serialize(URL url, OutputStream output) throws
IOException {
if (warn.compareAndSet(false, true)) {
- logger.error("Java serialization is unsafe. Dubbo Team do not
recommend anyone to use it." +
+ logger.error(PROTOCOL_UNSAFE_SERIALIZATION, "", "", "Java
serialization is unsafe. Dubbo Team do not recommend anyone to use it." +
"If you still want to use it, please follow [JEP
290](https://openjdk.java.net/jeps/290)" +
"to set serialization filter to prevent deserialization
leak.");
}
@@ -66,7 +67,7 @@ public class NativeJavaSerialization implements Serialization
{
@Override
public ObjectInput deserialize(URL url, InputStream input) throws
IOException {
if (warn.compareAndSet(false, true)) {
- logger.error("Java serialization is unsafe. Dubbo Team do not
recommend anyone to use it." +
+ logger.error(PROTOCOL_UNSAFE_SERIALIZATION, "", "", "Java
serialization is unsafe. Dubbo Team do not recommend anyone to use it." +
"If you still want to use it, please follow [JEP
290](https://openjdk.java.net/jeps/290)" +
"to set serialization filter to prevent deserialization
leak.");
}
diff --git
a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/condition/CompatibleOnEnabledEndpointCondition.java
b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/condition/CompatibleOnEnabledEndpointCondition.java
index 15caada2d0..0c76ea7605 100644
---
a/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/condition/CompatibleOnEnabledEndpointCondition.java
+++
b/dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/condition/CompatibleOnEnabledEndpointCondition.java
@@ -16,7 +16,7 @@
*/
package org.apache.dubbo.spring.boot.actuate.endpoint.condition;
-import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.springframework.beans.BeanUtils;
@@ -26,6 +26,8 @@ import org.springframework.context.annotation.Conditional;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.ClassUtils;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_CLASS_NOT_FOUND;
+
/**
* {@link Conditional} that checks whether or not an endpoint is enabled,
which is compatible with
*
org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnEnabledEndpointCondition
@@ -36,7 +38,7 @@ import org.springframework.util.ClassUtils;
*/
class CompatibleOnEnabledEndpointCondition implements Condition {
- private static final Logger LOGGER =
LoggerFactory.getLogger(CompatibleOnEnabledEndpointCondition.class);
+ private static final ErrorTypeAwareLogger LOGGER =
LoggerFactory.getErrorTypeAwareLogger(CompatibleOnEnabledEndpointCondition.class);
// Spring Boot [2.0.0 , 2.2.x]
static String CONDITION_CLASS_NAME_OLD =
@@ -62,7 +64,7 @@ class CompatibleOnEnabledEndpointCondition implements
Condition {
return true;
}
// No condition class found
- LOGGER.warn(String.format("No condition class found, Dubbo Health
Endpoint [%s] will not expose", metadata));
+ LOGGER.warn(COMMON_CLASS_NOT_FOUND, "No condition class found", "",
String.format("No condition class found, Dubbo Health Endpoint [%s] will not
expose", metadata));
return false;
}
}
diff --git
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsServiceDiscovery.java
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsServiceDiscovery.java
index 28945f85f0..9f2b856bb3 100644
---
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsServiceDiscovery.java
+++
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsServiceDiscovery.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.registry.xds;
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.registry.client.DefaultServiceInstance;
import org.apache.dubbo.registry.client.ReflectionBasedServiceDiscovery;
@@ -34,9 +34,12 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ERROR_INITIALIZE_XDS;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ERROR_PARSING_XDS;
+
public class XdsServiceDiscovery extends ReflectionBasedServiceDiscovery {
- private static final Logger logger =
LoggerFactory.getLogger(XdsServiceDiscovery.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(XdsServiceDiscovery.class);
private PilotExchanger exchanger;
@@ -49,7 +52,7 @@ public class XdsServiceDiscovery extends
ReflectionBasedServiceDiscovery {
try {
exchanger = PilotExchanger.initialize(registryURL);
} catch (Throwable t) {
- logger.error(t);
+ logger.error(REGISTRY_ERROR_INITIALIZE_XDS, "", "",
t.getMessage(), t);
}
}
@@ -58,7 +61,7 @@ public class XdsServiceDiscovery extends
ReflectionBasedServiceDiscovery {
try {
exchanger.destroy();
} catch (Throwable t) {
- logger.error(t);
+ logger.error(REGISTRY_ERROR_INITIALIZE_XDS, "", "",
t.getMessage(), t);
}
}
@@ -88,7 +91,7 @@ public class XdsServiceDiscovery extends
ReflectionBasedServiceDiscovery {
fillServiceInstance(serviceInstance);
instances.add(serviceInstance);
} catch (Throwable t) {
- logger.error("Error occurred when parsing endpoints. Endpoints
List:" + endpoints, t);
+ logger.error(REGISTRY_ERROR_PARSING_XDS, "", "", "Error
occurred when parsing endpoints. Endpoints List:" + endpoints, t);
}
});
instances.sort(Comparator.comparingInt(ServiceInstance::hashCode));
diff --git
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsServiceDiscoveryFactory.java
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsServiceDiscoveryFactory.java
index 41eba21a70..706e230c51 100644
---
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsServiceDiscoveryFactory.java
+++
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsServiceDiscoveryFactory.java
@@ -17,23 +17,25 @@
package org.apache.dubbo.registry.xds;
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.registry.client.AbstractServiceDiscoveryFactory;
import org.apache.dubbo.registry.client.ServiceDiscovery;
import org.apache.dubbo.rpc.model.ApplicationModel;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ERROR_INITIALIZE_XDS;
+
public class XdsServiceDiscoveryFactory extends
AbstractServiceDiscoveryFactory {
- private static final Logger logger =
LoggerFactory.getLogger(XdsServiceDiscoveryFactory.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(XdsServiceDiscoveryFactory.class);
@Override
protected ServiceDiscovery createDiscovery(URL registryURL) {
- XdsServiceDiscovery xdsServiceDiscovery = new
XdsServiceDiscovery(ApplicationModel.defaultModel() ,registryURL);
+ XdsServiceDiscovery xdsServiceDiscovery = new
XdsServiceDiscovery(ApplicationModel.defaultModel(), registryURL);
try {
xdsServiceDiscovery.doInitialize(registryURL);
} catch (Exception e) {
- logger.error("Error occurred when initialize xDS service discovery
impl.", e);
+ logger.error(REGISTRY_ERROR_INITIALIZE_XDS, "", "", "Error
occurred when initialize xDS service discovery impl.", e);
}
return xdsServiceDiscovery;
}
diff --git
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/istio/IstioCitadelCertificateSigner.java
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/istio/IstioCitadelCertificateSigner.java
index cf91f1ea98..ac72c2417f 100644
---
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/istio/IstioCitadelCertificateSigner.java
+++
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/istio/IstioCitadelCertificateSigner.java
@@ -17,7 +17,7 @@
package org.apache.dubbo.registry.xds.istio;
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.registry.xds.XdsCertificateSigner;
import org.apache.dubbo.rpc.RpcException;
@@ -62,9 +62,13 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_FAILED_GENERATE_CERT_ISTIO;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_FAILED_GENERATE_KEY_ISTIO;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_RECEIVE_ERROR_MSG_ISTIO;
+
public class IstioCitadelCertificateSigner implements XdsCertificateSigner {
- private static final Logger logger =
LoggerFactory.getLogger(IstioCitadelCertificateSigner.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(IstioCitadelCertificateSigner.class);
private final org.apache.dubbo.registry.xds.istio.IstioEnv istioEnv;
@@ -99,7 +103,7 @@ public class IstioCitadelCertificateSigner implements
XdsCertificateSigner {
try {
certPair = createCert();
} catch (IOException e) {
- logger.error("Generate Cert from Istio failed.", e);
+ logger.error(REGISTRY_FAILED_GENERATE_CERT_ISTIO, "", "",
"Generate Cert from Istio failed.", e);
throw new RpcException("Generate Cert from Istio failed.",
e);
}
}
@@ -122,7 +126,7 @@ public class IstioCitadelCertificateSigner implements
XdsCertificateSigner {
privateKey = keypair.getPrivate();
signer = new
JcaContentSignerBuilder("SHA256withECDSA").build(keypair.getPrivate());
} catch (NoSuchAlgorithmException |
InvalidAlgorithmParameterException | OperatorCreationException e) {
- logger.error("Generate Key with secp256r1 algorithm failed.
Please check if your system support. "
+ logger.error(REGISTRY_FAILED_GENERATE_KEY_ISTIO, "", "",
"Generate Key with secp256r1 algorithm failed. Please check if your system
support. "
+ "Will attempt to generate with RSA2048.", e);
}
}
@@ -136,7 +140,7 @@ public class IstioCitadelCertificateSigner implements
XdsCertificateSigner {
privateKey = keypair.getPrivate();
signer = new
JcaContentSignerBuilder("SHA256WithRSA").build(keypair.getPrivate());
} catch (NoSuchAlgorithmException | OperatorCreationException e) {
- logger.error("Generate Key with SHA256WithRSA algorithm
failed. Please check if your system support.", e);
+ logger.error(REGISTRY_FAILED_GENERATE_KEY_ISTIO, "", "",
"Generate Key with SHA256WithRSA algorithm failed. Please check if your system
support.", e);
throw new RpcException(e);
}
}
@@ -202,7 +206,7 @@ public class IstioCitadelCertificateSigner implements
XdsCertificateSigner {
@Override
public void onError(Throwable throwable) {
failed.set(true);
- logger.error("Receive error message from Istio Citadel grpc
stub.", throwable);
+ logger.error(REGISTRY_RECEIVE_ERROR_MSG_ISTIO, "", "",
"Receive error message from Istio Citadel grpc stub.", throwable);
countDownLatch.countDown();
}
diff --git
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/istio/IstioEnv.java
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/istio/IstioEnv.java
index 0bb0e06c96..9e0f47154b 100644
--- a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/istio/IstioEnv.java
+++ b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/istio/IstioEnv.java
@@ -16,7 +16,7 @@
*/
package org.apache.dubbo.registry.xds.istio;
-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.xds.XdsEnv;
@@ -27,12 +27,13 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ERROR_READ_FILE_ISTIO;
import static org.apache.dubbo.registry.xds.istio.IstioConstant.NS;
import static org.apache.dubbo.registry.xds.istio.IstioConstant.SA;
import static org.apache.dubbo.registry.xds.istio.IstioConstant.SPIFFE;
public class IstioEnv implements XdsEnv {
- private static final Logger logger =
LoggerFactory.getLogger(IstioEnv.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(IstioEnv.class);
private static final IstioEnv INSTANCE = new IstioEnv();
@@ -75,7 +76,7 @@ public class IstioEnv implements XdsEnv {
try {
return
FileUtils.readFileToString(namespaceFile, StandardCharsets.UTF_8);
} catch (IOException e) {
- logger.error("read namespace file error", e);
+ logger.error(REGISTRY_ERROR_READ_FILE_ISTIO,
"", "", "read namespace file error", e);
}
}
return IstioConstant.DEFAULT_WORKLOAD_NAMESPACE;
@@ -93,11 +94,11 @@ public class IstioEnv implements XdsEnv {
try {
caCert = FileUtils.readFileToString(caFile,
StandardCharsets.UTF_8);
} catch (IOException e) {
- logger.error("read ca file error", e);
+ logger.error(REGISTRY_ERROR_READ_FILE_ISTIO, "", "",
"read ca file error", e);
}
}
} catch (IOException e) {
- logger.error("Unable to read token file.", e);
+ logger.error(REGISTRY_ERROR_READ_FILE_ISTIO, "", "", "Unable
to read token file.", e);
}
}
if (serviceAccount == null) {
diff --git
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/XdsChannel.java
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/XdsChannel.java
index 9019d38018..3378cbf4dd 100644
--- a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/XdsChannel.java
+++ b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/XdsChannel.java
@@ -21,7 +21,7 @@ import
io.grpc.netty.shaded.io.netty.channel.epoll.EpollDomainSocketChannel;
import io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoopGroup;
import io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress;
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.URLAddress;
import org.apache.dubbo.registry.xds.XdsCertificateSigner;
@@ -37,12 +37,15 @@ import
io.grpc.netty.shaded.io.netty.handler.ssl.util.InsecureTrustManagerFactor
import io.grpc.stub.StreamObserver;
import org.apache.dubbo.registry.xds.util.bootstrap.Bootstrapper;
import org.apache.dubbo.registry.xds.util.bootstrap.BootstrapperImpl;
+
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ERROR_CREATE_CHANNEL_XDS;
+
public class XdsChannel {
- private static final Logger logger =
LoggerFactory.getLogger(XdsChannel.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(XdsChannel.class);
private static final String USE_AGENT = "use-agent";
@@ -51,7 +54,7 @@ public class XdsChannel {
protected XdsChannel(URL url) {
ManagedChannel managedChannel = null;
try {
- if(!url.getParameter(USE_AGENT,false)) {
+ if (!url.getParameter(USE_AGENT, false)) {
XdsCertificateSigner signer =
url.getOrDefaultApplicationModel().getExtensionLoader(XdsCertificateSigner.class)
.getExtension(url.getParameter("signer", "istio"));
XdsCertificateSigner.CertPair certPair =
signer.GenerateCert(url);
@@ -62,11 +65,10 @@ public class XdsChannel {
.build();
managedChannel = NettyChannelBuilder.forAddress(url.getHost(),
url.getPort()).sslContext(context)
.build();
- }
- else {
+ } else {
BootstrapperImpl bootstrapper = new BootstrapperImpl();
Bootstrapper.BootstrapInfo bootstrapInfo =
bootstrapper.bootstrap();
- URLAddress address
=URLAddress.parse(bootstrapInfo.servers().get(0).target(),null, false);
+ URLAddress address =
URLAddress.parse(bootstrapInfo.servers().get(0).target(), null, false);
EpollEventLoopGroup elg = new EpollEventLoopGroup();
managedChannel = NettyChannelBuilder.forAddress(new
DomainSocketAddress("/" + address.getPath()))
.eventLoopGroup(elg)
@@ -75,7 +77,7 @@ public class XdsChannel {
.build();
}
} catch (Exception e) {
- logger.error("Error occurred when creating gRPC channel to control
panel.", e);
+ logger.error(REGISTRY_ERROR_CREATE_CHANNEL_XDS, "", "", "Error
occurred when creating gRPC channel to control panel.", e);
}
channel = managedChannel;
}
diff --git
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/AbstractProtocol.java
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/AbstractProtocol.java
index eb21cf3548..47db181e2d 100644
---
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/AbstractProtocol.java
+++
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/AbstractProtocol.java
@@ -16,7 +16,7 @@
*/
package org.apache.dubbo.registry.xds.util.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.common.utils.NamedThreadFactory;
import org.apache.dubbo.registry.xds.util.XdsChannel;
@@ -39,9 +39,11 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ERROR_REQUEST_XDS;
+
public abstract class AbstractProtocol<T, S extends DeltaResource<T>>
implements XdsProtocol<T> {
- private static final Logger logger =
LoggerFactory.getLogger(AbstractProtocol.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(AbstractProtocol.class);
protected final XdsChannel xdsChannel;
@@ -114,7 +116,7 @@ public abstract class AbstractProtocol<T, S extends
DeltaResource<T>> implements
// get result
return future.get();
} catch (InterruptedException | ExecutionException e) {
- logger.error("Error occur when request control panel.");
+ logger.error(REGISTRY_ERROR_REQUEST_XDS, "", "", "Error occur when
request control panel.");
return null;
} finally {
// close observer
@@ -166,7 +168,7 @@ public abstract class AbstractProtocol<T, S extends
DeltaResource<T>> implements
// get result
consumer.accept(future.get());
} catch (InterruptedException | ExecutionException e) {
- logger.error("Error occur when request control panel.");
+ logger.error(REGISTRY_ERROR_REQUEST_XDS, "", "", "Error
occur when request control panel.");
} finally {
// close observer
//requestObserver.onCompleted();
@@ -175,7 +177,7 @@ public abstract class AbstractProtocol<T, S extends
DeltaResource<T>> implements
streamResult.remove(request);
}
} catch (Throwable t) {
- logger.error("Error when requesting observe data. Type: " +
getTypeUrl(), t);
+ logger.error(REGISTRY_ERROR_REQUEST_XDS, "", "", "Error when
requesting observe data. Type: " + getTypeUrl(), t);
}
}, pollingTimeout, pollingTimeout, TimeUnit.SECONDS);
@@ -235,7 +237,7 @@ public abstract class AbstractProtocol<T, S extends
DeltaResource<T>> implements
@Override
public void onError(Throwable t) {
- logger.error("xDS Client received error message! detail:", t);
+ logger.error(REGISTRY_ERROR_REQUEST_XDS, "", "", "xDS Client
received error message! detail:", t);
clear();
}
diff --git
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/EdsProtocol.java
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/EdsProtocol.java
index 510370a312..b171a5406a 100644
---
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/EdsProtocol.java
+++
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/EdsProtocol.java
@@ -16,7 +16,7 @@
*/
package org.apache.dubbo.registry.xds.util.protocol.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.registry.xds.util.XdsChannel;
import org.apache.dubbo.registry.xds.util.protocol.AbstractProtocol;
@@ -37,9 +37,11 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ERROR_RESPONSE_XDS;
+
public class EdsProtocol extends AbstractProtocol<EndpointResult,
DeltaEndpoint> {
- private static final Logger logger =
LoggerFactory.getLogger(EdsProtocol.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(EdsProtocol.class);
public EdsProtocol(XdsChannel xdsChannel, Node node, int pollingPoolSize,
int pollingTimeout) {
super(xdsChannel, node, pollingPoolSize, pollingTimeout);
@@ -86,7 +88,7 @@ public class EdsProtocol extends
AbstractProtocol<EndpointResult, DeltaEndpoint>
try {
return any.unpack(ClusterLoadAssignment.class);
} catch (InvalidProtocolBufferException e) {
- logger.error("Error occur when decode xDS response.", e);
+ logger.error(REGISTRY_ERROR_RESPONSE_XDS, "", "", "Error occur
when decode xDS response.", e);
return null;
}
}
diff --git
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/LdsProtocol.java
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/LdsProtocol.java
index b9a59a591b..8566e6e027 100644
---
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/LdsProtocol.java
+++
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/LdsProtocol.java
@@ -16,7 +16,7 @@
*/
package org.apache.dubbo.registry.xds.util.protocol.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.registry.xds.util.XdsChannel;
import org.apache.dubbo.registry.xds.util.protocol.AbstractProtocol;
@@ -38,9 +38,11 @@ import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ERROR_RESPONSE_XDS;
+
public class LdsProtocol extends AbstractProtocol<ListenerResult,
DeltaListener> {
- private static final Logger logger =
LoggerFactory.getLogger(LdsProtocol.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(LdsProtocol.class);
public LdsProtocol(XdsChannel xdsChannel, Node node, int pollingPoolSize,
int pollingTimeout) {
super(xdsChannel, node, pollingPoolSize, pollingTimeout);
@@ -87,7 +89,7 @@ public class LdsProtocol extends
AbstractProtocol<ListenerResult, DeltaListener>
try {
return any.unpack(Listener.class);
} catch (InvalidProtocolBufferException e) {
- logger.error("Error occur when decode xDS response.", e);
+ logger.error(REGISTRY_ERROR_RESPONSE_XDS, "", "", "Error occur
when decode xDS response.", e);
return null;
}
}
@@ -99,7 +101,7 @@ public class LdsProtocol extends
AbstractProtocol<ListenerResult, DeltaListener>
}
return any.unpack(HttpConnectionManager.class);
} catch (InvalidProtocolBufferException e) {
- logger.error("Error occur when decode xDS response.", e);
+ logger.error(REGISTRY_ERROR_RESPONSE_XDS, "", "", "Error occur
when decode xDS response.", e);
return null;
}
}
diff --git
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/RdsProtocol.java
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/RdsProtocol.java
index ff9ba67a1a..653b53e648 100644
---
a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/RdsProtocol.java
+++
b/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/protocol/impl/RdsProtocol.java
@@ -16,7 +16,7 @@
*/
package org.apache.dubbo.registry.xds.util.protocol.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.registry.xds.util.XdsChannel;
import org.apache.dubbo.registry.xds.util.protocol.AbstractProtocol;
@@ -37,9 +37,11 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
+import static
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ERROR_RESPONSE_XDS;
+
public class RdsProtocol extends AbstractProtocol<RouteResult, DeltaRoute> {
- private static final Logger logger =
LoggerFactory.getLogger(RdsProtocol.class);
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(RdsProtocol.class);
public RdsProtocol(XdsChannel xdsChannel, Node node, int pollingPoolSize,
int pollingTimeout) {
super(xdsChannel, node, pollingPoolSize, pollingTimeout);
@@ -85,7 +87,7 @@ public class RdsProtocol extends
AbstractProtocol<RouteResult, DeltaRoute> {
try {
return any.unpack(RouteConfiguration.class);
} catch (InvalidProtocolBufferException e) {
- logger.error("Error occur when decode xDS response.", e);
+ logger.error(REGISTRY_ERROR_RESPONSE_XDS, "", "", "Error occur
when decode xDS response.", e);
return null;
}
}