flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] tillrohrmann commented on a change in pull request #6734: [FLINK-9455][RM] Add support for multi task slot TaskExecutors
Date Wed, 26 Sep 2018 15:33:28 GMT
tillrohrmann commented on a change in pull request #6734: [FLINK-9455][RM] Add support for
multi task slot TaskExecutors
URL: https://github.com/apache/flink/pull/6734#discussion_r220614717
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/slotmanager/SlotManagerTest.java
 ##########
 @@ -1398,4 +1389,171 @@ private SlotManager createSlotManager(ResourceManagerId resourceManagerId,
Resou
 
 		return slotManager;
 	}
+
+	/**
+	 * Tests that we only request new resources/containers once we have assigned
+	 * all pending task manager slots.
+	 */
+	@Test
+	public void testRequestNewResources() throws Exception {
+		final int numberSlots = 2;
+		final AtomicInteger resourceRequests = new AtomicInteger(0);
+		final TestingResourceActions testingResourceActions = new TestingResourceActionsBuilder()
+			.setAllocateResourceFunction(
+				convert(ignored -> {
+					resourceRequests.incrementAndGet();
+					return numberSlots;
+				}))
+			.build();
+
+		try (final SlotManager slotManager = createSlotManager(
+			ResourceManagerId.generate(),
+			testingResourceActions)) {
+
+			final JobID jobId = new JobID();
+			assertThat(slotManager.registerSlotRequest(createSlotRequest(jobId)), is(true));
+			assertThat(resourceRequests.get(), is(1));
+
+			// the second slot request should not try to allocate a new resource because the
+			// previous resource was started with 2 slots.
+			assertThat(slotManager.registerSlotRequest(createSlotRequest(jobId)), is(true));
+			assertThat(resourceRequests.get(), is(1));
+
+			assertThat(slotManager.getNumberAssignedPendingTaskManagerSlots(), is(2));
+
+			assertThat(slotManager.registerSlotRequest(createSlotRequest(jobId)), is(true));
+			assertThat(resourceRequests.get(), is(2));
+		}
+	}
+
+	/**
+	 * Tests that a failing allocation/slot request will return the pending task manager slot.
+	 */
+	@Test
+	public void testFailingAllocationReturnsPendingTaskManagerSlot() throws Exception {
+		final int numberSlots = 2;
+		final TestingResourceActions resourceActions = new TestingResourceActionsBuilder()
+			.setAllocateResourceFunction(convert(value -> numberSlots))
+			.build();
+		try (final SlotManager slotManager = createSlotManager(ResourceManagerId.generate(), resourceActions))
{
+			final JobID jobId = new JobID();
+
+			final SlotRequest slotRequest = createSlotRequest(jobId);
+			assertThat(slotManager.registerSlotRequest(slotRequest), is(true));
+
+			assertThat(slotManager.getNumberPendingTaskManagerSlots(), is(numberSlots));
+			assertThat(slotManager.getNumberAssignedPendingTaskManagerSlots(), is(1));
+
+			slotManager.unregisterSlotRequest(slotRequest.getAllocationId());
+
+			assertThat(slotManager.getNumberPendingTaskManagerSlots(), is(numberSlots));
+			assertThat(slotManager.getNumberAssignedPendingTaskManagerSlots(), is(0));
+		}
+	}
+
+	/**
+	 * Tests the completion of pending task manager slots by registering a TaskExecutor.
+	 */
+	@Test
+	public void testPendingTaskManagerSlotCompletion() throws Exception {
+		final int numberSlots = 3;
+		final TestingResourceActions resourceActions = new TestingResourceActionsBuilder()
+			.setAllocateResourceFunction(convert(value -> numberSlots))
+			.build();
+
+		try (final SlotManager slotManager = createSlotManager(ResourceManagerId.generate(), resourceActions))
{
+			final JobID jobId = new JobID();
+			assertThat(slotManager.registerSlotRequest(createSlotRequest(jobId)), is(true));
+
+			assertThat(slotManager.getNumberPendingTaskManagerSlots(), is(numberSlots));
+			assertThat(slotManager.getNumberAssignedPendingTaskManagerSlots(), is(1));
+			assertThat(slotManager.getNumberRegisteredSlots(), is(0));
+
+			final TaskExecutorConnection taskExecutorConnection = createTaskExecutorConnection();
+			final SlotReport slotReport = createSlotReport(taskExecutorConnection.getResourceID(),
numberSlots - 1);
+
+			slotManager.registerTaskManager(taskExecutorConnection, slotReport);
+
+			assertThat(slotManager.getNumberRegisteredSlots(), is(numberSlots - 1));
+			assertThat(slotManager.getNumberPendingTaskManagerSlots(), is(1));
 
 Review comment:
   I think `getNumberPendingTaskManagerSlots == 1` is an even stricter condition, because
it requires that actually some of the pending task manager slots have been completed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message