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 ) ) { // Forced to drop the connection 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" ) ) ; } }
Replaces the existing addresses avoiding unnecessary reconnects .