@Override public List<JSONObject> getNodes(String dcGroup, String service, String nodeType) { List<JSONObject> results = new ArrayList<JSONObject>(); List<Check> checks = consulClient.getHealthChecksForService(getGroupName(dcGroup), new QueryParams(getDcName(dcGroup))).getValue(); for (Check check : checks) { String serviceId = check.getServiceId(); String[] strings = serviceId.split("-"); if (strings[1].equals(service)) { Check.CheckStatus status = check.getStatus(); JSONObject node = new JSONObject(); if (nodeType.equals(status.toString())) { node.put("host", strings[0]); node.put("info", null); results.add(node); } } } return results; }
@Override public Response<List<Check>> getHealthChecksState(Check.CheckStatus checkStatus, QueryParams queryParams) { String status = checkStatus == null ? "any" : checkStatus.name().toLowerCase(); RawResponse rawResponse = rawClient.makeGetRequest("/v1/health/state/" + status, queryParams); if (rawResponse.getStatusCode() == 200) { List<Check> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<Check>>() { }.getType()); return new Response<List<Check>>(value, rawResponse); } else { throw new OperationException(rawResponse); } }
@Override public Response<List<Check>> getHealthChecksState(Check.CheckStatus checkStatus, QueryParams queryParams) { String status = checkStatus == null ? "any" : checkStatus.name().toLowerCase(); RawResponse rawResponse = rawClient.makeGetRequest("/v1/health/state/" + status, queryParams); if (rawResponse.getStatusCode() == 200) { List<Check> value = GsonFactory.getGson().fromJson(rawResponse.getContent(), new TypeToken<List<Check>>() { }.getType()); return new Response<List<Check>>(value, rawResponse); } else { throw new OperationException(rawResponse); } }