public void removeContainer(ContainerId container) { synchronized(acceptedContainersByResource) { for(Map.Entry<Model, List<Container>> kv : launchedContainers.entrySet()) { for(Iterator<Container> it = kv.getValue().iterator();it.hasNext();) { Container c = it.next(); if(c.getId().equals(container)) { it.remove(); } } } } } public List<Container> getList(ModelRequest request) {
/** * Clean up all Gpus assigned to containerId * @param containerId containerId */ public synchronized void cleanupAssignGpus(ContainerId containerId) { Iterator<Map.Entry<GpuDevice, ContainerId>> iter = usedDevices.entrySet().iterator(); while (iter.hasNext()) { if (iter.next().getValue().equals(containerId)) { iter.remove(); } } }
protected boolean hasAMContainer(ContainerId containerId, Collection<ContainerReport> containers) { for (ContainerReport container : containers) { if (containerId.equals(container.getContainerId())) { return true; } } return false; }
protected boolean hasAMContainer(ContainerId containerId, Collection<ContainerReport> containers) { for (ContainerReport container : containers) { if (containerId.equals(container.getContainerId())) { return true; } } return false; }
protected boolean hasAMContainer(ContainerId containerId, Collection<ContainerReport> containers) { for (ContainerReport container : containers) { if (containerId.equals(container.getContainerId())) { return true; } } return false; }
/** * Return true iff {@code containerId} represents the NameNode container. */ private boolean isNameNode(ContainerId containerId) { return namenodeContainer != null && namenodeContainer.getId().equals(containerId); }
/** * Returns the Id of the Samza container that corresponds to the provided Yarn {@link ContainerId} * @param containerId the Yarn ContainerId * @return the id of the Samza container corresponding to the {@link ContainerId} that is pending launch */ private String getPendingSamzaContainerId(ContainerId containerId) { for (String samzaContainerId: state.pendingYarnContainers.keySet()) { YarnContainer yarnContainer = state.pendingYarnContainers.get(samzaContainerId); if (yarnContainer != null && yarnContainer.id().equals(containerId)) { return samzaContainerId; } } return null; }
/** * Returns the Id of the Samza container that corresponds to the provided Yarn {@link ContainerId} * @param containerId the Yarn ContainerId * @return the id of the Samza container corresponding to the {@link ContainerId} that is pending launch */ private String getPendingSamzaContainerId(ContainerId containerId) { for (String samzaContainerId: state.pendingYarnContainers.keySet()) { YarnContainer yarnContainer = state.pendingYarnContainers.get(samzaContainerId); if (yarnContainer != null && yarnContainer.id().equals(containerId)) { return samzaContainerId; } } return null; }
public synchronized void removeCompletedContainers(List<ContainerStatus> completedContainers) { LOG.debug("remove completed containers..."); for (ContainerStatus status : completedContainers) { Iterator<Container> it = this.containers.iterator(); while (it.hasNext()) { if (it.next().getId().equals(status.getContainerId())) { it.remove(); LOG.info("Remove completed container {}", status.getContainerId()); break; } } } }
private boolean isContainerIdInContainerStatus( List<ContainerStatus> containerStatuses, ContainerId containerId) { for (ContainerStatus status : containerStatuses) { if (status.getContainerId().equals(containerId)) { return true; } } return false; }
@Override public boolean equals(Object obj) { if (obj instanceof RMContainer) { if (null != getContainerId()) { return getContainerId().equals(((RMContainer) obj).getContainerId()); } } return false; }
/** * Releases a container based on container id * @param containerId * @return * @throws SliderInternalStateException */ public List<AbstractRMOperation> releaseContainer(ContainerId containerId) throws SliderInternalStateException { List<AbstractRMOperation> operations = new ArrayList<AbstractRMOperation>(); List<RoleInstance> activeRoleInstances = cloneOwnedContainerList(); for (RoleInstance role : activeRoleInstances) { if (role.container.getId().equals(containerId)) { containerReleaseSubmitted(role.container); operations.add(new ContainerReleaseOperation(role.getId())); } } return operations; }
/** * Releases a container based on container id * @param containerId * @return * @throws SliderInternalStateException */ public List<AbstractRMOperation> releaseContainer(ContainerId containerId) throws SliderInternalStateException { List<AbstractRMOperation> operations = new ArrayList<AbstractRMOperation>(); List<RoleInstance> activeRoleInstances = cloneOwnedContainerList(); for (RoleInstance role : activeRoleInstances) { if (role.container.getId().equals(containerId)) { containerReleaseSubmitted(role.container); operations.add(new ContainerReleaseOperation(role.getId())); } } return operations; }
public void waitForContainerToComplete(RMAppAttempt attempt, NMContainerStatus completedContainer) throws InterruptedException { while (true) { List<ContainerStatus> containers = attempt.getJustFinishedContainers(); System.out.println("Received completed containers " + containers); for (ContainerStatus container : containers) { if (container.getContainerId().equals( completedContainer.getContainerId())) { return; } } Thread.sleep(200); } }
public void waitForContainerToComplete(RMAppAttempt attempt, NMContainerStatus completedContainer) throws InterruptedException { drainEventsImplicitly(); int timeWaiting = 0; while (timeWaiting < TIMEOUT_MS_FOR_CONTAINER_AND_NODE) { List<ContainerStatus> containers = attempt.getJustFinishedContainers(); LOG.info("Received completed containers " + containers); for (ContainerStatus container : containers) { if (container.getContainerId().equals( completedContainer.getContainerId())) { return; } } Thread.sleep(WAIT_MS_PER_LOOP); timeWaiting += WAIT_MS_PER_LOOP; } }
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 checkTaskContainersHost(ApplicationAttemptId attemptId, ContainerId containerId, ResourceManager rm, String host) { YarnScheduler scheduler = rm.getRMContext().getScheduler(); SchedulerAppReport appReport = scheduler.getSchedulerAppInfo(attemptId); Assert.assertTrue(appReport.getLiveContainers().size() > 0); for (RMContainer c : appReport.getLiveContainers()) { if (c.getContainerId().equals(containerId)) { Assert.assertEquals(host, c.getAllocatedNode().getHost()); } } }
private void checkTaskContainersHost(ApplicationAttemptId attemptId, ContainerId containerId, ResourceManager rm, String host) { YarnScheduler scheduler = rm.getRMContext().getScheduler(); SchedulerAppReport appReport = scheduler.getSchedulerAppInfo(attemptId); Assert.assertTrue(appReport.getLiveContainers().size() > 0); for (RMContainer c : appReport.getLiveContainers()) { if (c.getContainerId().equals(containerId)) { Assert.assertEquals(host, c.getAllocatedNode().getHost()); } } }
private void verifyContainerDecreased(AllocateResponse response, ContainerId containerId, int mem) { List<UpdatedContainer> decreasedContainers = response.getUpdatedContainers(); boolean found = false; for (UpdatedContainer c : decreasedContainers) { if (c.getContainer().getId().equals(containerId)) { found = true; Assert.assertEquals(ContainerUpdateType.DECREASE_RESOURCE, c.getUpdateType()); Assert.assertEquals(mem, c.getContainer().getResource().getMemorySize()); } } if (!found) { Assert.fail("Container not decreased: containerId=" + containerId); } }
private void verifyContainerIncreased(AllocateResponse response, ContainerId containerId, int mem) { List<UpdatedContainer> increasedContainers = response.getUpdatedContainers(); boolean found = false; for (UpdatedContainer c : increasedContainers) { if (c.getContainer().getId().equals(containerId)) { found = true; Assert.assertEquals(ContainerUpdateType.INCREASE_RESOURCE, c.getUpdateType()); Assert.assertEquals(mem, c.getContainer().getResource().getMemorySize()); } } if (!found) { Assert.fail("Container not increased: containerId=" + containerId); } }