Search in sources :

Example 1 with NotExistsException

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

the class ApplicationApiHandler method deployment.

private HttpResponse deployment(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) {
    ApplicationId id = ApplicationId.from(tenantName, applicationName, instanceName);
    Application application = controller.applications().get(id).orElseThrow(() -> new NotExistsException(id + " not found"));
    DeploymentId deploymentId = new DeploymentId(application.id(), ZoneId.from(environment, region));
    Deployment deployment = application.deployments().get(deploymentId.zoneId());
    if (deployment == null)
        throw new NotExistsException(application + " is not deployed in " + deploymentId.zoneId());
    Slime slime = new Slime();
    toSlime(slime.setObject(), deploymentId, deployment, request);
    return new SlimeJsonResponse(slime);
}
Also used : DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) NotExistsException(com.yahoo.vespa.hosted.controller.NotExistsException) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ApplicationId(com.yahoo.config.provision.ApplicationId) Slime(com.yahoo.slime.Slime) Application(com.yahoo.vespa.hosted.controller.Application)

Example 2 with NotExistsException

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

the class ApplicationApiHandler method rotationStatus.

private HttpResponse rotationStatus(String tenantName, String applicationName, String instanceName, String environment, String region) {
    ApplicationId applicationId = ApplicationId.from(tenantName, applicationName, instanceName);
    Application application = controller.applications().require(applicationId);
    if (!application.rotation().isPresent()) {
        throw new NotExistsException("global rotation does not exist for '" + environment + "." + region + "'");
    }
    Slime slime = new Slime();
    Cursor response = slime.setObject();
    Map<String, RotationStatus> rotationHealthStatus = controller.getHealthStatus(application.rotation().get().dnsName());
    for (String rotationEndpoint : rotationHealthStatus.keySet()) {
        if (rotationEndpoint.contains(toDns(environment)) && rotationEndpoint.contains(toDns(region))) {
            Cursor bcpStatusObject = response.setObject("bcpStatus");
            bcpStatusObject.setString("rotationStatus", rotationHealthStatus.getOrDefault(rotationEndpoint, RotationStatus.UNKNOWN).name());
        }
    }
    return new SlimeJsonResponse(slime);
}
Also used : SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) NotExistsException(com.yahoo.vespa.hosted.controller.NotExistsException) ApplicationId(com.yahoo.config.provision.ApplicationId) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor) RotationStatus(com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus) Application(com.yahoo.vespa.hosted.controller.Application)

Example 3 with NotExistsException

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

the class ApplicationApiHandler method application.

private HttpResponse application(String tenantName, String applicationName, HttpRequest request) {
    ApplicationId applicationId = ApplicationId.from(tenantName, applicationName, "default");
    Application application = controller.applications().get(applicationId).orElseThrow(() -> new NotExistsException(applicationId + " not found"));
    Slime slime = new Slime();
    toSlime(slime.setObject(), application, request);
    return new SlimeJsonResponse(slime);
}
Also used : SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) NotExistsException(com.yahoo.vespa.hosted.controller.NotExistsException) ApplicationId(com.yahoo.config.provision.ApplicationId) Slime(com.yahoo.slime.Slime) Application(com.yahoo.vespa.hosted.controller.Application)

Aggregations

ApplicationId (com.yahoo.config.provision.ApplicationId)3 Slime (com.yahoo.slime.Slime)3 Application (com.yahoo.vespa.hosted.controller.Application)3 NotExistsException (com.yahoo.vespa.hosted.controller.NotExistsException)3 SlimeJsonResponse (com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse)3 Cursor (com.yahoo.slime.Cursor)1 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)1 RotationStatus (com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus)1 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)1