From f8f8598ea5e86330fa5b553963f5632da286409d 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 --- .../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 a88beef8c97..990c8f3de8c 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 @@ -1552,20 +1552,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;