@Test public void handleResolvedAddressGroups_shutsDownOldBalancer() { Map<String, Object> serviceConfig = new HashMap<String, Object>(); serviceConfig.put("loadBalancingPolicy", "round_robin"); Attributes serviceConfigAttrs = Attributes.newBuilder() .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig) .build(); final List<EquivalentAddressGroup> servers = Collections.singletonList( new EquivalentAddressGroup( new SocketAddress(){}, Attributes.EMPTY)); Helper helper = new TestHelper() { @Override public Subchannel createSubchannel(List<EquivalentAddressGroup> addrs, Attributes attrs) { assertThat(addrs).isEqualTo(servers); return new TestSubchannel(addrs, attrs); } @Override public void updateBalancingState(ConnectivityState newState, SubchannelPicker newPicker) { } }; AutoConfiguredLoadBalancer lb = (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(helper); final AtomicBoolean shutdown = new AtomicBoolean(); TestLoadBalancer testlb = new TestLoadBalancer() { @Override public void handleNameResolutionError(Status error) { } @Override public void handleSubchannelState(Subchannel subchannel, ConnectivityStateInfo stateInfo) { } @Override public void shutdown() { shutdown.set(true); } }; lb.setDelegate(testlb); lb.handleResolvedAddressGroups(servers, serviceConfigAttrs); assertThat(lb.getDelegateProvider().getClass().getName()).isEqualTo( "io.grpc.util.SecretRoundRobinLoadBalancerProvider$Provider"); assertTrue(shutdown.get()); }
@Override public LoadBalancer newLoadBalancer(Helper helper) { return new AutoConfiguredLoadBalancer(helper); }
AutoConfiguredLoadBalancerFactory extends LoadBalancer.Factory { @Override public LoadBalancer newLoadBalancer(Helper helper) { return new AutoConfiguredLoadBalancer(helper); } }
AutoConfiguredLoadBalancerFactory extends LoadBalancer.Factory { @Override public LoadBalancer newLoadBalancer(Helper helper) { return new AutoConfiguredLoadBalancer(helper); }  }
AutoConfiguredLoadBalancerFactory extends LoadBalancer.Factory { @Override public LoadBalancer newLoadBalancer(Helper helper) { return new AutoConfiguredLoadBalancer(helper); }  @Override LoadBalancer newLoadBalancer(Helper helper); }
AutoConfiguredLoadBalancerFactory extends LoadBalancer.Factory { @Override public LoadBalancer newLoadBalancer(Helper helper) { return new AutoConfiguredLoadBalancer(helper); }  @Override LoadBalancer newLoadBalancer(Helper helper);  }