@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)); }
@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 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 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); }
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); }
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);  }