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 Details

    • initialize

      void initialize(Context context) throws org.apache.hadoop.yarn.exceptions.YarnException
      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 return ResourceHandler when any special isolation required for the resource type. This will be added to ResourceHandlerChain during NodeManager startup. When no special isolation need, return null.
      Parameters:
      nmContext - NodeManager context.
      cGroupsHandler - CGroupsHandler
      privilegedOperationExecutor - Privileged Operation Executor.
      Returns:
      ResourceHandler
    • getNodeResourceHandlerInstance

      NodeResourceUpdaterPlugin getNodeResourceHandlerInstance()
      Plugin needs to return NodeResourceUpdaterPlugin when 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 a NodeResourceUpdaterPlugin and update fields of NodeHeartbeatRequest or RegisterNodeManagerRequest This 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.YarnException
      Do cleanup of the plugin, this will be invoked when NodeManager stops
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException - if any issue occurs
    • getDockerCommandPluginInstance

      DockerCommandPlugin getDockerCommandPluginInstance()
      Plugin need to get DockerCommandPlugin. This will be invoked by DockerLinuxContainerRuntime when 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

      NMResourceInfo getNMResourceInfo() throws org.apache.hadoop.yarn.exceptions.YarnException
      Get resource information from this plugin.
      Returns:
      NMResourceInfo, an example is GpuDeviceInformation
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException - when any issue occurs