MAPREDUCE-3910. Fixed a bug in CapacityScheduler LeafQueue which was causing app-submission to fail. Contributed by John George.
svn merge --ignore-ancestry -c 1293750 ../../trunk
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1293753 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt
index c428084..d6daeaa 100644
--- a/hadoop-mapreduce-project/CHANGES.txt
+++ b/hadoop-mapreduce-project/CHANGES.txt
@@ -77,6 +77,9 @@
MAPREDUCE-3904 Job history produced with mapreduce.cluster.acls.enabled
false can not be viewed with mapreduce.cluster.acls.enabled true
(Jonathon Eagles via tgraves)
+
+ MAPREDUCE-3910. Fixed a bug in CapacityScheduler LeafQueue which was causing
+ app-submission to fail. (John George via vinodkv)
Release 0.23.1 - 2012-02-17
diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
index f21cfc2..91f1c8e 100644
--- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
+++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/LeafQueue.java
@@ -572,12 +572,7 @@
// Careful! Locking order is important!
// Check queue ACLs
- UserGroupInformation userUgi;
- try {
- userUgi = UserGroupInformation.getCurrentUser();
- } catch (IOException ioe) {
- throw new AccessControlException(ioe);
- }
+ UserGroupInformation userUgi = UserGroupInformation.createRemoteUser(userName);
if (!hasAccess(QueueACL.SUBMIT_APPLICATIONS, userUgi)) {
throw new AccessControlException("User " + userName + " cannot submit" +
" applications to queue " + getQueuePath());
diff --git a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java
index 52430e8..75e0d20 100644
--- a/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java
+++ b/hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestLeafQueue.java
@@ -119,10 +119,11 @@
private static final String B = "b";
private static final String C = "c";
private static final String C1 = "c1";
+ private static final String D = "d";
private void setupQueueConfiguration(CapacitySchedulerConfiguration conf) {
// Define top-level queues
- conf.setQueues(CapacitySchedulerConfiguration.ROOT, new String[] {A, B, C});
+ conf.setQueues(CapacitySchedulerConfiguration.ROOT, new String[] {A, B, C, D});
conf.setCapacity(CapacitySchedulerConfiguration.ROOT, 100);
conf.setMaximumCapacity(CapacitySchedulerConfiguration.ROOT, 100);
conf.setAcl(CapacitySchedulerConfiguration.ROOT, QueueACL.SUBMIT_APPLICATIONS, " ");
@@ -133,7 +134,7 @@
conf.setAcl(Q_A, QueueACL.SUBMIT_APPLICATIONS, "*");
final String Q_B = CapacitySchedulerConfiguration.ROOT + "." + B;
- conf.setCapacity(Q_B, 90);
+ conf.setCapacity(Q_B, 80);
conf.setMaximumCapacity(Q_B, 99);
conf.setAcl(Q_B, QueueACL.SUBMIT_APPLICATIONS, "*");
@@ -146,6 +147,11 @@
final String Q_C1 = Q_C + "." + C1;
conf.setCapacity(Q_C1, 100);
+
+ final String Q_D = CapacitySchedulerConfiguration.ROOT + "." + D;
+ conf.setCapacity(Q_D, 10);
+ conf.setMaximumCapacity(Q_D, 11);
+ conf.setAcl(Q_D, QueueACL.SUBMIT_APPLICATIONS, "user_d");
}
@@ -202,8 +208,8 @@
assertEquals(0.2, a.getAbsoluteMaximumCapacity(), epsilon);
LeafQueue b = stubLeafQueue((LeafQueue)queues.get(B));
- assertEquals(0.9, b.getCapacity(), epsilon);
- assertEquals(0.9, b.getAbsoluteCapacity(), epsilon);
+ assertEquals(0.80, b.getCapacity(), epsilon);
+ assertEquals(0.80, b.getAbsoluteCapacity(), epsilon);
assertEquals(0.99, b.getMaximumCapacity(), epsilon);
assertEquals(0.99, b.getAbsoluteMaximumCapacity(), epsilon);
@@ -257,10 +263,35 @@
// Only 1 container
a.assignContainers(clusterResource, node_0);
- assertEquals(7*GB, a.getMetrics().getAvailableMB());
+ assertEquals(6*GB, a.getMetrics().getAvailableMB());
}
@Test
+ public void testUserQueueAcl() throws Exception {
+
+ // Manipulate queue 'a'
+ LeafQueue d = stubLeafQueue((LeafQueue) queues.get(D));
+
+ // Users
+ final String user_d = "user_d";
+
+ // Submit applications
+ final ApplicationAttemptId appAttemptId_0 = TestUtils
+ .getMockApplicationAttemptId(0, 1);
+ SchedulerApp app_0 = new SchedulerApp(appAttemptId_0, user_d, d, null,
+ rmContext, null);
+ d.submitApplication(app_0, user_d, D);
+
+ // Attempt the same application again
+ final ApplicationAttemptId appAttemptId_1 = TestUtils
+ .getMockApplicationAttemptId(0, 2);
+ SchedulerApp app_1 = new SchedulerApp(appAttemptId_1, user_d, d, null,
+ rmContext, null);
+ d.submitApplication(app_1, user_d, D); // same user
+ }
+
+
+ @Test
public void testAppAttemptMetrics() throws Exception {
// Manipulate queue 'a'