@Override public String authority() { return delegate.authority(); }
@Override public String authority() { return delegate.authority(); } }
@Override public String authority() { return delegate.authority(); }
/** * Initializes the channel pool. Assumes that all channels have the same authority. * * @param channels a List of channels to pool. */ ChannelPool(List<ManagedChannel> channels) { this.channels = ImmutableList.copyOf(channels); authority = channels.get(0).authority(); }
/** * Initializes the channel pool. Assumes that all channels have the same authority. * * @param channels a List of channels to pool. */ ChannelPool(List<ManagedChannel> channels) { this.channels = ImmutableList.copyOf(channels); authority = channels.get(0).authority(); }
/** * <p>Constructor for ChannelPool.</p> * * @param factory a {@link com.google.cloud.bigtable.grpc.io.ChannelPool.ChannelFactory} object. * @throws java.io.IOException if any. */ public ChannelPool(ChannelFactory factory, int count) throws IOException { Preconditions.checkArgument(count > 0, "Channel count has to be a positive number."); ImmutableList.Builder<ManagedChannel> channeListBuilder = ImmutableList.builder(); for (int i = 0; i < count; i++) { channeListBuilder.add(new InstrumentedChannel(factory.create())); } this.channels = channeListBuilder.build(); authority = channels.get(0).authority(); }
@Test public void testAuthority() { ManagedChannel sub1 = Mockito.mock(ManagedChannel.class); ManagedChannel sub2 = Mockito.mock(ManagedChannel.class); Mockito.when(sub1.authority()).thenReturn("myAuth"); ChannelPool pool = new ChannelPool(Lists.newArrayList(sub1, sub2)); Truth.assertThat(pool.authority()).isEqualTo("myAuth"); }
@Test public void testRoundRobin() { ManagedChannel sub1 = Mockito.mock(ManagedChannel.class); ManagedChannel sub2 = Mockito.mock(ManagedChannel.class); Mockito.when(sub1.authority()).thenReturn("myAuth"); ArrayList<ManagedChannel> channels = Lists.newArrayList(sub1, sub2); ChannelPool pool = new ChannelPool(channels); verifyTargetChannel(pool, channels, sub1); verifyTargetChannel(pool, channels, sub2); verifyTargetChannel(pool, channels, sub1); }
private void startLbComm(LbAddressGroup lbAddressGroup) { checkNotNull(lbAddressGroup, "lbAddressGroup"); if (lbCommChannel == null) { lbCommChannel = helper.createOobChannel( lbAddressGroup.getAddresses(), lbAddressGroup.getAuthority()); } else if (lbAddressGroup.getAuthority().equals(lbCommChannel.authority())) { helper.updateOobChannelAddresses(lbCommChannel, lbAddressGroup.getAddresses()); } else { // Full restart of channel shutdownLbComm(); lbCommChannel = helper.createOobChannel( lbAddressGroup.getAddresses(), lbAddressGroup.getAuthority()); } }