private ConsulService convertToConsulService(HealthService healthService) { ConsulService service = new ConsulService(); Service org = healthService.getService(); service.setAddress(org.getAddress()); service.setId(org.getId()); service.setName(org.getService()); service.setPort(org.getPort()); service.setTags(org.getTags()); return service; }
@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; }
} catch (Exception e) { String servcieid = "null"; if (orgService.getService() != null) { servcieid = orgService.getService().getId();
public static String findHost(HealthService healthService) { HealthService.Service service = healthService.getService(); HealthService.Node node = healthService.getNode(); if (StringUtils.isNotBlank(service.getAddress())) { return service.getAddress(); } else if (StringUtils.isNotBlank(node.getAddress())) { return node.getAddress(); } return node.getNode(); }
public static Map<String, String> getMetadata(HealthService healthService) { return getMetadata(healthService.getService().getTags()); }
@Override public String getAppName() { return service.getService().getService(); }
public ConsulServiceResp lookupHealthService(String serviceName, long lastConsulIndex) { QueryParams queryParams = new QueryParams(ConsulConstants.CONSUL_BLOCK_TIME_SECONDS, lastConsulIndex); Response<List<HealthService>> orgResponse = client.getHealthServices(serviceName, true, queryParams); if (orgResponse != null && orgResponse.getValue() != null && !orgResponse.getValue().isEmpty()) { List<HealthService> healthServices = orgResponse.getValue(); List<ConsulService> consulServices = Lists.newArrayList(); for (HealthService orgService : healthServices) { Service org = orgService.getService(); ConsulService newService = ConsulService.newService()// .withAddress(org.getAddress())// .withName(org.getService())// .withId(org.getId())// .withPort(org.getPort().toString())// .withTags(org.getTags())// .build(); consulServices.add(newService); } if (!consulServices.isEmpty()) { ConsulServiceResp response = ConsulServiceResp.newResponse()// .withValue(consulServices)// .withConsulIndex(orgResponse.getConsulIndex())// .withConsulLastContact(orgResponse.getConsulLastContact())// .withConsulKnowLeader(orgResponse.isConsulKnownLeader())// .build(); return response; } } return null; }
private static String findHost(HealthService healthService) { HealthService.Service service = healthService.getService(); HealthService.Node node = healthService.getNode(); if (StringUtils.isNotBlank(service.getAddress())) { return service.getAddress(); } else if (StringUtils.isNotBlank(node.getAddress())) { return node.getAddress(); } return node.getNode(); }
public static Map<String, String> getMetadata(HealthService healthService) { return getMetadata(healthService.getService().getTags()); }
@Override public String getInstanceId() { return service.getService().getId(); } };
@Override public String getAppName() { return service.getService().getService(); }
public ConsulServiceResp lookupHealthService(String serviceName, long lastConsulIndex) { QueryParams queryParams = new QueryParams(ConsulConstants.CONSUL_BLOCK_TIME_SECONDS, lastConsulIndex); Response<List<HealthService>> orgResponse = client.getHealthServices(serviceName, true, queryParams); if (orgResponse != null && orgResponse.getValue() != null && !orgResponse.getValue().isEmpty()) { List<HealthService> healthServices = orgResponse.getValue(); List<ConsulService> consulServices = Lists.newArrayList(); for (HealthService orgService : healthServices) { Service org = orgService.getService(); ConsulService newService = ConsulService.newService()// .withAddress(org.getAddress())// .withName(org.getService())// .withId(org.getId())// .withPort(org.getPort().toString())// .withTags(org.getTags())// .build(); consulServices.add(newService); } if (!consulServices.isEmpty()) { ConsulServiceResp response = ConsulServiceResp.newResponse()// .withValue(consulServices)// .withConsulIndex(orgResponse.getConsulIndex())// .withConsulLastContact(orgResponse.getConsulLastContact())// .withConsulKnowLeader(orgResponse.isConsulKnownLeader())// .build(); return response; } } return null; }
public static String findHost(HealthService healthService) { HealthService.Service service = healthService.getService(); HealthService.Node node = healthService.getNode(); if (StringUtils.hasText(service.getAddress())) { return fixIPv6Address(service.getAddress()); } else if (StringUtils.hasText(node.getAddress())) { return fixIPv6Address(node.getAddress()); } return node.getNode(); }
public static Map<String, String> getMetadata(HealthService healthService) { return getMetadata(healthService.getService().getTags()); }
@Override public String getInstanceId() { return service.getService().getId(); } };
private ConsulService convertToConsulService(HealthService healthService) { ConsulService service = new ConsulService(); Service org = healthService.getService(); service.setAddress(org.getAddress()); service.setId(org.getId()); service.setName(org.getService()); service.setPort(org.getPort()); service.setTags(org.getTags()); return service; }
public static String findHost(HealthService healthService) { HealthService.Service service = healthService.getService(); HealthService.Node node = healthService.getNode(); if (StringUtils.hasText(service.getAddress())) { return fixIPv6Address(service.getAddress()); } else if (StringUtils.hasText(node.getAddress())) { return fixIPv6Address(node.getAddress()); } return node.getNode(); }