XComp commented on a change in pull request #14465:
URL: https://github.com/apache/flink/pull/14465#discussion_r549776451



##########
File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/TestingPhysicalSlotProvider.java
##########
@@ -69,71 +63,43 @@ private 
TestingPhysicalSlotProvider(SlotSharingExecutionSlotAllocatorTest.Physic
                this.requests = new HashMap<>();
                this.responses = new HashMap<>();
                this.cancellations = new HashMap<>();
-
-               this.availableSlotCount = availableSlotCount;
-               this.allocateLatch = new CountDownLatch(availableSlotCount);
        }
 
        @Override
        public CompletableFuture<PhysicalSlotRequest.Result> 
allocatePhysicalSlot(PhysicalSlotRequest physicalSlotRequest) {
                SlotRequestId slotRequestId = 
physicalSlotRequest.getSlotRequestId();
                requests.put(slotRequestId, physicalSlotRequest);
-               CompletableFuture<TestingPhysicalSlot> resultFuture = new 
CompletableFuture<>();
-               responses.put(slotRequestId, resultFuture);
-
-               switch (physicalSlotFutureCompletion) {
-                       case SUCCESS:
-                               if (availableSlotCount > 0) {
-                                       
completePhysicalSlotFutureFor(slotRequestId, new AllocationID());
-                               } else {
-                                       resultFuture.completeExceptionally(new 
NoResourceAvailableException());
-                               }
-                               break;
-                       case FAILURE:
-                               resultFuture.completeExceptionally(new 
FlinkException("Test failure."));
-                               break;
+               CompletableFuture<TestingPhysicalSlot> resultFuture;
+               try {
+                       resultFuture = physicalSlotCreator.apply(
+                               taskManagerLocation,
+                               taskManagerGateway,
+                               
physicalSlotRequest.getSlotProfile().getPhysicalSlotResourceProfile());
+               } catch (Throwable t) {
+                       resultFuture = FutureUtils.completedExceptionally(t);

Review comment:
       Yeah, you're right. I should have used the `TriFunction` right away.




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


Reply via email to