hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkarana...@apache.org
Subject [16/50] [abbrv] hadoop git commit: YARN-7454. RMAppAttemptMetrics#getAggregateResourceUsage can NPE due to double lookup. Contributed by Jason Lowe.
Date Mon, 13 Nov 2017 23:29:12 GMT
YARN-7454. RMAppAttemptMetrics#getAggregateResourceUsage can NPE due to double lookup. Contributed
by Jason Lowe.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/0a72c2f5
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/0a72c2f5
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/0a72c2f5

Branch: refs/heads/YARN-6592
Commit: 0a72c2f56c37063609de72eef1f74632890c048a
Parents: 3a3566e
Author: bibinchundatt <bibinchundatt@apache.org>
Authored: Thu Nov 9 21:01:19 2017 +0530
Committer: bibinchundatt <bibinchundatt@apache.org>
Committed: Thu Nov 9 21:01:19 2017 +0530

----------------------------------------------------------------------
 .../rmapp/attempt/RMAppAttemptMetrics.java           | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/0a72c2f5/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
----------------------------------------------------------------------
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 0982ef9..015cff7 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
@@ -135,20 +135,21 @@ public class RMAppAttemptMetrics {
     // Only add in the running containers if this is the active attempt.
     RMApp rmApp = rmContext.getRMApps().get(attemptId.getApplicationId());
     if (rmApp != null) {
-      RMAppAttempt currentAttempt = rmContext.getRMApps().get(attemptId.getApplicationId()).getCurrentAppAttempt();
-      if (currentAttempt.getAppAttemptId().equals(attemptId)) {
+      RMAppAttempt currentAttempt = rmApp.getCurrentAppAttempt();
+      if (currentAttempt != null
+          && currentAttempt.getAppAttemptId().equals(attemptId)) {
         ApplicationResourceUsageReport appResUsageReport =
             rmContext.getScheduler().getAppResourceUsageReport(attemptId);
         if (appResUsageReport != null) {
           Map<String, Long> tmp = appResUsageReport.getResourceSecondsMap();
           for (Map.Entry<String, Long> entry : tmp.entrySet()) {
-            if (resourcesUsed.containsKey(entry.getKey())) {
-              Long value = resourcesUsed.get(entry.getKey());
+            Long value = resourcesUsed.get(entry.getKey());
+            if (value != null) {
               value += entry.getValue();
-              resourcesUsed.put(entry.getKey(), value);
-            } else{
-              resourcesUsed.put(entry.getKey(), entry.getValue());
+            } else {
+              value = entry.getValue();
             }
+            resourcesUsed.put(entry.getKey(), value);
           }
         }
       }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message