From 7f8549f4c9b3d342b1bedabc3c1c5326e5c0ce68 Mon Sep 17 00:00:00 2001 From: Alejandro Abdelnur Date: Tue, 23 Jul 2013 00:02:22 +0000 Subject: [PATCH] YARN-461. Fair scheduler should not accept apps with empty string queue name. (ywskycn via tucu) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1505862 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../scheduler/fair/FairScheduler.java | 9 ++++++++ .../scheduler/fair/TestFairScheduler.java | 23 +++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index b23c08fa6a0..7a42e0c0b2c 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -785,6 +785,9 @@ Release 2.1.0-beta - 2013-07-02 YARN-909. Disable TestLinuxContainerExecutorWithMocks on Windows. (Chuan Liu via cnauroth) + YARN-461. Fair scheduler should not accept apps with empty string queue name. + (ywskycn via tucu) + Release 2.0.5-alpha - 06/06/2013 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java index 81fbc16f16a..16b543cdec1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairScheduler.java @@ -604,6 +604,15 @@ public class FairScheduler implements ResourceScheduler { */ protected synchronized void addApplication( ApplicationAttemptId applicationAttemptId, String queueName, String user) { + if (queueName == null || queueName.isEmpty()) { + String message = "Reject application " + applicationAttemptId + + " submitted by user " + user + " with an empty queue name."; + LOG.info(message); + rmContext.getDispatcher().getEventHandler().handle( + new RMAppAttemptRejectedEvent(applicationAttemptId, message)); + return; + } + RMApp rmApp = rmContext.getRMApps().get(applicationAttemptId); FSLeafQueue queue = assignToQueue(rmApp, queueName, user); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java index eaaeda30095..11ea30a1cb0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java @@ -558,7 +558,26 @@ public class TestFairScheduler { assertEquals(0, scheduler.getQueueManager().getLeafQueue("user2") .getAppSchedulables().size()); } - + + @Test + public void testEmptyQueueName() throws Exception { + Configuration conf = createConfiguration(); + + // only default queue + assertEquals(1, scheduler.getQueueManager().getLeafQueues().size()); + + // submit app with empty queue + ApplicationAttemptId appAttemptId = createAppAttemptId(1, 1); + AppAddedSchedulerEvent appAddedEvent = new AppAddedSchedulerEvent( + appAttemptId, "", "user1"); + scheduler.handle(appAddedEvent); + + // submission rejected + assertEquals(1, scheduler.getQueueManager().getLeafQueues().size()); + assertNull(scheduler.getSchedulerApp(appAttemptId)); + assertEquals(0, resourceManager.getRMContext().getRMApps().size()); + } + @Test public void testAssignToQueue() throws Exception { Configuration conf = createConfiguration(); @@ -1929,7 +1948,7 @@ public class TestFairScheduler { scheduler.handle(node2UpdateEvent); assertEquals(1, app.getLiveContainers().size()); } - + /** * If we update our ask to strictly request a node, it doesn't make sense to keep * a reservation on another.