flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/rpc/akka/AkkaRpcServiceTest.java
/**
	 * Tests that the RPC service's scheduled executor service can execute runnables at a fixed
	 * rate.
	 */
Tests that the RPC service's scheduled executor service can execute runnables at a fixed
rate.
Tests that the RPC service ' s scheduled executor service can execute runnables at a fixed rate .
@Test(timeout = 60000)
	public void testScheduledExecutorServicePeriodicSchedule() throws ExecutionException, InterruptedException {
		ScheduledExecutor scheduledExecutor = akkaRpcService.getScheduledExecutor();
		final int tries = 4;
		final long delay = 10L;
		final CountDownLatch countDownLatch = new CountDownLatch(tries);
		long currentTime = System.nanoTime();
		ScheduledFuture<?> future = scheduledExecutor.scheduleAtFixedRate(
			new Runnable() {
				@Override
				public void run() {
					countDownLatch.countDown();
				}
			},
			delay,
			delay,
			TimeUnit.MILLISECONDS);
		assertTrue(!future.isDone());
		countDownLatch.await();
		assertTrue(!future.isDone());
		long finalTime = System.nanoTime() - currentTime;
		assertTrue(finalTime >= tries * delay);
		future.cancel(true);
	}
@ Test ( timeout = 60000 ) public void testScheduledExecutorServicePeriodicSchedule ( ) throws ExecutionException , InterruptedException { ScheduledExecutor scheduledExecutor = akkaRpcService . getScheduledExecutor ( ) ; final int tries = 4 ; final long delay = 10L ; final CountDownLatch countDownLatch = new CountDownLatch ( tries ) ; long currentTime = System . nanoTime ( ) ; ScheduledFuture < ? > future = scheduledExecutor . scheduleAtFixedRate ( new Runnable ( ) { @ Override public void run ( ) { countDownLatch . countDown ( ) ; } } , delay , delay , TimeUnit . MILLISECONDS ) ; assertTrue ( ! future . isDone ( ) ) ; countDownLatch . await ( ) ; assertTrue ( ! future . isDone ( ) ) ; long finalTime = System . nanoTime ( ) - currentTime ; assertTrue ( finalTime >= tries * delay ) ; future . cancel ( true ) ; }
Tests that the RPC service's scheduled executor service can execute runnables at a fixed
 rate.
Tests that the RPC service ' s scheduled executor service can execute runnables at a fixed rate .
// the future should not complete since we have a periodic task // the processing should have taken at least delay times the number of count downs.