use of com.spotify.helios.common.protocol.HostRegisterResponse in project helios by spotify.
the class HostsResource method put.
/**
* Registers a host with the cluster. The {@code host} is the name of the host. It SHOULD be
* the hostname of the machine. The {@code id} should be a persistent value for the host, but
* initially randomly generated. This way we don't have two machines claiming to be the same
* host: at least by accident.
*
* @param host The host to register.
* @param id The randomly generated ID for the host.
*
* @return The response.
*/
@PUT
@Path("{host}")
@Produces(APPLICATION_JSON)
@Timed
@ExceptionMetered
public Response.Status put(@PathParam("host") final String host, @QueryParam("id") @DefaultValue("") final String id) {
if (isNullOrEmpty(id)) {
throw badRequest(new HostRegisterResponse(HostRegisterResponse.Status.INVALID_ID, host));
}
model.registerHost(host, id);
log.info("added host {}", host);
return Response.Status.OK;
}
Aggregations