use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal in project hadoop by apache.
the class TestParentQueue method applyAllocationToQueue.
private void applyAllocationToQueue(Resource clusterResource, int allocatedMem, CSQueue queue) {
// Call accept & apply for queue
ResourceCommitRequest request = mock(ResourceCommitRequest.class);
when(request.anythingAllocatedOrReserved()).thenReturn(true);
ContainerAllocationProposal allocation = mock(ContainerAllocationProposal.class);
when(request.getTotalReleasedResource()).thenReturn(Resources.none());
when(request.getFirstAllocatedOrReservedContainer()).thenReturn(allocation);
SchedulerContainer scontainer = mock(SchedulerContainer.class);
when(allocation.getAllocatedOrReservedContainer()).thenReturn(scontainer);
when(allocation.getAllocatedOrReservedResource()).thenReturn(Resources.createResource(allocatedMem));
when(scontainer.getNodePartition()).thenReturn("");
if (queue.accept(clusterResource, request)) {
queue.apply(clusterResource, request);
}
}
use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.ContainerAllocationProposal in project hadoop by apache.
the class CapacityScheduler method createResourceCommitRequest.
@VisibleForTesting
public ResourceCommitRequest<FiCaSchedulerApp, FiCaSchedulerNode> createResourceCommitRequest(CSAssignment csAssignment) {
ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> allocated = null;
ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> reserved = null;
List<SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode>> released = null;
if (Resources.greaterThan(calculator, getClusterResource(), csAssignment.getResource(), Resources.none())) {
// Allocated something
List<AssignmentInformation.AssignmentDetails> allocations = csAssignment.getAssignmentInformation().getAllocationDetails();
if (!allocations.isEmpty()) {
RMContainer rmContainer = allocations.get(0).rmContainer;
allocated = new ContainerAllocationProposal<>(getSchedulerContainer(rmContainer, true), getSchedulerContainersToRelease(csAssignment), getSchedulerContainer(csAssignment.getFulfilledReservedContainer(), false), csAssignment.getType(), csAssignment.getRequestLocalityType(), csAssignment.getSchedulingMode() != null ? csAssignment.getSchedulingMode() : SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY, csAssignment.getResource());
}
// Reserved something
List<AssignmentInformation.AssignmentDetails> reservation = csAssignment.getAssignmentInformation().getReservationDetails();
if (!reservation.isEmpty()) {
RMContainer rmContainer = reservation.get(0).rmContainer;
reserved = new ContainerAllocationProposal<>(getSchedulerContainer(rmContainer, false), getSchedulerContainersToRelease(csAssignment), getSchedulerContainer(csAssignment.getFulfilledReservedContainer(), false), csAssignment.getType(), csAssignment.getRequestLocalityType(), csAssignment.getSchedulingMode() != null ? csAssignment.getSchedulingMode() : SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY, csAssignment.getResource());
}
}
// kill all to-release containers in the request.
if (null == allocated && null == reserved) {
released = getSchedulerContainersToRelease(csAssignment);
}
if (null != allocated || null != reserved || (null != released && !released.isEmpty())) {
List<ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode>> allocationsList = null;
if (allocated != null) {
allocationsList = new ArrayList<>();
allocationsList.add(allocated);
}
List<ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode>> reservationsList = null;
if (reserved != null) {
reservationsList = new ArrayList<>();
reservationsList.add(reserved);
}
return new ResourceCommitRequest<>(allocationsList, reservationsList, released);
}
return null;
}
Aggregations