Class AbstractCGroupsHandler
java.lang.Object
org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.AbstractCGroupsHandler
- All Implemented Interfaces:
CGroupsHandler
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsHandler
CGroupsHandler.CGroupController -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected final CGroupsMountConfigprotected Map<CGroupsHandler.CGroupController,String> protected static final Stringprotected final Stringprotected final PrivilegedOperationExecutorprotected final ReadWriteLockFields inherited from interface org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsHandler
CGROUP_CONTROLLERS_FILE, CGROUP_CPU_MAX, CGROUP_CPU_PERIOD_US, CGROUP_CPU_QUOTA_US, CGROUP_CPU_SHARES, CGROUP_MEMORY_LOW, CGROUP_MEMORY_MAX, CGROUP_NO_LIMIT, CGROUP_PARAM_CLASSID, CGROUP_PARAM_MEMORY_HARD_LIMIT_BYTES, CGROUP_PARAM_MEMORY_MEMSW_USAGE_BYTES, CGROUP_PARAM_MEMORY_OOM_CONTROL, CGROUP_PARAM_MEMORY_SOFT_LIMIT_BYTES, CGROUP_PARAM_MEMORY_SWAP_HARD_LIMIT_BYTES, CGROUP_PARAM_MEMORY_SWAPPINESS, CGROUP_PARAM_MEMORY_USAGE_BYTES, CGROUP_PARAM_WEIGHT, CGROUP_PROCS_FILE, CGROUP_SUBTREE_CONTROL_FILE, UNDER_OOM -
Method Summary
Modifier and TypeMethodDescriptioncreateCGroup(CGroupsHandler.CGroupController controller, String cGroupId) Creates a cgroup for a given controller.voiddeleteCGroup(CGroupsHandler.CGroupController controller, String cGroupId) Deletes the specified cgroup.protected StringFind the hierarchy of the subsystem.protected abstract List<CGroupsHandler.CGroupController>Returns CGroup Mount Path.getCGroupParam(CGroupsHandler.CGroupController controller, String cGroupId, String param) reads a cgroup parameter value, given a controller, cgroup id, parameter.Returns CGroupV2 Mount Path.getControllerPath(CGroupsHandler.CGroupController controller) Gets the absolute path to the specified cgroup controller.protected StringgetErrorWithDetails(String errorMessage, String subsystemName, String yarnCgroupPath) Creates an actionable error message for mtab parsing.getPathForCGroup(CGroupsHandler.CGroupController controller, String cGroupId) Gets the full path for the cgroup, given a controller and a cgroup id.getPathForCGroupParam(CGroupsHandler.CGroupController controller, String cGroupId, String param) Gets the full path for a cgroup parameter, given a controller, cgroup id and parameter name.getPathForCGroupTasks(CGroupsHandler.CGroupController controller, String cGroupId) Gets the full path for the cgroup's tasks file, given a controller and a cgroup id.getRelativePathForCGroup(String cGroupId) Gets the relative path for the cgroup, independent of a controller, for a given cgroup id.handleMtabEntry(String path, String type, String options) protected voidinit()voidMount cgroup or use existing mount point based on configuration.protected Map<CGroupsHandler.CGroupController,String> protected abstract voidmountCGroupController(CGroupsHandler.CGroupController controller) toString()voidupdateCGroupParam(CGroupsHandler.CGroupController controller, String cGroupId, String param, String value) updates a cgroup parameter, given a controller, cgroup id, parameter name.protected abstract voidupdateEnabledControllersInHierarchy(File yarnHierarchy, CGroupsHandler.CGroupController controller) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.CGroupsHandler
getValidCGroups
-
Field Details
-
MTAB_FILE
- See Also:
-
mtabFile
-
cGroupsMountConfig
-
rwLock
-
controllerPaths
-
parsedMtab
-
privilegedOperationExecutor
-
cGroupPrefix
-
-
Method Details
-
init
- Throws:
ResourceHandlerException
-
getControllerPath
Description copied from interface:CGroupsHandlerGets the absolute path to the specified cgroup controller.- Specified by:
getControllerPathin interfaceCGroupsHandler- Parameters:
controller- - controller type for the cgroup- Returns:
- the root of the controller.
-
parsePreConfiguredMountPath
- Throws:
IOException
-
initializeControllerPathsFromMtab
-
getCGroupControllers
-
parseMtab
- Throws:
IOException
-
handleMtabEntry
protected abstract Set<String> handleMtabEntry(String path, String type, String options) throws IOException - Throws:
IOException
-
findControllerInMtab
Find the hierarchy of the subsystem. The kernel ensures that a subsystem can only be part of a single hierarchy. The subsystem can be part of multiple mount points, if they belong to the same hierarchy.- Parameters:
controller- subsystem like cpu, cpuset, etc...entries- map of paths to mount options- Returns:
- the first mount path that has the requested subsystem
-
mountCGroupController
protected abstract void mountCGroupController(CGroupsHandler.CGroupController controller) throws ResourceHandlerException - Throws:
ResourceHandlerException
-
getRelativePathForCGroup
Description copied from interface:CGroupsHandlerGets the relative path for the cgroup, independent of a controller, for a given cgroup id.- Specified by:
getRelativePathForCGroupin interfaceCGroupsHandler- Parameters:
cGroupId- - id of the cgroup- Returns:
- path for the cgroup relative to the root of (any) controller.
-
getPathForCGroup
Description copied from interface:CGroupsHandlerGets the full path for the cgroup, given a controller and a cgroup id.- Specified by:
getPathForCGroupin interfaceCGroupsHandler- Parameters:
controller- - controller type for the cgroupcGroupId- - id of the cgroup- Returns:
- full path for the cgroup
-
getPathForCGroupTasks
Description copied from interface:CGroupsHandlerGets the full path for the cgroup's tasks file, given a controller and a cgroup id.- Specified by:
getPathForCGroupTasksin interfaceCGroupsHandler- Parameters:
controller- - controller type for the cgroupcGroupId- - id of the cgroup- Returns:
- full path for the cgroup's tasks file
-
getPathForCGroupParam
public String getPathForCGroupParam(CGroupsHandler.CGroupController controller, String cGroupId, String param) Description copied from interface:CGroupsHandlerGets the full path for a cgroup parameter, given a controller, cgroup id and parameter name.- Specified by:
getPathForCGroupParamin interfaceCGroupsHandler- Parameters:
controller- - controller type for the cgroupcGroupId- - id of the cgroupparam- - cgroup parameter ( e.g classid )- Returns:
- full path for the cgroup parameter
-
initializeCGroupController
public void initializeCGroupController(CGroupsHandler.CGroupController controller) throws ResourceHandlerException Mount cgroup or use existing mount point based on configuration.- Specified by:
initializeCGroupControllerin interfaceCGroupsHandler- Parameters:
controller- - the controller being initialized- Throws:
ResourceHandlerException- yarn hierarchy cannot be created or accessed for any reason
-
updateEnabledControllersInHierarchy
protected abstract void updateEnabledControllersInHierarchy(File yarnHierarchy, CGroupsHandler.CGroupController controller) throws ResourceHandlerException - Throws:
ResourceHandlerException
-
getErrorWithDetails
protected String getErrorWithDetails(String errorMessage, String subsystemName, String yarnCgroupPath) Creates an actionable error message for mtab parsing.- Parameters:
errorMessage- message to usesubsystemName- cgroup subsystemyarnCgroupPath- cgroup path that failed- Returns:
- a string builder that can be appended by the caller
-
createCGroup
public String createCGroup(CGroupsHandler.CGroupController controller, String cGroupId) throws ResourceHandlerException Description copied from interface:CGroupsHandlerCreates a cgroup for a given controller.- Specified by:
createCGroupin interfaceCGroupsHandler- Parameters:
controller- - controller type for which the cgroup is being createdcGroupId- - id of the cgroup being created- Returns:
- full path to created cgroup
- Throws:
ResourceHandlerException- creation failed
-
deleteCGroup
public void deleteCGroup(CGroupsHandler.CGroupController controller, String cGroupId) throws ResourceHandlerException Description copied from interface:CGroupsHandlerDeletes the specified cgroup.- Specified by:
deleteCGroupin interfaceCGroupsHandler- Parameters:
controller- - controller type for the cgroupcGroupId- - id of the cgroup being deleted- Throws:
ResourceHandlerException- deletion failed
-
updateCGroupParam
public void updateCGroupParam(CGroupsHandler.CGroupController controller, String cGroupId, String param, String value) throws ResourceHandlerException Description copied from interface:CGroupsHandlerupdates a cgroup parameter, given a controller, cgroup id, parameter name. and a parameter value- Specified by:
updateCGroupParamin interfaceCGroupsHandler- Parameters:
controller- - controller type for the cgroupcGroupId- - id of the cgroupparam- - cgroup parameter ( e.g classid )value- - value to be written to the parameter file- Throws:
ResourceHandlerException- the operation failed
-
getCGroupParam
public String getCGroupParam(CGroupsHandler.CGroupController controller, String cGroupId, String param) throws ResourceHandlerException Description copied from interface:CGroupsHandlerreads a cgroup parameter value, given a controller, cgroup id, parameter. name- Specified by:
getCGroupParamin interfaceCGroupsHandler- Parameters:
controller- - controller type for the cgroupcGroupId- - id of the cgroupparam- - cgroup parameter ( e.g classid )- Returns:
- parameter value as read from the parameter file
- Throws:
ResourceHandlerException- the operation failed
-
getCGroupMountPath
Description copied from interface:CGroupsHandlerReturns CGroup Mount Path.- Specified by:
getCGroupMountPathin interfaceCGroupsHandler- Returns:
- parameter value as read from the parameter file
-
getCGroupV2MountPath
Description copied from interface:CGroupsHandlerReturns CGroupV2 Mount Path.- Specified by:
getCGroupV2MountPathin interfaceCGroupsHandler- Returns:
- parameter value as read from the parameter file
-
toString
-