Search in sources :

Example 11 with ServiceInstance

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;
}
Also used : HashMap(java.util.HashMap) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) Node(com.yahoo.vespa.hosted.provision.Node) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ApplicationInstanceId(com.yahoo.vespa.applicationmodel.ApplicationInstanceId) TenantId(com.yahoo.vespa.applicationmodel.TenantId) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) ApplicationId(com.yahoo.config.provision.ApplicationId) HashMap(java.util.HashMap) Map(java.util.Map) HostName(com.yahoo.vespa.applicationmodel.HostName) HashSet(java.util.HashSet)

Example 12 with ServiceInstance

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);
    }
}
Also used : ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance)

Example 13 with ServiceInstance

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);
}
Also used : ApplicationId(com.yahoo.config.provision.ApplicationId) Inject(com.google.inject.Inject) HostedVespaClusterPolicy(com.yahoo.vespa.orchestrator.policy.HostedVespaClusterPolicy) HashMap(java.util.HashMap) ClusterControllerClientFactory(com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ApplicationApi(com.yahoo.vespa.orchestrator.model.ApplicationApi) MutableStatusRegistry(com.yahoo.vespa.orchestrator.status.MutableStatusRegistry) ApplicationApiImpl(com.yahoo.vespa.orchestrator.model.ApplicationApiImpl) BatchHostStateChangeDeniedException(com.yahoo.vespa.orchestrator.policy.BatchHostStateChangeDeniedException) HostName(com.yahoo.vespa.applicationmodel.HostName) HostStateChangeDeniedException(com.yahoo.vespa.orchestrator.policy.HostStateChangeDeniedException) Map(java.util.Map) LogLevel(com.yahoo.log.LogLevel) ClusterControllerStateResponse(com.yahoo.vespa.orchestrator.controller.ClusterControllerStateResponse) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ClusterControllerNodeState(com.yahoo.vespa.orchestrator.controller.ClusterControllerNodeState) StatusService(com.yahoo.vespa.orchestrator.status.StatusService) Policy(com.yahoo.vespa.orchestrator.policy.Policy) OrchestratorConfig(com.yahoo.vespa.orchestrator.config.OrchestratorConfig) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) VespaModelUtil(com.yahoo.vespa.orchestrator.model.VespaModelUtil) Set(java.util.Set) IOException(java.io.IOException) Logger(java.util.logging.Logger) ApplicationInstanceStatus(com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) ClusterControllerClient(com.yahoo.vespa.orchestrator.controller.ClusterControllerClient) List(java.util.List) NodeGroup(com.yahoo.vespa.orchestrator.model.NodeGroup) HostedVespaPolicy(com.yahoo.vespa.orchestrator.policy.HostedVespaPolicy) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus)

Aggregations

ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)13 HostName (com.yahoo.vespa.applicationmodel.HostName)9 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)8 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)6 ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)6 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)6 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)5 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)5 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)5 TenantId (com.yahoo.vespa.applicationmodel.TenantId)5 ApplicationId (com.yahoo.config.provision.ApplicationId)4 ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)4 HashSet (java.util.HashSet)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 Test (org.junit.Test)3 OrchestratorConfig (com.yahoo.vespa.orchestrator.config.OrchestratorConfig)2