use of com.yahoo.vespa.orchestrator.restapi.wire.PatchHostResponse in project vespa by vespa-engine.
the class HostResourceTest method patch_works.
@Test
public void patch_works() throws OrchestrationException {
Orchestrator orchestrator = mock(Orchestrator.class);
HostResource hostResource = new HostResource(orchestrator, uriInfo);
String hostNameString = "hostname";
PatchHostRequest request = new PatchHostRequest();
request.state = "NO_REMARKS";
PatchHostResponse response = hostResource.patch(hostNameString, request);
assertEquals(response.description, "ok");
verify(orchestrator, times(1)).setNodeStatus(new HostName(hostNameString), HostStatus.NO_REMARKS);
}
use of com.yahoo.vespa.orchestrator.restapi.wire.PatchHostResponse in project vespa by vespa-engine.
the class HostResource method patch.
@Override
public PatchHostResponse patch(String hostNameString, PatchHostRequest request) {
HostName hostName = new HostName(hostNameString);
if (request.state != null) {
HostStatus state;
try {
state = HostStatus.valueOf(request.state);
} catch (IllegalArgumentException dummy) {
throw new BadRequestException("Bad state in request: '" + request.state + "'");
}
try {
orchestrator.setNodeStatus(hostName, state);
} catch (HostNameNotFoundException e) {
log.log(LogLevel.INFO, "Host not found: " + hostName);
throw new NotFoundException(e);
} catch (OrchestrationException e) {
String message = "Failed to set " + hostName + " to " + state + ": " + e.getMessage();
log.log(LogLevel.INFO, message, e);
throw new InternalServerErrorException(message);
}
}
PatchHostResponse response = new PatchHostResponse();
response.description = "ok";
return response;
}
Aggregations