core: ManagedChannel should not depend on internal (#3898)

This commit is contained in:
zpencer 2017-12-28 11:04:11 -08:00 committed by GitHub
parent 40453c744f
commit e7b2089c85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 22 deletions

View File

@ -16,8 +16,6 @@
package io.grpc;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.concurrent.TimeUnit;
import javax.annotation.concurrent.ThreadSafe;
@ -25,10 +23,7 @@ import javax.annotation.concurrent.ThreadSafe;
* A {@link Channel} that provides lifecycle management.
*/
@ThreadSafe
public abstract class ManagedChannel
extends Channel implements InternalInstrumented<InternalChannelStats> {
private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
public abstract class ManagedChannel extends Channel {
/**
* Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
* cancelled.
@ -88,14 +83,6 @@ public abstract class ManagedChannel
throw new UnsupportedOperationException("Not implemented");
}
@Internal
@Override
public ListenableFuture<InternalChannelStats> getStats() {
SettableFuture<InternalChannelStats> ret = SettableFuture.create();
ret.set(null);
return ret;
}
/**
* Registers a one-off callback that will be run if the connectivity state of the channel diverges
* from the given {@code source}, which is typically what has just been returned by {@link
@ -127,10 +114,4 @@ public abstract class ManagedChannel
*/
@ExperimentalApi
public void resetConnectBackoff() {}
@Internal
@Override
public final InternalLogId getLogId() {
return logId;
}
}

View File

@ -41,6 +41,7 @@ import io.grpc.Context;
import io.grpc.DecompressorRegistry;
import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalChannelStats;
import io.grpc.InternalInstrumented;
import io.grpc.InternalLogId;
import io.grpc.LoadBalancer;
import io.grpc.LoadBalancer.PickResult;
@ -80,7 +81,8 @@ import javax.annotation.concurrent.ThreadSafe;
/** A communication channel for making outgoing RPCs. */
@ThreadSafe
public final class ManagedChannelImpl extends ManagedChannel {
public final class ManagedChannelImpl
extends ManagedChannel implements InternalInstrumented<InternalChannelStats> {
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.
@ -106,6 +108,7 @@ public final class ManagedChannelImpl extends ManagedChannel {
static final Status SUBCHANNEL_SHUTDOWN_STATUS =
Status.UNAVAILABLE.withDescription("Subchannel shutdown invoked");
private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final String target;
private final NameResolver.Factory nameResolverFactory;
private final Attributes nameResolverParams;
@ -272,6 +275,11 @@ public final class ManagedChannelImpl extends ManagedChannel {
return ret;
}
@Override
public InternalLogId getLogId() {
return logId;
}
// Run from channelExecutor
private class IdleModeTimer implements Runnable {
// Only mutated from channelExecutor

View File

@ -28,6 +28,8 @@ import io.grpc.ConnectivityStateInfo;
import io.grpc.Context;
import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalChannelStats;
import io.grpc.InternalInstrumented;
import io.grpc.InternalLogId;
import io.grpc.LoadBalancer;
import io.grpc.LoadBalancer.PickResult;
import io.grpc.LoadBalancer.PickSubchannelArgs;
@ -51,13 +53,15 @@ import javax.annotation.concurrent.ThreadSafe;
* to its own RPC needs.
*/
@ThreadSafe
final class OobChannel extends ManagedChannel {
final class OobChannel
extends ManagedChannel implements InternalInstrumented<InternalChannelStats> {
private static final Logger log = Logger.getLogger(OobChannel.class.getName());
private InternalSubchannel subchannel;
private AbstractSubchannel subchannelImpl;
private SubchannelPicker subchannelPicker;
private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final String authority;
private final DelayedClientTransport delayedTransport;
private final ObjectPool<? extends Executor> executorPool;
@ -245,4 +249,9 @@ final class OobChannel extends ManagedChannel {
ret.set(channelTracer.getStats());
return ret;
}
@Override
public InternalLogId getLogId() {
return logId;
}
}