tomicooler commented on a change in pull request #3459: URL: https://github.com/apache/hadoop/pull/3459#discussion_r712713688
########## File path: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueHelpers.java ########## @@ -0,0 +1,324 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity; + +import java.util.List; + +import static org.junit.Assert.assertEquals; + +public final class CapacitySchedulerQueueHelpers { + + public static final String A = CapacitySchedulerConfiguration.ROOT + ".a"; + public static final String B = CapacitySchedulerConfiguration.ROOT + ".b"; + public static final String A1 = A + ".a1"; + public static final String A2 = A + ".a2"; + public static final String B1 = B + ".b1"; + public static final String B2 = B + ".b2"; + public static final String B3 = B + ".b3"; + public static final float A_CAPACITY = 10.5f; + public static final float B_CAPACITY = 89.5f; + public static final String P1 = CapacitySchedulerConfiguration.ROOT + ".p1"; + public static final String P2 = CapacitySchedulerConfiguration.ROOT + ".p2"; + public static final String X1 = P1 + ".x1"; + public static final String X2 = P1 + ".x2"; + public static final String Y1 = P2 + ".y1"; + public static final String Y2 = P2 + ".y2"; + public static final float A1_CAPACITY = 30; + public static final float A2_CAPACITY = 70; + public static final float B1_CAPACITY = 79.2f; + public static final float B2_CAPACITY = 0.8f; + public static float B3_CAPACITY = 20; + + private CapacitySchedulerQueueHelpers() { + throw new IllegalStateException("Utility class"); + } + + /** + * @param conf, to be modified + * @return + * root + * / \ + * a b + * / \ / | \ + * a1 a2 b1 b2 b3 + * + */ + public static CapacitySchedulerConfiguration setupQueueConfiguration( + CapacitySchedulerConfiguration conf) { + + // Define top-level queues + conf.setQueues(CapacitySchedulerConfiguration.ROOT, new String[]{"a", "b"}); + + conf.setCapacity(A, A_CAPACITY); + conf.setCapacity(B, B_CAPACITY); + + // Define 2nd-level queues + conf.setQueues(A, new String[]{"a1", "a2"}); + conf.setCapacity(A1, A1_CAPACITY); + conf.setUserLimitFactor(A1, 100.0f); + conf.setCapacity(A2, A2_CAPACITY); + conf.setUserLimitFactor(A2, 100.0f); + + conf.setQueues(B, new String[]{"b1", "b2", "b3"}); + conf.setCapacity(B1, B1_CAPACITY); + conf.setUserLimitFactor(B1, 100.0f); + conf.setCapacity(B2, B2_CAPACITY); + conf.setUserLimitFactor(B2, 100.0f); + conf.setCapacity(B3, B3_CAPACITY); + conf.setUserLimitFactor(B3, 100.0f); + + return conf; + } + + /** + * @param conf, to be modified + * @return CS configuration which has deleted all childred of queue(b) + * root + * / \ + * a b + * / \ + * a1 a2 + */ + public static CapacitySchedulerConfiguration setupQueueConfWithOutChildrenOfB( + CapacitySchedulerConfiguration conf) { + + // Define top-level queues + conf.setQueues(CapacitySchedulerConfiguration.ROOT, + new String[]{"a", "b"}); + + conf.setCapacity(A, A_CAPACITY); + conf.setCapacity(B, B_CAPACITY); + + // Define 2nd-level queues + conf.setQueues(A, new String[]{"a1", "a2"}); + conf.setCapacity(A1, A1_CAPACITY); + conf.setUserLimitFactor(A1, 100.0f); + conf.setCapacity(A2, A2_CAPACITY); + conf.setUserLimitFactor(A2, 100.0f); + + return conf; + } + + /** + * @param conf, to be modified + * @return CS configuration which has deleted a queue(b1) + * root + * / \ + * a b + * / \ | \ + * a1 a2 b2 b3 + */ + public static CapacitySchedulerConfiguration setupQueueConfigurationWithOutB1( Review comment: Done. ########## File path: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueHelpers.java ########## @@ -0,0 +1,324 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity; + +import java.util.List; + +import static org.junit.Assert.assertEquals; + +public final class CapacitySchedulerQueueHelpers { + + public static final String A = CapacitySchedulerConfiguration.ROOT + ".a"; + public static final String B = CapacitySchedulerConfiguration.ROOT + ".b"; + public static final String A1 = A + ".a1"; + public static final String A2 = A + ".a2"; + public static final String B1 = B + ".b1"; + public static final String B2 = B + ".b2"; + public static final String B3 = B + ".b3"; + public static final float A_CAPACITY = 10.5f; + public static final float B_CAPACITY = 89.5f; + public static final String P1 = CapacitySchedulerConfiguration.ROOT + ".p1"; + public static final String P2 = CapacitySchedulerConfiguration.ROOT + ".p2"; + public static final String X1 = P1 + ".x1"; + public static final String X2 = P1 + ".x2"; + public static final String Y1 = P2 + ".y1"; + public static final String Y2 = P2 + ".y2"; + public static final float A1_CAPACITY = 30; + public static final float A2_CAPACITY = 70; + public static final float B1_CAPACITY = 79.2f; + public static final float B2_CAPACITY = 0.8f; + public static float B3_CAPACITY = 20; + + private CapacitySchedulerQueueHelpers() { + throw new IllegalStateException("Utility class"); + } + + /** + * @param conf, to be modified + * @return + * root + * / \ + * a b + * / \ / | \ + * a1 a2 b1 b2 b3 + * + */ + public static CapacitySchedulerConfiguration setupQueueConfiguration( + CapacitySchedulerConfiguration conf) { + + // Define top-level queues + conf.setQueues(CapacitySchedulerConfiguration.ROOT, new String[]{"a", "b"}); + + conf.setCapacity(A, A_CAPACITY); + conf.setCapacity(B, B_CAPACITY); + + // Define 2nd-level queues + conf.setQueues(A, new String[]{"a1", "a2"}); + conf.setCapacity(A1, A1_CAPACITY); + conf.setUserLimitFactor(A1, 100.0f); + conf.setCapacity(A2, A2_CAPACITY); + conf.setUserLimitFactor(A2, 100.0f); + + conf.setQueues(B, new String[]{"b1", "b2", "b3"}); + conf.setCapacity(B1, B1_CAPACITY); + conf.setUserLimitFactor(B1, 100.0f); + conf.setCapacity(B2, B2_CAPACITY); + conf.setUserLimitFactor(B2, 100.0f); + conf.setCapacity(B3, B3_CAPACITY); + conf.setUserLimitFactor(B3, 100.0f); + + return conf; + } + + /** + * @param conf, to be modified + * @return CS configuration which has deleted all childred of queue(b) + * root + * / \ + * a b + * / \ + * a1 a2 + */ + public static CapacitySchedulerConfiguration setupQueueConfWithOutChildrenOfB( + CapacitySchedulerConfiguration conf) { + + // Define top-level queues + conf.setQueues(CapacitySchedulerConfiguration.ROOT, + new String[]{"a", "b"}); + + conf.setCapacity(A, A_CAPACITY); + conf.setCapacity(B, B_CAPACITY); + + // Define 2nd-level queues + conf.setQueues(A, new String[]{"a1", "a2"}); + conf.setCapacity(A1, A1_CAPACITY); + conf.setUserLimitFactor(A1, 100.0f); + conf.setCapacity(A2, A2_CAPACITY); + conf.setUserLimitFactor(A2, 100.0f); + + return conf; + } + + /** + * @param conf, to be modified + * @return CS configuration which has deleted a queue(b1) + * root + * / \ + * a b + * / \ | \ + * a1 a2 b2 b3 + */ + public static CapacitySchedulerConfiguration setupQueueConfigurationWithOutB1( + CapacitySchedulerConfiguration conf) { + + // Define top-level queues + conf.setQueues(CapacitySchedulerConfiguration.ROOT, + new String[]{"a", "b"}); + + conf.setCapacity(A, A_CAPACITY); + conf.setCapacity(B, B_CAPACITY); + + // Define 2nd-level queues + conf.setQueues(A, new String[]{"a1", "a2"}); + conf.setCapacity(A1, A1_CAPACITY); + conf.setUserLimitFactor(A1, 100.0f); + conf.setCapacity(A2, A2_CAPACITY); + conf.setUserLimitFactor(A2, 100.0f); + + conf.setQueues(B, new String[]{"b2", "b3"}); + conf.setCapacity(B2, B2_CAPACITY + B1_CAPACITY); //as B1 is deleted + conf.setUserLimitFactor(B2, 100.0f); + conf.setCapacity(B3, B3_CAPACITY); + conf.setUserLimitFactor(B3, 100.0f); + + return conf; + } + + /** + * @param conf, to be modified + * @return CS configuration which has converted b1 to parent queue + * root + * / \ + * a b + * / \ / | \ + * a1 a2 b1 b2 b3 + * | + * b11 + */ + public static CapacitySchedulerConfiguration setupQueueConfigurationWithB1AsParentQueue( + CapacitySchedulerConfiguration conf) { + + // Define top-level queues + conf.setQueues(CapacitySchedulerConfiguration.ROOT, + new String[]{"a", "b"}); + + conf.setCapacity(A, A_CAPACITY); + conf.setCapacity(B, B_CAPACITY); + + // Define 2nd-level queues + conf.setQueues(A, new String[]{"a1", "a2"}); + conf.setCapacity(A1, A1_CAPACITY); + conf.setUserLimitFactor(A1, 100.0f); + conf.setCapacity(A2, A2_CAPACITY); + conf.setUserLimitFactor(A2, 100.0f); + + conf.setQueues(B, new String[]{"b1", "b2", "b3"}); + conf.setCapacity(B1, B1_CAPACITY); + conf.setUserLimitFactor(B1, 100.0f); + conf.setCapacity(B2, B2_CAPACITY); + conf.setUserLimitFactor(B2, 100.0f); + conf.setCapacity(B3, B3_CAPACITY); + conf.setUserLimitFactor(B3, 100.0f); + + // Set childQueue for B1 + conf.setQueues(B1, new String[]{"b11"}); + String B11 = B1 + ".b11"; + conf.setCapacity(B11, 100.0f); + conf.setUserLimitFactor(B11, 100.0f); + + return conf; + } + + /** + * @param conf, to be modified + * @return CS configuration which has deleted a Parent queue(b) + */ + public static CapacitySchedulerConfiguration setupQueueConfigurationWithOutB( Review comment: Done. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
