Interface ResourcePlugin
- All Known Implementing Classes:
DevicePluginAdapter,FpgaResourcePlugin,GpuResourcePlugin
public interface ResourcePlugin
ResourcePlugin is an interface for node manager to easier support
discovery/manage/isolation for new resource types.
It has two major part: createResourceHandler(Context, CGroupsHandler, PrivilegedOperationExecutor) and
getNodeResourceHandlerInstance(), see javadocs below
for more details.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()Do cleanup of the plugin, this will be invoked whenNodeManagerstopscreateResourceHandler(Context nmContext, CGroupsHandler cGroupsHandler, PrivilegedOperationExecutor privilegedOperationExecutor) Plugin needs to returnResourceHandlerwhen any special isolation required for the resource type.Plugin need to getDockerCommandPlugin.Get resource information from this plugin.Plugin needs to returnNodeResourceUpdaterPluginwhen any discovery mechanism required for the resource type.voidinitialize(Context context) Initialize the plugin, this will be invoked during NM startup.
-
Method Details
-
initialize
Initialize the plugin, this will be invoked during NM startup.- Parameters:
context- NM Context- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- when any issue occurs
-
createResourceHandler
ResourceHandler createResourceHandler(Context nmContext, CGroupsHandler cGroupsHandler, PrivilegedOperationExecutor privilegedOperationExecutor) Plugin needs to returnResourceHandlerwhen any special isolation required for the resource type. This will be added toResourceHandlerChainduring NodeManager startup. When no special isolation need, return null.- Parameters:
nmContext- NodeManager context.cGroupsHandler- CGroupsHandlerprivilegedOperationExecutor- Privileged Operation Executor.- Returns:
- ResourceHandler
-
getNodeResourceHandlerInstance
NodeResourceUpdaterPlugin getNodeResourceHandlerInstance()Plugin needs to returnNodeResourceUpdaterPluginwhen any discovery mechanism required for the resource type. For example, if we want to set resource-value during NM registration or send update during NM-RM heartbeat We can implement aNodeResourceUpdaterPluginand update fields ofNodeHeartbeatRequestorRegisterNodeManagerRequestThis will be invoked during every node status update or node registration, please avoid creating new instance every time.- Returns:
- NodeResourceUpdaterPlugin, could be null when no discovery needed.
-
cleanup
void cleanup() throws org.apache.hadoop.yarn.exceptions.YarnExceptionDo cleanup of the plugin, this will be invoked whenNodeManagerstops- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- if any issue occurs
-
getDockerCommandPluginInstance
DockerCommandPlugin getDockerCommandPluginInstance()Plugin need to getDockerCommandPlugin. This will be invoked byDockerLinuxContainerRuntimewhen execute docker commands such as run/stop/pull, etc.- Returns:
- DockerCommandPlugin instance. return null if plugin doesn't have requirement to update docker command.
-
getNMResourceInfo
Get resource information from this plugin.- Returns:
- NMResourceInfo, an example is
GpuDeviceInformation - Throws:
org.apache.hadoop.yarn.exceptions.YarnException- when any issue occurs
-