flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/concurrent/FutureUtilsTest.java
/**
	 * Tests that we can retry an operation.
	 */
Tests that we can retry an operation.
Tests that we can retry an operation .
@Test
	public void testRetrySuccess() throws Exception {
		final int retries = 10;
		final AtomicInteger atomicInteger = new AtomicInteger(0);
		CompletableFuture<Boolean> retryFuture = FutureUtils.retry(
			() ->
				CompletableFuture.supplyAsync(
					() -> {
						if (atomicInteger.incrementAndGet() == retries) {
							return true;
						} else {
							throw new CompletionException(new FlinkException("Test exception"));
						}
					},
					TestingUtils.defaultExecutor()),
			retries,
			TestingUtils.defaultExecutor());
		assertTrue(retryFuture.get());
		assertTrue(retries == atomicInteger.get());
	}
@ Test public void testRetrySuccess ( ) throws Exception { final int retries = 10 ; final AtomicInteger atomicInteger = new AtomicInteger ( 0 ) ; CompletableFuture < Boolean > retryFuture = FutureUtils . retry ( ( ) -> CompletableFuture . supplyAsync ( ( ) -> { if ( atomicInteger . incrementAndGet ( ) == retries ) { return true ; } else { throw new CompletionException ( new FlinkException ( "Test exception" ) ) ; } } , TestingUtils . defaultExecutor ( ) ) , retries , TestingUtils . defaultExecutor ( ) ) ; assertTrue ( retryFuture . get ( ) ) ; assertTrue ( retries == atomicInteger . get ( ) ) ; }
Tests that we can retry an operation.
Tests that we can retry an operation .