qbit/service-discovery/src/main/java/io/advantageous/qbit/service/discovery/dns/DnsServiceDiscoveryProvider.java
@Override
    public List<EndpointDefinition> loadServices(final String serviceName) {

        if (debug) logger.debug("Loading Service {}", serviceName);

        final CountDownLatch countDownLatch = new CountDownLatch(1);

        final AtomicReference<List<EndpointDefinition>> endPointsRef = new AtomicReference<>();

        final AtomicReference<Throwable> exceptionAtomicReference = new AtomicReference<>();

        dnsSupport.loadServiceEndpointsByServiceName(CallbackBuilder.newCallbackBuilder()
                .withListCallback(EndpointDefinition.class,
                        endpointDefinitions ->
                        {

                            endPointsRef.set(endpointDefinitions);
                            countDownLatch.countDown();

                        }).withErrorHandler(exceptionAtomicReference::set)
                .build(), serviceName);

        try {
            if (debug) logger.debug("Waiting for load services {} {}", timeout, timeUnit);

            countDownLatch.await(timeout, timeUnit);
        } catch (InterruptedException e) {
            throw new IllegalStateException("DNS Timeout", e);
        }


        if (exceptionAtomicReference.get() != null) {
            logger.error("DnsServiceDiscoveryProvider.loadServices EXCEPTION", exceptionAtomicReference.get());
            throw new IllegalStateException("Unable to read from DNS", exceptionAtomicReference.get());
        } else {

            if (debug) logger.debug("DnsServiceDiscoveryProvider.loadServices SUCCESS");
            return endPointsRef.get();
        }

    }
@Override
    public List<EndpointDefinition> loadServices(final String serviceName) {

        if (debug) logger.debug("Loading Service {}", serviceName);

        final CountDownLatch countDownLatch = new CountDownLatch(1);

        final AtomicReference<List<EndpointDefinition>> endPointsRef = new AtomicReference<>();

        final AtomicReference<Throwable> exceptionAtomicReference = new AtomicReference<>();

        dnsSupport.loadServiceEndpointsByServiceName(CallbackBuilder.newCallbackBuilder()
                .withListCallback(EndpointDefinition.class,
                        endpointDefinitions ->
                        {

                            endPointsRef.set(endpointDefinitions);
                            countDownLatch.countDown();

                        }).withErrorHandler(exceptionAtomicReference::set)
                .build(), serviceName);

        try {
            if (debug) logger.debug("Waiting for load services {} {}", timeout, timeUnit);

            countDownLatch.await(timeout, timeUnit);
        } catch (InterruptedException e) {
            throw new IllegalStateException("DNS Timeout", e);
        }


        if (exceptionAtomicReference.get() != null) {
            logger.error("DnsServiceDiscoveryProvider.loadServices EXCEPTION", exceptionAtomicReference.get());
            throw new IllegalStateException("Unable to read from DNS", exceptionAtomicReference.get());
        } else {

            if (debug) logger.debug("DnsServiceDiscoveryProvider.loadServices SUCCESS");
            return endPointsRef.get();
        }

    }
Load the services.

@param serviceName serviceName
@return list of EndpointDefinition