From 3043a93d461fd8b9ccc2ff4b8d17e5430ed77615 Mon Sep 17 00:00:00 2001 From: Wangda Tan Date: Tue, 24 Apr 2018 17:42:17 -0700 Subject: [PATCH] YARN-8183. Fix ConcurrentModificationException inside RMAppAttemptMetrics#convertAtomicLongMaptoLongMap. (Suma Shivaprasad via wangda) Change-Id: I347871d672001653a3afe2e99adefd74e0d798cd (cherry picked from commit bb3c504764f807fccba7f28298a12e2296f284cb) --- .../rmapp/attempt/RMAppAttemptMetrics.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 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/rmapp/attempt/RMAppAttemptMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptMetrics.java index 015cff7a960..4e755054bcf 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/RMAppAttemptMetrics.java @@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; @@ -53,8 +54,8 @@ public class RMAppAttemptMetrics { private ReadLock readLock; private WriteLock writeLock; - private Map resourceUsageMap = new HashMap<>(); - private Map preemptedResourceMap = new HashMap<>(); + private Map resourceUsageMap = new ConcurrentHashMap<>(); + private Map preemptedResourceMap = new ConcurrentHashMap<>(); private RMContext rmContext; private int[][] localityStatistics = @@ -97,7 +98,7 @@ public class RMAppAttemptMetrics { public Resource getResourcePreempted() { try { readLock.lock(); - return resourcePreempted; + return Resource.newInstance(resourcePreempted); } finally { readLock.unlock(); } @@ -230,7 +231,7 @@ public class RMAppAttemptMetrics { } public Resource getApplicationAttemptHeadroom() { - return applicationHeadroom; + return Resource.newInstance(applicationHeadroom); } public void setApplicationAttemptHeadRoom(Resource headRoom) {