YARN-4575. ApplicationResourceUsageReport should return ALL reserved resource.
Contributed by Bibin Chundatt and Eric Payne.
(cherry picked from commit 647be0c0f6
)
This commit is contained in:
parent
4eb1f81876
commit
9bf554deae
|
@ -1032,8 +1032,8 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
|
||||||
getRunningAggregateAppResourceUsage();
|
getRunningAggregateAppResourceUsage();
|
||||||
Resource usedResourceClone = Resources.clone(
|
Resource usedResourceClone = Resources.clone(
|
||||||
attemptResourceUsage.getAllUsed());
|
attemptResourceUsage.getAllUsed());
|
||||||
Resource reservedResourceClone = Resources.clone(
|
Resource reservedResourceClone =
|
||||||
attemptResourceUsage.getReserved());
|
Resources.clone(attemptResourceUsage.getAllReserved());
|
||||||
Resource cluster = rmContext.getScheduler().getClusterResource();
|
Resource cluster = rmContext.getScheduler().getClusterResource();
|
||||||
ResourceCalculator calc =
|
ResourceCalculator calc =
|
||||||
rmContext.getScheduler().getResourceCalculator();
|
rmContext.getScheduler().getResourceCalculator();
|
||||||
|
|
|
@ -653,7 +653,8 @@ public class FiCaSchedulerApp extends SchedulerApplicationAttempt {
|
||||||
+ " on node " + node + ", currently has "
|
+ " on node " + node + ", currently has "
|
||||||
+ reservedContainers.size()
|
+ reservedContainers.size()
|
||||||
+ " at priority " + schedulerKey.getPriority()
|
+ " at priority " + schedulerKey.getPriority()
|
||||||
+ "; currentReservation " + this.attemptResourceUsage.getReserved()
|
+ "; currentReservation "
|
||||||
|
+ this.attemptResourceUsage.getReserved(node.getPartition())
|
||||||
+ " on node-label=" + node.getPartition());
|
+ " on node-label=" + node.getPartition());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
|
||||||
|
|
||||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestUtils.toSchedulerKey;
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestUtils.toSchedulerKey;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -44,6 +45,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler;
|
||||||
import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey;
|
import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey;
|
||||||
import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
|
import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
|
||||||
|
import org.apache.hadoop.yarn.util.resource.Resources;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -311,6 +313,43 @@ public class TestSchedulerApplicationAttempt {
|
||||||
0.0f);
|
0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAllResourceUsage() throws Exception {
|
||||||
|
FifoScheduler scheduler = mock(FifoScheduler.class);
|
||||||
|
when(scheduler.getClusterResource()).thenReturn(Resource.newInstance(0, 0));
|
||||||
|
when(scheduler.getResourceCalculator())
|
||||||
|
.thenReturn(new DefaultResourceCalculator());
|
||||||
|
|
||||||
|
ApplicationAttemptId appAttId = createAppAttemptId(0, 0);
|
||||||
|
RMContext rmContext = mock(RMContext.class);
|
||||||
|
when(rmContext.getEpoch()).thenReturn(3L);
|
||||||
|
when(rmContext.getScheduler()).thenReturn(scheduler);
|
||||||
|
when(rmContext.getYarnConfiguration()).thenReturn(conf);
|
||||||
|
|
||||||
|
final String user = "user1";
|
||||||
|
Queue queue = createQueue("test", null);
|
||||||
|
SchedulerApplicationAttempt app = new SchedulerApplicationAttempt(appAttId,
|
||||||
|
user, queue, queue.getAbstractUsersManager(), rmContext);
|
||||||
|
|
||||||
|
// Resource request
|
||||||
|
Resource requestedResource = Resource.newInstance(1536, 2);
|
||||||
|
app.attemptResourceUsage.incUsed("X", requestedResource);
|
||||||
|
app.attemptResourceUsage.incUsed("Y", requestedResource);
|
||||||
|
Resource r2 = Resource.newInstance(1024, 1);
|
||||||
|
app.attemptResourceUsage.incReserved("X", r2);
|
||||||
|
app.attemptResourceUsage.incReserved("Y", r2);
|
||||||
|
|
||||||
|
assertTrue("getUsedResources expected " + Resource.newInstance(3072, 4)
|
||||||
|
+ " but was " + app.getResourceUsageReport().getUsedResources(),
|
||||||
|
Resources.equals(Resource.newInstance(3072, 4),
|
||||||
|
app.getResourceUsageReport().getUsedResources()));
|
||||||
|
assertTrue("getReservedResources expected " + Resource.newInstance(2048, 2)
|
||||||
|
+ " but was "
|
||||||
|
+ app.getResourceUsageReport().getReservedResources(),
|
||||||
|
Resources.equals(Resource.newInstance(2048, 2),
|
||||||
|
app.getResourceUsageReport().getReservedResources()));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSchedulingOpportunityOverflow() throws Exception {
|
public void testSchedulingOpportunityOverflow() throws Exception {
|
||||||
ApplicationAttemptId attemptId = createAppAttemptId(0, 0);
|
ApplicationAttemptId attemptId = createAppAttemptId(0, 0);
|
||||||
|
|
Loading…
Reference in New Issue