Search in sources :

Example 1 with ApplicationInfo

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

the class SuperModelManager method configActivated.

public synchronized void configActivated(TenantName tenant, ApplicationSet applicationSet) {
    // TODO: Should supermodel care about multiple versions?
    ApplicationInfo applicationInfo = applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()).toApplicationInfo();
    SuperModel newSuperModel = this.superModelConfigProvider.getSuperModel().cloneAndSetApplication(applicationInfo);
    makeNewSuperModelConfigProvider(newSuperModel);
    listeners.stream().forEach(listener -> listener.applicationActivated(newSuperModel, applicationInfo));
}
Also used : SuperModel(com.yahoo.config.model.api.SuperModel) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo)

Example 2 with ApplicationInfo

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

the class SuperModelConfigProvider method getConfig.

public <CONFIGTYPE extends ConfigInstance> CONFIGTYPE getConfig(Class<CONFIGTYPE> configClass, ApplicationId applicationId, String configId) {
    TenantName tenant = applicationId.tenant();
    if (!superModel.getAllModels().containsKey(tenant)) {
        throw new IllegalArgumentException("Tenant " + tenant + " not found");
    }
    Map<ApplicationId, ApplicationInfo> applications = superModel.getAllModels().get(tenant);
    if (!applications.containsKey(applicationId)) {
        throw new IllegalArgumentException("Application id " + applicationId + " not found");
    }
    ApplicationInfo application = applications.get(applicationId);
    ConfigKey<CONFIGTYPE> key = new ConfigKey<>(configClass, configId);
    ConfigPayload payload = application.getModel().getConfig(key, null);
    return payload.toInstance(configClass, configId);
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) TenantName(com.yahoo.config.provision.TenantName) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 3 with ApplicationInfo

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

the class LbServicesProducerTest method randomizeApplications.

private Map<ApplicationId, ApplicationInfo> randomizeApplications(Map<ApplicationId, ApplicationInfo> applicationIdApplicationMap, int seed) {
    Map<ApplicationId, ApplicationInfo> randomizedApplications = new LinkedHashMap<>();
    List<ApplicationId> keys = new ArrayList<>(applicationIdApplicationMap.keySet());
    Collections.shuffle(keys, new Random(seed));
    for (ApplicationId key : keys) {
        randomizedApplications.put(key, applicationIdApplicationMap.get(key));
    }
    return randomizedApplications;
}
Also used : Random(java.util.Random) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ArrayList(java.util.ArrayList) ApplicationId(com.yahoo.config.provision.ApplicationId) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with ApplicationInfo

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

the class LbServicesProducerTest method createTestApplications.

private Map<ApplicationId, ApplicationInfo> createTestApplications(TenantName tenant, DeployState.Builder deploystateBuilder) throws IOException, SAXException {
    Map<ApplicationId, ApplicationInfo> aMap = new LinkedHashMap<>();
    ApplicationId fooApp = new ApplicationId.Builder().tenant(tenant).applicationName("foo").build();
    ApplicationId barApp = new ApplicationId.Builder().tenant(tenant).applicationName("bar").build();
    ApplicationId bazApp = new ApplicationId.Builder().tenant(tenant).applicationName("baz").build();
    aMap.put(fooApp, createApplication(fooApp, deploystateBuilder));
    aMap.put(barApp, createApplication(barApp, deploystateBuilder));
    aMap.put(bazApp, createApplication(bazApp, deploystateBuilder));
    return aMap;
}
Also used : ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ApplicationId(com.yahoo.config.provision.ApplicationId) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with ApplicationInfo

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

the class ExampleModelTest method testEmptyApplication.

@Test
public void testEmptyApplication() {
    ApplicationInfo application = ExampleModel.createApplication("tenant", "app").build();
    assertEquals("tenant.app", application.getApplicationId().toString());
    assertEquals(1, application.getGeneration());
    assertEquals(0, application.getModel().getHosts().size());
}
Also used : ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) Test(org.junit.Test)

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