Search in sources :

Example 1 with HostRegisterResponse

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;
}
Also used : HostRegisterResponse(com.spotify.helios.common.protocol.HostRegisterResponse) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) ExceptionMetered(com.codahale.metrics.annotation.ExceptionMetered) PUT(javax.ws.rs.PUT)

Aggregations

ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)1 Timed (com.codahale.metrics.annotation.Timed)1 HostRegisterResponse (com.spotify.helios.common.protocol.HostRegisterResponse)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1