use of com.netflix.discovery.shared.Application in project spring-cloud-netflix by spring-cloud.
the class InstanceRegistry method renew.
@Override
public boolean renew(final String appName, final String serverId, boolean isReplication) {
log("renew " + appName + " serverId " + serverId + ", isReplication {}" + isReplication);
List<Application> applications = getSortedApplications();
for (Application input : applications) {
if (input.getName().equals(appName)) {
InstanceInfo instance = null;
for (InstanceInfo info : input.getInstances()) {
if (info.getId().equals(serverId)) {
instance = info;
break;
}
}
publishEvent(new EurekaInstanceRenewedEvent(this, appName, serverId, instance, isReplication));
break;
}
}
return super.renew(appName, serverId, isReplication);
}
use of com.netflix.discovery.shared.Application in project spring-cloud-netflix by spring-cloud.
the class EurekaHealthIndicator method getApplications.
private Map<String, Object> getApplications() {
Applications applications = this.eurekaClient.getApplications();
if (applications == null) {
return Collections.emptyMap();
}
Map<String, Object> result = new HashMap<>();
for (Application application : applications.getRegisteredApplications()) {
result.put(application.getName(), application.getInstances().size());
}
return result;
}
use of com.netflix.discovery.shared.Application in project spring-cloud-netflix by spring-cloud.
the class EurekaInstanceDiscovery method getInstancesForApp.
/**
* Private helper that fetches the Instances for each application.
* @param serviceId
* @return List<Instance>
* @throws Exception
*/
@Override
protected List<Instance> getInstancesForApp(String serviceId) throws Exception {
List<Instance> instances = new ArrayList<>();
log.info("Fetching instances for app: " + serviceId);
Application app = eurekaClient.getApplication(serviceId);
if (app == null) {
log.warn("Eureka returned null for app: " + serviceId);
return instances;
}
try {
List<InstanceInfo> instancesForApp = app.getInstances();
if (instancesForApp != null) {
log.info("Received instance list for app: " + serviceId + ", size=" + instancesForApp.size());
for (InstanceInfo iInfo : instancesForApp) {
Instance instance = marshall(iInfo);
if (instance != null) {
instances.add(instance);
}
}
}
} catch (Exception e) {
log.warn("Failed to retrieve instances from Eureka", e);
}
return instances;
}
use of com.netflix.discovery.shared.Application in project spring-cloud-netflix by spring-cloud.
the class EurekaBasedTurbineClustersProviderTest method application.
private Application application(String name) {
Application application = mock(Application.class);
when(application.getName()).thenReturn(name);
return application;
}
use of com.netflix.discovery.shared.Application in project eureka by Netflix.
the class BackUpRegistryTest method setupBackupMock.
private void setupBackupMock() {
Application localApp = createLocalApps();
Applications localApps = new Applications();
localApps.addApplication(localApp);
backupRegistry.setLocalRegionApps(localApps);
Application remoteApp = createRemoteApps();
Applications remoteApps = new Applications();
remoteApps.addApplication(remoteApp);
backupRegistry.getRemoteRegionVsApps().put(REMOTE_REGION, remoteApps);
}
Aggregations