YARN-8183. Fix ConcurrentModificationException inside RMAppAttemptMetrics#convertAtomicLongMaptoLongMap. (Suma Shivaprasad via wangda)

Change-Id: I347871d672001653a3afe2e99adefd74e0d798cd
(cherry picked from commit bb3c504764f807fccba7f28298a12e2296f284cb)
This commit is contained in:
Wangda Tan 2018-04-24 17:42:17 -07:00
parent 678e599879
commit 3043a93d46
1 changed files with 5 additions and 4 deletions

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
@ -53,8 +54,8 @@ public class RMAppAttemptMetrics {
private ReadLock readLock; private ReadLock readLock;
private WriteLock writeLock; private WriteLock writeLock;
private Map<String, AtomicLong> resourceUsageMap = new HashMap<>(); private Map<String, AtomicLong> resourceUsageMap = new ConcurrentHashMap<>();
private Map<String, AtomicLong> preemptedResourceMap = new HashMap<>(); private Map<String, AtomicLong> preemptedResourceMap = new ConcurrentHashMap<>();
private RMContext rmContext; private RMContext rmContext;
private int[][] localityStatistics = private int[][] localityStatistics =
@ -97,7 +98,7 @@ public class RMAppAttemptMetrics {
public Resource getResourcePreempted() { public Resource getResourcePreempted() {
try { try {
readLock.lock(); readLock.lock();
return resourcePreempted; return Resource.newInstance(resourcePreempted);
} finally { } finally {
readLock.unlock(); readLock.unlock();
} }
@ -230,7 +231,7 @@ public class RMAppAttemptMetrics {
} }
public Resource getApplicationAttemptHeadroom() { public Resource getApplicationAttemptHeadroom() {
return applicationHeadroom; return Resource.newInstance(applicationHeadroom);
} }
public void setApplicationAttemptHeadRoom(Resource headRoom) { public void setApplicationAttemptHeadRoom(Resource headRoom) {