use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class EurekaHttpResolver method getClusterEndpoints.
@Override
public List<AwsEndpoint> getClusterEndpoints() {
List<AwsEndpoint> result = new ArrayList<>();
EurekaHttpClient client = null;
try {
client = clientFactory.newClient();
EurekaHttpResponse<Applications> response = client.getVip(vipAddress);
if (validResponse(response)) {
Applications applications = response.getEntity();
if (applications != null) {
// filter out non-UP instances
applications.shuffleInstances(true);
List<InstanceInfo> validInstanceInfos = applications.getInstancesByVirtualHostName(vipAddress);
for (InstanceInfo instanceInfo : validInstanceInfos) {
AwsEndpoint endpoint = ResolverUtils.instanceInfoToEndpoint(clientConfig, transportConfig, instanceInfo);
if (endpoint != null) {
result.add(endpoint);
}
}
logger.debug("Retrieved endpoint list {}", result);
return result;
}
}
} catch (Exception e) {
logger.error("Error contacting server for endpoints with vipAddress:{}", vipAddress, e);
} finally {
if (client != null) {
client.shutdown();
}
}
logger.info("Returning empty endpoint list");
return Collections.emptyList();
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class InstanceRegionCheckerTest method testDefaults.
@Test
public void testDefaults() throws Exception {
PropertyBasedAzToRegionMapper azToRegionMapper = new PropertyBasedAzToRegionMapper(new DefaultEurekaClientConfig());
InstanceRegionChecker checker = new InstanceRegionChecker(azToRegionMapper, "us-east-1");
azToRegionMapper.setRegionsToFetch(new String[] { "us-east-1" });
AmazonInfo dcInfo = AmazonInfo.Builder.newBuilder().addMetadata(AmazonInfo.MetaDataKey.availabilityZone, "us-east-1c").build();
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("app").setDataCenterInfo(dcInfo).build();
String instanceRegion = checker.getInstanceRegion(instanceInfo);
Assert.assertEquals("Invalid instance region.", "us-east-1", instanceRegion);
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class BackUpRegistryTest method createLocalApps.
private Application createLocalApps() {
Application myapp = new Application(LOCAL_REGION_APP_NAME);
InstanceInfo instanceInfo = createLocalInstance(LOCAL_REGION_INSTANCE_1_HOSTNAME);
myapp.addInstance(instanceInfo);
return myapp;
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class BackUpRegistryTest method createRemoteApps.
private Application createRemoteApps() {
Application myapp = new Application(REMOTE_REGION_APP_NAME);
InstanceInfo instanceInfo = createRemoteInstance(REMOTE_REGION_INSTANCE_1_HOSTNAME);
myapp.addInstance(instanceInfo);
return myapp;
}
use of com.netflix.appinfo.InstanceInfo in project eureka by Netflix.
the class BaseDiscoveryClientTester method createInstance.
protected static InstanceInfo createInstance(String appName, String vipAddress, String instanceHostName, String zone) {
InstanceInfo.Builder instanceBuilder = InstanceInfo.Builder.newBuilder();
instanceBuilder.setAppName(appName);
instanceBuilder.setVIPAddress(vipAddress);
instanceBuilder.setHostName(instanceHostName);
instanceBuilder.setIPAddr("10.10.101.1");
AmazonInfo amazonInfo = getAmazonInfo(zone, instanceHostName);
instanceBuilder.setDataCenterInfo(amazonInfo);
instanceBuilder.setMetadata(amazonInfo.getMetadata());
instanceBuilder.setLeaseInfo(LeaseInfo.Builder.newBuilder().build());
return instanceBuilder.build();
}
Aggregations