From 8b59d8573306f95f83b598dd87c077574db4ca32 Mon Sep 17 00:00:00 2001 From: zeekling Date: Wed, 6 Nov 2024 00:37:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Capacity=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E5=99=A8=E7=9A=84=E6=BA=90=E7=A0=81=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resourcemanager/scheduler/capacity/CapacityScheduler.java | 4 ++++ .../resourcemanager/scheduler/capacity/ParentQueue.java | 2 ++ 2 files changed, 6 insertions(+) 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/CapacityScheduler.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/CapacityScheduler.java index 3e068888a7..148861f604 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/CapacityScheduler.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/CapacityScheduler.java @@ -1606,6 +1606,7 @@ private CSAssignment allocateContainerOnSingleNode( // 2. Schedule if there are no reservations RMContainer reservedContainer = node.getReservedContainer(); if (reservedContainer != null) { + // 存在预留资源,优先使用预留资源。 allocateFromReservedContainer(node, withNodeHeartbeat, reservedContainer); // Do not schedule if there are any reservations to fulfill on the node LOG.debug("Skipping scheduling since node {} is reserved by" @@ -1620,6 +1621,7 @@ private CSAssignment allocateContainerOnSingleNode( if (calculator.computeAvailableContainers(Resources .add(node.getUnallocatedResource(), node.getTotalKillableResources()), minimumAllocation) <= 0) { + // 对于剩余资源不够的情况,无须继续分配资源 LOG.debug("This node " + node.getNodeID() + " doesn't have sufficient " + "available or preemptible resource for minimum allocation"); ActivitiesLogger.QUEUE.recordQueueActivity(activitiesManager, node, @@ -1631,6 +1633,7 @@ private CSAssignment allocateContainerOnSingleNode( return null; } + // 开始分配或者预留资源 return allocateOrReserveNewContainers(candidates, withNodeHeartbeat); } @@ -1693,6 +1696,7 @@ private void allocateFromReservedContainer(FiCaSchedulerNode node, private CSAssignment allocateOrReserveNewContainers( CandidateNodeSet candidates, boolean withNodeHeartbeat) { + // 优先按照资源池标签从根队列开始分配。 CSAssignment assignment = getRootQueue().assignContainers( getClusterResource(), candidates, new ResourceLimits(labelManager .getResourceByLabel(candidates.getPartition(), 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/ParentQueue.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/ParentQueue.java index 1f31d8b0a0..c5dc31504c 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/ParentQueue.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/ParentQueue.java @@ -548,6 +548,7 @@ public CSAssignment assignContainers(Resource clusterResource, // if our queue cannot access this node, just return if (schedulingMode == SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY && !accessibleToPartition(candidates.getPartition())) { + // 没权限 if (LOG.isDebugEnabled()) { long now = System.currentTimeMillis(); // Do logging every 1 sec to avoid excessive logging. @@ -574,6 +575,7 @@ public CSAssignment assignContainers(Resource clusterResource, // queue doesn't need more resources. if (!super.hasPendingResourceRequest(candidates.getPartition(), clusterResource, schedulingMode)) { + // 没分配请求 if (LOG.isDebugEnabled()) { long now = System.currentTimeMillis(); // Do logging every 1 sec to avoid excessive logging.