Search in sources :

Example 1 with CatalogService

use of com.ecwid.consul.v1.catalog.model.CatalogService in project motan by weibocom.

the class ConsulRegistryService method getServicesByGroup.

@Override
public List<String> getServicesByGroup(String dcGroup) {
    Set<String> services = new HashSet<String>();
    List<CatalogService> serviceList = getCatalogServicesByGroup(dcGroup);
    for (CatalogService service : serviceList) {
        services.add(formatServiceName(service));
    }
    return new ArrayList<String>(services);
}
Also used : CatalogService(com.ecwid.consul.v1.catalog.model.CatalogService)

Example 2 with CatalogService

use of com.ecwid.consul.v1.catalog.model.CatalogService 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;
    }
}
Also used : ConsulClient(com.ecwid.consul.v1.ConsulClient) CatalogService(com.ecwid.consul.v1.catalog.model.CatalogService)

Aggregations

CatalogService (com.ecwid.consul.v1.catalog.model.CatalogService)2 ConsulClient (com.ecwid.consul.v1.ConsulClient)1