Search in sources :

Example 6 with VespaVersion

use of com.yahoo.vespa.hosted.controller.versions.VespaVersion in project vespa by vespa-engine.

the class DeploymentApiHandler method root.

private HttpResponse root(HttpRequest request) {
    Slime slime = new Slime();
    Cursor root = slime.setObject();
    Cursor platformArray = root.setArray("versions");
    for (VespaVersion version : controller.versionStatus().versions()) {
        Cursor versionObject = platformArray.addObject();
        versionObject.setString("version", version.versionNumber().toString());
        versionObject.setString("confidence", version.confidence().name());
        versionObject.setString("commit", version.releaseCommit());
        versionObject.setLong("date", version.committedAt().toEpochMilli());
        versionObject.setBool("controllerVersion", version.isSelfVersion());
        versionObject.setBool("systemVersion", version.isCurrentSystemVersion());
        Cursor configServerArray = versionObject.setArray("configServers");
        for (String configServerHostnames : version.configServerHostnames()) {
            Cursor configServerObject = configServerArray.addObject();
            configServerObject.setString("hostname", configServerHostnames);
        }
        Cursor failingArray = versionObject.setArray("failingApplications");
        for (ApplicationId id : version.statistics().failing()) {
            controller.applications().get(id).ifPresent(application -> {
                firstFailingOn(version.versionNumber(), application).ifPresent(firstFailing -> {
                    Cursor applicationObject = failingArray.addObject();
                    toSlime(applicationObject, application, request);
                    applicationObject.setString("failing", firstFailing.type().jobName());
                });
            });
        }
        Cursor productionArray = versionObject.setArray("productionApplications");
        for (ApplicationId id : version.statistics().production()) {
            controller.applications().get(id).ifPresent(application -> {
                int successes = productionSuccessesFor(version.versionNumber(), application);
                // Just upgraded to a newer version.
                if (successes == 0)
                    return;
                Cursor applicationObject = productionArray.addObject();
                toSlime(applicationObject, application, request);
                applicationObject.setLong("productionJobs", productionJobsFor(application));
                applicationObject.setLong("productionSuccesses", productionSuccessesFor(version.versionNumber(), application));
            });
        }
        Cursor runningArray = versionObject.setArray("deployingApplications");
        for (ApplicationId id : version.statistics().deploying()) {
            controller.applications().get(id).ifPresent(application -> {
                lastDeployingTo(version.versionNumber(), application).ifPresent(lastDeploying -> {
                    Cursor applicationObject = runningArray.addObject();
                    toSlime(applicationObject, application, request);
                    applicationObject.setString("running", lastDeploying.type().jobName());
                });
            });
        }
    }
    return new SlimeJsonResponse(slime);
}
Also used : SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 7 with VespaVersion

use of com.yahoo.vespa.hosted.controller.versions.VespaVersion in project vespa by vespa-engine.

the class ScrewdriverApiHandler method vespaVersion.

private HttpResponse vespaVersion() {
    VespaVersion version = controller.versionStatus().version(controller.systemVersion());
    if (version == null)
        return ErrorResponse.notFoundError("Information about the current system version is not available at this time");
    Slime slime = new Slime();
    Cursor cursor = slime.setObject();
    cursor.setString("version", version.versionNumber().toString());
    cursor.setString("sha", version.releaseCommit());
    cursor.setLong("date", version.committedAt().toEpochMilli());
    return new SlimeJsonResponse(slime);
}
Also used : SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor)

Aggregations

VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)7 Version (com.yahoo.component.Version)4 VersionStatus (com.yahoo.vespa.hosted.controller.versions.VersionStatus)3 Cursor (com.yahoo.slime.Cursor)2 Slime (com.yahoo.slime.Slime)2 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)2 SlimeJsonResponse (com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse)2 ArrayList (java.util.ArrayList)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Inject (com.google.inject.Inject)1 AbstractComponent (com.yahoo.component.AbstractComponent)1 Vtag (com.yahoo.component.Vtag)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 SystemName (com.yahoo.config.provision.SystemName)1 AthenzDomain (com.yahoo.vespa.athenz.api.AthenzDomain)1 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)1 Property (com.yahoo.vespa.hosted.controller.api.identifiers.Property)1 PropertyId (com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId)1 MetricsService (com.yahoo.vespa.hosted.controller.api.integration.MetricsService)1 AthenzClientFactory (com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactory)1