.withMaxRetries(retry.maxRetries()) .withMaxDuration(retry.maxDuration(), TimeUtil.chronoUnitToTimeUnit(retry.durationUnit())) .retryOn(retry.retryOn()); this.retryPolicy = new RetryPolicy().withMaxRetries(0); // no retries
@Override public RetryPolicy getRetryPolicy() { RetryPolicy retryPolicy = new RetryPolicy().withMaxRetries(configuration.getRetries()); if (configuration.isExponentialBackoffEnabled()) { retryPolicy = retryPolicy.withBackoff(configuration.getExponentialBackoffDelay(), configuration.getExponentialBackoffMaxDelay(), TimeUnit.SECONDS); } return retryPolicy; } }
TopicSchemaLoader(SchemaRepository schemaRepository, int retryCount, int threadPoolSize) { this.schemaRepository = schemaRepository; ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("topic-schema-loader-%d").build(); this.scheduler = Executors.newScheduledThreadPool(threadPoolSize, threadFactory); this.retryPolicy = new RetryPolicy() .withMaxRetries(retryCount) .retryIf(SchemaLoadingResult::isFailure); }
TopicMetadataLoader(BrokerMessageProducer brokerMessageProducer, int retryCount, long retryInterval, int threadPoolSize) { this.brokerMessageProducer = brokerMessageProducer; ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("topic-metadata-loader-%d").build(); this.scheduler = Executors.newScheduledThreadPool(threadPoolSize, threadFactory); this.retryPolicy = new RetryPolicy() .withMaxRetries(retryCount) .withDelay(retryInterval, TimeUnit.MILLISECONDS) .retryIf(MetadataLoadingResult::isFailure); }
protected RetryPolicy buildRetryPolicy() { RetryPolicy retryPolicy = new RetryPolicy().withMaxRetries(0); Properties userConfig = configurationGenerator.getUserConfig(); if (Boolean.parseBoolean((userConfig.getProperty(PARAM_RETRY_POLICY_ENABLED, "false")))) { int maxRetries = Integer.parseInt( userConfig.getProperty(PARAM_RETRY_POLICY_MAX_RETRIES, PARAM_RETRY_POLICY_DEFAULT_RETRIES)); int delay = Integer.parseInt( userConfig.getProperty(PARAM_RETRY_POLICY_DELAY_IN_MS, PARAM_POLICY_DEFAULT_DELAY_IN_MS)); retryPolicy = retryPolicy.retryOn(ConfigurationException.class).withMaxRetries(maxRetries).withDelay(delay, TimeUnit.MILLISECONDS); } return retryPolicy; }
public static RetryPolicy greedyRetryPolicy(long delayMs) { return new RetryPolicy() .retryOn(Arrays.asList( JedisException.class, DynoException.class, DynomiteClientDelegate.ClientDelegateException.class )) .withDelay(delayMs, TimeUnit.MILLISECONDS) .withMaxRetries(3); } }
private RetryPolicy createRetryPolicy(int retries, Predicate<HermesResponse> retryCondition, long retrySleepInMillis, long maxRetrySleepInMillis) { RetryPolicy retryPolicy = new RetryPolicy().withMaxRetries(retries) .retryIf(retryCondition::test); if (retrySleepInMillis > 0) { retryPolicy.withBackoff(retrySleepInMillis, maxRetrySleepInMillis, TimeUnit.MILLISECONDS); } return retryPolicy; }
/** Reset fileBackedOutputStream and retry if it fails. */ @SuppressWarnings("unchecked") private void reset() { RetryPolicy retryPolicy = new RetryPolicy() .retryOn(IOException.class) .withBackoff(INITIAL_RETRY_SLEEP, MAX_DELAY, INITIAL_RETRY_SLEEP_UNIT) .withMaxRetries(MAX_RETRY_ATTEMPTS); Failsafe.with(retryPolicy) .onFailedAttempt( throwable -> LOGGER.debug("failed to delete temporary file, will retry", throwable)) .onFailure(throwable -> LOGGER.debug("failed to delete temporary file", throwable)) .run(fileBackedOutputStream::reset); }
@Override public RetryPolicy getRetryPolicy() { RetryPolicy retryPolicy = new RetryPolicy().withMaxRetries(configuration.getRetries()); if (configuration.isExponentialBackoffEnabled()) { retryPolicy = retryPolicy.withBackoff(configuration.getExponentialBackoffDelay(), configuration.getExponentialBackoffMaxDelay(), TimeUnit.SECONDS); } return retryPolicy; } }
protected ComputationPolicy getComputationPolicy(PolicyDescriptor policyDescriptor) { if (policyDescriptor.klass != null) { if (!StreamComputationPolicy.class.isAssignableFrom(policyDescriptor.klass)) { throw new IllegalArgumentException("Cannot create policy: " + policyDescriptor.getId() + " for processor: " + this.getId() + ", class must implement StreamComputationPolicy"); } try { return policyDescriptor.klass.getDeclaredConstructor().newInstance().getPolicy(policyDescriptor); } catch (ReflectiveOperationException e) { throw new StreamRuntimeException( "Cannot create policy: " + policyDescriptor.getId() + " for processor: " + this.getId(), e); } } RetryPolicy retryPolicy = new RetryPolicy().withMaxRetries(policyDescriptor.maxRetries) .withBackoff(policyDescriptor.delay.toMillis(), policyDescriptor.maxDelay.toMillis(), TimeUnit.MILLISECONDS); return new ComputationPolicyBuilder().retryPolicy(retryPolicy) .batchPolicy(policyDescriptor.batchCapacity, policyDescriptor.batchThreshold) .continueOnFailure(policyDescriptor.continueOnFailure) .build(); }
failSafePolicy.withMaxRetries(policy.getMaxAttempts());
failSafePolicy.withMaxRetries(policy.getMaxAttempts());
failSafePolicy.withMaxRetries(policy.getMaxAttempts());
failSafePolicy.withMaxRetries(policy.getMaxAttempts());
failSafePolicy.withMaxRetries(policy.getMaxAttempts());
settings.setPolicy(SCROLLER_NAME, scrollerPolicy); RetryPolicy retryPolicy = new RetryPolicy().withMaxRetries( Integer.parseInt(confService.getProperty(BULK_STATUS_MAX_RETRIES_PROPERTY, DEFAULT_STATUS_MAX_RETRIES))) .withBackoff(
private void setPassword(String rootUrl) throws IOException, ClientProtocolException { HttpClient client = createClient("neo4j"); RetryPolicy retryPolicy = new RetryPolicy() .retryOn(NoHttpResponseException.class) .withDelay(1, TimeUnit.SECONDS) .withMaxRetries(3); Failsafe.with(retryPolicy).run(() -> callSetPassword(rootUrl, client)); }
public TreasureDataSender(Config config) { this.config = config; this.retryPolicy = new RetryPolicy(). retryOn(ex -> { if (ex == null) { // Success. Shouldn't retry. return false; } ErrorHandler errorHandler = config.getErrorHandler(); if (errorHandler != null) { errorHandler.handle(ex); } if (ex instanceof InterruptedException || ex instanceof NonRetryableException) { return false; } return true; }). withBackoff( getRetryInternalMs(), getMaxRetryInternalMs(), TimeUnit.MILLISECONDS, getRetryFactor()). withMaxRetries(getRetryMax()); this.client = buildClient(); }
/** * Pull the given virtual resource. * * @param virtualResource the virtual resource * @param image the image */ void pullImage(VirtualResource virtualResource, String image) { RetryPolicy retryPolicy = new RetryPolicy() .retryOn(Throwable.class) .withDelay(virtualResource.delay(), virtualResource.unit()) .withMaxRetries(virtualResource.maxRetries()); Failsafe.with(retryPolicy) .onRetry(throwable -> LoggingUtil.INSTANCE.warn( "Retrying pull request of image '{}'", image, throwable)) .onFailure(throwable -> LoggingUtil.INSTANCE.error( "Image image '{}' could not be pulled: ", image, throwable)) .run(() -> client.pull(image, new AnsiProgressHandler())); }