@Test public void updateAddresses_emptyEagList_throws() { SocketAddress addr = new FakeSocketAddress(); createInternalSubchannel(addr); thrown.expect(IllegalArgumentException.class); internalSubchannel.updateAddresses(Arrays.<EquivalentAddressGroup>asList()); }
public void updateAddresses(List<EquivalentAddressGroup> newAddressGroups) { Preconditions.checkNotNull(newAddressGroups, "newAddressGroups"); checkListHasNoNulls(newAddressGroups, "newAddressGroups contains null entry"); Preconditions.checkArgument(!newAddressGroups.isEmpty(), "newAddressGroups is empty"); newAddressGroups = Collections.unmodifiableList(new ArrayList<>(newAddressGroups)); ManagedClientTransport savedTransport = null; try { synchronized (lock) { SocketAddress previousAddress = addressIndex.getCurrentAddress(); addressIndex.updateGroups(newAddressGroups); if (state.getState() == READY || state.getState() == CONNECTING) { if (!addressIndex.seekTo(previousAddress)) { if (state.getState() == READY) { savedTransport = activeTransport; activeTransport = null; addressIndex.reset(); gotoNonErrorState(IDLE); } else { savedTransport = pendingTransport; pendingTransport = null; addressIndex.reset(); startNewTransport(); } } } } } finally { syncContext.drain(); } if (savedTransport != null) { savedTransport.shutdown( Status.UNAVAILABLE.withDescription( "InternalSubchannel closed transport due to address change")); } }
InternalSubchannel implements InternalInstrumented<ChannelStats> { public void updateAddresses(List<EquivalentAddressGroup> newAddressGroups) { Preconditions.checkNotNull(newAddressGroups, "newAddressGroups"); checkListHasNoNulls(newAddressGroups, "newAddressGroups contains null entry"); Preconditions.checkArgument(!newAddressGroups.isEmpty(), "newAddressGroups is empty"); newAddressGroups = Collections.unmodifiableList(new ArrayList<>(newAddressGroups)); ManagedClientTransport savedTransport = null; try { synchronized (lock) { SocketAddress previousAddress = addressIndex.getCurrentAddress(); addressIndex.updateGroups(newAddressGroups); if (state.getState() == READY || state.getState() == CONNECTING) { if (!addressIndex.seekTo(previousAddress)) { if (state.getState() == READY) { savedTransport = activeTransport; activeTransport = null; addressIndex.reset(); gotoNonErrorState(IDLE); } else { savedTransport = pendingTransport; pendingTransport = null; addressIndex.reset(); startNewTransport(); } } } } } finally { syncContext.drain(); } if (savedTransport != null) { savedTransport.shutdown( Status.UNAVAILABLE.withDescription( "InternalSubchannel closed transport due to address change")); } } }
InternalSubchannel implements InternalInstrumented<ChannelStats> { public void updateAddresses(List<EquivalentAddressGroup> newAddressGroups) { Preconditions.checkNotNull(newAddressGroups, "newAddressGroups"); checkListHasNoNulls(newAddressGroups, "newAddressGroups contains null entry"); Preconditions.checkArgument(!newAddressGroups.isEmpty(), "newAddressGroups is empty"); newAddressGroups = Collections.unmodifiableList(new ArrayList<>(newAddressGroups)); ManagedClientTransport savedTransport = null; try { synchronized (lock) { SocketAddress previousAddress = addressIndex.getCurrentAddress(); addressIndex.updateGroups(newAddressGroups); if (state.getState() == READY || state.getState() == CONNECTING) { if (!addressIndex.seekTo(previousAddress)) { if (state.getState() == READY) { savedTransport = activeTransport; activeTransport = null; addressIndex.reset(); gotoNonErrorState(IDLE); } else { savedTransport = pendingTransport; pendingTransport = null; addressIndex.reset(); startNewTransport(); } } } } } finally { syncContext.drain(); } if (savedTransport != null) { savedTransport.shutdown( Status.UNAVAILABLE.withDescription( "InternalSubchannel closed transport due to address change")); } } InternalSubchannel(List<EquivalentAddressGroup> addressGroups, String authority, String userAgent,
      BackoffPolicy.Provider backoffPolicyProvider,
      ClientTransportFactory transportFactory, ScheduledExecutorService scheduledExecutor,
      Supplier<Stopwatch> stopwatchSupplier, SynchronizationContext syncContext, Callback callback,
      InternalChannelz channelz, CallTracer callsTracer, ChannelTracer channelTracer,
      InternalLogId logId, TimeProvider timeProvider); }
InternalSubchannel implements InternalInstrumented<ChannelStats> { public void updateAddresses(List<EquivalentAddressGroup> newAddressGroups) { Preconditions.checkNotNull(newAddressGroups, "newAddressGroups"); checkListHasNoNulls(newAddressGroups, "newAddressGroups contains null entry"); Preconditions.checkArgument(!newAddressGroups.isEmpty(), "newAddressGroups is empty"); newAddressGroups = Collections.unmodifiableList(new ArrayList<>(newAddressGroups)); ManagedClientTransport savedTransport = null; try { synchronized (lock) { SocketAddress previousAddress = addressIndex.getCurrentAddress(); addressIndex.updateGroups(newAddressGroups); if (state.getState() == READY || state.getState() == CONNECTING) { if (!addressIndex.seekTo(previousAddress)) { if (state.getState() == READY) { savedTransport = activeTransport; activeTransport = null; addressIndex.reset(); gotoNonErrorState(IDLE); } else { savedTransport = pendingTransport; pendingTransport = null; addressIndex.reset(); startNewTransport(); } } } } } finally { syncContext.drain(); } if (savedTransport != null) { savedTransport.shutdown( Status.UNAVAILABLE.withDescription( "InternalSubchannel closed transport due to address change")); } } InternalSubchannel(List<EquivalentAddressGroup> addressGroups, String authority, String userAgent,
      BackoffPolicy.Provider backoffPolicyProvider,
      ClientTransportFactory transportFactory, ScheduledExecutorService scheduledExecutor,
      Supplier<Stopwatch> stopwatchSupplier, SynchronizationContext syncContext, Callback callback,
      InternalChannelz channelz, CallTracer callsTracer, ChannelTracer channelTracer,
      InternalLogId logId, TimeProvider timeProvider); void updateAddresses(List<EquivalentAddressGroup> newAddressGroups); void shutdown(Status reason); @Override String toString(); @Override InternalLogId getLogId(); @Override ListenableFuture<ChannelStats> getStats(); }
InternalSubchannel implements InternalInstrumented<ChannelStats> { public void updateAddresses(List<EquivalentAddressGroup> newAddressGroups) { Preconditions.checkNotNull(newAddressGroups, "newAddressGroups"); checkListHasNoNulls(newAddressGroups, "newAddressGroups contains null entry"); Preconditions.checkArgument(!newAddressGroups.isEmpty(), "newAddressGroups is empty"); newAddressGroups = Collections.unmodifiableList(new ArrayList<>(newAddressGroups)); ManagedClientTransport savedTransport = null; try { synchronized (lock) { SocketAddress previousAddress = addressIndex.getCurrentAddress(); addressIndex.updateGroups(newAddressGroups); if (state.getState() == READY || state.getState() == CONNECTING) { if (!addressIndex.seekTo(previousAddress)) { if (state.getState() == READY) { savedTransport = activeTransport; activeTransport = null; addressIndex.reset(); gotoNonErrorState(IDLE); } else { savedTransport = pendingTransport; pendingTransport = null; addressIndex.reset(); startNewTransport(); } } } } } finally { syncContext.drain(); } if (savedTransport != null) { savedTransport.shutdown( Status.UNAVAILABLE.withDescription( "InternalSubchannel closed transport due to address change")); } } InternalSubchannel(List<EquivalentAddressGroup> addressGroups, String authority, String userAgent,
      BackoffPolicy.Provider backoffPolicyProvider,
      ClientTransportFactory transportFactory, ScheduledExecutorService scheduledExecutor,
      Supplier<Stopwatch> stopwatchSupplier, SynchronizationContext syncContext, Callback callback,
      InternalChannelz channelz, CallTracer callsTracer, ChannelTracer channelTracer,
      InternalLogId logId, TimeProvider timeProvider); void updateAddresses(List<EquivalentAddressGroup> newAddressGroups); void shutdown(Status reason); @Override String toString(); @Override InternalLogId getLogId(); @Override ListenableFuture<ChannelStats> getStats();  }