core: move WithLog and LogId to io.grpc (#3813)

The channelz service must not live in io.grpc.internal, and channelz
needs to be able to get the identifier of the entities it
tracks. Since io.grpc can not refer to io.grpc.internal, the LogId
must be moved out of internal.
This commit is contained in:
zpencer 2017-11-30 15:04:40 -08:00 committed by GitHub
parent bc54970128
commit 9e7a4c44be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 79 additions and 56 deletions

View File

@ -14,28 +14,31 @@
* limitations under the License. * limitations under the License.
*/ */
package io.grpc.internal; package io.grpc;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
/** /**
* A loggable ID, unique for the duration of the program. * Do not use this.
*
* <p>A loggable ID, unique for the duration of the program.
*/ */
public final class LogId { @Internal
public final class InternalLogId {
private static final AtomicLong idAlloc = new AtomicLong(); private static final AtomicLong idAlloc = new AtomicLong();
/** /**
* @param tag a loggable tag associated with this tag. The ID that is allocated is guaranteed * @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. * to be unique and increasing, irrespective of the tag.
*/ */
public static LogId allocate(String tag) { public static InternalLogId allocate(String tag) {
return new LogId(tag, idAlloc.incrementAndGet()); return new InternalLogId(tag, idAlloc.incrementAndGet());
} }
private final String tag; private final String tag;
private final long id; private final long id;
private LogId(String tag, long id) { private InternalLogId(String tag, long id) {
this.tag = tag; this.tag = tag;
this.id = id; this.id = id;
} }

View File

@ -14,12 +14,15 @@
* limitations under the License. * limitations under the License.
*/ */
package io.grpc.internal; package io.grpc;
/** /**
* An object that has an ID that is unique within the JVM, primarily for debug logging. * Do not use this.
*
* <p>An object that has an ID that is unique within the JVM, primarily for debug logging.
*/ */
public interface WithLogId { @Internal
public interface InternalWithLogId {
/** /**
* Returns an ID that is primarily used in debug logs. It usually contains the class name and a * Returns an ID that is primarily used in debug logs. It usually contains the class name and a
* numeric ID that is unique among the instances. * numeric ID that is unique among the instances.
@ -27,5 +30,5 @@ public interface WithLogId {
* <p>The subclasses of this interface usually want to include the log ID in their {@link * <p>The subclasses of this interface usually want to include the log ID in their {@link
* #toString} results. * #toString} results.
*/ */
LogId getLogId(); InternalLogId getLogId();
} }

View File

@ -25,6 +25,7 @@ import io.grpc.Compressor;
import io.grpc.Decompressor; import io.grpc.Decompressor;
import io.grpc.DecompressorRegistry; import io.grpc.DecompressorRegistry;
import io.grpc.Grpc; import io.grpc.Grpc;
import io.grpc.InternalLogId;
import io.grpc.InternalTransportStats; import io.grpc.InternalTransportStats;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
@ -33,7 +34,6 @@ import io.grpc.Status;
import io.grpc.internal.ClientStream; import io.grpc.internal.ClientStream;
import io.grpc.internal.ClientStreamListener; import io.grpc.internal.ClientStreamListener;
import io.grpc.internal.ConnectionClientTransport; import io.grpc.internal.ConnectionClientTransport;
import io.grpc.internal.LogId;
import io.grpc.internal.ManagedClientTransport; import io.grpc.internal.ManagedClientTransport;
import io.grpc.internal.NoopClientStream; import io.grpc.internal.NoopClientStream;
import io.grpc.internal.ObjectPool; import io.grpc.internal.ObjectPool;
@ -63,7 +63,7 @@ import javax.annotation.concurrent.ThreadSafe;
final class InProcessTransport implements ServerTransport, ConnectionClientTransport { final class InProcessTransport implements ServerTransport, ConnectionClientTransport {
private static final Logger log = Logger.getLogger(InProcessTransport.class.getName()); private static final Logger log = Logger.getLogger(InProcessTransport.class.getName());
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final String name; private final String name;
private final String authority; private final String authority;
private ObjectPool<ScheduledExecutorService> serverSchedulerPool; private ObjectPool<ScheduledExecutorService> serverSchedulerPool;
@ -206,7 +206,7 @@ final class InProcessTransport implements ServerTransport, ConnectionClientTrans
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -20,6 +20,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.Context; import io.grpc.Context;
import io.grpc.InternalLogId;
import io.grpc.InternalTransportStats; import io.grpc.InternalTransportStats;
import io.grpc.LoadBalancer.PickResult; import io.grpc.LoadBalancer.PickResult;
import io.grpc.LoadBalancer.PickSubchannelArgs; import io.grpc.LoadBalancer.PickSubchannelArgs;
@ -48,7 +49,7 @@ import javax.annotation.concurrent.GuardedBy;
* thus the delayed transport stops owning the stream. * thus the delayed transport stops owning the stream.
*/ */
final class DelayedClientTransport implements ManagedClientTransport { final class DelayedClientTransport implements ManagedClientTransport {
private final LogId lodId = LogId.allocate(getClass().getName()); private final InternalLogId lodId = InternalLogId.allocate(getClass().getName());
private final Object lock = new Object(); private final Object lock = new Object();
@ -389,7 +390,7 @@ final class DelayedClientTransport implements ManagedClientTransport {
// TODO(carl-mastrangelo): remove this once the Subchannel change is in. // TODO(carl-mastrangelo): remove this once the Subchannel change is in.
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return lodId; return lodId;
} }

View File

@ -19,6 +19,7 @@ package io.grpc.internal;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import io.grpc.Attributes; import io.grpc.Attributes;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.InternalLogId;
import io.grpc.InternalTransportStats; import io.grpc.InternalTransportStats;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
@ -54,7 +55,7 @@ abstract class ForwardingConnectionClientTransport implements ConnectionClientTr
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return delegate().getLogId(); return delegate().getLogId();
} }

View File

@ -30,6 +30,8 @@ import com.google.errorprone.annotations.ForOverride;
import io.grpc.ConnectivityState; import io.grpc.ConnectivityState;
import io.grpc.ConnectivityStateInfo; import io.grpc.ConnectivityStateInfo;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
import io.grpc.Status; import io.grpc.Status;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.util.ArrayList; import java.util.ArrayList;
@ -48,10 +50,10 @@ import javax.annotation.concurrent.ThreadSafe;
* Transports for a single {@link SocketAddress}. * Transports for a single {@link SocketAddress}.
*/ */
@ThreadSafe @ThreadSafe
final class InternalSubchannel implements WithLogId { final class InternalSubchannel implements InternalWithLogId {
private static final Logger log = Logger.getLogger(InternalSubchannel.class.getName()); private static final Logger log = Logger.getLogger(InternalSubchannel.class.getName());
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final String authority; private final String authority;
private final String userAgent; private final String userAgent;
private final BackoffPolicy.Provider backoffPolicyProvider; private final BackoffPolicy.Provider backoffPolicyProvider;
@ -432,7 +434,7 @@ final class InternalSubchannel implements WithLogId {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -38,6 +38,8 @@ import io.grpc.ConnectivityStateInfo;
import io.grpc.Context; import io.grpc.Context;
import io.grpc.DecompressorRegistry; import io.grpc.DecompressorRegistry;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
import io.grpc.LoadBalancer; import io.grpc.LoadBalancer;
import io.grpc.LoadBalancer.PickResult; import io.grpc.LoadBalancer.PickResult;
import io.grpc.LoadBalancer.PickSubchannelArgs; import io.grpc.LoadBalancer.PickSubchannelArgs;
@ -74,7 +76,7 @@ import javax.annotation.concurrent.ThreadSafe;
/** A communication channel for making outgoing RPCs. */ /** A communication channel for making outgoing RPCs. */
@ThreadSafe @ThreadSafe
public final class ManagedChannelImpl extends ManagedChannel implements WithLogId { public final class ManagedChannelImpl extends ManagedChannel implements InternalWithLogId {
static final Logger logger = Logger.getLogger(ManagedChannelImpl.class.getName()); static final Logger logger = Logger.getLogger(ManagedChannelImpl.class.getName());
// Matching this pattern means the target string is a URI target or at least intended to be one. // Matching this pattern means the target string is a URI target or at least intended to be one.
@ -108,7 +110,7 @@ public final class ManagedChannelImpl extends ManagedChannel implements WithLogI
private final Executor executor; private final Executor executor;
private final ObjectPool<? extends Executor> executorPool; private final ObjectPool<? extends Executor> executorPool;
private final ObjectPool<? extends Executor> oobExecutorPool; private final ObjectPool<? extends Executor> oobExecutorPool;
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final ChannelExecutor channelExecutor = new ChannelExecutor(); private final ChannelExecutor channelExecutor = new ChannelExecutor();
@ -869,7 +871,7 @@ public final class ManagedChannelImpl extends ManagedChannel implements WithLogI
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }
@ -1026,7 +1028,7 @@ public final class ManagedChannelImpl extends ManagedChannel implements WithLogI
Boolean.parseBoolean(System.getProperty(ALLOCATION_SITE_PROPERTY_NAME, "true")); Boolean.parseBoolean(System.getProperty(ALLOCATION_SITE_PROPERTY_NAME, "true"));
private static final RuntimeException missingCallSite = missingCallSite(); private static final RuntimeException missingCallSite = missingCallSite();
private final LogId logId; private final InternalLogId logId;
private final String target; private final String target;
private final Reference<RuntimeException> allocationSite; private final Reference<RuntimeException> allocationSite;
private volatile boolean shutdown; private volatile boolean shutdown;

View File

@ -16,6 +16,7 @@
package io.grpc.internal; package io.grpc.internal;
import io.grpc.InternalWithLogId;
import io.grpc.Status; import io.grpc.Status;
import javax.annotation.CheckReturnValue; import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -33,7 +34,7 @@ import javax.annotation.concurrent.ThreadSafe;
* {@link Listener#transportTerminated}. * {@link Listener#transportTerminated}.
*/ */
@ThreadSafe @ThreadSafe
public interface ManagedClientTransport extends ClientTransport, WithLogId { public interface ManagedClientTransport extends ClientTransport, InternalWithLogId {
/** /**
* Starts transport. This method may only be called once. * Starts transport. This method may only be called once.

View File

@ -25,6 +25,8 @@ import io.grpc.ClientCall;
import io.grpc.ConnectivityStateInfo; import io.grpc.ConnectivityStateInfo;
import io.grpc.Context; import io.grpc.Context;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
import io.grpc.LoadBalancer.Subchannel; import io.grpc.LoadBalancer.Subchannel;
import io.grpc.LoadBalancer; import io.grpc.LoadBalancer;
import io.grpc.LoadBalancer.PickResult; import io.grpc.LoadBalancer.PickResult;
@ -48,14 +50,14 @@ import javax.annotation.concurrent.ThreadSafe;
* to its own RPC needs. * to its own RPC needs.
*/ */
@ThreadSafe @ThreadSafe
final class OobChannel extends ManagedChannel implements WithLogId { final class OobChannel extends ManagedChannel implements InternalWithLogId {
private static final Logger log = Logger.getLogger(OobChannel.class.getName()); private static final Logger log = Logger.getLogger(OobChannel.class.getName());
private InternalSubchannel subchannel; private InternalSubchannel subchannel;
private AbstractSubchannel subchannelImpl; private AbstractSubchannel subchannelImpl;
private SubchannelPicker subchannelPicker; private SubchannelPicker subchannelPicker;
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final String authority; private final String authority;
private final DelayedClientTransport delayedTransport; private final DelayedClientTransport delayedTransport;
private final ObjectPool<? extends Executor> executorPool; private final ObjectPool<? extends Executor> executorPool;
@ -172,7 +174,7 @@ final class OobChannel extends ManagedChannel implements WithLogId {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -32,7 +32,9 @@ import io.grpc.Context;
import io.grpc.Decompressor; import io.grpc.Decompressor;
import io.grpc.DecompressorRegistry; import io.grpc.DecompressorRegistry;
import io.grpc.HandlerRegistry; import io.grpc.HandlerRegistry;
import io.grpc.InternalLogId;
import io.grpc.InternalServerInterceptors; import io.grpc.InternalServerInterceptors;
import io.grpc.InternalWithLogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.ServerCall; import io.grpc.ServerCall;
import io.grpc.ServerCallHandler; import io.grpc.ServerCallHandler;
@ -70,11 +72,11 @@ import javax.annotation.concurrent.GuardedBy;
* <p>Starting the server starts the underlying transport for servicing requests. Stopping the * <p>Starting the server starts the underlying transport for servicing requests. Stopping the
* server stops servicing new requests and waits for all connections to terminate. * server stops servicing new requests and waits for all connections to terminate.
*/ */
public final class ServerImpl extends io.grpc.Server implements WithLogId { public final class ServerImpl extends io.grpc.Server implements InternalWithLogId {
private static final Logger log = Logger.getLogger(ServerImpl.class.getName()); private static final Logger log = Logger.getLogger(ServerImpl.class.getName());
private static final ServerStreamListener NOOP_LISTENER = new NoopListener(); private static final ServerStreamListener NOOP_LISTENER = new NoopListener();
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final ObjectPool<? extends Executor> executorPool; private final ObjectPool<? extends Executor> executorPool;
/** Executor for application processing. Safe to read after {@link #start()}. */ /** Executor for application processing. Safe to read after {@link #start()}. */
private Executor executor; private Executor executor;
@ -527,7 +529,7 @@ public final class ServerImpl extends io.grpc.Server implements WithLogId {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -17,12 +17,13 @@
package io.grpc.internal; package io.grpc.internal;
import io.grpc.InternalTransportStats; import io.grpc.InternalTransportStats;
import io.grpc.InternalWithLogId;
import io.grpc.Status; import io.grpc.Status;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
/** An inbound connection. */ /** An inbound connection. */
public interface ServerTransport extends WithLogId { public interface ServerTransport extends InternalWithLogId {
/** /**
* Initiates an orderly shutdown of the transport. Existing streams continue, but new streams will * Initiates an orderly shutdown of the transport. Existing streams continue, but new streams will
* eventually begin failing. New streams "eventually" begin failing because shutdown may need to * eventually begin failing. New streams "eventually" begin failing because shutdown may need to

View File

@ -60,6 +60,7 @@ import io.grpc.ConnectivityStateInfo;
import io.grpc.Context; import io.grpc.Context;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.IntegerMarshaller; import io.grpc.IntegerMarshaller;
import io.grpc.InternalLogId;
import io.grpc.LoadBalancer; import io.grpc.LoadBalancer;
import io.grpc.LoadBalancer.Helper; import io.grpc.LoadBalancer.Helper;
import io.grpc.LoadBalancer.PickResult; import io.grpc.LoadBalancer.PickResult;
@ -1596,7 +1597,7 @@ public class ManagedChannelImplTest {
false, // Don't create a transport, Helper maintains a ref to the channel. false, // Don't create a transport, Helper maintains a ref to the channel.
ManagedChannelImpl.IDLE_TIMEOUT_MILLIS_DISABLE); ManagedChannelImpl.IDLE_TIMEOUT_MILLIS_DISABLE);
assertNotNull(channel); assertNotNull(channel);
LogId logId = channel.getLogId(); InternalLogId logId = channel.getLogId();
// Try to capture the log output but without causing terminal noise. Adding the filter must // Try to capture the log output but without causing terminal noise. Adding the filter must
// be done before clearing the ref or else it might be missed. // be done before clearing the ref or else it might be missed.

View File

@ -50,6 +50,7 @@ import io.grpc.Context;
import io.grpc.Grpc; import io.grpc.Grpc;
import io.grpc.HandlerRegistry; import io.grpc.HandlerRegistry;
import io.grpc.IntegerMarshaller; import io.grpc.IntegerMarshaller;
import io.grpc.InternalLogId;
import io.grpc.InternalTransportStats; import io.grpc.InternalTransportStats;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
@ -1264,7 +1265,7 @@ public class ServerImplTest {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -22,12 +22,12 @@ import com.google.common.annotations.VisibleForTesting;
import io.grpc.Attributes; import io.grpc.Attributes;
import io.grpc.ConnectivityStateInfo; import io.grpc.ConnectivityStateInfo;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
import io.grpc.LoadBalancer; import io.grpc.LoadBalancer;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.grpclb.GrpclbConstants.LbPolicy; import io.grpc.grpclb.GrpclbConstants.LbPolicy;
import io.grpc.internal.LogId;
import io.grpc.internal.ObjectPool; import io.grpc.internal.ObjectPool;
import io.grpc.internal.WithLogId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -42,10 +42,10 @@ import javax.annotation.Nullable;
* <p>Optionally, when requested by the naming system, will delegate the work to a local pick-first * <p>Optionally, when requested by the naming system, will delegate the work to a local pick-first
* or round-robin balancer. * or round-robin balancer.
*/ */
class GrpclbLoadBalancer extends LoadBalancer implements WithLogId { class GrpclbLoadBalancer extends LoadBalancer implements InternalWithLogId {
private static final Logger logger = Logger.getLogger(GrpclbLoadBalancer.class.getName()); private static final Logger logger = Logger.getLogger(GrpclbLoadBalancer.class.getName());
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final Helper helper; private final Helper helper;
private final Factory pickFirstBalancerFactory; private final Factory pickFirstBalancerFactory;
@ -81,7 +81,7 @@ class GrpclbLoadBalancer extends LoadBalancer implements WithLogId {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -33,6 +33,7 @@ import io.grpc.Attributes;
import io.grpc.ConnectivityState; import io.grpc.ConnectivityState;
import io.grpc.ConnectivityStateInfo; import io.grpc.ConnectivityStateInfo;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalLogId;
import io.grpc.LoadBalancer.Helper; import io.grpc.LoadBalancer.Helper;
import io.grpc.LoadBalancer.PickResult; import io.grpc.LoadBalancer.PickResult;
import io.grpc.LoadBalancer.PickSubchannelArgs; import io.grpc.LoadBalancer.PickSubchannelArgs;
@ -42,7 +43,6 @@ import io.grpc.ManagedChannel;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.grpclb.LoadBalanceResponse.LoadBalanceResponseTypeCase; import io.grpc.grpclb.LoadBalanceResponse.LoadBalanceResponseTypeCase;
import io.grpc.internal.LogId;
import io.grpc.stub.StreamObserver; import io.grpc.stub.StreamObserver;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -53,8 +53,8 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -92,7 +92,7 @@ final class GrpclbState {
} }
}; };
private final LogId logId; private final InternalLogId logId;
private final String serviceName; private final String serviceName;
private final Helper helper; private final Helper helper;
private final TimeProvider time; private final TimeProvider time;
@ -127,7 +127,10 @@ final class GrpclbState {
new RoundRobinPicker(Collections.<DropEntry>emptyList(), Arrays.asList(BUFFER_ENTRY)); new RoundRobinPicker(Collections.<DropEntry>emptyList(), Arrays.asList(BUFFER_ENTRY));
GrpclbState( GrpclbState(
Helper helper, TimeProvider time, ScheduledExecutorService timerService, LogId logId) { Helper helper,
TimeProvider time,
ScheduledExecutorService timerService,
InternalLogId logId) {
this.helper = checkNotNull(helper, "helper"); this.helper = checkNotNull(helper, "helper");
this.time = checkNotNull(time, "time provider"); this.time = checkNotNull(time, "time provider");
this.timerService = checkNotNull(timerService, "timerService"); this.timerService = checkNotNull(timerService, "timerService");

View File

@ -24,6 +24,7 @@ import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import io.grpc.Attributes; import io.grpc.Attributes;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.InternalLogId;
import io.grpc.InternalTransportStats; import io.grpc.InternalTransportStats;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
@ -35,7 +36,6 @@ import io.grpc.internal.GrpcUtil;
import io.grpc.internal.Http2Ping; import io.grpc.internal.Http2Ping;
import io.grpc.internal.KeepAliveManager; import io.grpc.internal.KeepAliveManager;
import io.grpc.internal.KeepAliveManager.ClientKeepAlivePinger; import io.grpc.internal.KeepAliveManager.ClientKeepAlivePinger;
import io.grpc.internal.LogId;
import io.grpc.internal.StatsTraceContext; import io.grpc.internal.StatsTraceContext;
import io.grpc.internal.TransportTracer; import io.grpc.internal.TransportTracer;
import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.Bootstrap;
@ -60,7 +60,7 @@ import javax.annotation.Nullable;
* A Netty-based {@link ConnectionClientTransport} implementation. * A Netty-based {@link ConnectionClientTransport} implementation.
*/ */
class NettyClientTransport implements ConnectionClientTransport { class NettyClientTransport implements ConnectionClientTransport {
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final Map<ChannelOption<?>, ?> channelOptions; private final Map<ChannelOption<?>, ?> channelOptions;
private final SocketAddress address; private final SocketAddress address;
private final Class<? extends Channel> channelType; private final Class<? extends Channel> channelType;
@ -299,7 +299,7 @@ class NettyClientTransport implements ConnectionClientTransport {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -21,14 +21,14 @@ import static io.grpc.netty.NettyServerBuilder.MAX_CONNECTION_AGE_NANOS_DISABLED
import static io.netty.channel.ChannelOption.SO_BACKLOG; import static io.netty.channel.ChannelOption.SO_BACKLOG;
import static io.netty.channel.ChannelOption.SO_KEEPALIVE; import static io.netty.channel.ChannelOption.SO_KEEPALIVE;
import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
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;
@ -53,10 +53,10 @@ import javax.annotation.Nullable;
/** /**
* Netty-based server implementation. * Netty-based server implementation.
*/ */
class NettyServer implements InternalServer, WithLogId { class NettyServer implements InternalServer, InternalWithLogId {
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 InternalLogId logId = InternalLogId.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 Map<ChannelOption<?>, ?> channelOptions; private final Map<ChannelOption<?>, ?> channelOptions;
@ -238,7 +238,7 @@ class NettyServer implements InternalServer, WithLogId {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -20,10 +20,10 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import io.grpc.InternalLogId;
import io.grpc.InternalTransportStats; import io.grpc.InternalTransportStats;
import io.grpc.ServerStreamTracer; import io.grpc.ServerStreamTracer;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.internal.LogId;
import io.grpc.internal.ServerTransport; import io.grpc.internal.ServerTransport;
import io.grpc.internal.ServerTransportListener; import io.grpc.internal.ServerTransportListener;
import io.grpc.internal.TransportTracer; import io.grpc.internal.TransportTracer;
@ -53,7 +53,7 @@ class NettyServerTransport implements ServerTransport {
"Connection reset by peer", "Connection reset by peer",
"An existing connection was forcibly closed by the remote host"); "An existing connection was forcibly closed by the remote host");
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final Channel channel; private final Channel channel;
private final ProtocolNegotiator protocolNegotiator; private final ProtocolNegotiator protocolNegotiator;
private final int maxStreams; private final int maxStreams;
@ -139,7 +139,7 @@ class NettyServerTransport implements ServerTransport {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -30,6 +30,7 @@ import com.squareup.okhttp.Request;
import com.squareup.okhttp.internal.http.StatusLine; import com.squareup.okhttp.internal.http.StatusLine;
import io.grpc.Attributes; import io.grpc.Attributes;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.InternalLogId;
import io.grpc.InternalTransportStats; import io.grpc.InternalTransportStats;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
@ -42,7 +43,6 @@ import io.grpc.internal.GrpcUtil;
import io.grpc.internal.Http2Ping; import io.grpc.internal.Http2Ping;
import io.grpc.internal.KeepAliveManager; import io.grpc.internal.KeepAliveManager;
import io.grpc.internal.KeepAliveManager.ClientKeepAlivePinger; import io.grpc.internal.KeepAliveManager.ClientKeepAlivePinger;
import io.grpc.internal.LogId;
import io.grpc.internal.SerializingExecutor; import io.grpc.internal.SerializingExecutor;
import io.grpc.internal.SharedResourceHolder; import io.grpc.internal.SharedResourceHolder;
import io.grpc.internal.StatsTraceContext; import io.grpc.internal.StatsTraceContext;
@ -133,7 +133,7 @@ class OkHttpClientTransport implements ConnectionClientTransport {
private AsyncFrameWriter frameWriter; private AsyncFrameWriter frameWriter;
private OutboundFlowController outboundFlow; private OutboundFlowController outboundFlow;
private final Object lock = new Object(); private final Object lock = new Object();
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
@GuardedBy("lock") @GuardedBy("lock")
private int nextStreamId; private int nextStreamId;
@GuardedBy("lock") @GuardedBy("lock")
@ -568,7 +568,7 @@ class OkHttpClientTransport implements ConnectionClientTransport {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }