Search in sources :

Example 1 with ServiceDiscoveryClient

use of com.logicalclocks.servicediscoverclient.ServiceDiscoveryClient in project hopsworks by logicalclocks.

the class ServiceDiscoveryController method init.

@PostConstruct
public void init() {
    try {
        ServiceDiscoveryClient dnsClient = createClient(Type.DNS);
        clients.put(Type.DNS, dnsClient);
    } catch (ServiceDiscoveryException ex) {
        LOG.log(Level.SEVERE, "Failed to initialize Service Discovery client", ex);
    }
}
Also used : ServiceDiscoveryClient(com.logicalclocks.servicediscoverclient.ServiceDiscoveryClient) ServiceDiscoveryException(com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException) PostConstruct(javax.annotation.PostConstruct)

Example 2 with ServiceDiscoveryClient

use of com.logicalclocks.servicediscoverclient.ServiceDiscoveryClient in project hopsworks by logicalclocks.

the class Settings method getAlertManagerService.

private static Optional<Service> getAlertManagerService(String serviceFQDN) throws ServiceDiscoveryException {
    ServiceDiscoveryClient client = null;
    Optional<Service> services;
    try {
        client = new Builder(Type.DNS).build();
        String name = Strings.isNullOrEmpty(serviceFQDN) ? DEFAULT_ALERTMANAGER_FQDN : serviceFQDN;
        services = client.getService(ServiceQuery.of(name, Collections.emptySet())).findFirst();
    } finally {
        if (client != null) {
            client.close();
        }
    }
    return services;
}
Also used : ServiceDiscoveryClient(com.logicalclocks.servicediscoverclient.ServiceDiscoveryClient) Builder(com.logicalclocks.servicediscoverclient.Builder) UriBuilder(javax.ws.rs.core.UriBuilder) Service(com.logicalclocks.servicediscoverclient.service.Service)

Aggregations

ServiceDiscoveryClient (com.logicalclocks.servicediscoverclient.ServiceDiscoveryClient)2 Builder (com.logicalclocks.servicediscoverclient.Builder)1 ServiceDiscoveryException (com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)1 Service (com.logicalclocks.servicediscoverclient.service.Service)1 PostConstruct (javax.annotation.PostConstruct)1 UriBuilder (javax.ws.rs.core.UriBuilder)1