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));
}
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));
}
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());
}
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);
}
}
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);
}
Aggregations