@Override public ApplicationResourceUsageReport getAppResourceUsageReport( ApplicationAttemptId appAttemptId) { return scheduler.getAppResourceUsageReport(appAttemptId); }
public SchedulerInfo(final ResourceManager rm) { ResourceScheduler rs = rm.getResourceScheduler(); if (rs instanceof CapacityScheduler) { this.schedulerName = "Capacity Scheduler"; } else if (rs instanceof FairScheduler) { this.schedulerName = "Fair Scheduler"; } else if (rs instanceof FifoScheduler) { this.schedulerName = "Fifo Scheduler"; } this.minAllocResource = new ResourceInfo(rs.getMinimumResourceCapability()); this.maxAllocResource = new ResourceInfo(rs.getMaximumResourceCapability()); this.schedulingResourceTypes = rs.getSchedulingResourceTypes(); this.maximumClusterPriority = rs.getMaxClusterLevelAppPriority().getPriority(); }
@Override public SchedulerNodeReport getNodeReport(NodeId nodeId) { return scheduler.getNodeReport(nodeId); }
public SchedulerInfo(final ResourceManager rm) { ResourceScheduler rs = rm.getResourceScheduler(); if (rs instanceof CapacityScheduler) { this.schedulerName = "Capacity Scheduler"; } else if (rs instanceof FairScheduler) { this.schedulerName = "Fair Scheduler"; } else if (rs instanceof FifoScheduler) { this.schedulerName = "Fifo Scheduler"; } this.minAllocResource = new ResourceInfo(rs.getMinimumResourceCapability()); this.maxAllocResource = new ResourceInfo(rs.getMaximumResourceCapability()); this.schedulingResourceTypes = rs.getSchedulingResourceTypes(); }
private static ResourceScheduler createMockScheduler(Configuration conf) { ResourceScheduler mockSched = mock(ResourceScheduler.class); doReturn(BuilderUtils.newResource(512, 0)).when(mockSched) .getMinimumResourceCapability(); doReturn(BuilderUtils.newResource(5120, 0)).when(mockSched) .getMaximumResourceCapability(); return mockSched; }
private static ResourceScheduler mockResourceScheduler() throws YarnException { ResourceScheduler scheduler = mock(ResourceScheduler.class); when(scheduler.getMinimumResourceCapability()).thenReturn( Resources.createResource( YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB)); when(scheduler.getMaximumResourceCapability()).thenReturn( Resources.createResource( YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB)); when(scheduler.getMaximumResourceCapability(anyString())).thenReturn( Resources.createResource( YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB)); when(scheduler.getAppsInQueue(QUEUE_1)).thenReturn( Arrays.asList(getApplicationAttemptId(101), getApplicationAttemptId(102))); when(scheduler.getAppsInQueue(QUEUE_2)).thenReturn( Arrays.asList(getApplicationAttemptId(103))); ApplicationAttemptId attemptId = getApplicationAttemptId(1); when(scheduler.getAppResourceUsageReport(attemptId)).thenReturn(null); ResourceCalculator rs = mock(ResourceCalculator.class); when(scheduler.getResourceCalculator()).thenReturn(rs); when(scheduler.checkAndGetApplicationPriority(any(Priority.class), any(UserGroupInformation.class), anyString(), any(ApplicationId.class))) .thenReturn(Priority.newInstance(0)); return scheduler; }
private static ResourceScheduler mockResourceScheduler() { ResourceScheduler scheduler = mock(ResourceScheduler.class); when(scheduler.getMinimumResourceCapability()).thenReturn( Resources.createResource( YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB)); when(scheduler.getMaximumResourceCapability()).thenReturn( Resources.createResource( YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB)); when(scheduler.getMaximumResourceCapability(any(String.class))).thenReturn( Resources.createResource( YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB)); when(scheduler.getMaximumResourceCapability(anyString())).thenReturn( Resources.createResource( YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB)); ResourceCalculator rs = mock(ResourceCalculator.class); when(scheduler.getResourceCalculator()).thenReturn(rs); when(scheduler.getNormalizedResource(any(), any())) .thenAnswer(new Answer<Resource>() { @Override public Resource answer(InvocationOnMock invocationOnMock) throws Throwable { return (Resource) invocationOnMock.getArguments()[0]; } }); return scheduler; }
@Override public QueueMetrics getRootQueueMetrics() { return scheduler.getRootQueueMetrics(); }
@Override public void handle(SchedulerEvent event) { scheduler.handle(event); } };
private static ResourceScheduler mockResourceScheduler() { ResourceScheduler scheduler = mock(ResourceScheduler.class); when(scheduler.getMinimumResourceCapability()).thenReturn( Resources.createResource( YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB)); when(scheduler.getMaximumResourceCapability()).thenReturn( Resources.createResource( YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB)); ResourceCalculator rc = new DefaultResourceCalculator(); when(scheduler.getResourceCalculator()).thenReturn(rc); return scheduler; }
@Override public void reinitialize(Configuration conf, RMContext rmContext) throws IOException { scheduler.reinitialize(conf, rmContext); }
@Override public SchedulerAppReport getSchedulerAppInfo( ApplicationAttemptId attemptId) { return scheduler.getSchedulerAppInfo(attemptId); }
am1.registerAppAttempt(); SchedulerNodeReport report_nm1 = rm.getResourceScheduler().getNodeReport(nm1.getNodeId()); AllocateResponse allocResponse = am1.schedule(); ApplicationResourceUsageReport report = rm.getResourceScheduler().getAppResourceUsageReport( attempt1.getAppAttemptId()); Assert.assertEquals(0, allocResponse.getAllocatedContainers().size()); rm.getResourceScheduler().getAppResourceUsageReport( attempt1.getAppAttemptId()); Assert.assertEquals(1, allocResponse.getAllocatedContainers().size());
ResourceScheduler rs = mock(ResourceScheduler.class); when(rmContext.getScheduler()).thenReturn(rs); when(rmContext.getScheduler().getRMContainer(any(ContainerId.class))) .thenReturn(containerimpl); SchedulerAppReport sAppReport = mock(SchedulerAppReport.class); when( rmContext.getScheduler().getSchedulerAppInfo( any(ApplicationAttemptId.class))).thenReturn(sAppReport); List<RMContainer> rmContainers = new ArrayList<RMContainer>(); rmContainers.add(containerimpl); when( rmContext.getScheduler().getSchedulerAppInfo(attemptId) .getLiveContainers()).thenReturn(rmContainers); ContainerStatus cs = mock(ContainerStatus.class);
public void waitForContainerAllocated(MockNM nm, ContainerId containerId) throws Exception { int timeoutSecs = 0; while (getResourceScheduler().getRMContainer(containerId) == null && timeoutSecs++ < 40) { System.out.println("Waiting for" + containerId + " to be allocated."); nm.nodeHeartbeat(true); Thread.sleep(200); } }
@Override public void setRMContext(RMContext rmContext) { scheduler.setRMContext(rmContext); }
scheduler.handle(schedulerEvent); return; appRemoveEvent.getApplicationAttemptID(); String queue = appQueueMap.get(appAttemptId.getApplicationId()); SchedulerAppReport app = scheduler.getSchedulerAppInfo(appAttemptId); if (! app.getLiveContainers().isEmpty()) { // have 0 or 1 .get(schedulerEvent.getType()).time(); scheduler.handle(schedulerEvent); } finally { if (handlerTimer != null) handlerTimer.stop();
@Test (timeout = 30000) public void testConfValidation() throws Exception { ResourceScheduler scheduler = new CapacityScheduler(); scheduler.setRMContext(resourceManager.getRMContext()); Configuration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 2048); conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB, 1024); try { scheduler.reinitialize(conf, mockContext); fail("Exception is expected because the min memory allocation is" + " larger than the max memory allocation."); conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES, 1); try { scheduler.reinitialize(conf, mockContext); fail("Exception is expected because the min vcores allocation is" + " larger than the max vcores allocation.");
private void handleIncreaseRequests( SchedulerApplicationAttempt applicationAttempt, List<UpdateContainerRequest> updateContainerRequests) { for (UpdateContainerRequest uReq : updateContainerRequests) { RMContainer rmContainer = rmContext.getScheduler().getRMContainer(uReq.getContainerId()); // Check if this is a container update // And not in the middle of a Demotion if (rmContainer != null) { // Check if this is an executionType change request // If so, fix the rr to make it look like a normal rr // with relaxLocality=false and numContainers=1 SchedulerNode schedulerNode = rmContext.getScheduler() .getSchedulerNode(rmContainer.getContainer().getNodeId()); // Add only if no outstanding promote requests exist. if (!applicationAttempt.getUpdateContext() .checkAndAddToOutstandingIncreases( rmContainer, schedulerNode, uReq)) { applicationAttempt.addToUpdateContainerErrors( UpdateContainerError.newInstance( RMServerUtils.UPDATE_OUTSTANDING_ERROR, uReq)); } } else { LOG.warn("Cannot promote non-existent (or completed) Container [" + uReq.getContainerId() + "]"); } } }
@Override public Resource getMinimumResourceCapability() { return scheduler.getMinimumResourceCapability(); }