Class WorkerPoolClientImpl

java.lang.Object
co.yellowdog.platform.clients.scheduler.WorkerPoolClientImpl
All Implemented Interfaces:
WorkerPoolClient, AutoCloseable

public class WorkerPoolClientImpl extends Object implements WorkerPoolClient, AutoCloseable
Implementation of the WorkClient interface.
  • Method Details

    • create

      public static WorkerPoolClientImpl create(@NonNull @NonNull ServicesSchema servicesSchema, @NonNull @NonNull RetryFactory retryFactory, @NonNull @NonNull AuthenticationHeadersProvider authenticationHeadersProvider, @NonNull @NonNull com.fasterxml.jackson.databind.ObjectMapper objectMapper, @NonNull @NonNull UserAgent userAgent)
    • addConfiguredWorkerPool

      public AddConfiguredWorkerPoolResponse addConfiguredWorkerPool(@NonNull @NonNull AddConfiguredWorkerPoolRequest request)
      Description copied from interface: WorkerPoolClient
      Submits a NEW configured worker pool to the YellowDog Scheduler service to be initialised.
      Specified by:
      addConfiguredWorkerPool in interface WorkerPoolClient
      Parameters:
      request - the request containing details of the worker pool
      Returns:
      the response containing the worker pool and the token
    • refreshConfiguredWorkerPoolToken

      public WorkerPoolToken refreshConfiguredWorkerPoolToken(@NonNull @NonNull ConfiguredWorkerPool workerPool)
      Description copied from interface: WorkerPoolClient
      Refresh a configured worker pool token with an unlimited time-to-live.
      Specified by:
      refreshConfiguredWorkerPoolToken in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool
      Returns:
      the worker pool token
    • refreshConfiguredWorkerPoolToken

      public WorkerPoolToken refreshConfiguredWorkerPoolToken(@NonNull @NonNull ConfiguredWorkerPool workerPool, Duration tokenTtl)
      Description copied from interface: WorkerPoolClient
      Refresh a configured worker pool token with the specified time-to-live.
      Specified by:
      refreshConfiguredWorkerPoolToken in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool
      tokenTtl - the token time-to-live.
      Returns:
      the worker pool token
    • refreshConfiguredWorkerPoolToken

      public WorkerPoolToken refreshConfiguredWorkerPoolToken(@NonNull @NonNull String workerPoolId)
      Description copied from interface: WorkerPoolClient
      Refresh a configured worker pool token with an unlimited time-to-live.
      Specified by:
      refreshConfiguredWorkerPoolToken in interface WorkerPoolClient
      Parameters:
      workerPoolId - the worker pool ID
      Returns:
      the worker pool token
    • refreshConfiguredWorkerPoolToken

      public WorkerPoolToken refreshConfiguredWorkerPoolToken(@NonNull @NonNull String workerPoolId, Duration tokenTtl)
      Description copied from interface: WorkerPoolClient
      Refresh a configured worker pool token with the specified time-to-live.
      Specified by:
      refreshConfiguredWorkerPoolToken in interface WorkerPoolClient
      Parameters:
      workerPoolId - the worker pool ID
      tokenTtl - the token time-to-live.
      Returns:
      the worker pool token
    • regenerateConfiguredWorkerPoolToken

      public WorkerPoolToken regenerateConfiguredWorkerPoolToken(@NonNull @NonNull ConfiguredWorkerPool workerPool)
      Description copied from interface: WorkerPoolClient
      Regenerate a configured worker pool token with an unlimited time-to-live.
      Specified by:
      regenerateConfiguredWorkerPoolToken in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool
      Returns:
      the worker pool token
    • regenerateConfiguredWorkerPoolToken

      public WorkerPoolToken regenerateConfiguredWorkerPoolToken(@NonNull @NonNull ConfiguredWorkerPool workerPool, Duration tokenTtl)
      Description copied from interface: WorkerPoolClient
      Regenerate a configured worker pool token with the specified time-to-live.
      Specified by:
      regenerateConfiguredWorkerPoolToken in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool
      tokenTtl - the token time-to-live.
      Returns:
      the worker pool token
    • regenerateConfiguredWorkerPoolToken

      public WorkerPoolToken regenerateConfiguredWorkerPoolToken(@NonNull @NonNull String workerPoolId)
      Description copied from interface: WorkerPoolClient
      Regenerate a configured worker pool token with an unlimited time-to-live.
      Specified by:
      regenerateConfiguredWorkerPoolToken in interface WorkerPoolClient
      Parameters:
      workerPoolId - the worker pool ID
      Returns:
      the worker pool token
    • regenerateConfiguredWorkerPoolToken

      public WorkerPoolToken regenerateConfiguredWorkerPoolToken(@NonNull @NonNull String workerPoolId, Duration tokenTtl)
      Description copied from interface: WorkerPoolClient
      Regenerate a configured worker pool token with the specified time-to-live.
      Specified by:
      regenerateConfiguredWorkerPoolToken in interface WorkerPoolClient
      Parameters:
      workerPoolId - the worker pool ID
      tokenTtl - the token time-to-live.
      Returns:
      the worker pool token
    • getConfiguredWorkerPoolToken

      public WorkerPoolToken getConfiguredWorkerPoolToken(@NonNull @NonNull ConfiguredWorkerPool workerPool)
      Description copied from interface: WorkerPoolClient
      Get a configured worker pool token.
      Specified by:
      getConfiguredWorkerPoolToken in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool
      Returns:
      the worker pool token
    • getConfiguredWorkerPoolToken

      public WorkerPoolToken getConfiguredWorkerPoolToken(@NonNull @NonNull String workerPoolId)
      Description copied from interface: WorkerPoolClient
      Get a configured worker pool token.
      Specified by:
      getConfiguredWorkerPoolToken in interface WorkerPoolClient
      Parameters:
      workerPoolId - the worker pool ID
      Returns:
      the worker pool token
    • provisionWorkerPool

      public ProvisionedWorkerPool provisionWorkerPool(@NonNull @NonNull ComputeRequirementTemplateUsage computeRequirementTemplateUsage)
      Description copied from interface: WorkerPoolClient
      Requests that the supplied compute requirement template request is used to provision a worker pool.
      Specified by:
      provisionWorkerPool in interface WorkerPoolClient
      Parameters:
      computeRequirementTemplateUsage - the compute requirement template usage from which to provision a worker pool
      Returns:
      the provisioned worker pool
    • provisionWorkerPool

      public ProvisionedWorkerPool provisionWorkerPool(@NonNull @NonNull ComputeRequirementTemplateUsage computeRequirementTemplateUsage, ProvisionedWorkerPoolProperties provisionedProperties)
      Description copied from interface: WorkerPoolClient
      Requests that the supplied compute requirement template request is used to provision a worker pool.
      Specified by:
      provisionWorkerPool in interface WorkerPoolClient
      Parameters:
      computeRequirementTemplateUsage - the compute requirement template usage from which to provision a worker pool
      provisionedProperties - the properties used to determine behaviour when managing the worker pool
      Returns:
      the provisioned worker pool
    • resizeWorkerPool

      public ProvisionedWorkerPool resizeWorkerPool(@NonNull @NonNull ProvisionedWorkerPool workerPool, int size)
      Description copied from interface: WorkerPoolClient
      Resizes the specified worker pool to the given number of nodes.
      Specified by:
      resizeWorkerPool in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool to resize
      size - the target number of nodes when resizing the worker pool
      Returns:
      the latest state of the worker pool
    • resizeWorkerPool

      public ProvisionedWorkerPool resizeWorkerPool(@NonNull @NonNull String workerPoolId, int size)
      Description copied from interface: WorkerPoolClient
      Resizes the specified worker pool to the given number of nodes.
      Specified by:
      resizeWorkerPool in interface WorkerPoolClient
      Parameters:
      workerPoolId - the ID of the worker pool to resize
      size - the target number of nodes when resizing the worker pool
      Returns:
      the latest state of the worker pool
    • shutdownWorkerPool

      public void shutdownWorkerPool(@NonNull @NonNull WorkerPool workerPool)
      Description copied from interface: WorkerPoolClient
      Shuts down the specified worker pool.
      Specified by:
      shutdownWorkerPool in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool to shutdown
    • shutdownWorkerPool

      public void shutdownWorkerPool(@NonNull @NonNull String workerPoolId)
      Description copied from interface: WorkerPoolClient
      Shuts down the specified worker pool.
      Specified by:
      shutdownWorkerPool in interface WorkerPoolClient
      Parameters:
      workerPoolId - the ID of the worker pool to shutdown
    • getWorkerPool

      public <T extends WorkerPool> T getWorkerPool(@NonNull T workerPool)
      Description copied from interface: WorkerPoolClient
      Gets the latest state of the supplied worker pool.
      Specified by:
      getWorkerPool in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool for which to get the latest state
      Returns:
      the latest state of the worker pool
    • getWorkerPool

      public WorkerPool getWorkerPool(@NonNull @NonNull String workerPoolId)
      Description copied from interface: WorkerPoolClient
      Gets the latest state of the worker pool with the specified ID.
      Specified by:
      getWorkerPool in interface WorkerPoolClient
      Parameters:
      workerPoolId - the ID of the worker pool
      Returns:
      the latest state of the worker pool
    • getWorkerPool

      public WorkerPool getWorkerPool(@NonNull @NonNull String namespace, @NonNull @NonNull String name)
      Description copied from interface: WorkerPoolClient
      Gets the latest state of the worker pool with the specified namespace and name.
      Specified by:
      getWorkerPool in interface WorkerPoolClient
      Parameters:
      namespace - the namespace of the worker pool
      name - the name of the worker pool
      Returns:
      the latest state of the worker pool
    • getWorkerPool

      public <T extends WorkerPool> T getWorkerPool(@NonNull @NonNull String workerPoolId, @NonNull @NonNull Class<T> workerPoolClass)
      Description copied from interface: WorkerPoolClient
      Gets the latest state of the supplied worker pool by ID.
      Specified by:
      getWorkerPool in interface WorkerPoolClient
      Parameters:
      workerPoolId - the ID of the worker pool
      workerPoolClass - the type of the worker pool to return
      Returns:
      the latest state of the worker pool
    • getWorkerPool

      public <T extends WorkerPool> T getWorkerPool(@NonNull @NonNull String namespace, @NonNull @NonNull String name, @NonNull @NonNull Class<T> workerPoolClass)
      Description copied from interface: WorkerPoolClient
      Gets the latest state of the supplied worker pool by namespace and name.
      Specified by:
      getWorkerPool in interface WorkerPoolClient
      Parameters:
      namespace - the namespace of the worker pool
      name - the name of the worker pool
      workerPoolClass - the type of the worker pool to return
      Returns:
      the latest state of the worker pool
    • addWorkerPoolListener

      public void addWorkerPoolListener(@NonNull @NonNull WorkerPool workerPool, @NonNull @NonNull SubscriptionEventListener<WorkerPool> listener)
      Description copied from interface: WorkerPoolClient
      Adds an event listener to receive notifications of changes for the specified worker pool. The client manages subscriptions to YellowDog Scheduler such that the first listener created for a worker pool will cause a Server-Sent Events subscription to be initiated; additional listeners for the same worker pool share that subscription.
      Specified by:
      addWorkerPoolListener in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool for which to receive notifications
      listener - the event listener that will be invoked for notifications
    • addWorkerPoolListener

      public void addWorkerPoolListener(@NonNull @NonNull String workerPoolId, @NonNull @NonNull SubscriptionEventListener<WorkerPool> listener)
      Description copied from interface: WorkerPoolClient
      Adds an event listener to receive notifications of changes for the specified worker pool. The client manages subscriptions to YellowDog Scheduler such that the first listener created for a worker pool will cause a Server-Sent Events subscription to be initiated; additional listeners for the same worker pool share that subscription.
      Specified by:
      addWorkerPoolListener in interface WorkerPoolClient
      Parameters:
      workerPoolId - the ID of the worker pool for which to receive notifications
      listener - the event listener that will be invoked for notifications
    • removeWorkerPoolListener

      public void removeWorkerPoolListener(@NonNull @NonNull SubscriptionEventListener<WorkerPool> listener)
      Description copied from interface: WorkerPoolClient
      Removes the specified event listener. The client manages subscriptions to YellowDog Scheduler such that when the last listener for a worker pool is removed, the associated Server-Sent Events subscription is cancelled.
      Specified by:
      removeWorkerPoolListener in interface WorkerPoolClient
      Parameters:
      listener - the event listener that will no longer be invoked for notifications
    • getWorkerPoolHelper

      public WorkerPoolHelper getWorkerPoolHelper(@NonNull @NonNull WorkerPool workerPool)
      Description copied from interface: WorkerPoolClient
      Constructs a new worker pool helper for the specified worker pool.
      Specified by:
      getWorkerPoolHelper in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool for which the helper will be constructed
      Returns:
      a new worker pool helper
    • getWorkerPoolHelper

      public WorkerPoolHelper getWorkerPoolHelper(@NonNull @NonNull String workerPoolId)
      Description copied from interface: WorkerPoolClient
      Constructs a new worker pool helper for the specified worker pool.
      Specified by:
      getWorkerPoolHelper in interface WorkerPoolClient
      Parameters:
      workerPoolId - the ID of the worker pool for which the helper will be constructed
      Returns:
      a new worker pool helper
    • findAllWorkerPools

      public List<WorkerPoolSummary> findAllWorkerPools()
      Description copied from interface: WorkerPoolClient
      Returns summaries of all existing worker pools within the system for the requesting user.
      Specified by:
      findAllWorkerPools in interface WorkerPoolClient
      Returns:
      a list of worker pool summaries
    • getWorkerPools

      public SearchClient<WorkerPoolSummary> getWorkerPools(WorkerPoolSearch search)
      Description copied from interface: WorkerPoolClient
      Returns a SearchClient that offers the ability to search worker pools.
      Specified by:
      getWorkerPools in interface WorkerPoolClient
      Parameters:
      search - the search
      Returns:
      the search client
    • findNodes

      public List<Node> findNodes(@NonNull @NonNull NodeSearch search)
      Description copied from interface: WorkerPoolClient
      Returns worker pool nodes within the system that match the specified search. WARNING: If your search matches too many workers to fit into your application's memory limits, consider using WorkerPoolClient.streamNodes(NodeSearch) or WorkerPoolClient.findNodes(NodeSearch, SliceReference).
      Specified by:
      findNodes in interface WorkerPoolClient
      Parameters:
      search - the search
      Returns:
      a list of nodes
    • findNodes

      public Slice<Node> findNodes(@NonNull @NonNull NodeSearch search, @NonNull @NonNull SliceReference sliceReference)
      Description copied from interface: WorkerPoolClient
      Returns a slice of nodes that match the specified search and slice reference.
      Specified by:
      findNodes in interface WorkerPoolClient
      Parameters:
      search - the search
      sliceReference - the slice reference
      Returns:
      a slice of nodes
    • streamNodes

      public Stream<Node> streamNodes(@NonNull @NonNull NodeSearch search)
      Description copied from interface: WorkerPoolClient
      Streams nodes within the system that match the specified search.
      Specified by:
      streamNodes in interface WorkerPoolClient
      Parameters:
      search - the search
      Returns:
      a stream of nodes
    • getNode

      public Node getNode(@NonNull @NonNull Node node)
      Description copied from interface: WorkerPoolClient
      Gets the latest state of the node with the specified ID.
      Specified by:
      getNode in interface WorkerPoolClient
      Parameters:
      node - the node
      Returns:
      the latest state of the node
    • getNode

      public Node getNode(@NonNull @NonNull String nodeId)
      Description copied from interface: WorkerPoolClient
      Gets the latest state of the node with the specified ID.
      Specified by:
      getNode in interface WorkerPoolClient
      Parameters:
      nodeId - the ID of the node
      Returns:
      the latest state of the node
    • shutdownNode

      public Node shutdownNode(@NonNull @NonNull Node node)
      Description copied from interface: WorkerPoolClient
      Shuts down the specified node gracefully, allowing any running tasks to finish first.
      Specified by:
      shutdownNode in interface WorkerPoolClient
      Parameters:
      node - the node
      Returns:
      the latest state of the node
    • shutdownNode

      public Node shutdownNode(@NonNull @NonNull String nodeId)
      Description copied from interface: WorkerPoolClient
      Shuts down the specified node gracefully, allowing any running tasks to finish first.
      Specified by:
      shutdownNode in interface WorkerPoolClient
      Parameters:
      nodeId - the ID of the node
      Returns:
      the latest state of the node
    • addNodeActionsForNode

      public void addNodeActionsForNode(@NonNull @NonNull Node node, NodeAction... actions)
      Description copied from interface: WorkerPoolClient
      Adds node actions to be performed for the specified node. Sets the nodeIdFilter and nodeTypes properties of any actions to apply to the specified node.
      Specified by:
      addNodeActionsForNode in interface WorkerPoolClient
      Parameters:
      node - the node
      actions - the node actions
    • addNodeActionsForNode

      public void addNodeActionsForNode(@NonNull @NonNull String workerPoolId, @NonNull @NonNull String nodeId, NodeAction... actions)
      Description copied from interface: WorkerPoolClient
      Adds node actions to be performed for the specified node. Sets the nodeIdFilter and nodeTypes properties of any actions to apply to the specified node.
      Specified by:
      addNodeActionsForNode in interface WorkerPoolClient
      Parameters:
      workerPoolId - the ID of the worker pool containing the node
      nodeId - the ID of the node
      actions - the node actions
    • addNodeActions

      public void addNodeActions(@NonNull @NonNull String workerPoolId, NodeAction... actions)
      Description copied from interface: WorkerPoolClient
      Adds the specified node actions to be performed for the specified worker pool.
      Specified by:
      addNodeActions in interface WorkerPoolClient
      Parameters:
      workerPoolId - the ID of the worker pool
      actions - the node actions
    • addNodeActions

      public void addNodeActions(@NonNull @NonNull String workerPoolId, NodeActionGroup... actionGroups)
      Description copied from interface: WorkerPoolClient
      Adds the specified groups of node actions to be performed for the specified worker pool.
      Specified by:
      addNodeActions in interface WorkerPoolClient
      Parameters:
      workerPoolId - the ID of the worker pool
      actionGroups - the node action groups
    • addNodeActions

      public void addNodeActions(@NonNull @NonNull String workerPoolId, @NonNull @NonNull List<NodeActionGroup> actionGroups)
      Description copied from interface: WorkerPoolClient
      Adds the specified groups of node actions to be performed for the specified worker pool.
      Specified by:
      addNodeActions in interface WorkerPoolClient
      Parameters:
      workerPoolId - the ID of the worker pool
      actionGroups - the node action groups
    • addNodeActions

      public void addNodeActions(@NonNull @NonNull String workerPoolId, @NonNull @NonNull List<NodeActionGroup> actionGroups, List<String> nodeIdFilterList)
      Description copied from interface: WorkerPoolClient
      Adds the specified groups of node actions to be performed for the specified worker pool.
      Specified by:
      addNodeActions in interface WorkerPoolClient
      Parameters:
      workerPoolId - the ID of the worker pool
      actionGroups - the node action groups
      nodeIdFilterList - a list of node IDs that can be used to filter recipients of node actions
    • addNodeActions

      public void addNodeActions(@NonNull @NonNull WorkerPool workerPool, NodeAction... actions)
      Description copied from interface: WorkerPoolClient
      Adds the specified node actions to be performed for the specified worker pool.
      Specified by:
      addNodeActions in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool
      actions - the node actions
    • addNodeActions

      public void addNodeActions(@NonNull @NonNull WorkerPool workerPool, NodeActionGroup... actionGroups)
      Description copied from interface: WorkerPoolClient
      Adds the specified groups of node actions to be performed for the specified worker pool.
      Specified by:
      addNodeActions in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool
      actionGroups - the node action groups
    • addNodeActions

      public void addNodeActions(@NonNull @NonNull WorkerPool workerPool, List<NodeActionGroup> actionGroups)
      Description copied from interface: WorkerPoolClient
      Adds the specified groups of node actions to be performed for the specified worker pool.
      Specified by:
      addNodeActions in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool
      actionGroups - the node action groups
    • addNodeActions

      public void addNodeActions(@NonNull @NonNull WorkerPool workerPool, List<NodeActionGroup> actionGroups, List<String> nodeIdFilterList)
      Description copied from interface: WorkerPoolClient
      Adds the specified groups of node actions to be performed for the specified worker pool.
      Specified by:
      addNodeActions in interface WorkerPoolClient
      Parameters:
      workerPool - the worker pool
      actionGroups - the node action groups
      nodeIdFilterList - a list of node IDs that can be used to filter recipients of node actions
    • getNodeActions

      public NodeActionQueueSnapshot getNodeActions(@NonNull @NonNull Node node)
      Description copied from interface: WorkerPoolClient
      Gets the current state of the specified node's action queue.
      Specified by:
      getNodeActions in interface WorkerPoolClient
      Parameters:
      node - the node
      Returns:
      the current state of the action queue
    • getNodeActions

      public NodeActionQueueSnapshot getNodeActions(@NonNull @NonNull String nodeId)
      Description copied from interface: WorkerPoolClient
      Gets the current state of the specified node's action queue.
      Specified by:
      getNodeActions in interface WorkerPoolClient
      Parameters:
      nodeId - the ID of the node
      Returns:
      the current state of the action queue
    • getNodes

      public SearchClient<Node> getNodes(NodeSearch search)
      Description copied from interface: WorkerPoolClient
      Returns a SearchClient that offers the ability to search nodes.
      Specified by:
      getNodes in interface WorkerPoolClient
      Parameters:
      search - the search
      Returns:
      the search client
    • close

      public void close()
      Cancels any active Server-Sent Event subscriptions.
      Specified by:
      close in interface AutoCloseable