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



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/slot/TaskSlotTableImpl.java
##########
@@ -200,6 +200,17 @@ public boolean isClosed() {
                }
        }
 
+       @Override
+       public Set<AllocationID> getActiveTaskAllocationIdsPerJob(JobID jobId) {
+               Iterator<TaskSlot<T>> taskSlotIterator = new 
TaskSlotIterator(jobId, TaskSlotState.ACTIVE);
+               Set<AllocationID> allocationIds = new HashSet<>();
+               while (taskSlotIterator.hasNext()) {
+                       
allocationIds.add(taskSlotIterator.next().getAllocationId());
+               }
+
+               return allocationIds;

Review comment:
       ```suggestion
                return Sets.newHashSet(new TaskSlotIterator(jobId, 
TaskSlotState.ACTIVE))
                        .stream()
                        .map(TaskSlot::getAllocationId)
                        .collect(Collectors.toSet());
   ```
   The only other shorter way I can imagine is the one above. I just hesitated 
because it would mean iterating over the collection twice just to save a few 
lines.




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