From 154cfb2b620002a7d3b7fdbf8b68236c432771e1 Mon Sep 17 00:00:00 2001 From: Weiwei Yang Date: Fri, 16 Mar 2018 18:57:31 +0800 Subject: [PATCH] YARN-7636. Re-reservation count may overflow when cluster resource exhausted for a long time. contributed by Tao Yang. --- .../scheduler/SchedulerApplicationAttempt.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java index 753c2b8b440..857e7369803 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/SchedulerApplicationAttempt.java @@ -418,7 +418,11 @@ public class SchedulerApplicationAttempt implements SchedulableEntity { protected void addReReservation( SchedulerRequestKey schedulerKey) { - reReservations.add(schedulerKey); + try { + reReservations.add(schedulerKey); + } catch (IllegalArgumentException e) { + // This happens when count = MAX_INT, ignore the exception + } } public int getReReservations(SchedulerRequestKey schedulerKey) { @@ -1006,8 +1010,13 @@ public class SchedulerApplicationAttempt implements SchedulableEntity { public int addMissedNonPartitionedRequestSchedulingOpportunity( SchedulerRequestKey schedulerKey) { - return missedNonPartitionedReqSchedulingOpportunity.add( - schedulerKey, 1) + 1; + try { + return missedNonPartitionedReqSchedulingOpportunity.add( + schedulerKey, 1) + 1; + } catch (IllegalArgumentException e) { + // This happens when count = MAX_INT, ignore the exception + return Integer.MAX_VALUE; + } } public void