@Override public List<ResourceRequest> getPendingResourceRequestsForAttempt( ApplicationAttemptId attemptId) { SchedulerApplicationAttempt attempt = getApplicationAttempt(attemptId); if (attempt != null) { return attempt.getAppSchedulingInfo().getAllResourceRequests(); } return null; }
/** * Get {@link ApplicationAttemptId} of the application master. * @return <code>ApplicationAttemptId</code> of the application master */ public ApplicationAttemptId getApplicationAttemptId() { return appSchedulingInfo.getApplicationAttemptId(); }
public ApplicationId getApplicationId() { return appSchedulingInfo.getApplicationId(); }
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()); }
@SuppressWarnings("unchecked") @Override public void initialize(AppSchedulingInfo appSchedulingInfo, SchedulerRequestKey schedulerRequestKey, RMContext rmContext) { super.initialize(appSchedulingInfo, schedulerRequestKey, rmContext); multiNodeSortPolicyName = appSchedulingInfo .getApplicationSchedulingEnvs().get( ApplicationSchedulingConfig.ENV_MULTI_NODE_SORTING_POLICY_CLASS); multiNodeSortingManager = (MultiNodeSortingManager<N>) rmContext .getMultiNodeSortingManager(); if (LOG.isDebugEnabled()) { LOG.debug( "nodeLookupPolicy used for " + appSchedulingInfo .getApplicationId() + " is " + ((multiNodeSortPolicyName != null) ? multiNodeSortPolicyName : "")); } }
checkApps(queueSource, 1, 1, 0, 0, 0, 0, true); metrics.runAppAttempt(app.getApplicationId(), user); checkApps(queueSource, 1, 0, 1, 0, 0, 0, true); app.getApplicationId(), app.isPending(), app.getUser()); checkApps(queueSource, 1, 0, 0, 0, 0, 0, true); checkApps(queueSource, 1, 1, 0, 0, 0, 0, true); metrics.runAppAttempt(app.getApplicationId(), user); checkApps(queueSource, 1, 0, 1, 0, 0, 0, true); app.getApplicationId(), app.isPending(), app.getUser()); checkApps(queueSource, 1, 0, 0, 0, 0, 0, true); checkApps(queueSource, 1, 1, 0, 0, 0, 0, true); metrics.runAppAttempt(app.getApplicationId(), user); checkApps(queueSource, 1, 0, 1, 0, 0, 0, true); app.getApplicationId(), app.isPending(), app.getUser()); checkApps(queueSource, 1, 0, 0, 0, 0, 0, true);
AppSchedulingInfo info = new AppSchedulingInfo( appAttemptId, "test", queue, mock(ActiveUsersManager.class), 0); Assert.assertEquals(0, info.getPriorities().size()); reqs.add(req1); reqs.add(req2); info.updateResourceRequests(reqs, false); ArrayList<Priority> priorities = new ArrayList<>(info.getPriorities()); Assert.assertEquals(2, priorities.size()); Assert.assertEquals(req1.getPriority(), priorities.get(0)); for (Priority priority: info.getPriorities()) { info.allocate(NodeType.OFF_SWITCH, null, priority, req1, null); Assert.assertEquals(1, info.getPriorities().size()); Assert.assertEquals(req2.getPriority(), info.getPriorities().iterator().next()); reqs.clear(); reqs.add(req2); info.updateResourceRequests(reqs, false); info.allocate(NodeType.OFF_SWITCH, null, req2.getPriority(), req2, null); Assert.assertEquals(0, info.getPriorities().size()); reqs.clear(); reqs.add(req1); info.updateResourceRequests(reqs, false); Assert.assertEquals(1, info.getPriorities().size()); Assert.assertEquals(req1.getPriority(),
AppSchedulingInfo info = new AppSchedulingInfo( appAttemptId, "test", queue, mock(ActiveUsersManager.class), 0, new ResourceUsage(), new HashMap<>(), mock(RMContext.class)); Assert.assertEquals(0, info.getSchedulerKeys().size()); reqs.add(req1); reqs.add(req2); 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()); reqs.clear(); reqs.add(req2); info.updateResourceRequests(reqs, false); info.allocate(NodeType.OFF_SWITCH, null, SchedulerRequestKey.create(req2), null); Assert.assertEquals(0, info.getSchedulerKeys().size()); reqs.clear(); reqs.add(req1);
public synchronized void updateResourceRequests( List<ResourceRequest> requests) { if (!isStopped) { appSchedulingInfo.updateResourceRequests(requests, false); } }
private static AppSchedulingInfo mockApp(String user) { AppSchedulingInfo app = mock(AppSchedulingInfo.class); when(app.getUser()).thenReturn(user); ApplicationId appId = BuilderUtils.newApplicationId(1, 1); ApplicationAttemptId id = BuilderUtils.newApplicationAttemptId(appId, 1); when(app.getApplicationAttemptId()).thenReturn(id); return app; }
public String getUser() { return appSchedulingInfo.getUser(); }
@Before public void setup() throws Exception { // stub app scheduling info. appSchedulingInfo = mock(AppSchedulingInfo.class); when(appSchedulingInfo.getApplicationId()).thenReturn( TestUtils.getMockApplicationId(1)); when(appSchedulingInfo.getApplicationAttemptId()).thenReturn( TestUtils.getMockApplicationAttemptId(1, 1)); // stub RMContext rmContext = TestUtils.getMockRMContext(); // Create allocation tags manager AllocationTagsManager allocationTagsManager = new AllocationTagsManager( rmContext); PlacementConstraintManager placementConstraintManager = new MemoryPlacementConstraintManager(); spyAllocationTagsManager = spy(allocationTagsManager); schedulerRequestKey = new SchedulerRequestKey(Priority.newInstance(1), 2L, TestUtils.getMockContainerId(1, 1)); rmContext.setAllocationTagsManager(spyAllocationTagsManager); rmContext.setPlacementConstraintManager(placementConstraintManager); // Create allocator allocator = new SingleConstraintAppPlacementAllocator(); allocator.initialize(appSchedulingInfo, schedulerRequestKey, rmContext); }
AppSchedulingInfo appSchedulingInfo = new AppSchedulingInfo(appAttemptId, "test", queue, null, 0, new ResourceUsage(), new HashMap<String, String>(), null); appSchedulingInfo.updatePlacesBlacklistedByApp(new ArrayList<String>(), new ArrayList<String>()); Assert.assertFalse(appSchedulingInfo.getAndResetBlacklistChanged()); appSchedulingInfo.updatePlacesBlacklistedByApp(blacklistAdditions, new ArrayList<String>()); Assert.assertTrue(appSchedulingInfo.getAndResetBlacklistChanged()); appSchedulingInfo.updatePlacesBlacklistedByApp(blacklistAdditions, new ArrayList<String>()); Assert.assertFalse(appSchedulingInfo.getAndResetBlacklistChanged()); appSchedulingInfo.updatePlacesBlacklistedByApp(new ArrayList<String>(), blacklistRemovals); appSchedulingInfo.updatePlacesBlacklistedByApp(new ArrayList<String>(), blacklistRemovals); Assert.assertTrue(appSchedulingInfo.getAndResetBlacklistChanged()); appSchedulingInfo.updatePlacesBlacklistedByApp(new ArrayList<String>(), blacklistRemovals); Assert.assertFalse(appSchedulingInfo.getAndResetBlacklistChanged());
appSchedulingInfo.getAppPlacementAllocator(schedulerKey); if (null == ps) { LOG.warn("Failed to get " + AppPlacementAllocator.class.getName() appSchedulingInfo.getUser(), this.rmContext, ps.getPrimaryRequestedNodePartition()); ((RMContainerImpl) rmContainer).setQueueName(this.getQueueName());
getResourceRequest(priority, resourceName); || isRequestLabelChanged(previousAnyRequest, request)) { Map<String, ResourceRequest> resourceRequest = getResourceRequests(priority); if (resourceRequest != null) { for (ResourceRequest r : resourceRequest.values()) { getResourceRequest(priority, ResourceRequest.ANY); if (anyRequest != null) { request.setNodeLabelExpression(anyRequest.getNodeLabelExpression()); LOG.info("checking for deactivate of application :" + this.applicationId); checkForDeactivation();
/** * Is this application pending? * @return true if it is else false. */ public boolean isPending() { return appSchedulingInfo.isPending(); }
this.appSchedulingInfo = new AppSchedulingInfo(applicationAttemptId, user, queue, abstractUsersManager, rmContext.getEpoch(), attemptResourceUsage, applicationSchedulingEnvs, rmContext);
app.liveContainers.put(container1.getContainerId(), container1); SchedulerNode node = createNode(); app.appSchedulingInfo.allocate(NodeType.OFF_SWITCH, node, requestedPriority, request, container1.getContainer());