Search in sources :

Example 6 with UpdateHostResponse

use of com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse in project vespa by vespa-engine.

the class OrchestratorImplTest method testResumeCallWithFailureReason.

@Test(expected = OrchestratorException.class)
public void testResumeCallWithFailureReason() {
    when(configServerApi.delete(OrchestratorImpl.ORCHESTRATOR_PATH_PREFIX_HOST_API + "/" + hostName + "/suspended", UpdateHostResponse.class)).thenReturn(new UpdateHostResponse(hostName, new HostStateChangeDenialReason("hostname", "fail")));
    orchestrator.resume(hostName);
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) HostStateChangeDenialReason(com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason) Test(org.junit.Test)

Example 7 with UpdateHostResponse

use of com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse in project vespa by vespa-engine.

the class OrchestratorImpl method resume.

@Override
public void resume(final String hostName) {
    UpdateHostResponse response;
    try {
        String path = getSuspendPath(hostName);
        response = configServerApi.delete(path, UpdateHostResponse.class);
    } catch (HttpException.NotFoundException n) {
        throw new OrchestratorNotFoundException("Failed to resume " + hostName + ", host not found");
    } catch (HttpException e) {
        throw new OrchestratorException("Failed to suspend " + hostName + ": " + e.toString());
    } catch (Exception e) {
        throw new RuntimeException("Got error on resume", e);
    }
    Optional.ofNullable(response.reason()).ifPresent(reason -> {
        throw new OrchestratorException(reason.message());
    });
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException)

Example 8 with UpdateHostResponse

use of com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse in project vespa by vespa-engine.

the class OrchestratorImpl method suspend.

@Override
public void suspend(final String hostName) {
    UpdateHostResponse response;
    try {
        response = configServerApi.put(getSuspendPath(hostName), Optional.empty(), /* body */
        UpdateHostResponse.class);
    } catch (HttpException.NotFoundException n) {
        throw new OrchestratorNotFoundException("Failed to suspend " + hostName + ", host not found");
    } catch (HttpException e) {
        throw new OrchestratorException("Failed to suspend " + hostName + ": " + e.toString());
    } catch (Exception e) {
        throw new RuntimeException("Got error on suspend", e);
    }
    Optional.ofNullable(response.reason()).ifPresent(reason -> {
        throw new OrchestratorException(reason.message());
    });
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException)

Aggregations

UpdateHostResponse (com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse)8 Test (org.junit.Test)5 HostStateChangeDenialReason (com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason)3 HttpException (com.yahoo.vespa.hosted.node.admin.configserver.HttpException)2 WebApplicationException (javax.ws.rs.WebApplicationException)1