YARN-7489. ConcurrentModificationException in RMAppImpl#getRMAppMetrics. Contributed by Tao Yang.

This commit is contained in:
bibinchundatt 2017-11-20 21:31:50 +05:30
parent b57ea38fcf
commit 5c2986e58d
1 changed files with 22 additions and 17 deletions

View File

@ -1616,24 +1616,29 @@ public class RMAppImpl implements RMApp, Recoverable {
long vcoreSeconds = 0; long vcoreSeconds = 0;
long preemptedMemorySeconds = 0; long preemptedMemorySeconds = 0;
long preemptedVcoreSeconds = 0; long preemptedVcoreSeconds = 0;
for (RMAppAttempt attempt : attempts.values()) { this.readLock.lock();
if (null != attempt) { try {
RMAppAttemptMetrics attemptMetrics = for (RMAppAttempt attempt : attempts.values()) {
attempt.getRMAppAttemptMetrics(); if (null != attempt) {
Resources.addTo(resourcePreempted, RMAppAttemptMetrics attemptMetrics =
attemptMetrics.getResourcePreempted()); attempt.getRMAppAttemptMetrics();
numAMContainerPreempted += attemptMetrics.getIsPreempted() ? 1 : 0; Resources.addTo(resourcePreempted,
numNonAMContainerPreempted += attemptMetrics.getResourcePreempted());
attemptMetrics.getNumNonAMContainersPreempted(); numAMContainerPreempted += attemptMetrics.getIsPreempted() ? 1 : 0;
// getAggregateAppResourceUsage() will calculate resource usage stats numNonAMContainerPreempted +=
// for both running and finished containers. attemptMetrics.getNumNonAMContainersPreempted();
AggregateAppResourceUsage resUsage = // getAggregateAppResourceUsage() will calculate resource usage stats
attempt.getRMAppAttemptMetrics().getAggregateAppResourceUsage(); // for both running and finished containers.
memorySeconds += resUsage.getMemorySeconds(); AggregateAppResourceUsage resUsage =
vcoreSeconds += resUsage.getVcoreSeconds(); attempt.getRMAppAttemptMetrics().getAggregateAppResourceUsage();
preemptedMemorySeconds += attemptMetrics.getPreemptedMemory(); memorySeconds += resUsage.getMemorySeconds();
preemptedVcoreSeconds += attemptMetrics.getPreemptedVcore(); vcoreSeconds += resUsage.getVcoreSeconds();
preemptedMemorySeconds += attemptMetrics.getPreemptedMemory();
preemptedVcoreSeconds += attemptMetrics.getPreemptedVcore();
}
} }
} finally {
this.readLock.unlock();
} }
return new RMAppMetrics(resourcePreempted, return new RMAppMetrics(resourcePreempted,