com.netflix.loadbalancer.ServerList Java Examples
The following examples show how to use
com.netflix.loadbalancer.ServerList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LBBuilderTest.java From ribbon with Apache License 2.0 | 6 votes |
@Test public void testBuildWithDiscoveryEnabledNIWSServerListAndUpdater() { IRule rule = new AvailabilityFilteringRule(); ServerList<DiscoveryEnabledServer> list = new DiscoveryEnabledNIWSServerList("dummy:7001"); ServerListFilter<DiscoveryEnabledServer> filter = new ZoneAffinityServerListFilter<>(); ServerListUpdater updater = new PollingServerListUpdater(); ZoneAwareLoadBalancer<DiscoveryEnabledServer> lb = LoadBalancerBuilder.<DiscoveryEnabledServer>newBuilder() .withDynamicServerList(list) .withRule(rule) .withServerListFilter(filter) .withServerListUpdater(updater) .buildDynamicServerListLoadBalancerWithUpdater(); assertNotNull(lb); assertEquals(Lists.newArrayList(expected), lb.getAllServers()); assertSame(filter, lb.getFilter()); assertSame(list, lb.getServerListImpl()); assertSame(updater, lb.getServerListUpdater()); Server server = lb.chooseServer(); // make sure load balancer does not recreate the server instance assertTrue(server instanceof DiscoveryEnabledServer); }
Example #2
Source File: LBBuilderTest.java From ribbon with Apache License 2.0 | 6 votes |
@Test public void testBuildWithDiscoveryEnabledNIWSServerList() { IRule rule = new AvailabilityFilteringRule(); ServerList<DiscoveryEnabledServer> list = new DiscoveryEnabledNIWSServerList("dummy:7001"); ServerListFilter<DiscoveryEnabledServer> filter = new ZoneAffinityServerListFilter<>(); ZoneAwareLoadBalancer<DiscoveryEnabledServer> lb = LoadBalancerBuilder.<DiscoveryEnabledServer>newBuilder() .withDynamicServerList(list) .withRule(rule) .withServerListFilter(filter) .buildDynamicServerListLoadBalancer(); assertNotNull(lb); assertEquals(Lists.newArrayList(expected), lb.getAllServers()); assertSame(filter, lb.getFilter()); assertSame(list, lb.getServerListImpl()); Server server = lb.chooseServer(); // make sure load balancer does not recreate the server instance assertTrue(server instanceof DiscoveryEnabledServer); }
Example #3
Source File: MarathonRibbonClientConfiguration.java From spring-cloud-marathon with MIT License | 5 votes |
@Bean @ConditionalOnMissingBean public ServerList<?> ribbonServerList() { MarathonServerList serverList = new MarathonServerList(client, properties); serverList.initWithNiwsConfig(clientConfig); return serverList; }
Example #4
Source File: RibbonDiscoveryFilterTest.java From ribbon-discovery-filter-spring-cloud-starter with Apache License 2.0 | 5 votes |
@Bean public ServerList<?> ribbonServerList() { Map<String, String> metadata = new HashMap<>(); metadata.put("version", "1.0"); metadata.put("variant", "A"); InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder() .setAppName("local") .setHostName("localhost") .setPort(8761) .setMetadata(metadata) .build(); return new StaticServerList<>(Arrays.asList(new DiscoveryEnabledServer(instanceInfo, false))); }
Example #5
Source File: LatticeRibbonClientConfiguration.java From spring-cloud-lattice with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public ServerList<?> ribbonServerList(IClientConfig config) { // TODO: this is a common thing between impl, maybe ServerListFactory? LatticeServerList serverList = new LatticeServerList(props, receptorService, serviceId); return serverList; }
Example #6
Source File: KubernetesRibbonClientConfiguration.java From spring-cloud-kubernetes with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public ServerList<?> ribbonServerList(KubernetesClient client, IClientConfig config) { KubernetesServerList serverList = new KubernetesServerList(client); serverList.initWithNiwsConfig(config); return serverList; }
Example #7
Source File: ServiceCombRibbonClientConfiguration.java From spring-cloud-huawei with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public ServerList<?> ribbonServerList(IClientConfig config, ServiceCombDiscoveryProperties serviceCombProperties, ServiceCombClient serviceCombClient) { ServiceCombServerList serverList = new ServiceCombServerList(serviceCombProperties, serviceCombClient); serverList.initWithNiwsConfig(config); return serverList; }
Example #8
Source File: RibbonDefaultConfigApplication.java From spring-cloud-release-tools with Apache License 2.0 | 5 votes |
/** * Throws exception if the SpringClientFactory doesn't return a balancer with a server * list of the expected type. * */ @PostConstruct public void test() throws Exception { @SuppressWarnings("unchecked") ZoneAwareLoadBalancer<Server> lb = (ZoneAwareLoadBalancer<Server>) this.clientFactory.getLoadBalancer("baz"); ServerList<Server> serverList = lb.getServerListImpl(); if (!(serverList instanceof MyDefaultRibbonConfig.BazServiceList)) { throw new Exception("wrong server list type"); } }
Example #9
Source File: AbstractSupportTest.java From spring-cloud-ribbon-extensions with Apache License 2.0 | 5 votes |
@Bean public ServerList<Server> serverList() { return new ServerList<Server>() { @Override public List<Server> getInitialListOfServers() { return servers(); } @Override public List<Server> getUpdatedListOfServers() { return servers(); } }; }
Example #10
Source File: RuleBaseConfig.java From spring-cloud-ribbon-extensions with Apache License 2.0 | 5 votes |
/** * The load balancer definition. * * @param config the client config. * @param serverList the server list. * @param serverListFilter the server list filter. * @param rule the load balancing rule. * @param ping the ping strategy. * @param serverListUpdater the server list updater. * @return The Dynamic Server List Load Balancer. */ @Bean @ConditionalOnMissingBean public ILoadBalancer loadBalancer(IClientConfig config, ServerList<Server> serverList, ServerListFilter<Server> serverListFilter, IRule rule, IPing ping, ServerListUpdater serverListUpdater) { log.debug("dynamic server list load balancer enabled."); return new DynamicServerListLoadBalancer<>(config, rule, ping, serverList, serverListFilter, serverListUpdater); }
Example #11
Source File: RadarRibbonClientConfiguration.java From radar with Apache License 2.0 | 5 votes |
@Bean public ILoadBalancer createLoadBalancer(ServerList<? extends Server> serverList, IClientConfig config, IRule rule, IPing ping) { if (this.propertiesFactory.isSet(ILoadBalancer.class, serviceId)) { return this.propertiesFactory.get(ILoadBalancer.class, config, serviceId); } ILoadBalancer iLoadBalancer = new RadarLoadBalancer(serverList, config, rule, ping); return iLoadBalancer; }
Example #12
Source File: RadarRibbonClientConfiguration.java From radar with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public ServerList<RadarServer> radarRibbonServerList(IClientConfig config) { String clusterName = env.getProperty("radar.instance.clusterName", "default"); RadarServerList serverList = new RadarServerList(config, clusterName); return serverList; }
Example #13
Source File: MyDefaultRibbonConfig.java From spring-cloud-release-tools with Apache License 2.0 | 4 votes |
@Bean public ServerList<Server> ribbonServerList(IClientConfig config) { return new MyDefaultRibbonConfig.BazServiceList(config); }
Example #14
Source File: EtcdRibbonClientConfiguration.java From spring-cloud-etcd with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean public ServerList<?> ribbonServerList(IClientConfig config) { EtcdServerList serverList = new EtcdServerList(etcd, props, serviceId); return serverList; }
Example #15
Source File: LocalRibbonClientConfiguration.java From spring-cloud-square with Apache License 2.0 | 4 votes |
@Bean public ServerList<Server> ribbonServerList() { return new StaticServerList<>(new Server("localhost", this.port)); }
Example #16
Source File: OkHttpRibbonInterceptorTests.java From spring-cloud-square with Apache License 2.0 | 4 votes |
@Bean public ServerList<Server> ribbonServerList() { return new StaticServerList<>(new Server("localhost", this.port)); }
Example #17
Source File: RadarLoadBalancer.java From radar with Apache License 2.0 | 4 votes |
public RadarLoadBalancer(ServerList<? extends Server> serverList, IClientConfig config, IRule rule, IPing ping) { super(config, rule, ping); this.serverList = serverList; }
Example #18
Source File: CustomIloadBalancer.java From spring-cloud-formula with Apache License 2.0 | 4 votes |
public CustomIloadBalancer(IClientConfig config, IRule rule, IPing ping, ServerList serverList, ServerListFilter serverListFilter, ServerListUpdater serverListUpdater) { super(config, rule, ping, serverList, serverListFilter, serverListUpdater); }