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; }
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> ConsulServcies = Lists.newArrayList(); for (HealthService orgService : HealthServices) { Service org = orgService.getService(); ConsulService newService = ConsulService.newSalukiService()// .withAddress(org.getAddress())// .withName(org.getService())// .withId(org.getId())// .withPort(org.getPort().toString())// .withTags(org.getTags())// .build(); ConsulServcies.add(newService); } if (!ConsulServcies.isEmpty()) { ConsulServiceResp response = ConsulServiceResp.newResponse()// .withValue(ConsulServcies)// .withConsulIndex(orgResponse.getConsulIndex())// .withConsulLastContact(orgResponse.getConsulLastContact())// .withConsulKnowLeader(orgResponse.isConsulKnownLeader())// .build(); return response; } } return null; }
@Override public String getAppName() { return service.getService().getService(); }
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 String getAppName() { return service.getService().getService(); }
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; }