flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/legacy/ExecutionGraphCacheTest.java
/**
	 * Tests that we can cache AccessExecutionGraphs over multiple accesses.
	 */
Tests that we can cache AccessExecutionGraphs over multiple accesses.
Tests that we can cache AccessExecutionGraphs over multiple accesses .
@Test
	public void testExecutionGraphCaching() throws Exception {
		final Time timeout = Time.milliseconds(100L);
		final Time timeToLive = Time.hours(1L);
		final JobID jobId = new JobID();
		final AccessExecutionGraph accessExecutionGraph = mock(AccessExecutionGraph.class);
		final JobManagerGateway jobManagerGateway = mock(JobManagerGateway.class);
		when(jobManagerGateway.requestJob(eq(jobId), any(Time.class))).thenReturn(CompletableFuture.completedFuture(accessExecutionGraph));
		try (ExecutionGraphCache executionGraphCache = new ExecutionGraphCache(timeout, timeToLive)) {
			CompletableFuture<AccessExecutionGraph> accessExecutionGraphFuture = executionGraphCache.getExecutionGraph(jobId, jobManagerGateway);
			assertEquals(accessExecutionGraph, accessExecutionGraphFuture.get());
			CompletableFuture<AccessExecutionGraph> accessExecutionGraphFuture2 = executionGraphCache.getExecutionGraph(jobId, jobManagerGateway);
			assertEquals(accessExecutionGraph, accessExecutionGraphFuture2.get());
			verify(jobManagerGateway, times(1)).requestJob(eq(jobId), any(Time.class));
		}
	}
@ Test public void testExecutionGraphCaching ( ) throws Exception { final Time timeout = Time . milliseconds ( 100L ) ; final Time timeToLive = Time . hours ( 1L ) ; final JobID jobId = new JobID ( ) ; final AccessExecutionGraph accessExecutionGraph = mock ( AccessExecutionGraph . class ) ; final JobManagerGateway jobManagerGateway = mock ( JobManagerGateway . class ) ; when ( jobManagerGateway . requestJob ( eq ( jobId ) , any ( Time . class ) ) ) . thenReturn ( CompletableFuture . completedFuture ( accessExecutionGraph ) ) ; try ( ExecutionGraphCache executionGraphCache = new ExecutionGraphCache ( timeout , timeToLive ) ) { CompletableFuture < AccessExecutionGraph > accessExecutionGraphFuture = executionGraphCache . getExecutionGraph ( jobId , jobManagerGateway ) ; assertEquals ( accessExecutionGraph , accessExecutionGraphFuture . get ( ) ) ; CompletableFuture < AccessExecutionGraph > accessExecutionGraphFuture2 = executionGraphCache . getExecutionGraph ( jobId , jobManagerGateway ) ; assertEquals ( accessExecutionGraph , accessExecutionGraphFuture2 . get ( ) ) ; verify ( jobManagerGateway , times ( 1 ) ) . requestJob ( eq ( jobId ) , any ( Time . class ) ) ; } }
Tests that we can cache AccessExecutionGraphs over multiple accesses.
Tests that we can cache AccessExecutionGraphs over multiple accesses .
// verify that we only issued a single request to the gateway