/** * Retrieves the healthchecks for a state in a given datacenter with {@link io.advantageous.consul.domain.option.RequestOptions}. * <p> * GET /v1/health/state/{state}?dc={datacenter} * * @param status The state to query. * @param datacenter datacenter * @param tag tag * @param requestOptions The Query Options to use. * @return A {@link io.advantageous.consul.domain.ConsulResponse} containing a list of * {@link io.advantageous.consul.domain.HealthCheck} objects. */ public ConsulResponse<List<HealthCheck>> getChecksByState(final Status status, final String datacenter, final String tag, final RequestOptions requestOptions) { final URI uri = createURI("/state/" + status.getName()); final HttpRequestBuilder httpRequestBuilder = RequestUtils .getHttpRequestBuilder(datacenter, tag, requestOptions, ""); final HTTP.Response httpResponse = HTTP.getResponse(uri.toString() + "?" + httpRequestBuilder.paramString()); if (httpResponse.code() != 200) { die("Unable to retrieve the service", uri, httpResponse.code(), httpResponse.body()); } return RequestUtils.consulResponseList(HealthCheck.class, httpResponse); }
/** * Checks in with Consul. * * @param checkId The Check ID to check in. * @param status The current state of the Check. * @param note Any note to associate with the Check. */ public void check(String checkId, Status status, String note) { final URI uri = createURI("/check/" + status.getUri() + "/" + checkId); final HTTP.Response httpResponse = Str.isEmpty(note) ? HTTP.getResponse(uri.toString()) : HTTP.getResponse(uri.toString() + "?note=" + note); if (httpResponse.code() != 200) { notRegistered("Unable to perform check", uri, httpResponse.code(), httpResponse.statusMessageAsString(), httpResponse.body()); } }
/** * Checks in with Consul. * * @param checkId The Check ID to check in. * @param status The current state of the Check. * @param note Any note to associate with the Check. */ public void check(String checkId, Status status, String note) { final URI uri = createURI("/check/" + status.getUri() + "/" + checkId); final HTTP.Response httpResponse = Str.isEmpty(note) ? HTTP.getResponse(uri.toString()) : HTTP.getResponse(uri.toString() + "?note=" + note); if (httpResponse.code() != 200) { notRegistered("Unable to perform check", uri, httpResponse.code(), httpResponse.statusMessageAsString(), httpResponse.body()); } }
/** * Retrieves the healthchecks for a state in a given datacenter with {@link io.advantageous.consul.domain.option.RequestOptions}. * <p> * GET /v1/health/state/{state}?dc={datacenter} * * @param status The state to query. * @param datacenter datacenter * @param tag tag * @param requestOptions The Query Options to use. * @return A {@link io.advantageous.consul.domain.ConsulResponse} containing a list of * {@link io.advantageous.consul.domain.HealthCheck} objects. */ public ConsulResponse<List<HealthCheck>> getChecksByState(final Status status, final String datacenter, final String tag, final RequestOptions requestOptions) { final URI uri = createURI("/state/" + status.getName()); final HttpRequestBuilder httpRequestBuilder = RequestUtils .getHttpRequestBuilder(datacenter, tag, requestOptions, ""); final HTTP.Response httpResponse = HTTP.getResponse(uri.toString() + "?" + httpRequestBuilder.paramString()); if (httpResponse.code() != 200) { die("Unable to retrieve the service", uri, httpResponse.code(), httpResponse.body()); } return RequestUtils.consulResponseList(HealthCheck.class, httpResponse); }