flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/SlotManagerTest.java
/**
	 * Checks that un-registering a pending slot request will cancel it, removing it from all
	 * assigned task manager slots and then remove it from the slot manager.
	 */
Checks that un-registering a pending slot request will cancel it, removing it from all
assigned task manager slots and then remove it from the slot manager.
Checks that un - registering a pending slot request will cancel it removing it from all assigned task manager slots and then remove it from the slot manager .
@Test
	public void testUnregisterPendingSlotRequest() throws Exception {
		final ResourceManagerId resourceManagerId = ResourceManagerId.generate();
		final ResourceActions resourceManagerActions = mock(ResourceActions.class);
		final SlotID slotId = new SlotID(ResourceID.generate(), 0);
		final AllocationID allocationId = new AllocationID();
		final TaskExecutorGateway taskExecutorGateway = mock(TaskExecutorGateway.class);
		when(taskExecutorGateway.requestSlot(
			any(SlotID.class),
			any(JobID.class),
			any(AllocationID.class),
			anyString(),
			eq(resourceManagerId),
			any(Time.class))).thenReturn(new CompletableFuture<>());
		final ResourceProfile resourceProfile = new ResourceProfile(1.0, 1);
		final SlotStatus slotStatus = new SlotStatus(slotId, resourceProfile);
		final SlotReport slotReport = new SlotReport(slotStatus);
		final SlotRequest slotRequest = new SlotRequest(new JobID(), allocationId, resourceProfile, "foobar");
		final TaskExecutorConnection taskManagerConnection = new TaskExecutorConnection(taskExecutorGateway);
		try (SlotManager slotManager = createSlotManager(resourceManagerId, resourceManagerActions)) {
			slotManager.registerTaskManager(taskManagerConnection, slotReport);
			TaskManagerSlot slot = slotManager.getSlot(slotId);
			slotManager.registerSlotRequest(slotRequest);
			assertNotNull(slotManager.getSlotRequest(allocationId));
			assertTrue(slot.getState() == TaskManagerSlot.State.PENDING);
			slotManager.unregisterSlotRequest(allocationId);
			assertNull(slotManager.getSlotRequest(allocationId));
			slot = slotManager.getSlot(slotId);
			assertTrue(slot.getState() == TaskManagerSlot.State.FREE);
		}
	}
@ Test public void testUnregisterPendingSlotRequest ( ) throws Exception { final ResourceManagerId resourceManagerId = ResourceManagerId . generate ( ) ; final ResourceActions resourceManagerActions = mock ( ResourceActions . class ) ; final SlotID slotId = new SlotID ( ResourceID . generate ( ) , 0 ) ; final AllocationID allocationId = new AllocationID ( ) ; final TaskExecutorGateway taskExecutorGateway = mock ( TaskExecutorGateway . class ) ; when ( taskExecutorGateway . requestSlot ( any ( SlotID . class ) , any ( JobID . class ) , any ( AllocationID . class ) , anyString ( ) , eq ( resourceManagerId ) , any ( Time . class ) ) ) . thenReturn ( new CompletableFuture < > ( ) ) ; final ResourceProfile resourceProfile = new ResourceProfile ( 1.0 , 1 ) ; final SlotStatus slotStatus = new SlotStatus ( slotId , resourceProfile ) ; final SlotReport slotReport = new SlotReport ( slotStatus ) ; final SlotRequest slotRequest = new SlotRequest ( new JobID ( ) , allocationId , resourceProfile , "foobar" ) ; final TaskExecutorConnection taskManagerConnection = new TaskExecutorConnection ( taskExecutorGateway ) ; try ( SlotManager slotManager = createSlotManager ( resourceManagerId , resourceManagerActions ) ) { slotManager . registerTaskManager ( taskManagerConnection , slotReport ) ; TaskManagerSlot slot = slotManager . getSlot ( slotId ) ; slotManager . registerSlotRequest ( slotRequest ) ; assertNotNull ( slotManager . getSlotRequest ( allocationId ) ) ; assertTrue ( slot . getState ( ) == TaskManagerSlot . State . PENDING ) ; slotManager . unregisterSlotRequest ( allocationId ) ; assertNull ( slotManager . getSlotRequest ( allocationId ) ) ; slot = slotManager . getSlot ( slotId ) ; assertTrue ( slot . getState ( ) == TaskManagerSlot . State . FREE ) ; } }
Checks that un-registering a pending slot request will cancel it, removing it from all
 assigned task manager slots and then remove it from the slot manager.
Checks that un - registering a pending slot request will cancel it removing it from all assigned task manager slots and then remove it from the slot manager .