mirror of https://github.com/grpc/grpc-java.git
core: ManagedChannel should not depend on internal (#3898)
This commit is contained in:
parent
40453c744f
commit
e7b2089c85
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
package io.grpc;
|
package io.grpc;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
import com.google.common.util.concurrent.SettableFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.annotation.concurrent.ThreadSafe;
|
import javax.annotation.concurrent.ThreadSafe;
|
||||||
|
|
||||||
|
|
@ -25,10 +23,7 @@ import javax.annotation.concurrent.ThreadSafe;
|
||||||
* A {@link Channel} that provides lifecycle management.
|
* A {@link Channel} that provides lifecycle management.
|
||||||
*/
|
*/
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
public abstract class ManagedChannel
|
public abstract class ManagedChannel extends Channel {
|
||||||
extends Channel implements InternalInstrumented<InternalChannelStats> {
|
|
||||||
private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
|
* Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
|
||||||
* cancelled.
|
* cancelled.
|
||||||
|
|
@ -88,14 +83,6 @@ public abstract class ManagedChannel
|
||||||
throw new UnsupportedOperationException("Not implemented");
|
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
|
* 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
|
* from the given {@code source}, which is typically what has just been returned by {@link
|
||||||
|
|
@ -127,10 +114,4 @@ public abstract class ManagedChannel
|
||||||
*/
|
*/
|
||||||
@ExperimentalApi
|
@ExperimentalApi
|
||||||
public void resetConnectBackoff() {}
|
public void resetConnectBackoff() {}
|
||||||
|
|
||||||
@Internal
|
|
||||||
@Override
|
|
||||||
public final InternalLogId getLogId() {
|
|
||||||
return logId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import io.grpc.Context;
|
||||||
import io.grpc.DecompressorRegistry;
|
import io.grpc.DecompressorRegistry;
|
||||||
import io.grpc.EquivalentAddressGroup;
|
import io.grpc.EquivalentAddressGroup;
|
||||||
import io.grpc.InternalChannelStats;
|
import io.grpc.InternalChannelStats;
|
||||||
|
import io.grpc.InternalInstrumented;
|
||||||
import io.grpc.InternalLogId;
|
import io.grpc.InternalLogId;
|
||||||
import io.grpc.LoadBalancer;
|
import io.grpc.LoadBalancer;
|
||||||
import io.grpc.LoadBalancer.PickResult;
|
import io.grpc.LoadBalancer.PickResult;
|
||||||
|
|
@ -80,7 +81,8 @@ 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 {
|
public final class ManagedChannelImpl
|
||||||
|
extends ManagedChannel implements InternalInstrumented<InternalChannelStats> {
|
||||||
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.
|
||||||
|
|
@ -106,6 +108,7 @@ public final class ManagedChannelImpl extends ManagedChannel {
|
||||||
static final Status SUBCHANNEL_SHUTDOWN_STATUS =
|
static final Status SUBCHANNEL_SHUTDOWN_STATUS =
|
||||||
Status.UNAVAILABLE.withDescription("Subchannel shutdown invoked");
|
Status.UNAVAILABLE.withDescription("Subchannel shutdown invoked");
|
||||||
|
|
||||||
|
private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
|
||||||
private final String target;
|
private final String target;
|
||||||
private final NameResolver.Factory nameResolverFactory;
|
private final NameResolver.Factory nameResolverFactory;
|
||||||
private final Attributes nameResolverParams;
|
private final Attributes nameResolverParams;
|
||||||
|
|
@ -272,6 +275,11 @@ public final class ManagedChannelImpl extends ManagedChannel {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InternalLogId getLogId() {
|
||||||
|
return logId;
|
||||||
|
}
|
||||||
|
|
||||||
// Run from channelExecutor
|
// Run from channelExecutor
|
||||||
private class IdleModeTimer implements Runnable {
|
private class IdleModeTimer implements Runnable {
|
||||||
// Only mutated from channelExecutor
|
// Only mutated from channelExecutor
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ import io.grpc.ConnectivityStateInfo;
|
||||||
import io.grpc.Context;
|
import io.grpc.Context;
|
||||||
import io.grpc.EquivalentAddressGroup;
|
import io.grpc.EquivalentAddressGroup;
|
||||||
import io.grpc.InternalChannelStats;
|
import io.grpc.InternalChannelStats;
|
||||||
|
import io.grpc.InternalInstrumented;
|
||||||
|
import io.grpc.InternalLogId;
|
||||||
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;
|
||||||
|
|
@ -51,13 +53,15 @@ import javax.annotation.concurrent.ThreadSafe;
|
||||||
* to its own RPC needs.
|
* to its own RPC needs.
|
||||||
*/
|
*/
|
||||||
@ThreadSafe
|
@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 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 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;
|
||||||
|
|
@ -245,4 +249,9 @@ final class OobChannel extends ManagedChannel {
|
||||||
ret.set(channelTracer.getStats());
|
ret.set(channelTracer.getStats());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InternalLogId getLogId() {
|
||||||
|
return logId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue