use of org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container in project hadoop by apache.
the class NMTimelinePublisher method publishContainerLocalizationEvent.
private void publishContainerLocalizationEvent(ContainerLocalizationEvent event, String eventType) {
Container container = event.getContainer();
ContainerId containerId = container.getContainerId();
TimelineEntity entity = createContainerEntity(containerId);
TimelineEvent tEvent = new TimelineEvent();
tEvent.setId(eventType);
tEvent.setTimestamp(event.getTimestamp());
entity.addEvent(tEvent);
ApplicationId appId = container.getContainerId().getApplicationAttemptId().getApplicationId();
try {
// no need to put it as part of publisher as timeline client already has
// Queuing concept
TimelineV2Client timelineClient = getTimelineClient(appId);
if (timelineClient != null) {
timelineClient.putEntitiesAsync(entity);
} else {
LOG.error("Seems like client has been removed before the event could be" + " published for " + container.getContainerId());
}
} catch (IOException | YarnException e) {
LOG.error("Failed to publish Container metrics for container " + container.getContainerId(), e);
}
}
use of org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container in project hadoop by apache.
the class ContainersMonitorImpl method changeContainerResource.
private void changeContainerResource(ContainerId containerId, Resource resource) {
Container container = context.getContainers().get(containerId);
// Check container existence
if (container == null) {
LOG.warn("Container " + containerId.toString() + "does not exist");
return;
}
// YARN-5860: Route this through the ContainerScheduler to
// fix containerAllocation
container.setResource(resource);
}
use of org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container in project hadoop by apache.
the class ContainerScheduler method killOpportunisticContainers.
private void killOpportunisticContainers(Container container) {
List<Container> extraOpportContainersToKill = pickOpportunisticContainersToKill(container.getContainerId());
// Kill the opportunistic containers that were chosen.
for (Container contToKill : extraOpportContainersToKill) {
contToKill.sendKillEvent(ContainerExitStatus.KILLED_BY_CONTAINER_SCHEDULER, "Container Killed to make room for Guaranteed Container.");
oppContainersToKill.put(contToKill.getContainerId(), contToKill);
LOG.info("Opportunistic container {} will be killed in order to start the " + "execution of guaranteed container {}.", contToKill.getContainerId(), container.getContainerId());
}
}
use of org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container in project hadoop by apache.
the class ContainerScheduler method pickOpportunisticContainersToKill.
private List<Container> pickOpportunisticContainersToKill(ContainerId containerToStartId) {
// The opportunistic containers that need to be killed for the
// given container to start.
List<Container> extraOpportContainersToKill = new ArrayList<>();
// Track resources that need to be freed.
ResourceUtilization resourcesToFreeUp = resourcesToFreeUp(containerToStartId);
// Go over the running opportunistic containers.
// Use a descending iterator to kill more recently started containers.
Iterator<Container> lifoIterator = new LinkedList<>(runningContainers.values()).descendingIterator();
while (lifoIterator.hasNext() && !hasSufficientResources(resourcesToFreeUp)) {
Container runningCont = lifoIterator.next();
if (runningCont.getContainerTokenIdentifier().getExecutionType() == ExecutionType.OPPORTUNISTIC) {
if (oppContainersToKill.containsKey(runningCont.getContainerId())) {
// So exclude them..
continue;
}
extraOpportContainersToKill.add(runningCont);
ContainersMonitor.decreaseResourceUtilization(getContainersMonitor(), resourcesToFreeUp, runningCont.getResource());
}
}
if (!hasSufficientResources(resourcesToFreeUp)) {
LOG.warn("There are no sufficient resources to start guaranteed [{}]" + "at the moment. Opportunistic containers are in the process of" + "being killed to make room.", containerToStartId);
}
return extraOpportContainersToKill;
}
use of org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container in project hadoop by apache.
the class ContainerScheduler method startContainersFromQueue.
private boolean startContainersFromQueue(Collection<Container> queuedContainers) {
Iterator<Container> cIter = queuedContainers.iterator();
boolean resourcesAvailable = true;
while (cIter.hasNext() && resourcesAvailable) {
Container container = cIter.next();
if (this.utilizationTracker.hasResourcesAvailable(container)) {
startAllocatedContainer(container);
cIter.remove();
} else {
resourcesAvailable = false;
}
}
return resourcesAvailable;
}
Aggregations