YARN-7007. NPE in RM while using YarnClient.getApplications(). Contributed by Lingfeng Su.
This commit is contained in:
parent
c6b4e656b7
commit
e05fa3451d
|
@ -31,6 +31,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
|||
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport;
|
||||
import org.apache.hadoop.yarn.api.records.Resource;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
|
||||
import org.apache.hadoop.yarn.util.resource.Resources;
|
||||
|
@ -125,8 +126,9 @@ public class RMAppAttemptMetrics {
|
|||
long vcoreSeconds = finishedVcoreSeconds.get();
|
||||
|
||||
// Only add in the running containers if this is the active attempt.
|
||||
RMAppAttempt currentAttempt = rmContext.getRMApps()
|
||||
.get(attemptId.getApplicationId()).getCurrentAppAttempt();
|
||||
RMApp rmApp = rmContext.getRMApps().get(attemptId.getApplicationId());
|
||||
if (null != rmApp) {
|
||||
RMAppAttempt currentAttempt = rmApp.getCurrentAppAttempt();
|
||||
if (currentAttempt.getAppAttemptId().equals(attemptId)) {
|
||||
ApplicationResourceUsageReport appResUsageReport = rmContext
|
||||
.getScheduler().getAppResourceUsageReport(attemptId);
|
||||
|
@ -135,6 +137,7 @@ public class RMAppAttemptMetrics {
|
|||
vcoreSeconds += appResUsageReport.getVcoreSeconds();
|
||||
}
|
||||
}
|
||||
}
|
||||
return new AggregateAppResourceUsage(memorySeconds, vcoreSeconds);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue