Search in sources :

Example 1 with Predicate

use of net.jodah.failsafe.function.Predicate in project ddf by codice.

the class ContentProducerDataAccessObject method waitForAvailableSource.

private void waitForAvailableSource(CatalogFramework catalogFramework) throws SourceUnavailableException {
    RetryPolicy retryPolicy = new RetryPolicy().withDelay(3, TimeUnit.SECONDS).withMaxDuration(3, TimeUnit.MINUTES).retryIf((Predicate<Set>) Set::isEmpty).retryIf((Set<SourceDescriptor> result) -> !result.stream().findFirst().get().isAvailable());
    Failsafe.with(retryPolicy).get(() -> catalogFramework.getSourceInfo(new SourceInfoRequestLocal(false)).getSourceInfo());
}
Also used : Set(java.util.Set) SourceInfoRequestLocal(ddf.catalog.operation.impl.SourceInfoRequestLocal) RetryPolicy(net.jodah.failsafe.RetryPolicy) Predicate(net.jodah.failsafe.function.Predicate)

Aggregations

SourceInfoRequestLocal (ddf.catalog.operation.impl.SourceInfoRequestLocal)1 Set (java.util.Set)1 RetryPolicy (net.jodah.failsafe.RetryPolicy)1 Predicate (net.jodah.failsafe.function.Predicate)1