Skip to content

Commit 43e4dc3

Browse files
author
liubin04
committed
YARN-11833. Do not validate queue hierarchy when failing over.
1 parent ff6600c commit 43e4dc3

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,9 @@ public void reinitializeQueues(CapacitySchedulerConfiguration newConf)
193193
CSQueue newRoot = parseQueue(this.csContext.getQueueContext(), newConf, null,
194194
CapacitySchedulerConfiguration.ROOT, newQueues, queues, NOOP);
195195

196-
// When failing over, if using configuration store, don't validate queue
196+
// When failing over, don't validate queue
197197
// hierarchy since queues can be removed without being STOPPED.
198-
if (!csContext.isConfigurationMutable() ||
199-
csContext.getRMContext().getHAServiceState()
198+
if (csContext.getRMContext().getHAServiceState()
200199
!= HAServiceProtocol.HAServiceState.STANDBY) {
201200
// Ensure queue hierarchy in the new XML file is proper.
202201
CapacitySchedulerConfigValidator

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueStateManager.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,24 @@
2525
import static org.mockito.Mockito.mock;
2626
import static org.mockito.Mockito.when;
2727

28+
import java.io.IOException;
29+
import java.util.Arrays;
30+
31+
import org.apache.hadoop.conf.Configuration;
32+
import org.apache.hadoop.ha.HAServiceProtocol;
2833
import org.apache.hadoop.security.AccessControlException;
2934
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
3035
import org.apache.hadoop.yarn.api.records.ApplicationId;
3136
import org.apache.hadoop.yarn.api.records.Priority;
3237
import org.apache.hadoop.yarn.api.records.QueueState;
3338
import org.apache.hadoop.yarn.api.records.Resource;
39+
import org.apache.hadoop.yarn.conf.HAUtil;
3440
import org.apache.hadoop.yarn.conf.YarnConfiguration;
3541
import org.apache.hadoop.yarn.exceptions.YarnException;
3642
import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
43+
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
3744
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
45+
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
3846
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueStateManager;
3947
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp;
4048
import org.apache.hadoop.yarn.util.resource.Resources;
@@ -48,18 +56,22 @@ public class TestQueueStateManager {
4856
private static final String Q1 = "q1";
4957
private static final String Q2 = "q2";
5058
private static final String Q3 = "q3";
59+
private static final String Q4 = "q4";
5160

5261
private final static String Q1_PATH =
5362
CapacitySchedulerConfiguration.ROOT + "." + Q1;
5463
private final static String Q2_PATH =
5564
Q1_PATH + "." + Q2;
5665
private final static String Q3_PATH =
5766
Q1_PATH + "." + Q3;
67+
private final static String Q4_PATH =
68+
CapacitySchedulerConfiguration.ROOT + "." + Q4;
5869
private final static QueuePath ROOT_QUEUE_PATH =
5970
new QueuePath(CapacitySchedulerConfiguration.ROOT);
6071
private final static QueuePath Q1_QUEUE_PATH = new QueuePath(Q1_PATH);
6172
private final static QueuePath Q2_QUEUE_PATH = new QueuePath(Q2_PATH);
6273
private final static QueuePath Q3_QUEUE_PATH = new QueuePath(Q3_PATH);
74+
private final static QueuePath Q4_QUEUE_PATH = new QueuePath(Q4_PATH);
6375
private CapacityScheduler cs;
6476
private YarnConfiguration conf;
6577

@@ -147,6 +159,46 @@ public void testQueueStateManager() throws AccessControlException,
147159
assertEquals(QueueState.STOPPED, cs.getQueue(Q2).getState());
148160
}
149161

162+
@Test
163+
public void testRemoveQueueWithoutStopWhenFailover() throws IOException {
164+
Configuration configuration = new Configuration();
165+
configuration.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
166+
CapacityScheduler.class);
167+
configuration.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
168+
configuration.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
169+
configuration.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2");
170+
for (String confKey : YarnConfiguration
171+
.getServiceAddressConfKeys(configuration)) {
172+
configuration.set(HAUtil.addSuffix(confKey, "rm1"), "1.1.1.1:1");
173+
configuration.set(HAUtil.addSuffix(confKey, "rm2"), "0.0.0.0:0");
174+
}
175+
ResourceManager rm = new MockRM(configuration);
176+
rm.start();
177+
assertEquals(HAServiceProtocol.HAServiceState.STANDBY,
178+
rm.getRMContext().getRMAdminService().getServiceStatus().getState());
179+
180+
CapacitySchedulerConfiguration csConf =
181+
new CapacitySchedulerConfiguration();
182+
csConf.setQueues(ROOT_QUEUE_PATH, new String[] {Q1, Q4});
183+
csConf.setCapacity(Q1_QUEUE_PATH, 100);
184+
csConf.setCapacity(Q4_QUEUE_PATH, 0);
185+
186+
conf = new YarnConfiguration(csConf);
187+
rm.getResourceScheduler().reinitialize(conf, rm.getRMContext());
188+
189+
assertTrue(Arrays.asList(((CapacityScheduler) rm.getResourceScheduler()).getConfiguration()
190+
.get("yarn.scheduler.capacity.root.queues").split(",")).contains(Q1));
191+
assertTrue(Arrays.asList(((CapacityScheduler) rm.getResourceScheduler()).getConfiguration()
192+
.get("yarn.scheduler.capacity.root.queues").split(",")).contains(Q4));
193+
194+
csConf.setQueues(ROOT_QUEUE_PATH, new String[] {Q1});
195+
conf = new YarnConfiguration(csConf);
196+
rm.getResourceScheduler().reinitialize(conf, rm.getRMContext());
197+
198+
assertEquals(Q1, ((CapacityScheduler) rm.getResourceScheduler()).getConfiguration()
199+
.get("yarn.scheduler.capacity.root.queues"));
200+
}
201+
150202
private FiCaSchedulerApp getMockApplication(ApplicationId appId, String user,
151203
Resource amResource) {
152204
FiCaSchedulerApp application = mock(FiCaSchedulerApp.class);

0 commit comments

Comments
 (0)