com.evanlennick.retry4j.CallResults Java Examples
The following examples show how to use
com.evanlennick.retry4j.CallResults.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ATest.java From aws-s3-virusscan with Apache License 2.0 | 6 votes |
protected final <T> T retry(Callable<T> callable) { final Callable<T> wrapper = () -> { try { return callable.call(); } catch (final Exception e) { System.out.println("retry[] exception: " + e.getMessage()); e.printStackTrace(); throw e; } }; final RetryConfig config = new RetryConfigBuilder() .retryOnAnyException() .withMaxNumberOfTries(30) .withDelayBetweenTries(10, ChronoUnit.SECONDS) .withFixedBackoff() .build(); final CallResults<Object> results = new CallExecutor(config).execute(wrapper); return (T) results.getResult(); }
Example #2
Source File: ATest.java From aws-ec2-ssh with MIT License | 6 votes |
protected final <T> T retry(Callable<T> callable) { final Callable<T> wrapper = () -> { try { return callable.call(); } catch (final Exception e) { System.out.println("retry[] exception: " + e.getMessage()); e.printStackTrace(); throw e; } }; final RetryConfig config = new RetryConfigBuilder() .retryOnAnyException() .withMaxNumberOfTries(30) .withDelayBetweenTries(10, ChronoUnit.SECONDS) .withFixedBackoff() .build(); final CallResults<Object> results = new CallExecutor(config).execute(wrapper); return (T) results.getResult(); }
Example #3
Source File: ATest.java From aws-cf-templates with Apache License 2.0 | 6 votes |
protected final <T> T retry(Callable<T> callable) { final Callable<T> wrapper = () -> { try { return callable.call(); } catch (final Exception e) { System.out.println("retry[] exception: " + e.getMessage()); e.printStackTrace(); throw e; } }; final RetryConfig config = new RetryConfigBuilder() .retryOnAnyException() .withMaxNumberOfTries(30) .withDelayBetweenTries(10, ChronoUnit.SECONDS) .withFixedBackoff() .build(); final CallResults<Object> results = new CallExecutor(config).execute(wrapper); return (T) results.getResult(); }
Example #4
Source File: S3EventIterator.java From bender with Apache License 2.0 | 5 votes |
@Override public InternalEvent next() { updateCursor(); /* * Wrap reading next row in retry logic. This is because there is intermittent socket timeouts * when reading from S3 that cause the function to hang/fail. */ Callable<String> callable = () -> { return this.lineIterator.next(); }; String nextRow; try { CallResults<Object> results = new CallExecutor(this.config).execute(callable); nextRow = (String) results.getResult(); } catch (RetriesExhaustedException ree) { throw new RuntimeException(ree.getCallResults().getLastExceptionThatCausedRetry()); } catch (UnexpectedException ue) { throw ue; } /* * Construct the internal event */ return new S3InternalEvent(nextRow, this.context, this.arrivalTime, currentS3Entity.getObject().getKey(), currentS3Entity.getBucket().getName(), currentS3Entity.getObject().getVersionId()); }