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); } }
private Container getContainer( MockRM rm, ContainerId containerId, Resource resource) { RMContainer rmContainer = rm.getResourceScheduler() .getRMContainer(containerId); return Container.newInstance( containerId, rmContainer.getAllocatedNode(), null, resource, null, null); } }
Set<ContainerId> outstandingUpdate = new HashSet<>(); for (UpdateContainerRequest updateReq : request.getUpdateRequests()) { RMContainer rmContainer = rmContext.getScheduler().getRMContainer( updateReq.getContainerId()); String msg = validateContainerIdAndVersion(outstandingUpdate,
"' doesn't exist in RM."); RMContainer rmConatiner = this.rmContext.getScheduler().getRMContainer( containerId); if (rmConatiner == null) {
"' doesn't exist in RM."); RMContainer rmConatiner = this.rmContext.getScheduler().getRMContainer( containerId); if (rmConatiner == null) {
ResourceScheduler rs = mock(ResourceScheduler.class); when(rmContext.getScheduler()).thenReturn(rs); when(rmContext.getScheduler().getRMContainer(any(ContainerId.class))) .thenReturn(containerimpl); SchedulerAppReport sAppReport = mock(SchedulerAppReport.class);
private void waitforContainerCompletion(MockRM rm, MockNM nm, ContainerId amContainerId, RMContainer container) throws Exception { ContainerId containerId = container.getContainerId(); if (null != rm.scheduler.getRMContainer(containerId)) { if (containerId.equals(amContainerId)) { rm.waitForState(nm, containerId, RMContainerState.COMPLETED); } else { rm.waitForState(nm, containerId, RMContainerState.KILLED); } } else { rm.drainEvents(); } }
private void checkRMContainerLabelExpression(ContainerId containerId, MockRM rm, String labelExpression) { RMContainer container = rm.getRMContext().getScheduler().getRMContainer(containerId); Assert.assertNotNull("Cannot find RMContainer=" + containerId, container); Assert.assertEquals(labelExpression, container.getNodeLabelExpression()); }
public boolean waitForState(MockNM nm, ContainerId containerId, RMContainerState containerState, int timeoutMillisecs) throws Exception { RMContainer container = getResourceScheduler().getRMContainer(containerId); int timeoutSecs = 0; while(container == null && timeoutSecs++ < timeoutMillisecs / 100) { nm.nodeHeartbeat(true); container = getResourceScheduler().getRMContainer(containerId); System.out.println("Waiting for container " + containerId + " to be allocated."); Thread.sleep(100);
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() + "]"); } } }
"' doesn't exist in RM."); RMContainer rmContainer = this.rmContext.getScheduler().getRMContainer( containerId); if (rmContainer == null) {
RMContainerState containerState, int timeoutMsecs) throws Exception { drainEventsImplicitly(); RMContainer container = getResourceScheduler().getRMContainer(containerId); int timeWaiting = 0; while (container == null) { container = getResourceScheduler().getRMContainer(containerId); LOG.info("Waiting for container " + containerId + " to be " + containerState + ", container is null right now.");
@Test public void testExistenceOfResourceRequestInRMContainer() throws Exception { Configuration conf = new Configuration(); MockRM rm1 = new MockRM(conf); rm1.start(); MockNM nm1 = rm1.registerNode("unknownhost:1234", 8000); RMApp app1 = rm1.submitApp(1024); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); ResourceScheduler scheduler = rm1.getResourceScheduler(); // request a container. am1.allocate("127.0.0.1", 1024, 1, new ArrayList<ContainerId>()); ContainerId containerId2 = ContainerId.newContainerId( am1.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED); // Verify whether list of ResourceRequest is present in RMContainer // while moving to ALLOCATED state Assert.assertNotNull(scheduler.getRMContainer(containerId2) .getResourceRequests()); // Allocate container am1.allocate(new ArrayList<ResourceRequest>(), new ArrayList<ContainerId>()) .getAllocatedContainers(); rm1.waitForState(nm1, containerId2, RMContainerState.ACQUIRED); // After RMContainer moving to ACQUIRED state, list of ResourceRequest will // be empty Assert.assertNull(scheduler.getRMContainer(containerId2) .getResourceRequests()); }
@Test public void testExistenceOfResourceRequestInRMContainer() throws Exception { Configuration conf = new Configuration(); MockRM rm1 = new MockRM(conf); rm1.start(); MockNM nm1 = rm1.registerNode("unknownhost:1234", 8000); RMApp app1 = rm1.submitApp(1024); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); ResourceScheduler scheduler = rm1.getResourceScheduler(); // request a container. am1.allocate("127.0.0.1", 1024, 1, new ArrayList<ContainerId>()); ContainerId containerId2 = ContainerId.newContainerId( am1.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED); // Verify whether list of ResourceRequest is present in RMContainer // while moving to ALLOCATED state Assert.assertNotNull( scheduler.getRMContainer(containerId2).getContainerRequest()); // Allocate container am1.allocate(new ArrayList<ResourceRequest>(), new ArrayList<ContainerId>()) .getAllocatedContainers(); rm1.waitForState(nm1, containerId2, RMContainerState.ACQUIRED); // After RMContainer moving to ACQUIRED state, list of ResourceRequest will // be empty Assert.assertNull( scheduler.getRMContainer(containerId2).getContainerRequest()); }
for (UpdateContainerRequest uReq : demotionRequests) { RMContainer rmContainer = rmContext.getScheduler().getRMContainer(uReq.getContainerId()); if (rmContainer != null) { SchedulerNode schedulerNode = rmContext.getScheduler()
@Test public void testContainerTokenGeneratedOnPullRequest() throws Exception { MockRM rm1 = new MockRM(conf); rm1.start(); MockNM nm1 = rm1.registerNode("127.0.0.1:1234", 8000); RMApp app1 = rm1.submitApp(200); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); // request a container. am1.allocate("127.0.0.1", 1024, 1, new ArrayList<ContainerId>()); ContainerId containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED); RMContainer container = rm1.getResourceScheduler().getRMContainer(containerId2); // no container token is generated. Assert.assertEquals(containerId2, container.getContainerId()); Assert.assertNull(container.getContainer().getContainerToken()); // acquire the container. List<Container> containers = am1.allocate(new ArrayList<ResourceRequest>(), new ArrayList<ContainerId>()).getAllocatedContainers(); Assert.assertEquals(containerId2, containers.get(0).getId()); // container token is generated. Assert.assertNotNull(containers.get(0).getContainerToken()); rm1.stop(); }
@Test public void testContainerTokenGeneratedOnPullRequest() throws Exception { MockRM rm1 = new MockRM(conf); rm1.start(); MockNM nm1 = rm1.registerNode("127.0.0.1:1234", 8000); RMApp app1 = rm1.submitApp(200); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); // request a container. am1.allocate("127.0.0.1", 1024, 1, new ArrayList<ContainerId>()); ContainerId containerId2 = ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED); RMContainer container = rm1.getResourceScheduler().getRMContainer(containerId2); // no container token is generated. Assert.assertEquals(containerId2, container.getContainerId()); Assert.assertNull(container.getContainer().getContainerToken()); // acquire the container. List<Container> containers = am1.allocate(new ArrayList<ResourceRequest>(), new ArrayList<ContainerId>()).getAllocatedContainers(); Assert.assertEquals(containerId2, containers.get(0).getId()); // container token is generated. Assert.assertNotNull(containers.get(0).getContainerToken()); rm1.stop(); }
1 * GB, rm1.getResourceScheduler().getRMContainer(containerId2) .getAllocatedResource().getMemorySize()); disp.waitForEventThreadToWait();
.getRMContainer(attempt0.getMasterContainer().getId());
.getRMContainer(attempt0.getMasterContainer().getId());