diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/FederationQueueWeight.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/FederationQueueWeight.java index aa9d114527410..d1b8bcbad04de 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/FederationQueueWeight.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/FederationQueueWeight.java @@ -170,6 +170,26 @@ public static void checkHeadRoomAlphaValid(String headRoomAlpha) throws YarnExce } } + public static void checkPolicyManagerValid(String policyManager) throws YarnException { + switch (policyManager) { + case "org.apache.hadoop.yarn.server.federation.policies.manager.HashBroadcastPolicyManager": + throw new YarnException("HashBroadcastPolicyManager does not support the use of queue weights."); + case "org.apache.hadoop.yarn.server.federation.policies.manager.HomePolicyManager": + throw new YarnException("HomePolicyManager does not support the use of queue weights."); + case "org.apache.hadoop.yarn.server.federation.policies.manager.RejectAllPolicyManager": + throw new YarnException("RejectAllPolicyManager does not support the " + + "use of queue weights."); + case "org.apache.hadoop.yarn.server.federation.policies.manager.UniformBroadcastPolicyManager": + throw new YarnException("UniformBroadcastPolicyManager does not support the " + + "use of queue weights."); + case "org.apache.hadoop.yarn.server.federation.policies.manager.WeightedLocalityPolicyManager": + case "org.apache.hadoop.yarn.server.federation.policies.manager.PriorityBroadcastPolicyManager": + break; + default: + throw new YarnException("Unknown PolicyManager"); + } + } + /** * Determines whether the given value is a number. * diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RouterCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RouterCLI.java index 2da584f9d61bb..c8f7efe5d8ea1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RouterCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RouterCLI.java @@ -75,6 +75,7 @@ import static org.apache.hadoop.yarn.server.api.protocolrecords.FederationQueueWeight.checkHeadRoomAlphaValid; import static org.apache.hadoop.yarn.server.api.protocolrecords.FederationQueueWeight.checkSubClusterQueueWeightRatioValid; +import static org.apache.hadoop.yarn.server.api.protocolrecords.FederationQueueWeight.checkPolicyManagerValid; public class RouterCLI extends Configured implements Tool { @@ -634,6 +635,8 @@ protected SaveFederationQueuePolicyRequest parsePolicy(String policy) throws Yar FederationQueueWeight.newInstance(routerWeight, amrmWeight, headroomalpha); String policyManager = getConf().get(YarnConfiguration.FEDERATION_POLICY_MANAGER, YarnConfiguration.DEFAULT_FEDERATION_POLICY_MANAGER); + checkPolicyManagerValid(policyManager); + SaveFederationQueuePolicyRequest request = SaveFederationQueuePolicyRequest.newInstance( queue, federationQueueWeight, policyManager); @@ -654,6 +657,11 @@ protected SaveFederationQueuePolicyRequest parsePolicy(String policy) throws Yar */ protected int parseXml2PoliciesAndBatchSavePolicies(String policiesXml) { try { + + String policyManager = getConf().get(YarnConfiguration.FEDERATION_POLICY_MANAGER, + YarnConfiguration.DEFAULT_FEDERATION_POLICY_MANAGER); + checkPolicyManagerValid(policyManager); + List federationQueueWeightsList = parsePoliciesByXml(policiesXml); MemoryPageUtils memoryPageUtils = new MemoryPageUtils<>(20); federationQueueWeightsList.forEach(federationQueueWeight -> @@ -726,7 +734,6 @@ protected List parsePoliciesByXml(String policiesXml) String policyManager = getConf().get(YarnConfiguration.FEDERATION_POLICY_MANAGER, YarnConfiguration.DEFAULT_FEDERATION_POLICY_MANAGER); - LOG.debug("Queue: {}, AmrmPolicyWeights: {}, RouterWeight: {}, HeadroomAlpha: {}.", queueName, amrmWeight, routerWeight, headroomAlpha);