From 1dbf87c9ff33b5e2f6cbb0ce8efd348c4314a0e2 Mon Sep 17 00:00:00 2001 From: Jonathan Hung Date: Tue, 10 Sep 2019 15:19:07 -0700 Subject: [PATCH] YARN-9824. Fall back to configured queue ordering policy class name (cherry picked from commit f8f8598ea5e86330fa5b553963f5632da286409d) --- .../CapacitySchedulerConfiguration.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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/CapacitySchedulerConfiguration.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/CapacitySchedulerConfiguration.java index dec6a84ed1a..4e49474782c 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/CapacitySchedulerConfiguration.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/CapacitySchedulerConfiguration.java @@ -1561,20 +1561,23 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur } String policyType = get(getQueuePrefix(queue) + ORDERING_POLICY, - defaultPolicy); + defaultPolicy).trim(); QueueOrderingPolicy qop; - if (policyType.trim().equals(QUEUE_UTILIZATION_ORDERING_POLICY)) { + if (policyType.equals(QUEUE_UTILIZATION_ORDERING_POLICY)) { // Doesn't respect priority qop = new PriorityUtilizationQueueOrderingPolicy(false); - } else if (policyType.trim().equals( + } else if (policyType.equals( QUEUE_PRIORITY_UTILIZATION_ORDERING_POLICY)) { qop = new PriorityUtilizationQueueOrderingPolicy(true); } else { - String message = - "Unable to construct queue ordering policy=" + policyType + " queue=" - + queue; - throw new YarnRuntimeException(message); + try { + qop = (QueueOrderingPolicy) Class.forName(policyType).newInstance(); + } catch (Exception e) { + String message = "Unable to construct queue ordering policy=" + + policyType + " queue=" + queue; + throw new YarnRuntimeException(message, e); + } } return qop;