diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/ReservedContainerCandidatesSelector.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/ReservedContainerCandidatesSelector.java index 1aafbdc73f..5a3bcff487 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/ReservedContainerCandidatesSelector.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/ReservedContainerCandidatesSelector.java @@ -170,6 +170,9 @@ private NodeForPreemption getPreemptionCandidatesOnNode( Map> selectedCandidates, Resource totalPreemptionAllowed, boolean readOnly) { RMContainer reservedContainer = node.getReservedContainer(); + if (reservedContainer == null) { + return null; + } Resource available = Resources.clone(node.getUnallocatedResource()); Resource totalSelected = Resources.createResource(0); List sortedRunningContainers = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AbstractYarnScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AbstractYarnScheduler.java index b892c6c1e8..3343c5f931 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AbstractYarnScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/AbstractYarnScheduler.java @@ -876,10 +876,9 @@ private void completeOustandingUpdatesWhichAreReserved( RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event) { N schedulerNode = getSchedulerNode(rmContainer.getNodeId()); - if (schedulerNode != null && - schedulerNode.getReservedContainer() != null) { + if (schedulerNode != null) { RMContainer resContainer = schedulerNode.getReservedContainer(); - if (resContainer.getReservedSchedulerKey() != null) { + if (resContainer != null && resContainer.getReservedSchedulerKey() != null) { ContainerId containerToUpdate = resContainer .getReservedSchedulerKey().getContainerToUpdate(); if (containerToUpdate != null && diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/RegularContainerAllocator.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/RegularContainerAllocator.java index 1db33408d7..2fde382b8e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/RegularContainerAllocator.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/allocator/RegularContainerAllocator.java @@ -858,12 +858,13 @@ private ContainerAllocation allocate(Resource clusterResource, FiCaSchedulerNode node = iter.next(); // Do not schedule if there are any reservations to fulfill on the node + RMContainer nodeReservedContainer = node.getReservedContainer(); if (iter.hasNext() && - node.getReservedContainer() != null && + nodeReservedContainer != null && isSkipAllocateOnNodesWithReservedContainer()) { LOG.debug("Skipping scheduling on node {} since it has already been" + " reserved by {}", node.getNodeID(), - node.getReservedContainer().getContainerId()); + nodeReservedContainer.getContainerId()); ActivitiesLogger.APP.recordSkippedAppActivityWithoutAllocation( activitiesManager, node, application, schedulerKey, ActivityDiagnosticConstant.NODE_HAS_BEEN_RESERVED, ActivityLevel.NODE); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java index f050dc3ebc..6497bfdc59 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/common/fica/FiCaSchedulerApp.java @@ -520,13 +520,13 @@ public boolean accept(Resource cluster, // When reserve a resource (state == NEW is for new container, // state == RUNNING is for increase container). // Just check if the node is not already reserved by someone - if (schedulerContainer.getSchedulerNode().getReservedContainer() - != null) { + RMContainer reservedContainer = + schedulerContainer.getSchedulerNode().getReservedContainer(); + if (reservedContainer != null) { if (LOG.isDebugEnabled()) { LOG.debug("Try to reserve a container, but the node is " + "already reserved by another container=" - + schedulerContainer.getSchedulerNode() - .getReservedContainer().getContainerId()); + + reservedContainer.getContainerId()); } return false; }