tillrohrmann commented on a change in pull request #15251:
URL: https://github.com/apache/flink/pull/15251#discussion_r597597099



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/allocator/SlotAllocator.java
##########
@@ -45,27 +42,26 @@
      * <p>If a {@link VertexParallelism} is returned then it covers all 
vertices contained in the
      * given job information.
      *
-     * <p>A returned {@link VertexParallelism} should be directly consumed 
afterwards (by either
-     * discarding it or calling {@link #reserveResources(VertexParallelism)}, 
as there is no
-     * guarantee that the assignment remains valid over time (because slots 
can be lost).
-     *
      * <p>Implementations of this method must be side-effect free. There is no 
guarantee that the
-     * result of this method is ever passed to {@link 
#reserveResources(VertexParallelism)}.
+     * result of this method is ever passed to {@link 
#tryReserveResources(VertexParallelism)}.
      *
      * @param jobInformation information about the job graph
      * @param slots slots to consider for determining the parallelism
      * @return potential parallelism for all vertices and 
implementation-specific information for
      *     how the vertices could be assigned to slots, if all vertices could 
be run with the given
      *     slots
      */
-    Optional<T> determineParallelism(
+    Optional<? extends VertexParallelism> determineParallelism(
             JobInformation jobInformation, Collection<? extends SlotInfo> 
slots);
 
     /**
-     * Reserves slots according to the given assignment.
+     * Reserves slots according to the given assignment if possible. If the 
underlying set of
+     * resources has changed and the reservation with respect to 
vertexParallelism is no longer
+     * possible, then this method returns {@link Optional#empty()}.
      *
      * @param vertexParallelism information on how slots should be assigned to 
the slots
-     * @return mapping of vertices to slots
+     * @return Set of reserved slots if the reservation was successful; 
otherwise {@link
+     *     Optional#empty()}
      */
-    Map<ExecutionVertexID, LogicalSlot> reserveResources(T vertexParallelism);
+    Optional<? extends ReservedSlots> tryReserveResources(VertexParallelism 
vertexParallelism);

Review comment:
       The idea is to have a way to tell the caller that the `SlotAllocator` 
could not reserve the required slots for the given `VertexParallelism`. The 
alternative would be to return an empty `ReservedSlots` instance but this would 
be a bit less expressive but also possible.




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