@Test void givenServerList_whenChooseServer_thenSetChosenInstanceInfoToRequestContext() { InstanceInfo info = InstanceInfo.Builder.newBuilder() .setAppName("appname") .setInstanceId("instance") .build(); underTest.addServer(new DiscoveryEnabledServer(info, true)); underTest.chooseServer("instance"); RequestContext context = RequestContext.getCurrentContext(); assertThat(context.get(ApimlLoadBalancer.LOADBALANCED_INSTANCE_INFO_KEY), is(info)); }
@Override public Server chooseServer(Object key) { Server server = super.chooseServer(key); if (server == null) { return null; } if (server instanceof DiscoveryEnabledServer) { RequestContextUtils.setInstanceInfo(((DiscoveryEnabledServer) server).getInstanceInfo()); RequestContextUtils.addDebugInfo("Load Balancer chooses: " + ((DiscoveryEnabledServer) server).getInstanceInfo()); } else { throw new IllegalStateException("Unexpected error, please contact Broadcom support"); } return server; }
ApimlLoadBalancer extends ZoneAwareLoadBalancer<T> { @Override public Server chooseServer(Object key) { Server server = super.chooseServer(key); if (server == null) { return null; } if (server instanceof DiscoveryEnabledServer) { RequestContextUtils.setInstanceInfo(((DiscoveryEnabledServer) server).getInstanceInfo()); RequestContextUtils.addDebugInfo("Load Balancer chooses: " + ((DiscoveryEnabledServer) server).getInstanceInfo()); } else { throw new IllegalStateException("Unexpected error, please contact Broadcom support"); } return server; } }
ApimlLoadBalancer extends ZoneAwareLoadBalancer<T> { @Override public Server chooseServer(Object key) { Server server = super.chooseServer(key); if (server == null) { return null; } if (server instanceof DiscoveryEnabledServer) { RequestContextUtils.setInstanceInfo(((DiscoveryEnabledServer) server).getInstanceInfo()); RequestContextUtils.addDebugInfo("Load Balancer chooses: " + ((DiscoveryEnabledServer) server).getInstanceInfo()); } else { throw new IllegalStateException("Unexpected error, please contact Broadcom support"); } return server; } ApimlLoadBalancer(
        IClientConfig clientConfig,
        IRule rule,
        IPing ping,
        ServerList<T> serverList,
        ServerListFilter<T> filter,
        ServerListUpdater serverListUpdater,
        LoadBalancerRegistry loadBalancerRegistry
    ); }
ApimlLoadBalancer extends ZoneAwareLoadBalancer<T> { @Override public Server chooseServer(Object key) { Server server = super.chooseServer(key); if (server == null) { return null; } if (server instanceof DiscoveryEnabledServer) { RequestContextUtils.setInstanceInfo(((DiscoveryEnabledServer) server).getInstanceInfo()); RequestContextUtils.addDebugInfo("Load Balancer chooses: " + ((DiscoveryEnabledServer) server).getInstanceInfo()); } else { throw new IllegalStateException("Unexpected error, please contact Broadcom support"); } return server; } ApimlLoadBalancer(
        IClientConfig clientConfig,
        IRule rule,
        IPing ping,
        ServerList<T> serverList,
        ServerListFilter<T> filter,
        ServerListUpdater serverListUpdater,
        LoadBalancerRegistry loadBalancerRegistry
    ); @Override Server chooseServer(Object key); }
ApimlLoadBalancer extends ZoneAwareLoadBalancer<T> { @Override public Server chooseServer(Object key) { Server server = super.chooseServer(key); if (server == null) { return null; } if (server instanceof DiscoveryEnabledServer) { RequestContextUtils.setInstanceInfo(((DiscoveryEnabledServer) server).getInstanceInfo()); RequestContextUtils.addDebugInfo("Load Balancer chooses: " + ((DiscoveryEnabledServer) server).getInstanceInfo()); } else { throw new IllegalStateException("Unexpected error, please contact Broadcom support"); } return server; } ApimlLoadBalancer(
        IClientConfig clientConfig,
        IRule rule,
        IPing ping,
        ServerList<T> serverList,
        ServerListFilter<T> filter,
        ServerListUpdater serverListUpdater,
        LoadBalancerRegistry loadBalancerRegistry
    ); @Override Server chooseServer(Object key); static final String LOADBALANCED_INSTANCE_INFO_KEY; }