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; 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,6 +27,8 @@ import javax.annotation.concurrent.ThreadSafe;
@ThreadSafe @ThreadSafe
public abstract class ManagedChannel public abstract class ManagedChannel
extends Channel implements InternalInstrumented<InternalChannelStats> { 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.
@ -84,6 +88,14 @@ 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
@ -115,4 +127,10 @@ public abstract class ManagedChannel
*/ */
@ExperimentalApi @ExperimentalApi
public void resetConnectBackoff() {} 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 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 InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final ChannelExecutor channelExecutor = new ChannelExecutor(); 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 { private class NameResolverListenerImpl implements NameResolver.Listener {
final LoadBalancer balancer; final LoadBalancer balancer;
final LoadBalancer.Helper helper; final LoadBalancer.Helper helper;
@ -1151,7 +1145,7 @@ public final class ManagedChannelImpl extends ManagedChannel {
ENABLE_ALLOCATION_TRACKING ENABLE_ALLOCATION_TRACKING
? new RuntimeException("ManagedChannel allocation site") ? new RuntimeException("ManagedChannel allocation site")
: missingCallSite); : missingCallSite);
logId = chan.logId; logId = chan.getLogId();
target = chan.target; target = chan.target;
refs.put(this, this); refs.put(this, this);
cleanQueue(); cleanQueue();

View File

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