use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project spring-cloud-netflix by spring-cloud.
the class DomainExtractingServerListTests method testDomainExtractingServer.
@Test
public void testDomainExtractingServer() {
DomainExtractingServerList serverList = getDomainExtractingServerList(new DefaultClientConfigImpl(), true);
List<DiscoveryEnabledServer> servers = serverList.getInitialListOfServers();
assertNotNull("servers was null", servers);
assertEquals("servers was not size 1", 1, servers.size());
DomainExtractingServer des = assertDomainExtractingServer(servers, ZONE);
assertEquals("hostPort was wrong", HOST_NAME + ":" + PORT, des.getHostPort());
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project spring-cloud-netflix by spring-cloud.
the class DomainExtractingServerListTests method testDomainExtractingServerUseIpAddress.
@Test
public void testDomainExtractingServerUseIpAddress() {
DefaultClientConfigImpl config = new DefaultClientConfigImpl();
config.setProperty(CommonClientConfigKey.UseIPAddrForServer, true);
DomainExtractingServerList serverList = getDomainExtractingServerList(config, true);
List<DiscoveryEnabledServer> servers = serverList.getInitialListOfServers();
assertNotNull("servers was null", servers);
assertEquals("servers was not size 1", 1, servers.size());
DomainExtractingServer des = assertDomainExtractingServer(servers, ZONE);
assertEquals("hostPort was wrong", IP_ADDR + ":" + PORT, des.getHostPort());
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project spring-cloud-netflix by spring-cloud.
the class DomainExtractingServerListTests method assertDomainExtractingServer.
protected DomainExtractingServer assertDomainExtractingServer(List<DiscoveryEnabledServer> servers, String zone) {
Server actualServer = servers.get(0);
assertTrue("server was not a DomainExtractingServer", actualServer instanceof DomainExtractingServer);
DomainExtractingServer des = DomainExtractingServer.class.cast(actualServer);
assertEquals("zone was wrong", zone, des.getZone());
assertEquals("instanceId was wrong", HOST_NAME + ":" + INSTANCE_ID, des.getId());
return des;
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project spring-cloud-netflix by spring-cloud.
the class DomainExtractingServerListTests method testZoneInMetaData.
@Test
public void testZoneInMetaData() {
this.metadata = new HashMap<String, String>();
this.metadata.put("zone", "us-west-1");
this.metadata.put("instanceId", INSTANCE_ID);
DomainExtractingServerList serverList = getDomainExtractingServerList(new DefaultClientConfigImpl(), false);
List<DiscoveryEnabledServer> servers = serverList.getInitialListOfServers();
assertNotNull("servers was null", servers);
assertEquals("servers was not size 1", 1, servers.size());
DomainExtractingServer des = assertDomainExtractingServer(servers, "us-west-1");
assertEquals("Zone was wrong", "us-west-1", des.getZone());
}
use of com.netflix.niws.loadbalancer.DiscoveryEnabledServer in project spring-cloud-netflix by spring-cloud.
the class DomainExtractingServer method extractId.
private String extractId(Server server) {
if (server instanceof DiscoveryEnabledServer) {
DiscoveryEnabledServer enabled = (DiscoveryEnabledServer) server;
InstanceInfo instance = enabled.getInstanceInfo();
if (instance.getMetadata().containsKey("instanceId")) {
return instance.getHostName() + ":" + instance.getMetadata().get("instanceId");
}
}
return super.getId();
}
Aggregations