use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class HealthServiceServerListFilterTests method newServer.
private ConsulServer newServer(Check.CheckStatus checkStatus) {
HealthService healthService = new HealthService();
HealthService.Node node = new HealthService.Node();
node.setAddress("nodeaddr" + checkStatus.name());
node.setNode("nodenode" + checkStatus.name());
healthService.setNode(node);
HealthService.Service service = new HealthService.Service();
service.setAddress("serviceaddr" + checkStatus.name());
service.setId("serviceid" + checkStatus.name());
service.setPort(8080);
service.setService("serviceservice" + checkStatus.name());
healthService.setService(service);
ArrayList<Check> checks = new ArrayList<>();
Check check = new Check();
check.setStatus(checkStatus);
checks.add(check);
healthService.setChecks(checks);
return new ConsulServer(healthService);
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project cloudbreak by hortonworks.
the class ConsulServiceCheckerTask method checkStatus.
@Override
public boolean checkStatus(ConsulContext consulContext) {
String serviceName = consulContext.getTargets().get(0);
ConsulClient client = consulContext.getConsulClient();
LOGGER.info("Checking consul service registration of '{}'", serviceName);
List<CatalogService> service = ConsulUtils.getService(Collections.singletonList(client), serviceName);
if (service.isEmpty()) {
LOGGER.info("Consul service '{}' is not registered yet", serviceName);
return false;
} else {
LOGGER.info("Consul service '{}' found on '{}'", serviceName, service.get(0).getNode());
return true;
}
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project motan by weibocom.
the class ConsulRegistryService method getGroups.
@Override
public List<String> getGroups() {
List<String> groups = new ArrayList<String>();
for (String dc : getDatacenters()) {
QueryParams queryParams = new QueryParams(dc);
Map<String, List<String>> serviceMap = consulClient.getCatalogServices(queryParams).getValue();
serviceMap.remove("consul");
for (String service : serviceMap.keySet()) {
groups.add(formatGroupName(dc, service));
}
}
return groups;
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project motan by weibocom.
the class ConsulEcwidClient method convertService.
private NewService convertService(ConsulService service) {
NewService newService = new NewService();
newService.setAddress(service.getAddress());
newService.setId(service.getId());
newService.setName(service.getName());
newService.setPort(service.getPort());
newService.setTags(service.getTags());
NewService.Check check = new NewService.Check();
check.setTtl(service.getTtl() + "s");
newService.setCheck(check);
return newService;
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project motan by weibocom.
the class ConsulEcwidClient method registerService.
@Override
public void registerService(ConsulService service) {
NewService newService = convertService(service);
client.agentServiceRegister(newService);
}
Aggregations