use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project zuul by Netflix.
the class DiscoveryResultTest method sameUnderlyingInstanceInfoEqualsSameResult.
@Test
public void sameUnderlyingInstanceInfoEqualsSameResult() {
final InstanceInfo instanceInfo = Builder.newBuilder().setAppName("server-equality").setHostName("server-equality").setPort(7777).build();
final DiscoveryEnabledServer server = new DiscoveryEnabledServer(instanceInfo, false);
final DiscoveryEnabledServer otherServer = new DiscoveryEnabledServer(instanceInfo, false);
final DynamicServerListLoadBalancer<Server> lb = new DynamicServerListLoadBalancer<>(new DefaultClientConfigImpl());
final DiscoveryResult result = new DiscoveryResult(server, lb.getLoadBalancerStats());
final DiscoveryResult otherResult = new DiscoveryResult(otherServer, lb.getLoadBalancerStats());
Truth.assertThat(result).isEqualTo(otherResult);
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project zuul by Netflix.
the class DiscoveryResultTest method serverStatsDifferForDifferentServer.
@Test
public void serverStatsDifferForDifferentServer() {
final InstanceInfo instanceInfo = Builder.newBuilder().setAppName("serverstats-cache").setHostName("serverstats-cache").setPort(7777).build();
final InstanceInfo otherInstance = Builder.newBuilder().setAppName("serverstats-cache-2").setHostName("serverstats-cache-2").setPort(7777).build();
final DiscoveryEnabledServer server = new DiscoveryEnabledServer(instanceInfo, false);
final DiscoveryEnabledServer serverSecure = new DiscoveryEnabledServer(otherInstance, false);
final DynamicServerListLoadBalancer<Server> lb = new DynamicServerListLoadBalancer<>(new DefaultClientConfigImpl());
final DiscoveryResult result = new DiscoveryResult(server, lb.getLoadBalancerStats());
final DiscoveryResult result1 = new DiscoveryResult(serverSecure, lb.getLoadBalancerStats());
Truth.assertThat(result.getServerStats()).isNotSameInstanceAs(result1.getServerStats());
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project ribbon by Netflix.
the class EurekaDynamicServerListLoadBalancerTest method testShutdownMultiple.
@Test
public void testShutdownMultiple() {
try {
eurekaClientMock.registerEventListener(EasyMock.anyObject(EurekaEventListener.class));
EasyMock.expectLastCall().anyTimes();
PowerMock.replay(DiscoveryClient.class);
PowerMock.replay(eurekaClientMock);
DynamicServerListLoadBalancer<DiscoveryEnabledServer> lb1 = new DynamicServerListLoadBalancer<DiscoveryEnabledServer>(config, new AvailabilityFilteringRule(), new DummyPing(), new DiscoveryEnabledNIWSServerList(vipAddress, eurekaClientProvider), new ZoneAffinityServerListFilter<DiscoveryEnabledServer>(), new EurekaNotificationServerListUpdater(eurekaClientProvider));
DynamicServerListLoadBalancer<DiscoveryEnabledServer> lb2 = new DynamicServerListLoadBalancer<DiscoveryEnabledServer>(config, new AvailabilityFilteringRule(), new DummyPing(), new DiscoveryEnabledNIWSServerList(vipAddress, eurekaClientProvider), new ZoneAffinityServerListFilter<DiscoveryEnabledServer>(), new EurekaNotificationServerListUpdater(eurekaClientProvider));
DynamicServerListLoadBalancer<DiscoveryEnabledServer> lb3 = new DynamicServerListLoadBalancer<DiscoveryEnabledServer>(config, new AvailabilityFilteringRule(), new DummyPing(), new DiscoveryEnabledNIWSServerList(vipAddress, eurekaClientProvider), new ZoneAffinityServerListFilter<DiscoveryEnabledServer>(), new EurekaNotificationServerListUpdater(eurekaClientProvider));
lb3.shutdown();
lb1.shutdown();
lb2.shutdown();
} finally {
PowerMock.verify(eurekaClientMock);
PowerMock.verify(DiscoveryClient.class);
}
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project nutzboot by nutzam.
the class FeignStarter method getLoadBalancer.
public Object getLoadBalancer(String name, FeignInject fc) {
EurekaClient eurekaClient = ioc.get(EurekaClient.class, "eurekaClient");
DefaultClientConfigImpl clientConfig = DefaultClientConfigImpl.getClientConfigWithDefaultValues(name);
ServerList<DiscoveryEnabledServer> list = new DiscoveryEnabledNIWSServerList(name, () -> eurekaClient);
ServerListFilter<DiscoveryEnabledServer> filter = new ZoneAffinityServerListFilter<DiscoveryEnabledServer>(clientConfig);
ServerListUpdater updater = new EurekaNotificationServerListUpdater(() -> eurekaClient);
IRule rule = null;
switch(getLbRuleString(fc.lbRule())) {
case "random":
rule = new RandomRule();
break;
case "availability":
default:
AvailabilityFilteringRule _rule = new AvailabilityFilteringRule();
_rule.initWithNiwsConfig(clientConfig);
rule = _rule;
break;
}
ZoneAwareLoadBalancer<DiscoveryEnabledServer> lb = LoadBalancerBuilder.<DiscoveryEnabledServer>newBuilder().withDynamicServerList(list).withRule(rule).withServerListFilter(filter).withServerListUpdater(updater).withClientConfig(clientConfig).buildDynamicServerListLoadBalancerWithUpdater();
return LBClient.create(lb, clientConfig);
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project spring-cloud-netflix by spring-cloud.
the class DomainExtractingServerListTests method getDomainExtractingServerList.
protected DomainExtractingServerList getDomainExtractingServerList(DefaultClientConfigImpl config, boolean approximateZoneFromHostname) {
DiscoveryEnabledServer server = mock(DiscoveryEnabledServer.class);
@SuppressWarnings("unchecked") ServerList<DiscoveryEnabledServer> originalServerList = mock(ServerList.class);
InstanceInfo instanceInfo = mock(InstanceInfo.class);
given(server.getInstanceInfo()).willReturn(instanceInfo);
given(server.getHost()).willReturn(HOST_NAME);
given(instanceInfo.getMetadata()).willReturn(this.metadata);
given(instanceInfo.getHostName()).willReturn(HOST_NAME);
given(instanceInfo.getIPAddr()).willReturn(IP_ADDR);
given(instanceInfo.getPort()).willReturn(PORT);
given(originalServerList.getInitialListOfServers()).willReturn(Arrays.asList(server));
return new DomainExtractingServerList(originalServerList, config, approximateZoneFromHostname);
}
Aggregations