use of com.yahoo.vespa.service.monitor.ServiceModel 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.vespa.service.monitor.ServiceModel 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.vespa.service.monitor.ServiceModel 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);
}
use of com.yahoo.vespa.service.monitor.ServiceModel in project vespa by vespa-engine.
the class MetricsReporterTest method test_registered_metric.
@Test
public void test_registered_metric() throws Exception {
NodeFlavors nodeFlavors = FlavorConfigBuilder.createDummies("default");
Curator curator = new MockCurator();
NodeRepository nodeRepository = new NodeRepository(nodeFlavors, curator, Clock.systemUTC(), Zone.defaultZone(), new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
Node node = nodeRepository.createNode("openStackId", "hostname", Optional.empty(), nodeFlavors.getFlavorOrThrow("default"), NodeType.tenant);
nodeRepository.addNodes(Collections.singletonList(node));
Node hostNode = nodeRepository.createNode("openStackId2", "parent", Optional.empty(), nodeFlavors.getFlavorOrThrow("default"), NodeType.proxy);
nodeRepository.addNodes(Collections.singletonList(hostNode));
Map<String, Number> expectedMetrics = new HashMap<>();
expectedMetrics.put("hostedVespa.provisionedHosts", 1L);
expectedMetrics.put("hostedVespa.parkedHosts", 0L);
expectedMetrics.put("hostedVespa.readyHosts", 0L);
expectedMetrics.put("hostedVespa.reservedHosts", 0L);
expectedMetrics.put("hostedVespa.activeHosts", 0L);
expectedMetrics.put("hostedVespa.inactiveHosts", 0L);
expectedMetrics.put("hostedVespa.dirtyHosts", 0L);
expectedMetrics.put("hostedVespa.failedHosts", 0L);
expectedMetrics.put("hostedVespa.docker.totalCapacityDisk", 0.0);
expectedMetrics.put("hostedVespa.docker.totalCapacityMem", 0.0);
expectedMetrics.put("hostedVespa.docker.totalCapacityCpu", 0.0);
expectedMetrics.put("hostedVespa.docker.freeCapacityDisk", 0.0);
expectedMetrics.put("hostedVespa.docker.freeCapacityMem", 0.0);
expectedMetrics.put("hostedVespa.docker.freeCapacityCpu", 0.0);
expectedMetrics.put("wantedRebootGeneration", 0L);
expectedMetrics.put("currentRebootGeneration", 0L);
expectedMetrics.put("wantToReboot", 0);
expectedMetrics.put("wantToRetire", 0);
expectedMetrics.put("wantToDeprovision", 0);
expectedMetrics.put("hardwareFailure", 0);
expectedMetrics.put("hardwareDivergence", 0);
expectedMetrics.put("allowedToBeDown", 0);
expectedMetrics.put("numberOfServices", 0L);
Orchestrator orchestrator = mock(Orchestrator.class);
ServiceMonitor serviceMonitor = mock(ServiceMonitor.class);
when(orchestrator.getNodeStatus(any())).thenReturn(HostStatus.NO_REMARKS);
ServiceModel serviceModel = mock(ServiceModel.class);
when(serviceMonitor.getServiceModelSnapshot()).thenReturn(serviceModel);
when(serviceModel.getServiceInstancesByHostName()).thenReturn(Collections.emptyMap());
TestMetric metric = new TestMetric();
MetricsReporter metricsReporter = new MetricsReporter(nodeRepository, metric, orchestrator, serviceMonitor, Duration.ofMinutes(1), new JobControl(nodeRepository.database()));
metricsReporter.maintain();
assertEquals(expectedMetrics, metric.values);
}
use of com.yahoo.vespa.service.monitor.ServiceModel 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);
}
Aggregations