Class DeviceResourceHandlerImpl
java.lang.Object
org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.deviceframework.DeviceResourceHandlerImpl
- All Implemented Interfaces:
ResourceHandler
The Hooks into container lifecycle.
Get device list from device plugin in
bootstrap
Assign devices for a container in preStart
Restore statue in reacquireContainer
Recycle devices from container in postComplete-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDeviceResourceHandlerImpl(String resName, DevicePluginAdapter devPluginAdapter, DeviceMappingManager devMappingManager, CGroupsHandler cgHandler, PrivilegedOperationExecutor operation, Context ctx) DeviceResourceHandlerImpl(String resName, DevicePluginAdapter devPluginAdapter, DeviceMappingManager devMappingManager, CGroupsHandler cgHandler, PrivilegedOperationExecutor operation, Context ctx, ShellWrapper shell) -
Method Summary
Modifier and TypeMethodDescriptionbootstrap(org.apache.hadoop.conf.Configuration configuration) Bootstrap resource susbsystem.org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.deviceframework.DeviceResourceHandlerImpl.DeviceTypegetDeviceType(Device device) org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.deviceframework.DeviceResourceHandlerImpl.DeviceTypegetDeviceTypeFromDeviceNumber(int major, int minor) Get the device type used for cgroups value set.postComplete(org.apache.hadoop.yarn.api.records.ContainerId containerId) Perform any tasks necessary after container completion.Prepare a resource environment for container launchreacquireContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) Require state for container that was already launchedteardown()Teardown environment for resource subsystem if requested.toString()updateContainer(Container container) Update state for container that was already launched
-
Field Details
-
EXCLUDED_DEVICES_CLI_OPTION
- See Also:
-
ALLOWED_DEVICES_CLI_OPTION
- See Also:
-
CONTAINER_ID_CLI_OPTION
- See Also:
-
-
Constructor Details
-
DeviceResourceHandlerImpl
public DeviceResourceHandlerImpl(String resName, DevicePluginAdapter devPluginAdapter, DeviceMappingManager devMappingManager, CGroupsHandler cgHandler, PrivilegedOperationExecutor operation, Context ctx) -
DeviceResourceHandlerImpl
@VisibleForTesting public DeviceResourceHandlerImpl(String resName, DevicePluginAdapter devPluginAdapter, DeviceMappingManager devMappingManager, CGroupsHandler cgHandler, PrivilegedOperationExecutor operation, Context ctx, ShellWrapper shell)
-
-
Method Details
-
bootstrap
public List<PrivilegedOperation> bootstrap(org.apache.hadoop.conf.Configuration configuration) throws ResourceHandlerException Description copied from interface:ResourceHandlerBootstrap resource susbsystem.- Specified by:
bootstrapin interfaceResourceHandler- Returns:
- (possibly empty) list of operations that require elevated privileges
- Throws:
ResourceHandlerException
-
preStart
Description copied from interface:ResourceHandlerPrepare a resource environment for container launch- Specified by:
preStartin interfaceResourceHandler- Parameters:
container- Container being launched- Returns:
- (possibly empty) list of operations that require elevated privileges e.g a) create a custom cgroup b) add pid for container to tasks file for a cgroup.
- Throws:
ResourceHandlerException
-
reacquireContainer
public List<PrivilegedOperation> reacquireContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) throws ResourceHandlerException Description copied from interface:ResourceHandlerRequire state for container that was already launched- Specified by:
reacquireContainerin interfaceResourceHandler- Parameters:
containerId- id of the container being reacquired.- Returns:
- (possibly empty) list of operations that require elevated privileges
- Throws:
ResourceHandlerException
-
updateContainer
public List<PrivilegedOperation> updateContainer(Container container) throws ResourceHandlerException Description copied from interface:ResourceHandlerUpdate state for container that was already launched- Specified by:
updateContainerin interfaceResourceHandler- Parameters:
container- the container being updated.- Returns:
- (possibly empty) list of operations that require elevated privileges
- Throws:
ResourceHandlerException
-
postComplete
public List<PrivilegedOperation> postComplete(org.apache.hadoop.yarn.api.records.ContainerId containerId) throws ResourceHandlerException Description copied from interface:ResourceHandlerPerform any tasks necessary after container completion.- Specified by:
postCompletein interfaceResourceHandler- Parameters:
containerId- of the container that was completed.- Returns:
- (possibly empty) list of operations that require elevated privileges
- Throws:
ResourceHandlerException
-
teardown
Description copied from interface:ResourceHandlerTeardown environment for resource subsystem if requested. This method needs to be used with care since it could impact running containers.- Specified by:
teardownin interfaceResourceHandler- Returns:
- (possibly empty) list of operations that require elevated privileges
- Throws:
ResourceHandlerException
-
toString
-
getDeviceType
public org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.deviceframework.DeviceResourceHandlerImpl.DeviceType getDeviceType(Device device) -
getDeviceTypeFromDeviceNumber
public org.apache.hadoop.yarn.server.nodemanager.containermanager.resourceplugin.deviceframework.DeviceResourceHandlerImpl.DeviceType getDeviceTypeFromDeviceNumber(int major, int minor) Get the device type used for cgroups value set. If sys file "/sys/dev/block/major:minor" exists, it's block device. Otherwise, it's char device. An exception is that Nvidia GPU doesn't create this sys file. so assume character device by default.
-