@Test public void failure() throws IOException { AtomicInteger count = new AtomicInteger(0); try { RetryUtils.retry("failure test", () -> { count.incrementAndGet(); throw new IOException(Integer.toString(count.get())); }, new CountingRetry(10)); fail("Expected an exception to be thrown"); } catch (IOException e) { assertEquals("11", e.getMessage()); } assertEquals(11, count.get()); }
public static void retry(String action, RunnableThrowsIOException f, RetryPolicy policy) throws IOException { IOException e = null; while (policy.attempt()) { try { f.run(); return; } catch (IOException ioe) { e = ioe; LOG.warn("Failed to {} (attempt {}): {}", action, policy.getAttemptCount(), e.toString()); } } throw e; }
RetryUtils { public static void retry(String action, RunnableThrowsIOException f, RetryPolicy policy) throws IOException { IOException e = null; while (policy.attempt()) { try { f.run(); return; } catch (IOException ioe) { e = ioe; LOG.warn("Failed to {} (attempt {}): {}", action, policy.getAttemptCount(), e.toString()); } } throw e; } }
RetryUtils { public static void retry(String action, RunnableThrowsIOException f, RetryPolicy policy) throws IOException { IOException e = null; while (policy.attempt()) { try { f.run(); return; } catch (IOException ioe) { e = ioe; LOG.warn("Failed to {} (attempt {}): {}", action, policy.getAttemptCount(), e.toString()); } } throw e; } private  RetryUtils(); }
RetryUtils { public static void retry(String action, RunnableThrowsIOException f, RetryPolicy policy) throws IOException { IOException e = null; while (policy.attempt()) { try { f.run(); return; } catch (IOException ioe) { e = ioe; LOG.warn("Failed to {} (attempt {}): {}", action, policy.getAttemptCount(), e.toString()); } } throw e; } private  RetryUtils(); static void retry(String action, RunnableThrowsIOException f, RetryPolicy policy); static RetryPolicy defaultClientRetry(Duration maxRetryDuration, Duration baseSleepMs,
      Duration maxSleepMs); static RetryPolicy defaultWorkerMasterClientRetry(
      Duration workerMasterConnectRetryTimeout); static RetryPolicy defaultMetricsClientRetry(); static RetryPolicy defaultActiveSyncClientRetry(long activeUfsPollTimeoutMs); static RetryPolicy defaultBlockReadRetry(Duration maxRetryDuration, Duration baseSleepMs,
      Duration maxSleepMs); }
RetryUtils { public static void retry(String action, RunnableThrowsIOException f, RetryPolicy policy) throws IOException { IOException e = null; while (policy.attempt()) { try { f.run(); return; } catch (IOException ioe) { e = ioe; LOG.warn("Failed to {} (attempt {}): {}", action, policy.getAttemptCount(), e.toString()); } } throw e; } private  RetryUtils(); static void retry(String action, RunnableThrowsIOException f, RetryPolicy policy); static RetryPolicy defaultClientRetry(Duration maxRetryDuration, Duration baseSleepMs,
      Duration maxSleepMs); static RetryPolicy defaultWorkerMasterClientRetry(
      Duration workerMasterConnectRetryTimeout); static RetryPolicy defaultMetricsClientRetry(); static RetryPolicy defaultActiveSyncClientRetry(long activeUfsPollTimeoutMs); static RetryPolicy defaultBlockReadRetry(Duration maxRetryDuration, Duration baseSleepMs,
      Duration maxSleepMs);  }