Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/RouterPolicyFacade.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/RouterPolicyFacade.java (revision eb72628e151b70c6513723f37f87c7855a624876) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/policies/RouterPolicyFacade.java (revision c269e222ce08e945729ff32e51f5d43cd1853f0d) @@ -144,9 +144,14 @@ // 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 SubClusterPolicyConfiguration configuration = null; Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/TestRouterPolicyFacade.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/TestRouterPolicyFacade.java (revision eb72628e151b70c6513723f37f87c7855a624876) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/TestRouterPolicyFacade.java (revision c269e222ce08e945729ff32e51f5d43cd1853f0d) @@ -178,6 +178,35 @@ } + @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 {