You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by el...@apache.org on 2020/03/13 09:50:34 UTC
[incubator-ratis] branch master updated: RATIS-816. Use peerId in
error log / exception of GrpcServerProtocolClient.
This is an automated email from the ASF dual-hosted git repository.
elek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 636239f RATIS-816. Use peerId in error log / exception of GrpcServerProtocolClient.
636239f is described below
commit 636239f9c546782683bdb77f26c275f45a39af27
Author: Elek Márton <el...@apache.org>
AuthorDate: Mon Feb 17 14:04:52 2020 +0100
RATIS-816. Use peerId in error log / exception of GrpcServerProtocolClient.
---
.../org/apache/ratis/grpc/server/GrpcServerProtocolClient.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java
index 8ca32e1..cb46f99 100644
--- a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java
+++ b/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java
@@ -18,6 +18,7 @@
package org.apache.ratis.grpc.server;
import org.apache.ratis.grpc.GrpcTlsConfig;
+import org.apache.ratis.protocol.RaftPeerId;
import org.apache.ratis.thirdparty.io.grpc.ManagedChannel;
import org.apache.ratis.thirdparty.io.grpc.netty.GrpcSslContexts;
import org.apache.ratis.thirdparty.io.grpc.netty.NegotiationType;
@@ -46,9 +47,12 @@ public class GrpcServerProtocolClient implements Closeable {
private final RaftServerProtocolServiceBlockingStub blockingStub;
private final RaftServerProtocolServiceStub asyncStub;
private static final Logger LOG = LoggerFactory.getLogger(GrpcServerProtocolClient.class);
+ //visible for using in log / error messages AND to use in instrumented tests
+ private final RaftPeerId raftPeerId;
public GrpcServerProtocolClient(RaftPeer target, int flowControlWindow,
TimeDuration requestTimeoutDuration, GrpcTlsConfig tlsConfig) {
+ raftPeerId = target.getId();
NettyChannelBuilder channelBuilder =
NettyChannelBuilder.forTarget(target.getAddress());
@@ -71,7 +75,8 @@ public class GrpcServerProtocolClient implements Closeable {
try {
channelBuilder.useTransportSecurity().sslContext(sslContextBuilder.build());
} catch (Exception ex) {
- throw new IllegalArgumentException("Failed to build SslContext, tlsConfig=" + tlsConfig, ex);
+ throw new IllegalArgumentException("Failed to build SslContext, peerId=" + raftPeerId
+ + ", tlsConfig=" + tlsConfig, ex);
}
} else {
channelBuilder.negotiationType(NegotiationType.PLAINTEXT);
@@ -88,7 +93,7 @@ public class GrpcServerProtocolClient implements Closeable {
try {
channel.awaitTermination(5, TimeUnit.SECONDS);
} catch (Exception e) {
- LOG.error("Unexpected exception while waiting for channel termination", e);
+ LOG.error("Unexpected exception while waiting for channel termination, peerId={}", raftPeerId, e);
}
}