diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/RouterPolicyFacade.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/RouterPolicyFacade.java index 6bde4a312b4..66ac106e558 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/RouterPolicyFacade.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/RouterPolicyFacade.java @@ -144,8 +144,12 @@ public SubClusterId getHomeSubcluster( // respecting YARN behavior we assume default queue if the queue is not // specified. This also ensures that "null" can be used as a key to get the // default behavior. + //While in YARN at root.abc is equivalent to the abc queue, the routing + // behavior of both should be consistent in yarn federation if (queue == null) { queue = YarnConfiguration.DEFAULT_QUEUE_NAME; + } else if (queue.startsWith("root.") && queue.length()>5) { + queue = queue.substring(5); } // the facade might cache this request, based on its parameterization diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/TestRouterPolicyFacade.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/TestRouterPolicyFacade.java index d0e2decb2de..e68c1c5bff5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/TestRouterPolicyFacade.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/TestRouterPolicyFacade.java @@ -178,6 +178,35 @@ public void testFallbacks() throws YarnException { } + @Test + public void testEquivalentQueue() throws YarnException { + + // The test is that if we enter the queue with the full name or omit the + // prefix "root.", the routing cluster behavior should be consistent. + ApplicationSubmissionContext applicationSubmissionContext = + mock(ApplicationSubmissionContext.class); + + // then the operator changes how queue1 is routed setting it to + // PriorityRouterPolicy with weights favoring the first subcluster in + // subClusterIds. + store.setPolicyConfiguration(SetSubClusterPolicyConfigurationRequest + .newInstance(getPriorityPolicy(queue1))); + + String shortQueue = queue1; + when(applicationSubmissionContext.getQueue()).thenReturn(shortQueue); + SubClusterId chosen1 = + routerFacade.getHomeSubcluster(applicationSubmissionContext, null); + + //use the full queue name with prefix "root." + String fullQueue = "root." + queue1; + when(applicationSubmissionContext.getQueue()).thenReturn(fullQueue); + SubClusterId chosen2 = + routerFacade.getHomeSubcluster(applicationSubmissionContext, null); + + Assert.assertTrue(chosen1.equals(chosen2)); + + } + public static SubClusterPolicyConfiguration getUniformPolicy(String queue) throws FederationPolicyInitializationException {