Search in sources :

Example 1 with DnsResolver

use of com.logicalclocks.servicediscoverclient.resolvers.DnsResolver in project hopsworks by logicalclocks.

the class ServiceDiscoveryController method getAnyAddressOfServiceWithDNSSRVOnly.

@Lock(LockType.READ)
public Service getAnyAddressOfServiceWithDNSSRVOnly(HopsworksService serviceName) throws ServiceDiscoveryException {
    ServiceQuery serviceQuery = ServiceQuery.of(constructServiceFQDN(serviceName), Collections.emptySet());
    DnsResolver client = (DnsResolver) getClient(Type.DNS);
    Optional<Service> serviceOpt = client.getServiceSRVOnly(serviceQuery).findAny();
    return serviceOpt.orElseThrow(() -> new ServiceNotFoundException("Could not find service with: " + serviceQuery));
}
Also used : DnsResolver(com.logicalclocks.servicediscoverclient.resolvers.DnsResolver) ServiceNotFoundException(com.logicalclocks.servicediscoverclient.exceptions.ServiceNotFoundException) Service(com.logicalclocks.servicediscoverclient.service.Service) ServiceQuery(com.logicalclocks.servicediscoverclient.service.ServiceQuery) Lock(javax.ejb.Lock)

Aggregations

ServiceNotFoundException (com.logicalclocks.servicediscoverclient.exceptions.ServiceNotFoundException)1 DnsResolver (com.logicalclocks.servicediscoverclient.resolvers.DnsResolver)1 Service (com.logicalclocks.servicediscoverclient.service.Service)1 ServiceQuery (com.logicalclocks.servicediscoverclient.service.ServiceQuery)1 Lock (javax.ejb.Lock)1