in eureka-core/src/main/java/com/netflix/eureka/registry/ResponseCacheImpl.java [464:502]
private static Applications getApplicationsForVip(Key key, AbstractInstanceRegistry registry) {
logger.debug(
"Retrieving applications from registry for key : {} {} {} {}",
key.getEntityType(), key.getName(), key.getVersion(), key.getType());
Applications toReturn = new Applications();
Applications applications = registry.getApplications();
for (Application application : applications.getRegisteredApplications()) {
Application appToAdd = null;
for (InstanceInfo instanceInfo : application.getInstances()) {
String vipAddress;
if (Key.EntityType.VIP.equals(key.getEntityType())) {
vipAddress = instanceInfo.getVIPAddress();
} else if (Key.EntityType.SVIP.equals(key.getEntityType())) {
vipAddress = instanceInfo.getSecureVipAddress();
} else {
// should not happen, but just in case.
continue;
}
if (null != vipAddress) {
String[] vipAddresses = vipAddress.split(",");
Arrays.sort(vipAddresses);
if (Arrays.binarySearch(vipAddresses, key.getName()) >= 0) {
if (null == appToAdd) {
appToAdd = new Application(application.getName());
toReturn.addApplication(appToAdd);
}
appToAdd.addInstance(instanceInfo);
}
}
}
}
toReturn.setAppsHashCode(toReturn.getReconcileHashCode());
logger.debug(
"Retrieved applications from registry for key : {} {} {} {}, reconcile hashcode: {}",
key.getEntityType(), key.getName(), key.getVersion(), key.getType(),
toReturn.getReconcileHashCode());
return toReturn;
}