YARN-2105. Fix TestFairScheduler after YARN-2012. (Ashwin Shankar via Sandy Ryza)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1597902 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sanford Ryza 2014-05-27 23:46:22 +00:00
parent 0ec6fc9e3c
commit edfbc8ad4a
3 changed files with 44 additions and 1 deletions

View File

@ -149,6 +149,9 @@ Release 2.5.0 - UNRELEASED
YARN-2096. Race in TestRMRestart#testQueueMetricsOnRMRestart.
(Anubhav Dhoot via kasha)
YARN-2105. Fix TestFairScheduler after YARN-2012. (Ashwin Shankar via
Sandy Ryza)
Release 2.4.1 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -280,8 +280,18 @@ public boolean isTerminal() {
* specified the app is placed in root.default queue.
*/
public static class Default extends QueuePlacementRule {
private String defaultQueueName;
@VisibleForTesting
String defaultQueueName;
@Override
public QueuePlacementRule initialize(boolean create,
Map<String, String> args) {
if (defaultQueueName == null) {
defaultQueueName = "root." + YarnConfiguration.DEFAULT_QUEUE_NAME;
}
return super.initialize(create, args);
}
@Override
public void initializeFromXml(Element el)
throws AllocationConfigurationException {

View File

@ -88,6 +88,7 @@
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeRemovedSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueuePlacementRule.Default;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.policies.DominantResourceFairnessPolicy;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.policies.FifoPolicy;
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
@ -2423,6 +2424,35 @@ public void testDontAllowUndeclaredPools() throws Exception{
assertEquals(2, defaultQueue.getRunnableAppSchedulables().size());
}
@Test
public void testDefaultRuleInitializesProperlyWhenPolicyNotConfigured()
throws IOException {
// This test verifies if default rule in queue placement policy
// initializes properly when policy is not configured and
// undeclared pools is not allowed.
conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
conf.setBoolean(FairSchedulerConfiguration.ALLOW_UNDECLARED_POOLS, false);
// Create an alloc file with no queue placement policy
PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
out.println("<?xml version=\"1.0\"?>");
out.println("<allocations>");
out.println("</allocations>");
out.close();
scheduler.reinitialize(conf, resourceManager.getRMContext());
List<QueuePlacementRule> rules = scheduler.allocConf.placementPolicy
.getRules();
for (QueuePlacementRule rule : rules) {
if (rule instanceof Default) {
Default defaultRule = (Default) rule;
assertNotNull(defaultRule.defaultQueueName);
}
}
}
@SuppressWarnings("resource")
@Test
public void testBlacklistNodes() throws Exception {