core: fix unimplemented API in ManageChannel

Two APIs were added to ManageChannel. This would be API breaking if they are still abstract.
This commit is contained in:
ZHANG Dapeng 2017-12-27 13:30:12 -08:00 committed by GitHub
parent 3e76bf143b
commit 40453c744f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 17 deletions

View File

@ -16,6 +16,8 @@
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,6 +27,8 @@ import javax.annotation.concurrent.ThreadSafe;
@ThreadSafe
public abstract class ManagedChannel
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
* cancelled.
@ -84,6 +88,14 @@ 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
@ -115,4 +127,10 @@ public abstract class ManagedChannel
*/
@ExperimentalApi
public void resetConnectBackoff() {}
@Internal
@Override
public final InternalLogId getLogId() {
return logId;
}
}

View File

@ -114,7 +114,6 @@ public final class ManagedChannelImpl extends ManagedChannel {
private final Executor executor;
private final ObjectPool<? extends Executor> executorPool;
private final ObjectPool<? extends Executor> oobExecutorPool;
private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final ChannelExecutor channelExecutor = new ChannelExecutor();
@ -975,11 +974,6 @@ public final class ManagedChannelImpl extends ManagedChannel {
}
}
@Override
public InternalLogId getLogId() {
return logId;
}
private class NameResolverListenerImpl implements NameResolver.Listener {
final LoadBalancer balancer;
final LoadBalancer.Helper helper;
@ -1151,7 +1145,7 @@ public final class ManagedChannelImpl extends ManagedChannel {
ENABLE_ALLOCATION_TRACKING
? new RuntimeException("ManagedChannel allocation site")
: missingCallSite);
logId = chan.logId;
logId = chan.getLogId();
target = chan.target;
refs.put(this, this);
cleanQueue();

View File

@ -28,12 +28,10 @@ import io.grpc.ConnectivityStateInfo;
import io.grpc.Context;
import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalChannelStats;
import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
import io.grpc.LoadBalancer.Subchannel;
import io.grpc.LoadBalancer;
import io.grpc.LoadBalancer.PickResult;
import io.grpc.LoadBalancer.PickSubchannelArgs;
import io.grpc.LoadBalancer.Subchannel;
import io.grpc.LoadBalancer.SubchannelPicker;
import io.grpc.ManagedChannel;
import io.grpc.Metadata;
@ -53,14 +51,13 @@ import javax.annotation.concurrent.ThreadSafe;
* to its own RPC needs.
*/
@ThreadSafe
final class OobChannel extends ManagedChannel implements InternalWithLogId {
final class OobChannel extends ManagedChannel {
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;
@ -179,11 +176,6 @@ final class OobChannel extends ManagedChannel implements InternalWithLogId {
return authority;
}
@Override
public InternalLogId getLogId() {
return logId;
}
@Override
public boolean isTerminated() {
return terminatedLatch.getCount() == 0;