diff options
author | Kun Zhang <zhangkun83@users.noreply.github.com> | 2017-08-16 10:23:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-16 10:23:07 -0700 |
commit | 41410345e6b8f9e022dc06a8466a857726c32efa (patch) | |
tree | 32df577e83e3674cc9b2ce5bc9f44ae1fea156c3 /netty | |
parent | ca7685ef50a0970662a55e3ad84b7cba73c2f2d0 (diff) | |
download | grpc-grpc-java-41410345e6b8f9e022dc06a8466a857726c32efa.tar.gz |
core: pass status to ManagedClientTransport.shutdown() (#3351)
This aligns with shutdownNow(), which is already accepting a status.
The status will be propagated to application when RPCs failed because
of transport shutdown, which will become useful information for debug.
Diffstat (limited to 'netty')
3 files changed, 4 insertions, 7 deletions
diff --git a/netty/src/main/java/io/grpc/netty/NettyClientHandler.java b/netty/src/main/java/io/grpc/netty/NettyClientHandler.java index 2295b17eb..93b25dbb8 100644 --- a/netty/src/main/java/io/grpc/netty/NettyClientHandler.java +++ b/netty/src/main/java/io/grpc/netty/NettyClientHandler.java @@ -540,8 +540,7 @@ class NettyClientHandler extends AbstractNettyHandler { private void forcefulClose(final ChannelHandlerContext ctx, final ForcefulCloseCommand msg, ChannelPromise promise) throws Exception { - lifecycleManager.notifyShutdown( - Status.UNAVAILABLE.withDescription("Channel requested transport to shut down")); + lifecycleManager.notifyShutdown(msg.getStatus()); close(ctx, promise); connection().forEachActiveStream(new Http2StreamVisitor() { @Override diff --git a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java index 29e30b065..94c31663f 100644 --- a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java +++ b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java @@ -248,16 +248,14 @@ class NettyClientTransport implements ConnectionClientTransport { } @Override - public void shutdown() { + public void shutdown(Status reason) { // start() could have failed if (channel == null) { return; } // Notifying of termination is automatically done when the channel closes. if (channel.isOpen()) { - Status status - = Status.UNAVAILABLE.withDescription("Channel requested transport to shut down"); - handler.getWriteQueue().enqueue(new GracefulCloseCommand(status), true); + handler.getWriteQueue().enqueue(new GracefulCloseCommand(reason), true); } } diff --git a/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java b/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java index e805cdd80..5c7362447 100644 --- a/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java +++ b/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java @@ -118,7 +118,7 @@ public class NettyClientTransportTest { public void teardown() throws Exception { Context.ROOT.attach(); for (NettyClientTransport transport : transports) { - transport.shutdown(); + transport.shutdown(Status.UNAVAILABLE); } if (server != null) { |