Search in sources :

Example 31 with Version

use of com.yahoo.component.Version 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 32 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class DocumentProtocolTest method requireThat50SerializationPrecedes5xSerialization.

@SuppressWarnings("deprecation")
@Test
public void requireThat50SerializationPrecedes5xSerialization() {
    DocumentProtocol protocol = new DocumentProtocol(manager);
    GetDocumentMessage prev = new GetDocumentMessage(new DocumentId("doc:scheme:"), "foo");
    byte[] buf = protocol.encode(new Version(5, 0), prev);
    GetDocumentMessage next = (GetDocumentMessage) protocol.decode(new Version(5, 0), buf);
    assertEquals(GetDocumentMessage.DEFAULT_FIELD_SET, next.getFieldSet());
}
Also used : Version(com.yahoo.component.Version) DocumentId(com.yahoo.document.DocumentId) Test(org.junit.Test)

Example 33 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class YqlParser method populateLinguisticsAnnotations.

private void populateLinguisticsAnnotations(OperatorNode<ExpressionOperator> filterExpression) {
    Map<?, ?> segmenter = getAnnotation(filterExpression, SEGMENTER, Map.class, null, "segmenter engine and version");
    if (segmenter == null) {
        segmenterVersion = null;
        segmenterBackend = null;
        resegment = false;
    } else {
        segmenterBackend = getMapValue(SEGMENTER, segmenter, SEGMENTER_BACKEND, String.class);
        try {
            segmenterVersion = new Version(getMapValue(SEGMENTER, segmenter, SEGMENTER_VERSION, String.class));
        } catch (RuntimeException e) {
            segmenterVersion = null;
        }
        resegment = !localSegmenterBackend.equals(segmenterBackend) || !localSegmenterVersion.equals(segmenterVersion);
    }
}
Also used : Version(com.yahoo.component.Version)

Example 34 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class Upgrader method maintain.

/**
 * Schedule application upgrades. Note that this implementation must be idempotent.
 */
@Override
public void maintain() {
    // Determine target versions for each upgrade policy
    Optional<Version> canaryTarget = controller().versionStatus().systemVersion().map(VespaVersion::versionNumber);
    Optional<Version> defaultTarget = newestVersionWithConfidence(Confidence.normal);
    Optional<Version> conservativeTarget = newestVersionWithConfidence(Confidence.high);
    // Cancel upgrades to broken targets (let other ongoing upgrades complete to avoid starvation
    for (VespaVersion version : controller().versionStatus().versions()) {
        if (version.confidence() == Confidence.broken)
            cancelUpgradesOf(applications().without(UpgradePolicy.canary).upgradingTo(version.versionNumber()), version.versionNumber() + " is broken");
    }
    // Canaries should always try the canary target
    cancelUpgradesOf(applications().with(UpgradePolicy.canary).upgrading().notUpgradingTo(canaryTarget), "Outdated target version for Canaries");
    // Cancel *failed* upgrades to earlier versions, as the new version may fix it
    String reason = "Failing on outdated version";
    cancelUpgradesOf(applications().with(UpgradePolicy.defaultPolicy).upgrading().failing().notUpgradingTo(defaultTarget), reason);
    cancelUpgradesOf(applications().with(UpgradePolicy.conservative).upgrading().failing().notUpgradingTo(conservativeTarget), reason);
    // Schedule the right upgrades
    canaryTarget.ifPresent(target -> upgrade(applications().with(UpgradePolicy.canary), target));
    defaultTarget.ifPresent(target -> upgrade(applications().with(UpgradePolicy.defaultPolicy), target));
    conservativeTarget.ifPresent(target -> upgrade(applications().with(UpgradePolicy.conservative), target));
}
Also used : Version(com.yahoo.component.Version) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion)

Example 35 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class JobStatus method withCompletion.

public JobStatus withCompletion(long runId, ApplicationVersion applicationVersion, Optional<DeploymentJobs.JobError> jobError, Instant completionTime, Controller controller) {
    Version version;
    String reason;
    if (type == DeploymentJobs.JobType.component) {
        // not triggered by us
        version = controller.systemVersion();
        reason = "Application commit";
    } else if (!lastTriggered.isPresent()) {
        throw new IllegalStateException("Got notified about completion of " + this + ", but that has neither been triggered nor deployed");
    } else {
        // TODO jvenstad: This is wrong, because triggering versions are not necessarily the same as deployed versions!
        version = lastTriggered.get().version();
        applicationVersion = lastTriggered.get().applicationVersion();
        reason = lastTriggered.get().reason();
    }
    JobRun thisCompletion = new JobRun(runId, version, applicationVersion, reason, completionTime);
    Optional<JobRun> firstFailing = this.firstFailing;
    if (jobError.isPresent() && !this.firstFailing.isPresent())
        firstFailing = Optional.of(thisCompletion);
    Optional<JobRun> lastSuccess = this.lastSuccess;
    if (!jobError.isPresent()) {
        lastSuccess = Optional.of(thisCompletion);
        firstFailing = Optional.empty();
    }
    return new JobStatus(type, jobError, lastTriggered, Optional.of(thisCompletion), firstFailing, lastSuccess);
}
Also used : Version(com.yahoo.component.Version)

Aggregations

Version (com.yahoo.component.Version)83 Test (org.junit.Test)46 Application (com.yahoo.vespa.hosted.controller.Application)32 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)30 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)25 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)25 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)24 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)22 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)17 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)15 ApplicationId (com.yahoo.config.provision.ApplicationId)11 Collections (java.util.Collections)11 List (java.util.List)11 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)10 Optional (java.util.Optional)10 Slime (com.yahoo.slime.Slime)9 Map (java.util.Map)9 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)7 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)7 URI (java.net.URI)7