Search in sources :

Example 1 with SuperModel

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

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

the class SuperModelManager method applicationRemoved.

public synchronized void applicationRemoved(ApplicationId applicationId) {
    SuperModel newSuperModel = this.superModelConfigProvider.getSuperModel().cloneAndRemoveApplication(applicationId);
    makeNewSuperModelConfigProvider(newSuperModel);
    listeners.stream().forEach(listener -> listener.applicationRemoved(newSuperModel, applicationId));
}
Also used : SuperModel(com.yahoo.config.model.api.SuperModel)

Example 3 with SuperModel

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

the class ModelGeneratorTest method toApplicationModel.

@Test
public void toApplicationModel() throws Exception {
    SuperModel superModel = ExampleModel.createExampleSuperModelWithOneRpcPort(HOSTNAME, PORT);
    ModelGenerator modelGenerator = new ModelGenerator();
    Zone zone = new Zone(Environment.from(ENVIRONMENT), RegionName.from(REGION));
    List<String> configServerHosts = Collections.emptyList();
    SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
    when(slobrokMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(ServiceStatus.UP);
    ServiceModel serviceModel = modelGenerator.toServiceModel(superModel, zone, configServerHosts, slobrokMonitorManager);
    Map<ApplicationInstanceReference, ApplicationInstance> applicationInstances = serviceModel.getAllApplicationInstances();
    assertEquals(1, applicationInstances.size());
    verifyOtherApplication(applicationInstances.values().iterator().next());
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) SuperModel(com.yahoo.config.model.api.SuperModel) Zone(com.yahoo.config.provision.Zone) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) Test(org.junit.Test)

Example 4 with SuperModel

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

the class ModelGeneratorTest method toApplicationModelWithConfigServerApplication.

@Test
public void toApplicationModelWithConfigServerApplication() throws Exception {
    SuperModel superModel = ExampleModel.createExampleSuperModelWithOneRpcPort(HOSTNAME, PORT);
    ModelGenerator modelGenerator = new ModelGenerator();
    Zone zone = new Zone(Environment.from(ENVIRONMENT), RegionName.from(REGION));
    List<String> configServerHosts = Stream.of("cfg1", "cfg2", "cfg3").collect(Collectors.toList());
    SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
    when(slobrokMonitorManager.getStatus(any(), any(), any(), any())).thenReturn(ServiceStatus.UP);
    ServiceModel serviceModel = modelGenerator.toServiceModel(superModel, zone, configServerHosts, slobrokMonitorManager);
    Map<ApplicationInstanceReference, ApplicationInstance> applicationInstances = serviceModel.getAllApplicationInstances();
    assertEquals(2, applicationInstances.size());
    Iterator<Map.Entry<ApplicationInstanceReference, ApplicationInstance>> iterator = applicationInstances.entrySet().iterator();
    ApplicationInstance applicationInstance1 = iterator.next().getValue();
    ApplicationInstance applicationInstance2 = iterator.next().getValue();
    if (applicationInstance1.applicationInstanceId().equals(ConfigServerApplication.APPLICATION_INSTANCE_ID)) {
        verifyConfigServerApplication(applicationInstance1);
        verifyOtherApplication(applicationInstance2);
    } else {
        verifyConfigServerApplication(applicationInstance2);
        verifyOtherApplication(applicationInstance1);
    }
}
Also used : ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) SuperModel(com.yahoo.config.model.api.SuperModel) Zone(com.yahoo.config.provision.Zone) ApplicationInstanceReference(com.yahoo.vespa.applicationmodel.ApplicationInstanceReference) Test(org.junit.Test)

Example 5 with SuperModel

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

the class SuperModelListenerImplTest method sanityCheck.

@Test
public void sanityCheck() {
    SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
    ServiceMonitorMetrics metrics = mock(ServiceMonitorMetrics.class);
    ModelGenerator modelGenerator = mock(ModelGenerator.class);
    Zone zone = mock(Zone.class);
    List<String> configServers = new ArrayList<>();
    SuperModelListenerImpl listener = new SuperModelListenerImpl(slobrokMonitorManager, metrics, modelGenerator, zone, configServers);
    SuperModelProvider superModelProvider = mock(SuperModelProvider.class);
    SuperModel superModel = mock(SuperModel.class);
    when(superModelProvider.snapshot(listener)).thenReturn(superModel);
    ApplicationInfo application1 = mock(ApplicationInfo.class);
    ApplicationInfo application2 = mock(ApplicationInfo.class);
    List<ApplicationInfo> applications = Stream.of(application1, application2).collect(Collectors.toList());
    when(superModel.getAllApplicationInfos()).thenReturn(applications);
    listener.start(superModelProvider);
    verify(slobrokMonitorManager).applicationActivated(superModel, application1);
    verify(slobrokMonitorManager).applicationActivated(superModel, application2);
    ServiceModel serviceModel = listener.get();
    verify(modelGenerator).toServiceModel(superModel, zone, configServers, slobrokMonitorManager);
}
Also used : Zone(com.yahoo.config.provision.Zone) SuperModel(com.yahoo.config.model.api.SuperModel) ArrayList(java.util.ArrayList) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) SuperModelProvider(com.yahoo.config.model.api.SuperModelProvider) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) Test(org.junit.Test)

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