Class CGroupsCpuResourceHandlerImpl
java.lang.Object
org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.AbstractCGroupsCpuResourceHandler
org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsCpuResourceHandlerImpl
- All Implemented Interfaces:
CpuResourceHandler,ResourceHandler
@Unstable
@Private
public class CGroupsCpuResourceHandlerImpl
extends AbstractCGroupsCpuResourceHandler
An implementation for using CGroups to restrict CPU usage on Linux. The
implementation supports 3 different controls - restrict usage of all YARN
containers, restrict relative usage of individual YARN containers and
restrict usage of individual YARN containers. Admins can set the overall CPU
to be used by all YARN containers - this is implemented by setting
cpu.cfs_period_us and cpu.cfs_quota_us to the ratio desired. If strict
resource usage mode is not enabled, cpu.shares is set for individual
containers - this prevents containers from exceeding the overall limit for
YARN containers but individual containers can use as much of the CPU as
available(under the YARN limit). If strict resource usage is enabled, then
container can only use the percentage of CPU allocated to them and this is
again implemented using cpu.cfs_period_us and cpu.cfs_quota_us.
-
Field Summary
Fields inherited from class org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.AbstractCGroupsCpuResourceHandler
cGroupsHandler -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanbooleancpuLimitExists(String cgroupPath) protected intgetCpuWeightByContainerVcores(int containerVCores) protected intprotected voidupdateCgroupCpuWeight(String cgroupId, int weight) protected voidupdateCgroupMaxCpuLimit(String cgroupId, String quota, String period) Methods inherited from class org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.AbstractCGroupsCpuResourceHandler
bootstrap, getOverallLimits, postComplete, preStart, reacquireContainer, teardown, toString, updateContainer
-
Method Details
-
updateCgroupMaxCpuLimit
protected void updateCgroupMaxCpuLimit(String cgroupId, String quota, String period) throws ResourceHandlerException - Specified by:
updateCgroupMaxCpuLimitin classAbstractCGroupsCpuResourceHandler- Throws:
ResourceHandlerException
-
getOpportunisticCpuWeight
protected int getOpportunisticCpuWeight()- Specified by:
getOpportunisticCpuWeightin classAbstractCGroupsCpuResourceHandler
-
getCpuWeightByContainerVcores
protected int getCpuWeightByContainerVcores(int containerVCores) - Specified by:
getCpuWeightByContainerVcoresin classAbstractCGroupsCpuResourceHandler
-
updateCgroupCpuWeight
- Specified by:
updateCgroupCpuWeightin classAbstractCGroupsCpuResourceHandler- Throws:
ResourceHandlerException
-
cpuLimitExists
- Specified by:
cpuLimitExistsin classAbstractCGroupsCpuResourceHandler- Throws:
ResourceHandlerException
-
checkCgroupV1CPULimitExists
- Throws:
IOException
-