flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/checkpoint/CompletedCheckpointTest.java
/**
	 * Tests that the garbage collection properties are respected when shutting down.
	 */
Tests that the garbage collection properties are respected when shutting down.
Tests that the garbage collection properties are respected when shutting down .
@Test
	public void testCleanUpOnShutdown() throws Exception {
		File file = tmpFolder.newFile();
		String externalPath = file.getAbsolutePath();
		JobStatus[] terminalStates = new JobStatus[] {
				JobStatus.FINISHED, JobStatus.CANCELED, JobStatus.FAILED, JobStatus.SUSPENDED
		};
		OperatorState state = mock(OperatorState.class);
		Map<OperatorID, OperatorState> operatorStates = new HashMap<>();
		operatorStates.put(new OperatorID(), state);
		for (JobStatus status : terminalStates) {
			Mockito.reset(state);
			CheckpointProperties props = new CheckpointProperties(false, true, false, false, false, false, false, false);
			CompletedCheckpoint checkpoint = new CompletedCheckpoint(
					new JobID(), 0, 0, 1,
					new HashMap<>(operatorStates),
					Collections.<MasterState>emptyList(),
					props,
					new FileStateHandle(new Path(file.toURI()), file.length()),
					externalPath);
			SharedStateRegistry sharedStateRegistry = new SharedStateRegistry();
			checkpoint.registerSharedStatesAfterRestored(sharedStateRegistry);
			checkpoint.discardOnShutdown(status);
			verify(state, times(0)).discardState();
			assertEquals(true, file.exists());
			props = new CheckpointProperties(false, false, false, true, true, true, true, true);
			checkpoint = new CompletedCheckpoint(
					new JobID(), 0, 0, 1,
					new HashMap<>(operatorStates),
					Collections.<MasterState>emptyList(),
					props,
					null,
					null);
			checkpoint.discardOnShutdown(status);
			verify(state, times(1)).discardState();
		}
	}
@ Test public void testCleanUpOnShutdown ( ) throws Exception { File file = tmpFolder . newFile ( ) ; String externalPath = file . getAbsolutePath ( ) ; JobStatus [ ] terminalStates = new JobStatus [ ] { JobStatus . FINISHED , JobStatus . CANCELED , JobStatus . FAILED , JobStatus . SUSPENDED } ; OperatorState state = mock ( OperatorState . class ) ; Map < OperatorID , OperatorState > operatorStates = new HashMap < > ( ) ; operatorStates . put ( new OperatorID ( ) , state ) ; for ( JobStatus status : terminalStates ) { Mockito . reset ( state ) ; CheckpointProperties props = new CheckpointProperties ( false , true , false , false , false , false , false , false ) ; CompletedCheckpoint checkpoint = new CompletedCheckpoint ( new JobID ( ) , 0 , 0 , 1 , new HashMap < > ( operatorStates ) , Collections . < MasterState > emptyList ( ) , props , new FileStateHandle ( new Path ( file . toURI ( ) ) , file . length ( ) ) , externalPath ) ; SharedStateRegistry sharedStateRegistry = new SharedStateRegistry ( ) ; checkpoint . registerSharedStatesAfterRestored ( sharedStateRegistry ) ; checkpoint . discardOnShutdown ( status ) ; verify ( state , times ( 0 ) ) . discardState ( ) ; assertEquals ( true , file . exists ( ) ) ; props = new CheckpointProperties ( false , false , false , true , true , true , true , true ) ; checkpoint = new CompletedCheckpoint ( new JobID ( ) , 0 , 0 , 1 , new HashMap < > ( operatorStates ) , Collections . < MasterState > emptyList ( ) , props , null , null ) ; checkpoint . discardOnShutdown ( status ) ; verify ( state , times ( 1 ) ) . discardState ( ) ; } }
Tests that the garbage collection properties are respected when shutting down.
Tests that the garbage collection properties are respected when shutting down .
// Keep // Discard