Class ResourceSelectorScript<R,C extends ResourceSelectionContext<R>>

java.lang.Object
com.netflix.genie.web.scripts.ManagedScript
com.netflix.genie.web.scripts.ResourceSelectorScript<R,C>
Type Parameters:
R - The type of resource this script is selecting from
C - The context for resource selection which must extend ResourceSelectionContext
Direct Known Subclasses:
AgentLauncherSelectorManagedScript, ClusterSelectorManagedScript, CommandSelectorManagedScript

public class ResourceSelectorScript<R,C extends ResourceSelectionContext<R>> extends ManagedScript
Interface for defining the contract between the selection of a resource from a set of resources for a given job request.
Since:
4.0.0
  • Constructor Details

    • ResourceSelectorScript

      protected ResourceSelectorScript(ScriptManager scriptManager, ManagedScriptBaseProperties properties, io.micrometer.core.instrument.MeterRegistry registry, com.netflix.genie.common.internal.util.PropertiesMapCache propertyMapCache)
      Constructor.
      Parameters:
      scriptManager - The ScriptManager instance to use
      properties - The ManagedScriptBaseProperties instance to use
      registry - The MeterRegistry instance to use
      propertyMapCache - The PropertiesMapCache instance to use
  • Method Details

    • selectResource

      public ResourceSelectorScriptResult<R> selectResource(C context) throws ResourceSelectionException
      Given the JobRequest and an associated set of resources which matched the request criteria invoke the configured script to see if a preferred resource is selected based on the current logic.
      Parameters:
      context - The ResourceSelectionContext instance containing information about the context for this selection
      Returns:
      A ResourceSelectorScriptResult instance
      Throws:
      ResourceSelectionException - If an unexpected error occurs during selection
    • addParametersForScript

      protected void addParametersForScript(Map<String,Object> parameters, C context)
      Add any implementation specific parameters to the map of parameters to send to the script.
      Parameters:
      parameters - The existing set of parameters for implementations to add to
      context - The selection context