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
/**
	 * Tests that idle task managers time out after the configured timeout. A timed out task manager
	 * will be removed from the slot manager and the resource manager will be notified about the
	 * timeout.
	 */
Tests that idle task managers time out after the configured timeout. A timed out task manager
will be removed from the slot manager and the resource manager will be notified about the
timeout.
Tests that idle task managers time out after the configured timeout . A timed out task manager will be removed from the slot manager and the resource manager will be notified about the timeout .
@Test
	public void testTaskManagerTimeout() throws Exception {
		final long tmTimeout = 500L;
		final ResourceActions resourceManagerActions = mock(ResourceActions.class);
		final ResourceManagerId resourceManagerId = ResourceManagerId.generate();
		final TaskExecutorGateway taskExecutorGateway = mock(TaskExecutorGateway.class);
		final TaskExecutorConnection taskManagerConnection = new TaskExecutorConnection(taskExecutorGateway);
		final SlotID slotId = new SlotID(ResourceID.generate(), 0);
		final ResourceProfile resourceProfile = new ResourceProfile(1.0, 1);
		final SlotStatus slotStatus = new SlotStatus(slotId, resourceProfile);
		final SlotReport slotReport = new SlotReport(slotStatus);
		final Executor mainThreadExecutor = TestingUtils.defaultExecutor();
		try (SlotManager slotManager = new SlotManager(
			TestingUtils.defaultScheduledExecutor(),
			TestingUtils.infiniteTime(),
			TestingUtils.infiniteTime(),
			Time.milliseconds(tmTimeout))) {
			slotManager.start(resourceManagerId, mainThreadExecutor, resourceManagerActions);
			mainThreadExecutor.execute(new Runnable() {
				@Override
				public void run() {
					slotManager.registerTaskManager(taskManagerConnection, slotReport);
				}
			});
			verify(resourceManagerActions, timeout(100L * tmTimeout).times(1))
				.releaseResource(eq(taskManagerConnection.getInstanceID()));
		}
	}
@ Test public void testTaskManagerTimeout ( ) throws Exception { final long tmTimeout = 500L ; final ResourceActions resourceManagerActions = mock ( ResourceActions . class ) ; final ResourceManagerId resourceManagerId = ResourceManagerId . generate ( ) ; final TaskExecutorGateway taskExecutorGateway = mock ( TaskExecutorGateway . class ) ; final TaskExecutorConnection taskManagerConnection = new TaskExecutorConnection ( taskExecutorGateway ) ; final SlotID slotId = new SlotID ( ResourceID . generate ( ) , 0 ) ; final ResourceProfile resourceProfile = new ResourceProfile ( 1.0 , 1 ) ; final SlotStatus slotStatus = new SlotStatus ( slotId , resourceProfile ) ; final SlotReport slotReport = new SlotReport ( slotStatus ) ; final Executor mainThreadExecutor = TestingUtils . defaultExecutor ( ) ; try ( SlotManager slotManager = new SlotManager ( TestingUtils . defaultScheduledExecutor ( ) , TestingUtils . infiniteTime ( ) , TestingUtils . infiniteTime ( ) , Time . milliseconds ( tmTimeout ) ) ) { slotManager . start ( resourceManagerId , mainThreadExecutor , resourceManagerActions ) ; mainThreadExecutor . execute ( new Runnable ( ) { @ Override public void run ( ) { slotManager . registerTaskManager ( taskManagerConnection , slotReport ) ; } } ) ; verify ( resourceManagerActions , timeout ( 100L * tmTimeout ) . times ( 1 ) ) . releaseResource ( eq ( taskManagerConnection . getInstanceID ( ) ) ) ; } }
Tests that idle task managers time out after the configured timeout.
Tests that idle task managers time out after the configured timeout .