@Test public void channelTracing_lbPolicyChanged() { final FakeClock clock = new FakeClock(); List<EquivalentAddressGroup> servers = Collections.singletonList( new EquivalentAddressGroup(new SocketAddress(){}, Attributes.EMPTY)); Helper helper = new TestHelper() { @Override public Subchannel createSubchannel(List<EquivalentAddressGroup> addrs, Attributes attrs) { return new TestSubchannel(addrs, attrs); } @Override public ManagedChannel createOobChannel(EquivalentAddressGroup eag, String authority) { return mock(ManagedChannel.class, RETURNS_DEEP_STUBS); } @Override public String getAuthority() { return "fake_authority"; } @Override public void updateBalancingState(ConnectivityState newState, SubchannelPicker newPicker) { } @Override public SynchronizationContext getSynchronizationContext() { return new SynchronizationContext( new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { throw new AssertionError(e); } }); } @Override public ScheduledExecutorService getScheduledExecutorService() { return clock.getScheduledExecutorService(); } }; LoadBalancer lb = new AutoConfiguredLoadBalancerFactory().newLoadBalancer(helper); lb.handleResolvedAddressGroups(servers, Attributes.EMPTY); verifyNoMoreInteractions(channelLogger); Map<String, Object> serviceConfig = new HashMap<String, Object>(); serviceConfig.put("loadBalancingPolicy", "round_robin"); lb.handleResolvedAddressGroups(servers, Attributes.newBuilder() .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build()); verify(channelLogger).log( eq(ChannelLogLevel.INFO), eq("Load balancer changed from {0} to {1}"), eq("PickFirstLoadBalancer"), eq("RoundRobinLoadBalancer")); verifyNoMoreInteractions(channelLogger); serviceConfig.put("loadBalancingPolicy", "round_robin"); lb.handleResolvedAddressGroups(servers, Attributes.newBuilder() .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build()); verifyNoMoreInteractions(channelLogger); servers = Collections.singletonList(new EquivalentAddressGroup( new SocketAddress(){}, Attributes.newBuilder().set(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY, "ok").build())); lb.handleResolvedAddressGroups(servers, Attributes.EMPTY); verify(channelLogger).log( eq(ChannelLogLevel.INFO), eq("Load balancer changed from {0} to {1}"), eq("RoundRobinLoadBalancer"), eq("GrpclbLoadBalancer")); verifyNoMoreInteractions(channelLogger); }
@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);  }