zentol commented on a change in pull request #13508:
URL: https://github.com/apache/flink/pull/13508#discussion_r500085542



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/slotmanager/DefaultSlotTracker.java
##########
@@ -0,0 +1,251 @@
+/*
+ * 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.resourcemanager.slotmanager;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
+import org.apache.flink.runtime.clusterframework.types.SlotID;
+import 
org.apache.flink.runtime.resourcemanager.registration.TaskExecutorConnection;
+import org.apache.flink.runtime.taskexecutor.SlotStatus;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+
+/**
+ * Default SlotTracker implementation.
+ */
+class DefaultSlotTracker implements SlotTracker {
+       private static final Logger LOG = 
LoggerFactory.getLogger(DefaultSlotTracker.class);
+
+       /**
+        * Map for all registered slots.
+        */
+       private final Map<SlotID, DeclarativeTaskManagerSlot> slots = new 
HashMap<>();
+
+       /**
+        * Index of all currently free slots.
+        */
+       private final Map<SlotID, DeclarativeTaskManagerSlot> freeSlots = new 
LinkedHashMap<>();
+
+       private final SlotStatusUpdateListener slotStatusUpdateListener;
+
+       private final SlotStatusStateReconciler slotStatusStateReconciler = new 
SlotStatusStateReconciler(this::transitionSlotToFree, 
this::transitionSlotToPending, this::transitionSlotToAllocated);
+
+       public DefaultSlotTracker(SlotStatusUpdateListener 
slotStatusUpdateListener) {

Review comment:
       yes, and the tracker returned by the factory must accept the listener 
passed by the slot manager. So you have to instantiate the tracker instance 
within the factory; you can't create it upfront, and if you want to access it 
later one you must use an AtomicReference or such.
   (And you can't just ignore the listener because it is tying multiple 
components in the slot manager together (which is kinda bad, but I did not see 
another way))




----------------------------------------------------------------
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]


Reply via email to