if (container.getAllocationTags() != null && !container.getAllocationTags().isEmpty()) { List<SchedulingRequest> schedReqs = outstandingSchedRequests.get(container.getAllocationTags()); if (schedReqs != null && !schedReqs.isEmpty()) { Iterator<SchedulingRequest> iter = schedReqs.iterator();
public RMContainerImpl(Container container, SchedulerRequestKey schedulerKey, ApplicationAttemptId appAttemptId, NodeId nodeId, String user, RMContext rmContext, long creationTime, String nodeLabelExpression, boolean isExternallyAllocated) { this.stateMachine = stateMachineFactory.make(this); this.nodeId = nodeId; this.container = container; this.allocatedSchedulerKey = schedulerKey; this.appAttemptId = appAttemptId; this.user = user; this.creationTime = creationTime; this.rmContext = rmContext; this.eventHandler = rmContext.getDispatcher().getEventHandler(); this.containerAllocationExpirer = rmContext.getContainerAllocationExpirer(); this.isAMContainer = false; this.nodeLabelExpression = nodeLabelExpression; this.lastConfirmedResource = container.getResource(); this.isExternallyAllocated = isExternallyAllocated; ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); this.readLock = lock.readLock(); this.writeLock = lock.writeLock(); saveNonAMContainerMetaInfo = shouldPublishNonAMContainerEventstoATS(rmContext); if (container.getId() != null) { rmContext.getRMApplicationHistoryWriter().containerStarted(this); } if (this.container != null) { this.allocationTags = this.container.getAllocationTags(); } }
rmContext.getAllocationTagsManager() .removeContainer(container.getNodeId(), container.getId(), container.getAllocationTags());
private List<Container> waitForAllocation(int allocNum, int timeout, MockAM am, MockNM... nms) throws Exception { final List<Container> result = new ArrayList<>(); GenericTestUtils.waitFor(() -> { try { AllocateResponse response = am.schedule(); List<Container> allocated = response.getAllocatedContainers(); System.out.println("Expecting allocation: " + allocNum + ", actual allocation: " + allocated.size()); for (Container c : allocated) { System.out.println("Container " + c.getId().toString() + " is allocated on node: " + c.getNodeId().toString() + ", allocation tags: " + String.join(",", c.getAllocationTags())); } result.addAll(allocated); if (result.size() == allocNum) { return true; } doNodeHeartbeat(nms); } catch (Exception e) { e.printStackTrace(); } return false; }, 500, timeout); return result; }