ChannelPool extends ManagedChannel { @Override public <ReqT, RespT> ClientCall<ReqT, RespT> newCall( MethodDescriptor<ReqT, RespT> methodDescriptor, CallOptions callOptions) { Preconditions.checkState(!shutdown, "Cannot perform operations on a closed connection"); return getNextChannel().newCall(methodDescriptor, callOptions); } ChannelPool(ChannelFactory factory, int count); @InternalApi("For internal usage only") static final String extractIdentifier(Metadata trailers); @Override String authority(); @Override ClientCall<ReqT, RespT> newCall(
      MethodDescriptor<ReqT, RespT> methodDescriptor, CallOptions callOptions); int size(); @Override synchronized ManagedChannel shutdown(); @Override boolean isShutdown(); @Override boolean isTerminated(); @Override ManagedChannel shutdownNow(); @Override boolean awaitTermination(long timeout, TimeUnit unit);  }
@Test public void testInterceptorIsCalled() throws Exception { MethodDescriptor descriptor = BigtableGrpc.getMutateRowMethod(); ChannelPool pool = new ChannelPool(new MockChannelFactory(), 1); ClientCall call = pool.newCall(descriptor, CallOptions.DEFAULT); Metadata headers = new Metadata(); call.start(null, headers); }
@Test public void testChannelsAreRoundRobinned() throws IOException { MockChannelFactory factory = new MockChannelFactory(); MethodDescriptor descriptor = BigtableGrpc.getMutateRowMethod(); ChannelPool pool = new ChannelPool(factory, 2); pool.newCall(descriptor, CallOptions.DEFAULT); verify(factory.channels.get(0), times(1)).newCall(same(descriptor), same(CallOptions.DEFAULT)); verify(factory.channels.get(1), times(0)).newCall(same(descriptor), same(CallOptions.DEFAULT)); pool.newCall(descriptor, CallOptions.DEFAULT); verify(factory.channels.get(0), times(1)).newCall(same(descriptor), same(CallOptions.DEFAULT)); verify(factory.channels.get(1), times(1)).newCall(same(descriptor), same(CallOptions.DEFAULT)); }