@VisibleForTesting protected boolean requestsGpu(Container container) { return GpuResourceAllocator.getRequestedGpus(container.getResource()) > 0; }
@VisibleForTesting protected boolean requestsGpu(Container container) { return GpuResourceAllocator.getRequestedGpus(container.getResource()) > 0; }
/** * Add Container's resources to the accumulated Utilization. * @param container Container. */ @Override public void addContainerResources(Container container) { ContainersMonitor.increaseResourceUtilization( getContainersMonitor(), this.containersAllocation, container.getResource()); }
/** * Subtract Container's resources to the accumulated Utilization. * @param container Container. */ @Override public void subtractContainerResource(Container container) { ContainersMonitor.decreaseResourceUtilization( getContainersMonitor(), this.containersAllocation, container.getResource()); }
private synchronized long getReleasingGpus() { long releasingGpus = 0; Iterator<Map.Entry<GpuDevice, ContainerId>> iter = usedDevices.entrySet() .iterator(); while (iter.hasNext()) { ContainerId containerId = iter.next().getValue(); Container container; if ((container = nmContext.getContainers().get(containerId)) != null) { if (container.isContainerInFinalStates()) { releasingGpus = releasingGpus + container.getResource() .getResourceInformation(ResourceInformation.GPU_URI).getValue(); } } } return releasingGpus; }
/** * Check if NM has resources available currently to run the container. * @param container Container. * @return True, if NM has resources available currently to run the container. */ @Override public boolean hasResourcesAvailable(Container container) { long pMemBytes = container.getResource().getMemorySize() * 1024 * 1024L; return hasResourcesAvailable(pMemBytes, (long) (getContainersMonitor().getVmemRatio()* pMemBytes), container.getResource().getVirtualCores()); }
/** * Check if a given container exceeds its limits. */ private boolean isContainerOutOfLimit(Container container) { boolean outOfLimit = false; String value = null; try { value = cgroups.getCGroupParam(CGroupsHandler.CGroupController.MEMORY, container.getContainerId().toString(), memoryStatFile); long usage = Long.parseLong(value); long request = container.getResource().getMemorySize() * 1024 * 1024; // Check if the container has exceeded its limits. if (usage > request) { outOfLimit = true; String message = String.format( "Container %s is out of its limits, using %d " + "when requested only %d", container.getContainerId(), usage, request); LOG.warn(message); } } catch (ResourceHandlerException ex) { LOG.warn(String.format("Could not access memory resource for %s", container.getContainerId()), ex); } catch (NumberFormatException ex) { LOG.warn(String.format("Could not parse %s in %s", value, container.getContainerId())); } return outOfLimit; }
private void startContainer(Container container) { LOG.info("Starting container [" + container.getContainerId()+ "]"); // Skip to put into runningContainers and addUtilization when recover if (!runningContainers.containsKey(container.getContainerId())) { runningContainers.put(container.getContainerId(), container); this.utilizationTracker.addContainerResources(container); } if (container.getContainerTokenIdentifier().getExecutionType() == ExecutionType.OPPORTUNISTIC) { this.metrics.startOpportunisticContainer(container.getResource()); } container.sendLaunchEvent(); }
ContainersMonitor.decreaseResourceUtilization( getContainersMonitor(), resourcesToFreeUp, runningCont.getResource());
(long) (container.getResource().getMemorySize() * this.softLimit); long containerHardLimit = container.getResource().getMemorySize(); if (enforce) { try {
private ResourceUtilization resourcesToFreeUp( ContainerId containerToStartId) { // Get allocation of currently allocated containers. ResourceUtilization resourceAllocationToFreeUp = ResourceUtilization .newInstance(this.utilizationTracker.getCurrentUtilization()); // Add to the allocation the allocation of the pending guaranteed // containers that will start before the current container will be started. for (Container container : queuedGuaranteedContainers.values()) { ContainersMonitor.increaseResourceUtilization( getContainersMonitor(), resourceAllocationToFreeUp, container.getResource()); if (container.getContainerId().equals(containerToStartId)) { break; } } // These resources are being freed, likely at the behest of another // guaranteed container.. for (Container container : oppContainersToKill.values()) { ContainersMonitor.decreaseResourceUtilization( getContainersMonitor(), resourceAllocationToFreeUp, container.getResource()); } // Subtract the overall node resources. getContainersMonitor().subtractNodeResourcesFromResourceUtilization( resourceAllocationToFreeUp); return resourceAllocationToFreeUp; }
@Override public List<PrivilegedOperation> updateContainer(Container container) throws ResourceHandlerException { Resource containerResource = container.getResource(); String cgroupId = container.getContainerId().toString(); File cgroup = new File(cGroupsHandler.getPathForCGroup(CPU, cgroupId));
if (container.getContainerTokenIdentifier().getExecutionType() == ExecutionType.OPPORTUNISTIC) { this.metrics.completeOpportunisticContainer(container.getResource());
private synchronized GpuAllocation internalAssignGpus(Container container) throws ResourceHandlerException { Resource requestedResource = container.getResource(); ContainerId containerId = container.getContainerId(); int numRequestedGpuDevices = getRequestedGpus(requestedResource);
/** * Allocates the available NUMA nodes for the requested containerId with * resource in a round robin fashion. * * @param container the container to allocate NUMA resources * @return the assigned NUMA Node info or null if resources not available. * @throws ResourceHandlerException when failed to store NUMA resources */ public synchronized NumaResourceAllocation allocateNumaNodes( Container container) throws ResourceHandlerException { NumaResourceAllocation allocation = allocate(container.getContainerId(), container.getResource()); if (allocation != null) { try { // Update state store. context.getNMStateStore().storeAssignedResources(container, NUMA_RESOURCE_TYPE, Arrays.asList(allocation)); } catch (IOException e) { releaseNumaResource(container.getContainerId()); throw new ResourceHandlerException(e); } } return allocation; }
ContainerEntity entity = createContainerEntity(containerId); Container container = context.getContainers().get(containerId); Resource resource = container.getResource();
Resource res = container.getResource(); if (res != null) { this.totalMemoryNeededMB = res.getMemory();
Resource res = container.getResource(); if (res != null) { this.totalMemoryNeededMB = res.getMemory();
Resource res = container.getResource(); if (res != null) { this.totalMemoryNeededMB = res.getMemorySize();
Resource res = container.getResource(); if (res != null) { this.totalMemoryNeededMB = res.getMemorySize();