public Collection<SchedulerRequestKey> getSchedulerKeys() { return appSchedulingInfo.getSchedulerKeys(); }
private void decrementOutstanding(SchedulerRequestKey schedulerRequestKey, ResourceRequest offSwitchRequest) { int numOffSwitchContainers = offSwitchRequest.getNumContainers() - 1; offSwitchRequest.setNumContainers(numOffSwitchContainers); // Do we have any outstanding requests? // If there is nothing, we need to deactivate this application if (numOffSwitchContainers == 0) { appSchedulingInfo.getSchedulerKeys().remove(schedulerRequestKey); appSchedulingInfo.checkForDeactivation(); resourceRequestMap.remove(ResourceRequest.ANY); if (resourceRequestMap.isEmpty()) { appSchedulingInfo.removeAppPlacement(schedulerRequestKey); } } appSchedulingInfo.decPendingResource( offSwitchRequest.getNodeLabelExpression(), offSwitchRequest.getCapability()); }
public Map<String, Resource> getTotalPendingRequestsPerPartition() { try { readLock.lock(); Map<String, Resource> ret = new HashMap<>(); for (SchedulerRequestKey schedulerKey : appSchedulingInfo .getSchedulerKeys()) { AppPlacementAllocator<FiCaSchedulerNode> ps = appSchedulingInfo.getAppPlacementAllocator(schedulerKey); String nodePartition = ps.getPrimaryRequestedNodePartition(); Resource res = ret.get(nodePartition); if (null == res) { res = Resources.createResource(0); ret.put(nodePartition, res); } PendingAsk ask = ps.getPendingAsk(ResourceRequest.ANY); if (ask.getCount() > 0) { Resources.addTo(res, Resources .multiply(ask.getPerAllocationResource(), ask.getCount())); } } return ret; } finally { readLock.unlock(); } }
appAttemptId, "test", queue, mock(ActiveUsersManager.class), 0, new ResourceUsage(), new HashMap<>(), mock(RMContext.class)); Assert.assertEquals(0, info.getSchedulerKeys().size()); info.updateResourceRequests(reqs, false); ArrayList<SchedulerRequestKey> keys = new ArrayList<>(info.getSchedulerKeys()); Assert.assertEquals(2, keys.size()); Assert.assertEquals(SchedulerRequestKey.create(req1), keys.get(0)); for (SchedulerRequestKey schedulerKey : info.getSchedulerKeys()) { info.allocate(NodeType.OFF_SWITCH, null, schedulerKey, null); Assert.assertEquals(1, info.getSchedulerKeys().size()); Assert.assertEquals(SchedulerRequestKey.create(req2), info.getSchedulerKeys().iterator().next()); info.allocate(NodeType.OFF_SWITCH, null, SchedulerRequestKey.create(req2), null); Assert.assertEquals(0, info.getSchedulerKeys().size()); reqs.add(req1); info.updateResourceRequests(reqs, false); Assert.assertEquals(1, info.getSchedulerKeys().size()); Assert.assertEquals(SchedulerRequestKey.create(req1), info.getSchedulerKeys().iterator().next()); req1 = ResourceRequest.newInstance(pri1, ResourceRequest.ANY, Resource.newInstance(1024, 1), 0);
private void checkNodePartitionOfRequestedPriority(AppSchedulingInfo info, int priority, String expectedPartition) { for (SchedulerRequestKey key : info.getSchedulerKeys()) { if (key.getPriority().getPriority() == priority) { Assert.assertEquals("Expected partition is " + expectedPartition, expectedPartition, info.getAppPlacementAllocator(key) .getPrimaryRequestedNodePartition()); } } }
.getAppSchedulingInfo().getSchedulerKeys(); Assert.assertEquals(4, schedulerKeys.size()); .getAppSchedulingInfo().getSchedulerKeys();