Search in sources :

Example 1 with ServiceNotFoundException

use of com.logicalclocks.servicediscoverclient.exceptions.ServiceNotFoundException 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)

Example 2 with ServiceNotFoundException

use of com.logicalclocks.servicediscoverclient.exceptions.ServiceNotFoundException in project hopsworks by logicalclocks.

the class ServiceDiscoveryController method getAnyAddressOfServiceWithDNS.

@Lock(LockType.READ)
public Service getAnyAddressOfServiceWithDNS(HopsworksService serviceName) throws ServiceDiscoveryException {
    ServiceQuery serviceQuery = ServiceQuery.of(constructServiceFQDN(serviceName), Collections.emptySet());
    Optional<Service> serviceOpt = getService(Type.DNS, serviceQuery).findAny();
    return serviceOpt.orElseThrow(() -> new ServiceNotFoundException("Could not find service with: " + serviceQuery));
}
Also used : 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)2 Service (com.logicalclocks.servicediscoverclient.service.Service)2 ServiceQuery (com.logicalclocks.servicediscoverclient.service.ServiceQuery)2 Lock (javax.ejb.Lock)2 DnsResolver (com.logicalclocks.servicediscoverclient.resolvers.DnsResolver)1