azagrebin commented on a change in pull request #10682: [FLINK-15247][Runtime]
Wait for all slots to be free before task executor services shutdown upon
stopping
URL: https://github.com/apache/flink/pull/10682#discussion_r365833036
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/slot/TaskSlotTableTest.java
##########
@@ -243,8 +252,181 @@ public void testGenerateSlotReport() throws
SlotNotFoundException {
}
}
+ @Test
+ public void testAllocateSlot() {
+ final JobID jobId = new JobID();
+ final AllocationID allocationId = new AllocationID();
+ TaskSlotTable taskSlotTable = null;
+ try {
+ taskSlotTable = createTaskSlotTableWithAllocatedSlot(
+ jobId,
+ allocationId,
+ new TestingSlotActionsBuilder().build());
+ Iterator<TaskSlot> allocatedSlots =
taskSlotTable.getAllocatedSlots(jobId);
+ TaskSlot nextSlot = allocatedSlots.next();
+ assertThat(nextSlot.getIndex(), is(0));
+ assertThat(nextSlot.getAllocationId(),
is(allocationId));
+ assertThat(nextSlot.getJobId(), is(jobId));
+ assertThat(allocatedSlots.hasNext(), is(false));
+ } finally {
+ stopTable(taskSlotTable);
+ }
+ }
+
+ @Test
+ public void testAddTask() throws Exception {
+ final JobID jobId = new JobID();
+ final ExecutionAttemptID executionAttemptId = new
ExecutionAttemptID();
+ final AllocationID allocationId = new AllocationID();
+ Task task = createTask(
+ jobId,
+ executionAttemptId,
+ allocationId,
+ EmptyInvokable.class);
+ TaskSlotTable taskSlotTable = null;
+ try {
+ taskSlotTable =
createTaskSlotTableWithStartedTask(task, new
TestingSlotActionsBuilder().build());
+ Iterator<Task> tasks = taskSlotTable.getTasks(jobId);
+ Task nextTask = tasks.next();
+ assertThat(nextTask.getExecutionId(),
is(executionAttemptId));
+ assertThat(nextTask.getAllocationId(),
is(allocationId));
+ assertThat(tasks.hasNext(), is(false));
+ taskSlotTable.freeSlot(allocationId);
+ taskSlotTable.removeTask(executionAttemptId);
Review comment:
I removed the unnecessary calls, also for subsequent comments and added
comment in code for one where I think it was needed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services