Search in sources :

Example 6 with SuperModel

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

the class InstanceValidatorTest method mockSuperModelProvider.

private SuperModelProvider mockSuperModelProvider(ApplicationInfo... appInfos) {
    SuperModel superModel = new SuperModel(Stream.of(appInfos).collect(Collectors.groupingBy(appInfo -> appInfo.getApplicationId().tenant(), Collectors.toMap(ApplicationInfo::getApplicationId, Function.identity()))));
    SuperModelProvider superModelProvider = mock(SuperModelProvider.class);
    when(superModelProvider.getSuperModel()).thenReturn(superModel);
    return superModelProvider;
}
Also used : SuperModel(com.yahoo.config.model.api.SuperModel) SuperModelProvider(com.yahoo.config.model.api.SuperModelProvider)

Example 7 with SuperModel

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

the class SuperModelControllerTest method test_lb_config_multiple_apps.

@Test
public void test_lb_config_multiple_apps() throws IOException, SAXException {
    Map<TenantName, Map<ApplicationId, ApplicationInfo>> models = new LinkedHashMap<>();
    models.put(TenantName.from("t1"), new LinkedHashMap<>());
    models.put(TenantName.from("t2"), new LinkedHashMap<>());
    File testApp1 = new File("src/test/resources/deploy/app");
    File testApp2 = new File("src/test/resources/deploy/advancedapp");
    File testApp3 = new File("src/test/resources/deploy/advancedapp");
    // TODO must fix equals, hashCode on Tenant
    Version vespaVersion = Version.fromIntValues(1, 2, 3);
    models.get(TenantName.from("t1")).put(applicationId("mysimpleapp"), new ApplicationInfo(applicationId("mysimpleapp"), 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp1))));
    models.get(TenantName.from("t1")).put(applicationId("myadvancedapp"), new ApplicationInfo(applicationId("myadvancedapp"), 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp2))));
    models.get(TenantName.from("t2")).put(applicationId("minetooadvancedapp"), new ApplicationInfo(applicationId("minetooadvancedapp"), 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp3))));
    SuperModel superModel = new SuperModel(models);
    SuperModelController han = new SuperModelController(new SuperModelConfigProvider(superModel, Zone.defaultZone()), new TestConfigDefinitionRepo(), 2, new UncompressedConfigResponseFactory());
    LbServicesConfig.Builder lb = new LbServicesConfig.Builder();
    han.getSuperModel().getConfig(lb);
    LbServicesConfig lbc = new LbServicesConfig(lb);
    assertThat(lbc.tenants().size(), is(2));
    assertThat(lbc.tenants("t1").applications().size(), is(2));
    assertThat(lbc.tenants("t2").applications().size(), is(1));
    assertThat(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default").hosts().size(), is(1));
    assertQrServer(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default"));
}
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) Version(com.yahoo.config.provision.Version) VespaModel(com.yahoo.vespa.model.VespaModel) UncompressedConfigResponseFactory(com.yahoo.vespa.config.server.rpc.UncompressedConfigResponseFactory) LbServicesConfig(com.yahoo.cloud.config.LbServicesConfig) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) File(java.io.File) Test(org.junit.Test)

Example 8 with SuperModel

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

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

SuperModel (com.yahoo.config.model.api.SuperModel)9 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)5 Test (org.junit.Test)4 TenantName (com.yahoo.config.provision.TenantName)3 Zone (com.yahoo.config.provision.Zone)3 ServiceModel (com.yahoo.vespa.service.monitor.ServiceModel)3 Map (java.util.Map)3 SuperModelProvider (com.yahoo.config.model.api.SuperModelProvider)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 LinkedHashMap (java.util.LinkedHashMap)2 LbServicesConfig (com.yahoo.cloud.config.LbServicesConfig)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Version (com.yahoo.config.provision.Version)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1