mirror of https://github.com/grpc/grpc-java.git
core,netty: add ID to NettyServer (#3745)
These are already WithLogId: ManagedChannelImpl, InternalSubchannel, ServerTransport
This commit is contained in:
parent
df357cb8d3
commit
2f155606b8
|
|
@ -25,7 +25,8 @@ public final class LogId {
|
||||||
private static final AtomicLong idAlloc = new AtomicLong();
|
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) {
|
public static LogId allocate(String tag) {
|
||||||
return new LogId(tag, idAlloc.incrementAndGet());
|
return new LogId(tag, idAlloc.incrementAndGet());
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,12 @@ import static io.netty.channel.ChannelOption.SO_KEEPALIVE;
|
||||||
|
|
||||||
import io.grpc.ServerStreamTracer;
|
import io.grpc.ServerStreamTracer;
|
||||||
import io.grpc.internal.InternalServer;
|
import io.grpc.internal.InternalServer;
|
||||||
|
import io.grpc.internal.LogId;
|
||||||
import io.grpc.internal.ServerListener;
|
import io.grpc.internal.ServerListener;
|
||||||
import io.grpc.internal.ServerTransportListener;
|
import io.grpc.internal.ServerTransportListener;
|
||||||
import io.grpc.internal.SharedResourceHolder;
|
import io.grpc.internal.SharedResourceHolder;
|
||||||
import io.grpc.internal.TransportTracer;
|
import io.grpc.internal.TransportTracer;
|
||||||
|
import io.grpc.internal.WithLogId;
|
||||||
import io.netty.bootstrap.ServerBootstrap;
|
import io.netty.bootstrap.ServerBootstrap;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelFuture;
|
import io.netty.channel.ChannelFuture;
|
||||||
|
|
@ -48,9 +50,10 @@ import javax.annotation.Nullable;
|
||||||
/**
|
/**
|
||||||
* Netty-based server implementation.
|
* Netty-based server implementation.
|
||||||
*/
|
*/
|
||||||
class NettyServer implements InternalServer {
|
class NettyServer implements InternalServer, WithLogId {
|
||||||
private static final Logger log = Logger.getLogger(InternalServer.class.getName());
|
private static final Logger log = Logger.getLogger(InternalServer.class.getName());
|
||||||
|
|
||||||
|
private final LogId logId = LogId.allocate(getClass().getName());
|
||||||
private final SocketAddress address;
|
private final SocketAddress address;
|
||||||
private final Class<? extends ServerChannel> channelType;
|
private final Class<? extends ServerChannel> channelType;
|
||||||
private final ProtocolNegotiator protocolNegotiator;
|
private final ProtocolNegotiator protocolNegotiator;
|
||||||
|
|
@ -218,6 +221,11 @@ class NettyServer implements InternalServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LogId getLogId() {
|
||||||
|
return logId;
|
||||||
|
}
|
||||||
|
|
||||||
class EventLoopReferenceCounter extends AbstractReferenceCounted {
|
class EventLoopReferenceCounter extends AbstractReferenceCounted {
|
||||||
@Override
|
@Override
|
||||||
protected void deallocate() {
|
protected void deallocate() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue