Search in sources :

Example 1 with ServiceStatus

use of com.yahoo.vespa.applicationmodel.ServiceStatus in project vespa by vespa-engine.

the class ModelGenerator method toServiceInstance.

private ServiceInstance toServiceInstance(ApplicationId applicationId, ClusterId clusterId, ServiceInfo serviceInfo, HostName hostName, ServiceStatusProvider serviceStatusProvider) {
    ConfigId configId = new ConfigId(serviceInfo.getConfigId());
    ServiceStatus status = serviceStatusProvider.getStatus(applicationId, clusterId, toServiceType(serviceInfo), configId);
    return new ServiceInstance(configId, hostName, status);
}
Also used : ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId)

Example 2 with ServiceStatus

use of com.yahoo.vespa.applicationmodel.ServiceStatus in project vespa by vespa-engine.

the class MetricsReporter method updateNodeMetrics.

private void updateNodeMetrics(Node node, Map<HostName, List<ServiceInstance>> servicesByHost) {
    Metric.Context context;
    Optional<Allocation> allocation = node.allocation();
    if (allocation.isPresent()) {
        ApplicationId applicationId = allocation.get().owner();
        context = getContextAt("state", node.state().name(), "host", node.hostname(), "tenantName", applicationId.tenant().value(), "applicationId", applicationId.serializedForm().replace(':', '.'), "app", toApp(applicationId), "clustertype", allocation.get().membership().cluster().type().name(), "clusterid", allocation.get().membership().cluster().id().value());
        long wantedRestartGeneration = allocation.get().restartGeneration().wanted();
        metric.set("wantedRestartGeneration", wantedRestartGeneration, context);
        long currentRestartGeneration = allocation.get().restartGeneration().current();
        metric.set("currentRestartGeneration", currentRestartGeneration, context);
        boolean wantToRestart = currentRestartGeneration < wantedRestartGeneration;
        metric.set("wantToRestart", wantToRestart ? 1 : 0, context);
        Version wantedVersion = allocation.get().membership().cluster().vespaVersion();
        double wantedVersionNumber = getVersionAsNumber(wantedVersion);
        metric.set("wantedVespaVersion", wantedVersionNumber, context);
        Optional<Version> currentVersion = node.status().vespaVersion();
        boolean converged = currentVersion.isPresent() && currentVersion.get().equals(wantedVersion);
        metric.set("wantToChangeVespaVersion", converged ? 0 : 1, context);
    } else {
        context = getContextAt("state", node.state().name(), "host", node.hostname());
    }
    Optional<Version> currentVersion = node.status().vespaVersion();
    // Node repo checks for !isEmpty(), so let's do that here too.
    if (currentVersion.isPresent() && !currentVersion.get().isEmpty()) {
        double currentVersionNumber = getVersionAsNumber(currentVersion.get());
        metric.set("currentVespaVersion", currentVersionNumber, context);
    }
    long wantedRebootGeneration = node.status().reboot().wanted();
    metric.set("wantedRebootGeneration", wantedRebootGeneration, context);
    long currentRebootGeneration = node.status().reboot().current();
    metric.set("currentRebootGeneration", currentRebootGeneration, context);
    boolean wantToReboot = currentRebootGeneration < wantedRebootGeneration;
    metric.set("wantToReboot", wantToReboot ? 1 : 0, context);
    metric.set("wantToRetire", node.status().wantToRetire() ? 1 : 0, context);
    metric.set("wantToDeprovision", node.status().wantToDeprovision() ? 1 : 0, context);
    metric.set("hardwareFailure", node.status().hardwareFailureDescription().isPresent() ? 1 : 0, context);
    metric.set("hardwareDivergence", node.status().hardwareDivergence().isPresent() ? 1 : 0, context);
    try {
        HostStatus status = orchestrator.getNodeStatus(new HostName(node.hostname()));
        boolean allowedToBeDown = status == HostStatus.ALLOWED_TO_BE_DOWN;
        metric.set("allowedToBeDown", allowedToBeDown ? 1 : 0, context);
    } catch (HostNameNotFoundException e) {
    // Ignore
    }
    long numberOfServices;
    HostName hostName = new HostName(node.hostname());
    List<ServiceInstance> services = servicesByHost.get(hostName);
    if (services == null) {
        numberOfServices = 0;
    } else {
        Map<ServiceStatus, Long> servicesCount = services.stream().collect(Collectors.groupingBy(ServiceInstance::serviceStatus, Collectors.counting()));
        numberOfServices = servicesCount.values().stream().mapToLong(Long::longValue).sum();
        metric.set("numberOfServicesUp", servicesCount.getOrDefault(ServiceStatus.UP, 0L), context);
        metric.set("numberOfServicesNotChecked", servicesCount.getOrDefault(ServiceStatus.NOT_CHECKED, 0L), context);
        long numberOfServicesDown = servicesCount.getOrDefault(ServiceStatus.DOWN, 0L);
        metric.set("numberOfServicesDown", numberOfServicesDown, context);
        metric.set("someServicesDown", (numberOfServicesDown > 0 ? 1 : 0), context);
        boolean badNode = NodeFailer.badNode(services);
        metric.set("nodeFailerBadNode", (badNode ? 1 : 0), context);
        boolean nodeDownInNodeRepo = node.history().event(History.Event.Type.down).isPresent();
        metric.set("downInNodeRepo", (nodeDownInNodeRepo ? 1 : 0), context);
    }
    metric.set("numberOfServices", numberOfServices, context);
}
Also used : ServiceInstance(com.yahoo.vespa.applicationmodel.ServiceInstance) Allocation(com.yahoo.vespa.hosted.provision.node.Allocation) Version(com.yahoo.component.Version) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) Metric(com.yahoo.jdisc.Metric) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) ApplicationId(com.yahoo.config.provision.ApplicationId) HostName(com.yahoo.vespa.applicationmodel.HostName) HostNameNotFoundException(com.yahoo.vespa.orchestrator.HostNameNotFoundException)

Example 3 with ServiceStatus

use of com.yahoo.vespa.applicationmodel.ServiceStatus in project vespa by vespa-engine.

the class InstanceResourceTest method testGetServiceStatus.

@Test
public void testGetServiceStatus() {
    ServiceType serviceType = new ServiceType("serviceType");
    ConfigId configId = new ConfigId("configId");
    ServiceStatus serviceStatus = ServiceStatus.UP;
    when(slobrokApi.getStatus(APPLICATION_ID, CLUSTER_ID, serviceType, configId)).thenReturn(serviceStatus);
    ServiceStatus actualServiceStatus = resource.getServiceStatus(APPLICATION_INSTANCE_REFERENCE, CLUSTER_ID.s(), serviceType.s(), configId.s());
    verify(slobrokApi).getStatus(APPLICATION_ID, CLUSTER_ID, serviceType, configId);
    assertEquals(serviceStatus, actualServiceStatus);
}
Also used : ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) ConfigId(com.yahoo.vespa.applicationmodel.ConfigId) Test(org.junit.Test)

Example 4 with ServiceStatus

use of com.yahoo.vespa.applicationmodel.ServiceStatus in project vespa by vespa-engine.

the class ApplicationApiImplTest method verifyUpConditionWith.

private void verifyUpConditionWith(HostStatus hostStatus, ServiceStatus serviceStatus, boolean expectUp) {
    HostName hostName1 = modelUtils.createNode("host1", hostStatus);
    ApplicationInstance applicationInstance = modelUtils.createApplicationInstance(Arrays.asList(modelUtils.createServiceCluster("cluster-1", VespaModelUtil.STORAGENODE_SERVICE_TYPE, Arrays.asList(modelUtils.createServiceInstance("config-id-1", hostName1, serviceStatus)))));
    ApplicationApiImpl applicationApi = modelUtils.createApplicationApiImpl(applicationInstance, hostName1);
    List<HostName> upStorageNodes = expectUp ? Arrays.asList(hostName1) : new ArrayList<>();
    List<HostName> actualStorageNodes = applicationApi.getUpStorageNodesInGroupInClusterOrder().stream().map(storageNode -> storageNode.hostName()).collect(Collectors.toList());
    assertEquals(upStorageNodes, actualStorageNodes);
}
Also used : ServiceType(com.yahoo.vespa.applicationmodel.ServiceType) Arrays(java.util.Arrays) List(java.util.List) HostName(com.yahoo.vespa.applicationmodel.HostName) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) Test(org.junit.Test) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) ServiceStatus(com.yahoo.vespa.applicationmodel.ServiceStatus) Collectors(java.util.stream.Collectors) Assert.assertEquals(org.junit.Assert.assertEquals) ArrayList(java.util.ArrayList) ApplicationInstance(com.yahoo.vespa.applicationmodel.ApplicationInstance) HostName(com.yahoo.vespa.applicationmodel.HostName)

Aggregations

ServiceStatus (com.yahoo.vespa.applicationmodel.ServiceStatus)4 ConfigId (com.yahoo.vespa.applicationmodel.ConfigId)2 HostName (com.yahoo.vespa.applicationmodel.HostName)2 ServiceInstance (com.yahoo.vespa.applicationmodel.ServiceInstance)2 ServiceType (com.yahoo.vespa.applicationmodel.ServiceType)2 HostStatus (com.yahoo.vespa.orchestrator.status.HostStatus)2 Test (org.junit.Test)2 Version (com.yahoo.component.Version)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Metric (com.yahoo.jdisc.Metric)1 ApplicationInstance (com.yahoo.vespa.applicationmodel.ApplicationInstance)1 Allocation (com.yahoo.vespa.hosted.provision.node.Allocation)1 HostNameNotFoundException (com.yahoo.vespa.orchestrator.HostNameNotFoundException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Assert.assertEquals (org.junit.Assert.assertEquals)1