YARN-8222. Fix potential NPE when gets RMApp from RM context. Contributed by Tao Yang.
This commit is contained in:
parent
2741af505f
commit
6fce88765a
|
@ -44,6 +44,7 @@ import org.apache.hadoop.yarn.event.EventHandler;
|
|||
import org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppRunningOnNodeEvent;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEvent;
|
||||
|
@ -737,10 +738,10 @@ public class RMContainerImpl implements RMContainer {
|
|||
|
||||
private static void updateAttemptMetrics(RMContainerImpl container) {
|
||||
Resource resource = container.getContainer().getResource();
|
||||
RMAppAttempt rmAttempt = container.rmContext.getRMApps()
|
||||
.get(container.getApplicationAttemptId().getApplicationId())
|
||||
.getCurrentAppAttempt();
|
||||
|
||||
RMApp app = container.rmContext.getRMApps()
|
||||
.get(container.getApplicationAttemptId().getApplicationId());
|
||||
if (app != null) {
|
||||
RMAppAttempt rmAttempt = app.getCurrentAppAttempt();
|
||||
if (rmAttempt != null) {
|
||||
long usedMillis = container.finishTime - container.creationTime;
|
||||
rmAttempt.getRMAppAttemptMetrics()
|
||||
|
@ -756,6 +757,7 @@ public class RMContainerImpl implements RMContainer {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final class KillTransition extends FinishedTransition {
|
||||
|
||||
|
|
|
@ -1241,12 +1241,13 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
|
|||
return;
|
||||
}
|
||||
|
||||
RMAppAttempt attempt =
|
||||
rmContext.getRMApps().get(attemptId.getApplicationId())
|
||||
.getCurrentAppAttempt();
|
||||
RMApp app = rmContext.getRMApps().get(attemptId.getApplicationId());
|
||||
if (app != null) {
|
||||
RMAppAttempt attempt = app.getCurrentAppAttempt();
|
||||
if (attempt != null) {
|
||||
attempt.getRMAppAttemptMetrics().incNumAllocatedContainers(containerType,
|
||||
requestType);
|
||||
attempt.getRMAppAttemptMetrics()
|
||||
.incNumAllocatedContainers(containerType, requestType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue