protected void waitForContainerCleanup(MockRM rm, MockNM nm, NodeHeartbeatResponse resp) throws Exception { int waitCount = 0, cleanedConts = 0; List<ContainerId> contsToClean; do { rm.drainEvents(); contsToClean = resp.getContainersToCleanup(); cleanedConts += contsToClean.size(); if (cleanedConts >= 1) { break; } Thread.sleep(100); resp = nm.nodeHeartbeat(true); } while(waitCount++ < 200); if (contsToClean.isEmpty()) { LOG.error("Failed to get any containers to cleanup"); } else { LOG.info("Got cleanup for " + contsToClean.get(0)); } Assert.assertEquals(1, cleanedConts); }
protected void waitForContainerCleanup(DrainDispatcher dispatcher, MockNM nm, NodeHeartbeatResponse resp) throws Exception { int waitCount = 0, cleanedConts = 0; List<ContainerId> contsToClean; do { dispatcher.await(); contsToClean = resp.getContainersToCleanup(); cleanedConts += contsToClean.size(); if (cleanedConts >= 1) { break; } Thread.sleep(100); resp = nm.nodeHeartbeat(true); } while(waitCount++ < 200); if (contsToClean.isEmpty()) { LOG.error("Failed to get any containers to cleanup"); } else { LOG.info("Got cleanup for " + contsToClean.get(0)); } Assert.assertEquals(1, cleanedConts); }
NodeHeartbeatResponse beatResponse = rm.getResourceTrackerService().nodeHeartbeat(beatRequest); if (! beatResponse.getContainersToCleanup().isEmpty()) { for (ContainerId containerId : beatResponse.getContainersToCleanup()){ if (amContainerList.contains(containerId)) {
.getContainersToCleanup(); if (!containersToCleanup.isEmpty()) { dispatcher.getEventHandler().handle(
.getContainersToCleanup(); if (!containersToCleanup.isEmpty()) { dispatcher.getEventHandler().handle(
lastHeartbeatID = response.getResponseId(); List<ContainerId> containersToCleanup = response .getContainersToCleanup(); if (!containersToCleanup.isEmpty()) { dispatcher.getEventHandler().handle(
List<ContainerId> containersToCleanup = resp.getContainersToCleanup(); List<ApplicationId> appsToCleanup = resp.getApplicationsToCleanup(); int numCleanedContainers = containersToCleanup.size(); resp = nm1.nodeHeartbeat(true); List<ContainerId> deltaContainersToCleanup = resp.getContainersToCleanup(); List<ApplicationId> deltaAppsToCleanup = resp.getApplicationsToCleanup();
List<ContainerId> cleaned = resp.getContainersToCleanup(); int cleanedSize = cleaned.size(); waitCount = 0; Thread.sleep(300); resp = nm.nodeHeartbeat(true); cleaned = resp.getContainersToCleanup(); cleanedSize += cleaned.size();
List<ContainerId> containersToCleanup = resp.getContainersToCleanup(); List<ApplicationId> appsToCleanup = resp.getApplicationsToCleanup(); int numCleanedContainers = containersToCleanup.size(); resp = nm1.nodeHeartbeat(true); List<ContainerId> deltaContainersToCleanup = resp.getContainersToCleanup(); List<ApplicationId> deltaAppsToCleanup = resp.getApplicationsToCleanup();
@Test(timeout=20000) public void testUpdateHeartbeatResponseForCleanup() { RMNodeImpl node = getRunningNode(); NodeId nodeId = node.getNodeID(); // Expire a container ContainerId completedContainerId = BuilderUtils.newContainerId( BuilderUtils.newApplicationAttemptId( BuilderUtils.newApplicationId(0, 0), 0), 0); node.handle(new RMNodeCleanContainerEvent(nodeId, completedContainerId)); Assert.assertEquals(1, node.getContainersToCleanUp().size()); // Finish an application ApplicationId finishedAppId = BuilderUtils.newApplicationId(0, 1); node.handle(new RMNodeCleanAppEvent(nodeId, finishedAppId)); Assert.assertEquals(1, node.getAppsToCleanup().size()); // Verify status update does not clear containers/apps to cleanup // but updating heartbeat response for cleanup does RMNodeStatusEvent statusEvent = getMockRMNodeStatusEvent(null); node.handle(statusEvent); Assert.assertEquals(1, node.getContainersToCleanUp().size()); Assert.assertEquals(1, node.getAppsToCleanup().size()); NodeHeartbeatResponse hbrsp = Records.newRecord(NodeHeartbeatResponse.class); node.setAndUpdateNodeHeartbeatResponse(hbrsp); Assert.assertEquals(0, node.getContainersToCleanUp().size()); Assert.assertEquals(0, node.getAppsToCleanup().size()); Assert.assertEquals(1, hbrsp.getContainersToCleanup().size()); Assert.assertEquals(completedContainerId, hbrsp.getContainersToCleanup().get(0)); Assert.assertEquals(1, hbrsp.getApplicationsToCleanup().size()); Assert.assertEquals(finishedAppId, hbrsp.getApplicationsToCleanup().get(0)); }
List<ContainerId> cleaned = resp.getContainersToCleanup(); int cleanedSize = cleaned.size(); waitCount = 0; Thread.sleep(300); resp = nm.nodeHeartbeat(true); cleaned = resp.getContainersToCleanup(); cleanedSize += cleaned.size();
@Test(timeout=20000) public void testUpdateHeartbeatResponseForCleanup() { RMNodeImpl node = getRunningNode(); NodeId nodeId = node.getNodeID(); // Expire a container ContainerId completedContainerId = BuilderUtils.newContainerId( BuilderUtils.newApplicationAttemptId( BuilderUtils.newApplicationId(0, 0), 0), 0); node.handle(new RMNodeCleanContainerEvent(nodeId, completedContainerId)); Assert.assertEquals(1, node.getContainersToCleanUp().size()); // Finish an application ApplicationId finishedAppId = BuilderUtils.newApplicationId(0, 1); node.handle(new RMNodeCleanAppEvent(nodeId, finishedAppId)); Assert.assertEquals(1, node.getAppsToCleanup().size()); // Verify status update does not clear containers/apps to cleanup // but updating heartbeat response for cleanup does RMNodeStatusEvent statusEvent = getMockRMNodeStatusEvent(); node.handle(statusEvent); Assert.assertEquals(1, node.getContainersToCleanUp().size()); Assert.assertEquals(1, node.getAppsToCleanup().size()); NodeHeartbeatResponse hbrsp = Records.newRecord(NodeHeartbeatResponse.class); node.updateNodeHeartbeatResponseForCleanup(hbrsp); Assert.assertEquals(0, node.getContainersToCleanUp().size()); Assert.assertEquals(0, node.getAppsToCleanup().size()); Assert.assertEquals(1, hbrsp.getContainersToCleanup().size()); Assert.assertEquals(completedContainerId, hbrsp.getContainersToCleanup().get(0)); Assert.assertEquals(1, hbrsp.getApplicationsToCleanup().size()); Assert.assertEquals(finishedAppId, hbrsp.getApplicationsToCleanup().get(0)); }
lastHeartbeatID = response.getResponseId(); List<ContainerId> containersToCleanup = response .getContainersToCleanup(); if (!containersToCleanup.isEmpty()) { dispatcher.getEventHandler().handle(