use of com.yahoo.vespa.applicationmodel.ServiceInstance in project vespa by vespa-engine.
the class ServiceMonitorStub method getAllApplicationInstances.
@Override
public Map<ApplicationInstanceReference, ApplicationInstance> getAllApplicationInstances() {
// Convert apps information to the response payload to return
Map<ApplicationInstanceReference, ApplicationInstance> status = new HashMap<>();
for (Map.Entry<ApplicationId, MockDeployer.ApplicationContext> app : apps.entrySet()) {
Set<ServiceInstance> serviceInstances = new HashSet<>();
for (Node node : nodeRepository.getNodes(app.getValue().id(), Node.State.active)) {
serviceInstances.add(new ServiceInstance(new ConfigId("configid"), new HostName(node.hostname()), getHostStatus(node.hostname())));
}
Set<ServiceCluster> serviceClusters = new HashSet<>();
serviceClusters.add(new ServiceCluster(new ClusterId(app.getValue().clusterContexts().get(0).cluster().id().value()), new ServiceType("serviceType"), serviceInstances));
TenantId tenantId = new TenantId(app.getKey().tenant().value());
ApplicationInstanceId applicationInstanceId = new ApplicationInstanceId(app.getKey().application().value());
status.put(new ApplicationInstanceReference(tenantId, applicationInstanceId), new ApplicationInstance(tenantId, applicationInstanceId, serviceClusters));
}
return status;
}
use of com.yahoo.vespa.applicationmodel.ServiceInstance in project vespa by vespa-engine.
the class NodeFailerTest method addServiceInstances.
private void addServiceInstances(List<ServiceInstance> list, ServiceStatus status, int num) {
for (int i = 0; i < num; ++i) {
ServiceInstance service = mock(ServiceInstance.class);
when(service.serviceStatus()).thenReturn(status);
list.add(service);
}
}
use of com.yahoo.vespa.applicationmodel.ServiceInstance in project vespa by vespa-engine.
the class OrchestratorImpl method getHost.
@Override
public Host getHost(HostName hostName) throws HostNameNotFoundException {
ApplicationInstance applicationInstance = getApplicationInstance(hostName);
List<ServiceInstance> serviceInstances = applicationInstance.serviceClusters().stream().flatMap(cluster -> cluster.serviceInstances().stream()).filter(serviceInstance -> hostName.equals(serviceInstance.hostName())).collect(Collectors.toList());
HostStatus hostStatus = getNodeStatus(applicationInstance.reference(), hostName);
return new Host(hostName, hostStatus, applicationInstance.reference(), serviceInstances);
}
Aggregations