@Test public void success() throws IOException { AtomicInteger count = new AtomicInteger(0); RetryUtils.retry("success test", () -> { count.incrementAndGet(); if (count.get() == 5) { return; } throw new IOException("Fail"); }, new CountingRetry(10)); assertEquals(5, 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);  }