Search in sources :

Example 11 with ClusterId

use of com.yahoo.vespa.applicationmodel.ClusterId in project vespa by vespa-engine.

the class ModelGenerator method toApplicationInstance.

ApplicationInstance toApplicationInstance(ApplicationInfo applicationInfo, Zone zone, ServiceStatusProvider serviceStatusProvider) {
    Map<ServiceClusterKey, Set<ServiceInstance>> groupedServiceInstances = new HashMap<>();
    for (HostInfo host : applicationInfo.getModel().getHosts()) {
        HostName hostName = new HostName(host.getHostname());
        for (ServiceInfo serviceInfo : host.getServices()) {
            ServiceClusterKey serviceClusterKey = toServiceClusterKey(serviceInfo);
            ServiceInstance serviceInstance = toServiceInstance(applicationInfo.getApplicationId(), serviceClusterKey.clusterId(), serviceInfo, hostName, serviceStatusProvider);
            if (!groupedServiceInstances.containsKey(serviceClusterKey)) {
                groupedServiceInstances.put(serviceClusterKey, new HashSet<>());
            }
            groupedServiceInstances.get(serviceClusterKey).add(serviceInstance);
        }
    }
    Set<ServiceCluster> serviceClusters = groupedServiceInstances.entrySet().stream().map(entry -> new ServiceCluster(entry.getKey().clusterId(), entry.getKey().serviceType(), entry.getValue())).collect(Collectors.toSet());
    ApplicationInstance applicationInstance = new ApplicationInstance(new TenantId(applicationInfo.getApplicationId().tenant().toString()), toApplicationInstanceId(applicationInfo, zone), serviceClusters);
    // Fill back-references
    for (ServiceCluster serviceCluster : applicationInstance.serviceClusters()) {
        serviceCluster.setApplicationInstance(applicationInstance);
        for (ServiceInstance serviceInstance : serviceCluster.serviceInstances()) {
            serviceInstance.setServiceCluster(serviceCluster);
        }
    }
    return applicationInstance;
}
Also used : ApplicationId(com.yahoo.config.provision.ApplicationId) HostInfo(com.yahoo.config.model.api.HostInfo) HashMap(java.util.HashMap) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) HashSet(java.util.HashSet) HostName(com.yahoo.vespa.applicationmodel.HostName) Map(java.util.Map) SuperModel(com.yahoo.config.model.api.SuperModel) ServiceStatusProvider(com.yahoo.vespa.service.monitor.ServiceStatusProvider) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) Set(java.util.Set) TenantId(com.yahoo.vespa.applicationmodel.TenantId) Collectors(java.util.stream.Collectors) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) ServiceClusterKey(com.yahoo.vespa.applicationmodel.ServiceClusterKey) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) List(java.util.List) ApplicationInstanceId(com.yahoo.vespa.applicationmodel.ApplicationInstanceId) Zone(com.yahoo.config.provision.Zone) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) HashSet(java.util.HashSet) Set(java.util.Set) ServiceClusterKey(com.yahoo.vespa.applicationmodel.ServiceClusterKey) HashMap(java.util.HashMap) ServiceCluster(com.yahoo.vespa.applicationmodel.ServiceCluster) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) TenantId(com.yahoo.vespa.applicationmodel.TenantId) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) HostInfo(com.yahoo.config.model.api.HostInfo) HostName(com.yahoo.vespa.applicationmodel.HostName)

Example 12 with ClusterId

use of com.yahoo.vespa.applicationmodel.ClusterId 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 13 with ClusterId

use of com.yahoo.vespa.applicationmodel.ClusterId in project vespa by vespa-engine.

the class HostedVespaClusterPolicyTest method testStorageSuspensionLimit.

@Test
public void testStorageSuspensionLimit() {
    when(clusterApi.clusterId()).thenReturn(new ClusterId("some-cluster-id"));
    when(clusterApi.isStorageCluster()).thenReturn(true);
    assertEquals(ConcurrentSuspensionLimitForCluster.ONE_NODE, policy.getConcurrentSuspensionLimit(clusterApi));
}
Also used : ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) Test(org.junit.Test)

Example 14 with ClusterId

use of com.yahoo.vespa.applicationmodel.ClusterId in project vespa by vespa-engine.

the class HostedVespaClusterPolicyTest method testDefaultSuspensionLimit.

@Test
public void testDefaultSuspensionLimit() {
    when(applicationApi.applicationId()).thenReturn(ApplicationId.fromSerializedForm("a:b:c"));
    when(clusterApi.clusterId()).thenReturn(new ClusterId("some-cluster-id"));
    when(clusterApi.isStorageCluster()).thenReturn(false);
    assertEquals(ConcurrentSuspensionLimitForCluster.TEN_PERCENT, policy.getConcurrentSuspensionLimit(clusterApi));
}
Also used : ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) Test(org.junit.Test)

Aggregations

ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)14 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)7 Test (org.junit.Test)7 HostName (com.yahoo.vespa.applicationmodel.HostName)6 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)5 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)5 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)4 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)4 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)4 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)4 TenantId (com.yahoo.vespa.applicationmodel.TenantId)4 ApplicationId (com.yahoo.config.provision.ApplicationId)3 ServiceClusterKey (com.yahoo.vespa.applicationmodel.ServiceClusterKey)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)1 HostInfo (com.yahoo.config.model.api.HostInfo)1 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)1