public List<LookupResult> dnsSrvLookup(String url) { return DnsSrvResolvers.newBuilder() .cachingLookups(true) .retainingDataOnFailures(true) .metered(dnsReporter) .dnsLookupTimeoutMillis(1000) .build() .resolve(url); } }
private boolean areAllInitial(List<ChangeNotifier<T>> changeNotifiers) { for (final ChangeNotifier<T> changeNotifier : changeNotifiers) { if (!ChangeNotifiers.isInitialEmptyData(changeNotifier.current())) { return false; } } return true; } }
public static <T> RunnableChangeNotifier<T> direct(AtomicReference<Set<T>> recordsHolder) { return new DirectChangeNotifier<T>(supplierFromRef(recordsHolder)); }
private synchronized void checkChange() { Set<T> currentRecords = aggregateSet(); if (ChangeNotifiers.isNoLongerInitial(currentRecords, records) || !currentRecords.equals(records)) { final ChangeNotification<T> changeNotification = newChangeNotification(currentRecords, records); records = currentRecords; fireRecordsUpdated(changeNotification); } }
private Set<T> aggregateSet() { if (areAllInitial(changeNotifiers)) { return ChangeNotifiers.initialEmptyDataInstance(); } ImmutableSet.Builder<T> records = ImmutableSet.builder(); for (final ChangeNotifier<T> changeNotifier : changeNotifiers) { records.addAll(changeNotifier.current()); } return records.build(); }
public DnsSrvResolverBuilder retentionDurationMillis(long retentionDurationMillis) { return new DnsSrvResolverBuilder(reporter, retainData, cacheLookups, dnsLookupTimeoutMillis, retentionDurationMillis); } }
@Override public Set<T> previous() { return unmodifiable(previous); } }
@Override public RunnableChangeNotifier<T> create(String fqdn) { return new ServiceResolvingChangeNotifier<T>(resolver, fqdn, resultTransformer, errorHandler); } };
public DnsSrvWatcherBuilder<T> usingExecutor(ScheduledExecutorService scheduledExecutorService) { return new DnsSrvWatcherBuilder<T>(resolver, resultTransformer, polling, pollingInterval, pollingIntervalUnit, errorHandler, dnsSrvWatcherFactory, scheduledExecutorService); }
@Override protected void closeImplementation() { for (ChangeNotifier<T> provider : changeNotifiers) { provider.close(); } }
@Override public Lookup call() { return delegate.forName(fqdn); } }
@Override public DnsSrvWatcher<T> create(ChangeNotifierFactory<T> changeNotifierFactory) { return new PollingDnsSrvWatcher<T>(changeNotifierFactory, executor, pollingInterval, pollingIntervalUnit); } };
private boolean areAllInitial(List<ChangeNotifier<T>> changeNotifiers) { for (final ChangeNotifier<T> changeNotifier : changeNotifiers) { if (!ChangeNotifiers.isInitialEmptyData(changeNotifier.current())) { return false; } } return true; } }
public static <T> RunnableChangeNotifier<T> direct(AtomicReference<Set<T>> recordsHolder) { return new DirectChangeNotifier<T>(supplierFromRef(recordsHolder)); }
public DnsSrvResolverBuilder cachingLookups(boolean cacheLookups) { return new DnsSrvResolverBuilder(reporter, retainData, cacheLookups, dnsLookupTimeoutMillis, retentionDurationMillis); }
@Override public Set<T> current() { return unmodifiable(current); }
@Override public RunnableChangeNotifier<T> create(String fqdn) { return new ServiceResolvingChangeNotifier<T>(resolver, fqdn, resultTransformer, errorHandler); } };
public DnsSrvWatcherBuilder<T> usingExecutor(ScheduledExecutorService scheduledExecutorService) { return new DnsSrvWatcherBuilder<T>(resolver, resultTransformer, polling, pollingInterval, pollingIntervalUnit, errorHandler, dnsSrvWatcherFactory, scheduledExecutorService); }
@Override protected void closeImplementation() { for (ChangeNotifier<T> provider : changeNotifiers) { provider.close(); } }
public DnsSrvResolverBuilder dnsLookupTimeoutMillis(long dnsLookupTimeoutMillis) { return new DnsSrvResolverBuilder(reporter, retainData, cacheLookups, dnsLookupTimeoutMillis, retentionDurationMillis, servers); }