Search in sources :

Example 1 with ServiceClusterKey

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

the class ModelGenerator method toServiceClusterKey.

private ServiceClusterKey toServiceClusterKey(ServiceInfo serviceInfo) {
    ClusterId clusterId = getClusterId(serviceInfo);
    ServiceType serviceType = toServiceType(serviceInfo);
    return new ServiceClusterKey(clusterId, serviceType);
}
Also used : ServiceClusterKey(com.yahoo.vespa.applicationmodel.ServiceClusterKey) ClusterId(com.yahoo.vespa.applicationmodel.ClusterId) ServiceType(com.yahoo.vespa.applicationmodel.ServiceType)

Example 2 with ServiceClusterKey

use of com.yahoo.vespa.applicationmodel.ServiceClusterKey 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)

Aggregations

ClusterId (com.yahoo.vespa.applicationmodel.ClusterId)2 ServiceClusterKey (com.yahoo.vespa.applicationmodel.ServiceClusterKey)2 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)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 SuperModel (com.yahoo.config.model.api.SuperModel)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Zone (com.yahoo.config.provision.Zone)1 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)1 ApplicationInstanceId (com.yahoo.vespa.applicationmodel.ApplicationInstanceId)1 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)1 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)1 HostName (com.yahoo.vespa.applicationmodel.HostName)1 ServiceCluster (com.yahoo.vespa.applicationmodel.ServiceCluster)1 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)1 ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)1 TenantId (com.yahoo.vespa.applicationmodel.TenantId)1 ServiceModel (com.yahoo.vespa.service.monitor.ServiceModel)1 ServiceStatusProvider (com.yahoo.vespa.service.monitor.ServiceStatusProvider)1