String servcieid = "null"; if (orgService.getService() != null) { servcieid = orgService.getService().getId();
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; }
String servcieid = "null"; if (orgService.getService() != null) { servcieid = orgService.getService().getId();
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; }
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 void addInstancesToList(List<ServiceInstance> instances, String serviceId, QueryParams queryParams) { String aclToken = properties.getAclToken(); Response<List<HealthService>> services; if (StringUtils.hasText(aclToken)) { services = client.getHealthServices(serviceId, this.properties.getDefaultQueryTag(), this.properties.isQueryPassing(), queryParams, aclToken); } else { services = client.getHealthServices(serviceId, this.properties.getDefaultQueryTag(), this.properties.isQueryPassing(), queryParams); } for (HealthService service : services.getValue()) { String host = findHost(service); Map<String, String> metadata = getMetadata(service); boolean secure = false; if (metadata.containsKey("secure")) { secure = Boolean.parseBoolean(metadata.get("secure")); } instances.add(new DefaultServiceInstance(service.getService().getId(), serviceId, host, service .getService().getPort(), secure, metadata)); } }
private void addInstancesToList(List<ServiceInstance> instances, String serviceId, QueryParams queryParams) { String aclToken = properties.getAclToken(); Response<List<HealthService>> services; if (StringUtils.hasText(aclToken)) { services = client.getHealthServices(serviceId, this.properties.getDefaultQueryTag(), this.properties.isQueryPassing(), queryParams, aclToken); } else { services = client.getHealthServices(serviceId, this.properties.getDefaultQueryTag(), this.properties.isQueryPassing(), queryParams); } for (HealthService service : services.getValue()) { String host = findHost(service); Map<String, String> metadata = getMetadata(service); boolean secure = false; if (metadata.containsKey("secure")) { secure = Boolean.parseBoolean(metadata.get("secure")); } instances.add(new DefaultServiceInstance(service.getService().getId(), serviceId, host, service .getService().getPort(), secure, metadata)); } }
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 getInstanceId() { return service.getService().getId(); } };
@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; }