Search in sources :

Example 11 with ApplicationInfo

use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.

the class SuperModelControllerTest method setupHandler.

@Before
public void setupHandler() throws IOException, SAXException {
    Map<TenantName, Map<ApplicationId, ApplicationInfo>> models = new LinkedHashMap<>();
    models.put(TenantName.from("a"), new LinkedHashMap<>());
    File testApp = new File("src/test/resources/deploy/app");
    ApplicationId app = ApplicationId.from(TenantName.from("a"), ApplicationName.from("foo"), InstanceName.defaultName());
    models.get(app.tenant()).put(app, new ApplicationInfo(app, 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp))));
    SuperModel superModel = new SuperModel(models);
    handler = new SuperModelController(new SuperModelConfigProvider(superModel, Zone.defaultZone()), new TestConfigDefinitionRepo(), 2, new UncompressedConfigResponseFactory());
}
Also used : TenantName(com.yahoo.config.provision.TenantName) SuperModel(com.yahoo.config.model.api.SuperModel) SuperModelConfigProvider(com.yahoo.vespa.config.server.model.SuperModelConfigProvider) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) LinkedHashMap(java.util.LinkedHashMap) VespaModel(com.yahoo.vespa.model.VespaModel) UncompressedConfigResponseFactory(com.yahoo.vespa.config.server.rpc.UncompressedConfigResponseFactory) ApplicationId(com.yahoo.config.provision.ApplicationId) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) File(java.io.File) Before(org.junit.Before)

Example 12 with ApplicationInfo

use of com.yahoo.config.model.api.ApplicationInfo 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 13 with ApplicationInfo

use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.

the class ModelGenerator method toServiceModel.

/**
 * Create service model based primarily on super model.
 *
 * If the configServerhosts is non-empty, a config server application is added.
 */
ServiceModel toServiceModel(SuperModel superModel, Zone zone, List<String> configServerHosts, ServiceStatusProvider serviceStatusProvider) {
    Map<ApplicationInstanceReference, ApplicationInstance> applicationInstances = new HashMap<>();
    for (ApplicationInfo applicationInfo : superModel.getAllApplicationInfos()) {
        ApplicationInstance applicationInstance = toApplicationInstance(applicationInfo, zone, serviceStatusProvider);
        applicationInstances.put(applicationInstance.reference(), applicationInstance);
    }
    // The config server is part of the service model (but not super model)
    if (!configServerHosts.isEmpty()) {
        ConfigServerApplication configServerApplication = new ConfigServerApplication();
        ApplicationInstance configServerApplicationInstance = configServerApplication.toApplicationInstance(configServerHosts);
        applicationInstances.put(configServerApplicationInstance.reference(), configServerApplicationInstance);
    }
    return new ServiceModel(applicationInstances);
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) HashMap(java.util.HashMap) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)

Example 14 with ApplicationInfo

use of com.yahoo.config.model.api.ApplicationInfo in project vespa by vespa-engine.

the class ExampleModel method createExampleSuperModelWithOneRpcPort.

static SuperModel createExampleSuperModelWithOneRpcPort(String hostname, int rpcPort) {
    List<String> hosts = Stream.of(hostname).collect(Collectors.toList());
    ApplicationInfo applicationInfo = ExampleModel.createApplication(TENANT, APPLICATION_NAME).addServiceCluster(CLUSTER_ID, SERVICE_NAME, SERVICE_TYPE, hosts).addPort(rpcPort, "footag", SlobrokMonitor.SLOBROK_RPC_PORT_TAG).addPort(rpcPort + 1, "bartag").then().build();
    Map<TenantName, Map<ApplicationId, ApplicationInfo>> applicationInfos = new HashMap<>();
    applicationInfos.put(applicationInfo.getApplicationId().tenant(), new HashMap<>());
    applicationInfos.get(applicationInfo.getApplicationId().tenant()).put(applicationInfo.getApplicationId(), applicationInfo);
    return new SuperModel(applicationInfos);
}
Also used : HashMap(java.util.HashMap) TenantName(com.yahoo.config.provision.TenantName) SuperModel(com.yahoo.config.model.api.SuperModel) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)14 SuperModel (com.yahoo.config.model.api.SuperModel)7 ApplicationId (com.yahoo.config.provision.ApplicationId)7 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)5 Test (org.junit.Test)5 TenantName (com.yahoo.config.provision.TenantName)4 HashMap (java.util.HashMap)4 HostInfo (com.yahoo.config.model.api.HostInfo)3 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)3 ServiceModel (com.yahoo.vespa.service.monitor.ServiceModel)3 SuperModelProvider (com.yahoo.config.model.api.SuperModelProvider)2 Zone (com.yahoo.config.provision.Zone)2 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)2 ApplicationInstanceReference (com.yahoo.vespa.applicationmodel.ApplicationInstanceReference)2 SuperModelConfigProvider (com.yahoo.vespa.config.server.model.SuperModelConfigProvider)2 UncompressedConfigResponseFactory (com.yahoo.vespa.config.server.rpc.UncompressedConfigResponseFactory)2 VespaModel (com.yahoo.vespa.model.VespaModel)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2