From 2f155606b8aa2548420ced9bd8033861fdb2562a Mon Sep 17 00:00:00 2001 From: zpencer Date: Wed, 15 Nov 2017 11:49:13 -0800 Subject: [PATCH] core,netty: add ID to NettyServer (#3745) These are already WithLogId: ManagedChannelImpl, InternalSubchannel, ServerTransport --- core/src/main/java/io/grpc/internal/LogId.java | 3 ++- netty/src/main/java/io/grpc/netty/NettyServer.java | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/io/grpc/internal/LogId.java b/core/src/main/java/io/grpc/internal/LogId.java index 0e00bec701..cafe8e33a3 100644 --- a/core/src/main/java/io/grpc/internal/LogId.java +++ b/core/src/main/java/io/grpc/internal/LogId.java @@ -25,7 +25,8 @@ public final class LogId { private static final AtomicLong idAlloc = new AtomicLong(); /** - * @param tag a loggable tag associated with this ID. + * @param tag a loggable tag associated with this tag. The ID that is allocated is guaranteed + * to be unique and increasing, irrespective of the tag. */ public static LogId allocate(String tag) { return new LogId(tag, idAlloc.incrementAndGet()); diff --git a/netty/src/main/java/io/grpc/netty/NettyServer.java b/netty/src/main/java/io/grpc/netty/NettyServer.java index 12e7179d2a..6fb594ad20 100644 --- a/netty/src/main/java/io/grpc/netty/NettyServer.java +++ b/netty/src/main/java/io/grpc/netty/NettyServer.java @@ -23,10 +23,12 @@ import static io.netty.channel.ChannelOption.SO_KEEPALIVE; import io.grpc.ServerStreamTracer; import io.grpc.internal.InternalServer; +import io.grpc.internal.LogId; import io.grpc.internal.ServerListener; import io.grpc.internal.ServerTransportListener; import io.grpc.internal.SharedResourceHolder; import io.grpc.internal.TransportTracer; +import io.grpc.internal.WithLogId; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; @@ -48,9 +50,10 @@ import javax.annotation.Nullable; /** * Netty-based server implementation. */ -class NettyServer implements InternalServer { +class NettyServer implements InternalServer, WithLogId { private static final Logger log = Logger.getLogger(InternalServer.class.getName()); + private final LogId logId = LogId.allocate(getClass().getName()); private final SocketAddress address; private final Class channelType; private final ProtocolNegotiator protocolNegotiator; @@ -218,6 +221,11 @@ class NettyServer implements InternalServer { } } + @Override + public LogId getLogId() { + return logId; + } + class EventLoopReferenceCounter extends AbstractReferenceCounted { @Override protected void deallocate() {