YARN-853. Fixed CapacityScheduler's maximum-am-resource-percent to properly work beyond refreshing queues. Contributed by Devaraj K.

svn merge --ignore-ancestry -c 1505855 ../../trunk/


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1505856 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2013-07-22 23:50:54 +00:00
parent 9c790a8fb7
commit 10e4f3b4bd
4 changed files with 67 additions and 11 deletions

View File

@ -717,6 +717,9 @@ Release 2.1.0-beta - 2013-07-02
YARN-897. Ensure child queues are ordered correctly to account for YARN-897. Ensure child queues are ordered correctly to account for
completed containers. (Djellel Eddine Difallah via acmurthy) completed containers. (Djellel Eddine Difallah via acmurthy)
YARN-853. Fixed CapacityScheduler's maximum-am-resource-percent to properly
work beyond refreshing queues. (Devaraj K via vinodkv)
BREAKDOWN OF HADOOP-8562/YARN-191 SUBTASKS AND RELATED JIRAS BREAKDOWN OF HADOOP-8562/YARN-191 SUBTASKS AND RELATED JIRAS
YARN-158. Yarn creating package-info.java must not depend on sh. YARN-158. Yarn creating package-info.java must not depend on sh.

View File

@ -151,6 +151,7 @@
<Field name="state" /> <Field name="state" />
<Field name="userLimit" /> <Field name="userLimit" />
<Field name="userLimitFactor" /> <Field name="userLimitFactor" />
<Field name="maxAMResourcePerQueuePercent" />
</Or> </Or>
<Bug pattern="IS2_INCONSISTENT_SYNC" /> <Bug pattern="IS2_INCONSISTENT_SYNC" />
</Match> </Match>

View File

@ -171,9 +171,8 @@ public class LeafQueue implements CSQueue {
maxApplicationsPerUser = maxApplicationsPerUser =
(int)(maxApplications * (userLimit / 100.0f) * userLimitFactor); (int)(maxApplications * (userLimit / 100.0f) * userLimitFactor);
this.maxAMResourcePerQueuePercent = float maxAMResourcePerQueuePercent = cs.getConfiguration()
cs.getConfiguration(). .getMaximumApplicationMasterResourcePerQueuePercent(getQueuePath());
getMaximumApplicationMasterResourcePerQueuePercent(getQueuePath());
int maxActiveApplications = int maxActiveApplications =
CSQueueUtils.computeMaxActiveApplications( CSQueueUtils.computeMaxActiveApplications(
resourceCalculator, resourceCalculator,
@ -202,9 +201,9 @@ public class LeafQueue implements CSQueue {
capacity, absoluteCapacity, capacity, absoluteCapacity,
maximumCapacity, absoluteMaxCapacity, maximumCapacity, absoluteMaxCapacity,
userLimit, userLimitFactor, userLimit, userLimitFactor,
maxApplications, maxApplicationsPerUser, maxApplications, maxAMResourcePerQueuePercent, maxApplicationsPerUser,
maxActiveApplications, maxActiveApplicationsPerUser, maxActiveApplications, maxActiveApplicationsPerUser, state, acls, cs
state, acls, cs.getConfiguration().getNodeLocalityDelay()); .getConfiguration().getNodeLocalityDelay());
if(LOG.isDebugEnabled()) { if(LOG.isDebugEnabled()) {
LOG.debug("LeafQueue:" + " name=" + queueName LOG.debug("LeafQueue:" + " name=" + queueName
@ -223,10 +222,10 @@ public class LeafQueue implements CSQueue {
float capacity, float absoluteCapacity, float capacity, float absoluteCapacity,
float maximumCapacity, float absoluteMaxCapacity, float maximumCapacity, float absoluteMaxCapacity,
int userLimit, float userLimitFactor, int userLimit, float userLimitFactor,
int maxApplications, int maxApplicationsPerUser, int maxApplications, float maxAMResourcePerQueuePercent,
int maxActiveApplications, int maxActiveApplicationsPerUser, int maxApplicationsPerUser, int maxActiveApplications,
QueueState state, Map<QueueACL, AccessControlList> acls, int maxActiveApplicationsPerUser, QueueState state,
int nodeLocalityDelay) Map<QueueACL, AccessControlList> acls, int nodeLocalityDelay)
{ {
// Sanity check // Sanity check
CSQueueUtils.checkMaxCapacity(getQueueName(), capacity, maximumCapacity); CSQueueUtils.checkMaxCapacity(getQueueName(), capacity, maximumCapacity);
@ -243,6 +242,7 @@ public class LeafQueue implements CSQueue {
this.userLimitFactor = userLimitFactor; this.userLimitFactor = userLimitFactor;
this.maxApplications = maxApplications; this.maxApplications = maxApplications;
this.maxAMResourcePerQueuePercent = maxAMResourcePerQueuePercent;
this.maxApplicationsPerUser = maxApplicationsPerUser; this.maxApplicationsPerUser = maxApplicationsPerUser;
this.maxActiveApplications = maxActiveApplications; this.maxActiveApplications = maxActiveApplications;
@ -392,6 +392,14 @@ public class LeafQueue implements CSQueue {
public float getMinimumAllocationFactor() { public float getMinimumAllocationFactor() {
return minimumAllocationFactor; return minimumAllocationFactor;
} }
/**
* Used only by tests.
*/
@Private
public float getMaxAMResourcePerQueuePercent() {
return maxAMResourcePerQueuePercent;
}
public int getMaxApplications() { public int getMaxApplications() {
return maxApplications; return maxApplications;
@ -604,6 +612,7 @@ public class LeafQueue implements CSQueue {
newlyParsedLeafQueue.absoluteMaxCapacity, newlyParsedLeafQueue.absoluteMaxCapacity,
newlyParsedLeafQueue.userLimit, newlyParsedLeafQueue.userLimitFactor, newlyParsedLeafQueue.userLimit, newlyParsedLeafQueue.userLimitFactor,
newlyParsedLeafQueue.maxApplications, newlyParsedLeafQueue.maxApplications,
newlyParsedLeafQueue.maxAMResourcePerQueuePercent,
newlyParsedLeafQueue.getMaxApplicationsPerUser(), newlyParsedLeafQueue.getMaxApplicationsPerUser(),
newlyParsedLeafQueue.getMaximumActiveApplications(), newlyParsedLeafQueue.getMaximumActiveApplications(),
newlyParsedLeafQueue.getMaximumActiveApplicationsPerUser(), newlyParsedLeafQueue.getMaximumActiveApplicationsPerUser(),

View File

@ -43,7 +43,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest;
import org.apache.hadoop.yarn.api.records.Container; import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.ContainerStatus;
@ -1961,6 +1960,50 @@ public class TestLeafQueue {
assertEquals(0, app_0.getTotalRequiredResources(priority)); assertEquals(0, app_0.getTotalRequiredResources(priority));
} }
@Test
public void testMaxAMResourcePerQueuePercentAfterQueueRefresh()
throws Exception {
CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration();
Resource clusterResource = Resources
.createResource(100 * 16 * GB, 100 * 32);
CapacitySchedulerContext csContext = mockCSContext(csConf, clusterResource);
csConf.setFloat(CapacitySchedulerConfiguration.
MAXIMUM_APPLICATION_MASTERS_RESOURCE_PERCENT, 0.1f);
ParentQueue root = new ParentQueue(csContext,
CapacitySchedulerConfiguration.ROOT, null, null);
csConf.setCapacity(CapacitySchedulerConfiguration.ROOT + "." + A, 80);
LeafQueue a = new LeafQueue(csContext, A, root, null);
assertEquals(0.1f, a.getMaxAMResourcePerQueuePercent(), 1e-3f);
assertEquals(160, a.getMaximumActiveApplications());
csConf.setFloat(CapacitySchedulerConfiguration.
MAXIMUM_APPLICATION_MASTERS_RESOURCE_PERCENT, 0.2f);
LeafQueue newA = new LeafQueue(csContext, A, root, null);
a.reinitialize(newA, clusterResource);
assertEquals(0.2f, a.getMaxAMResourcePerQueuePercent(), 1e-3f);
assertEquals(320, a.getMaximumActiveApplications());
Resource newClusterResource = Resources.createResource(100 * 20 * GB,
100 * 32);
a.updateClusterResource(newClusterResource);
// 100 * 20 * 0.2 = 400
assertEquals(400, a.getMaximumActiveApplications());
}
private CapacitySchedulerContext mockCSContext(
CapacitySchedulerConfiguration csConf, Resource clusterResource) {
CapacitySchedulerContext csContext = mock(CapacitySchedulerContext.class);
when(csContext.getConfiguration()).thenReturn(csConf);
when(csContext.getConf()).thenReturn(new YarnConfiguration());
when(csContext.getResourceCalculator()).thenReturn(resourceCalculator);
when(csContext.getClusterResources()).thenReturn(clusterResource);
when(csContext.getMinimumResourceCapability()).thenReturn(
Resources.createResource(GB, 1));
when(csContext.getMaximumResourceCapability()).thenReturn(
Resources.createResource(2 * GB, 2));
return csContext;
}
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {