} catch (Exception e) { String servcieid = "null"; if (orgService.getService() != null) { servcieid = orgService.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 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 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; }
@Override public String getInstanceId() { return service.getService().getId(); } };
@Override public String getAppName() { return service.getService().getService(); }
@Override public String getInstanceId() { return service.getService().getId(); } };
@Override public String getAppName() { return service.getService().getService(); }
@Override public List<Server> getFilteredListOfServers(List<Server> servers) { Set<String> liveNodes = filteringAgentClient.getAliveAgentsAddresses(); List<Server> filteredServers = new ArrayList<>(); for (Server server : servers) { ConsulServer consulServer = ConsulServer.class.cast(server); if (liveNodes.contains(consulServer.getHealthService().getService().getAddress())) { filteredServers.add(server); } } return filteredServers; } }
@Override public List<Server> getFilteredListOfServers(List<Server> servers) { Set<String> liveNodes = filteringAgentClient.getAliveAgentsAddresses(); List<Server> filteredServers = new ArrayList<>(); for (Server server : servers) { ConsulServer consulServer = ConsulServer.class.cast(server); if (liveNodes.contains(consulServer.getHealthService().getService().getAddress())) { filteredServers.add(server); } } return filteredServers; } }
public static Map<String, String> getMetadata(HealthService healthService) { return getMetadata(healthService.getService().getTags()); }
public static Map<String, String> getMetadata(HealthService healthService) { return getMetadata(healthService.getService().getTags()); }
public static Map<String, String> getMetadata(HealthService healthService) { return getMetadata(healthService.getService().getTags()); }
public List<URL> getProviderUrls(String serviceName) { List<URL> urls = new ArrayList<>(); Response<List<HealthService>> healthServices = consulClient.getHealthServices(serviceName, true, null); for (HealthService healthService : healthServices.getValue()) { urls.add(URL.valueOf(healthService.getService().getAddress())); } return urls; } }
public List<URL> getProviderUrls(String serviceName) { List<URL> urls = new ArrayList<>(); Response<List<HealthService>> healthServices = consulClient.getHealthServices(serviceName, true, null); for (HealthService healthService : healthServices.getValue()) { urls.add(URL.valueOf(healthService.getService().getAddress())); } return urls; } }
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(); }
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; }