tillrohrmann 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_r369013987
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/slot/TaskSlotTableImpl.java ########## @@ -0,0 +1,777 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.runtime.taskexecutor.slot; + +import org.apache.flink.annotation.VisibleForTesting; +import org.apache.flink.api.common.JobID; +import org.apache.flink.api.common.time.Time; +import org.apache.flink.runtime.clusterframework.types.AllocationID; +import org.apache.flink.runtime.clusterframework.types.ResourceBudgetManager; +import org.apache.flink.runtime.clusterframework.types.ResourceID; +import org.apache.flink.runtime.clusterframework.types.ResourceProfile; +import org.apache.flink.runtime.clusterframework.types.SlotID; +import org.apache.flink.runtime.concurrent.FutureUtils; +import org.apache.flink.runtime.executiongraph.ExecutionAttemptID; +import org.apache.flink.runtime.memory.MemoryManager; +import org.apache.flink.runtime.taskexecutor.SlotReport; +import org.apache.flink.runtime.taskexecutor.SlotStatus; +import org.apache.flink.runtime.taskmanager.Task; +import org.apache.flink.util.FlinkException; +import org.apache.flink.util.Preconditions; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.stream.Collectors; + +/** + * Default implementation of {@link TaskSlotTable}. + */ +public class TaskSlotTableImpl implements TaskSlotTable { + + private static final Logger LOG = LoggerFactory.getLogger(TaskSlotTableImpl.class); + + /** + * Number of slots in static slot allocation. + * If slot is requested with an index, the requested index must within the range of [0, numberSlots). + * When generating slot report, we should always generate slots with index in [0, numberSlots) even the slot does not exist. + */ + private final int numberSlots; + + /** Slot resource profile for static slot allocation. */ + private final ResourceProfile defaultSlotResourceProfile; + + /** Page size for memory manager. */ + private final int memoryPageSize; + + /** Timer service used to time out allocated slots. */ + private final TimerService<AllocationID> timerService; + + /** The list of all task slots. */ + private final Map<Integer, TaskSlot> taskSlots; + + /** Mapping from allocation id to task slot. */ + private final Map<AllocationID, TaskSlot> allocatedSlots; + + /** Mapping from execution attempt id to task and task slot. */ + private final Map<ExecutionAttemptID, TaskSlotMapping> taskSlotMappings; + + /** Mapping from job id to allocated slots for a job. */ + private final Map<JobID, Set<AllocationID>> slotsPerJob; + + /** Interface for slot actions, such as freeing them or timing them out. */ + private SlotActions slotActions; Review comment: `@Nullable` annotation is missing or we need a default value. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services