@Test public void stateChangeBeforeResolution() throws Exception { loadBalancer.handleSubchannelState(mockSubchannel, ConnectivityStateInfo.forNonError(READY)); verifyNoMoreInteractions(mockHelper); }
@Override public void handleSubchannelState(Subchannel subchannel, ConnectivityStateInfo stateInfo) { ConnectivityState currentState = stateInfo.getState(); if (currentState == SHUTDOWN) { return; } EquivalentAddressGroup addressGroup = subchannel.getAddresses(); Subchannel theSubchannel = subchannels.get(addressGroup); if (theSubchannel == null) { return; } if (theSubchannel != currentSubchannel) { return; } SubchannelPicker picker; switch (currentState) { case IDLE: picker = new RequestConnectionPicker(subchannel); break; case CONNECTING: picker = new Picker(PickResult.withNoResult()); break; case READY: picker = new Picker(PickResult.withSubchannel(subchannel)); break; case TRANSIENT_FAILURE: picker = new Picker(PickResult.withError(stateInfo.getStatus())); break; default: throw new IllegalArgumentException("Unsupported state:" + currentState); } helper.updateBalancingState(currentState, picker); }
PickFirstLoadBalancer extends LoadBalancer { @Override public void handleSubchannelState(Subchannel subchannel, ConnectivityStateInfo stateInfo) { ConnectivityState currentState = stateInfo.getState(); if (currentState == SHUTDOWN) { return; } EquivalentAddressGroup addressGroup = subchannel.getAddresses(); Subchannel theSubchannel = subchannels.get(addressGroup); if (theSubchannel == null) { return; } if (theSubchannel != currentSubchannel) { return; } SubchannelPicker picker; switch (currentState) { case IDLE: picker = new RequestConnectionPicker(subchannel); break; case CONNECTING: picker = new Picker(PickResult.withNoResult()); break; case READY: picker = new Picker(PickResult.withSubchannel(subchannel)); break; case TRANSIENT_FAILURE: picker = new Picker(PickResult.withError(stateInfo.getStatus())); break; default: throw new IllegalArgumentException("Unsupported state:" + currentState); } helper.updateBalancingState(currentState, picker); } }
PickFirstLoadBalancer extends LoadBalancer { @Override public void handleSubchannelState(Subchannel subchannel, ConnectivityStateInfo stateInfo) { ConnectivityState currentState = stateInfo.getState(); if (currentState == SHUTDOWN) { return; } EquivalentAddressGroup addressGroup = subchannel.getAddresses(); Subchannel theSubchannel = subchannels.get(addressGroup); if (theSubchannel == null) { return; } if (theSubchannel != currentSubchannel) { return; } SubchannelPicker picker; switch (currentState) { case IDLE: picker = new RequestConnectionPicker(subchannel); break; case CONNECTING: picker = new Picker(PickResult.withNoResult()); break; case READY: picker = new Picker(PickResult.withSubchannel(subchannel)); break; case TRANSIENT_FAILURE: picker = new Picker(PickResult.withError(stateInfo.getStatus())); break; default: throw new IllegalArgumentException("Unsupported state:" + currentState); } helper.updateBalancingState(currentState, picker); } PickFirstLoadBalancer(Helper helper); }
PickFirstLoadBalancer extends LoadBalancer { @Override public void handleSubchannelState(Subchannel subchannel, ConnectivityStateInfo stateInfo) { ConnectivityState currentState = stateInfo.getState(); if (currentState == SHUTDOWN) { return; } EquivalentAddressGroup addressGroup = subchannel.getAddresses(); Subchannel theSubchannel = subchannels.get(addressGroup); if (theSubchannel == null) { return; } if (theSubchannel != currentSubchannel) { return; } SubchannelPicker picker; switch (currentState) { case IDLE: picker = new RequestConnectionPicker(subchannel); break; case CONNECTING: picker = new Picker(PickResult.withNoResult()); break; case READY: picker = new Picker(PickResult.withSubchannel(subchannel)); break; case TRANSIENT_FAILURE: picker = new Picker(PickResult.withError(stateInfo.getStatus())); break; default: throw new IllegalArgumentException("Unsupported state:" + currentState); } helper.updateBalancingState(currentState, picker); } PickFirstLoadBalancer(Helper helper); @Override void handleResolvedAddressGroups(
      List<EquivalentAddressGroup> servers, Attributes attributes); @Override void handleNameResolutionError(Status error); @Override void handleSubchannelState(Subchannel subchannel, ConnectivityStateInfo stateInfo); @Override void shutdown(); @Override EquivalentAddressGroup getAddresses(); @Override void setAddress(EquivalentAddressGroup addressGroup); @Override void removeInvalidCacheSubchannels(Set<String> removeHostPorts); }
PickFirstLoadBalancer extends LoadBalancer { @Override public void handleSubchannelState(Subchannel subchannel, ConnectivityStateInfo stateInfo) { ConnectivityState currentState = stateInfo.getState(); if (currentState == SHUTDOWN) { return; } EquivalentAddressGroup addressGroup = subchannel.getAddresses(); Subchannel theSubchannel = subchannels.get(addressGroup); if (theSubchannel == null) { return; } if (theSubchannel != currentSubchannel) { return; } SubchannelPicker picker; switch (currentState) { case IDLE: picker = new RequestConnectionPicker(subchannel); break; case CONNECTING: picker = new Picker(PickResult.withNoResult()); break; case READY: picker = new Picker(PickResult.withSubchannel(subchannel)); break; case TRANSIENT_FAILURE: picker = new Picker(PickResult.withError(stateInfo.getStatus())); break; default: throw new IllegalArgumentException("Unsupported state:" + currentState); } helper.updateBalancingState(currentState, picker); } PickFirstLoadBalancer(Helper helper); @Override void handleResolvedAddressGroups(
      List<EquivalentAddressGroup> servers, Attributes attributes); @Override void handleNameResolutionError(Status error); @Override void handleSubchannelState(Subchannel subchannel, ConnectivityStateInfo stateInfo); @Override void shutdown(); @Override EquivalentAddressGroup getAddresses(); @Override void setAddress(EquivalentAddressGroup addressGroup); @Override void removeInvalidCacheSubchannels(Set<String> removeHostPorts);  }