@Override public Host apply(HealthService info) { String hostName = ConsulHelper.findHost(info); Map<String, String> metaData = ConsulHelper.getMetadata(info); Host.Status status = Host.Status.Up; for (com.ecwid.consul.v1.health.model.Check check : info.getChecks()) { if (check.getStatus() == Check.CheckStatus.CRITICAL) { status = Host.Status.Down; break; } } String rack = null; try { if (metaData.containsKey("cloud") && StringUtils.equals(metaData.get("cloud"), "aws")) { rack = metaData.get("availability-zone"); } else { rack = metaData.get("rack"); } } catch (Throwable t) { Logger.error("Error getting rack for host " + info.getNode(), t); } if (rack == null) { Logger.error("Rack wasn't found for host:" + info.getNode() + " there may be issues matching it up to the token map"); } Host host = new Host(hostName, hostName, info.getService().getPort(), rack, String.valueOf(metaData.get("datacenter")), status); return host; } }));
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(); }
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 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 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(); }