Skip to content

Commit 2b68496

Browse files
ferdelyislfan1989
authored andcommitted
YARN-11639. CME and NPE in PriorityUtilizationQueueOrderingPolicy (#6455)
1 parent 95951e9 commit 2b68496

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/policy/PriorityUtilizationQueueOrderingPolicy.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
.CapacitySchedulerConfiguration;
2929
import org.apache.hadoop.yarn.util.resource.Resources;
3030

31+
import java.util.ArrayList;
3132
import java.util.Comparator;
3233
import java.util.Iterator;
3334
import java.util.List;
@@ -254,9 +255,9 @@ public Iterator<CSQueue> getAssignmentIterator(String partition) {
254255
// partitionToLookAt is a thread local variable, therefore it is safe to mutate it.
255256
PriorityUtilizationQueueOrderingPolicy.partitionToLookAt.set(partition);
256257

257-
// Sort the snapshot of the queues in order to avoid breaking the prerequisites of TimSort.
258-
// See YARN-10178 for details.
259-
return queues.stream().map(PriorityQueueResourcesForSorting::new).sorted(
258+
// Copy (for thread safety) and sort the snapshot of the queues in order to avoid breaking
259+
// the prerequisites of TimSort. See YARN-10178 for details.
260+
return new ArrayList<>(queues).stream().map(PriorityQueueResourcesForSorting::new).sorted(
260261
new PriorityQueueComparator()).map(PriorityQueueResourcesForSorting::getQueue).collect(
261262
Collectors.toList()).iterator();
262263
}

0 commit comments

Comments
 (0)