@Override public void onReceive(Object message) { if (message instanceof Retry) { Retry retry = (Retry) message; retryPart(retry.getBlockIndex(), retry.getData(), retry.getAttempt()); } else { super.onReceive(message); } }
public void bulk(Resource resource, TrackingBytesArray data) throws IOException { Retry retry = retryPolicy.init(); int httpStatus = 0; do { Response response = execute(PUT, resource.bulk(), data); httpStatus = (retryFailedEntries(response.body(), data) ? HttpStatus.SERVICE_UNAVAILABLE : HttpStatus.OK); } while (data.length() > 0 && retry.retry(httpStatus)); }
@Test public void failureTheSuccessBeforeCountShouldNotThrowsException() throws Exception { retry.attempt( () -> { if (i++ == 0) { throw new IllegalStateException(); } }); }
@Test public void failureAfterCountShouldThrowException() throws Exception { expectedException.expect(IllegalStateException.class); retry.attempt( () -> { throw new IllegalStateException(); }); }