Search in sources :

Example 1 with StringResponse

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

the class ApplicationApiHandler method deactivate.

private HttpResponse deactivate(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) {
    Application application = controller.applications().require(ApplicationId.from(tenantName, applicationName, instanceName));
    ZoneId zone = ZoneId.from(environment, region);
    Deployment deployment = application.deployments().get(zone);
    if (deployment == null) {
        // Attempt to deactivate application even if the deployment is not known by the controller
        controller.applications().deactivate(application, zone);
    } else {
        controller.applications().deactivate(application, deployment, false);
    }
    // TODO: Change to return JSON
    return new StringResponse("Deactivated " + path(TenantResource.API_PATH, tenantName, ApplicationResource.API_PATH, applicationName, EnvironmentResource.API_PATH, environment, "region", region, "instance", instanceName));
}
Also used : ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) StringResponse(com.yahoo.vespa.hosted.controller.restapi.StringResponse) Application(com.yahoo.vespa.hosted.controller.Application)

Example 2 with StringResponse

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

the class ApplicationApiHandler method restart.

/**
 * Schedule restart of deployment, or specific host in a deployment
 */
private HttpResponse restart(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) {
    DeploymentId deploymentId = new DeploymentId(ApplicationId.from(tenantName, applicationName, instanceName), ZoneId.from(environment, region));
    // TODO: Propagate all filters
    Optional<Hostname> hostname = Optional.ofNullable(request.getProperty("hostname")).map(Hostname::new);
    controller.applications().restart(deploymentId, hostname);
    // TODO: Change to return JSON
    return new StringResponse("Requested restart of " + path(TenantResource.API_PATH, tenantName, ApplicationResource.API_PATH, applicationName, EnvironmentResource.API_PATH, environment, "region", region, "instance", instanceName));
}
Also used : DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) Hostname(com.yahoo.vespa.hosted.controller.api.identifiers.Hostname) StringResponse(com.yahoo.vespa.hosted.controller.restapi.StringResponse)

Aggregations

StringResponse (com.yahoo.vespa.hosted.controller.restapi.StringResponse)2 Application (com.yahoo.vespa.hosted.controller.Application)1 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)1 Hostname (com.yahoo.vespa.hosted.controller.api.identifiers.Hostname)1 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)1 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)1