Interface GridService

All Superinterfaces:
Service

public interface GridService
extends Service
Service for working with the Computational Grid, including APIs to work with GridTask and GridJob objects.
  • Method Summary

    Modifier and Type Method Description
    GridTask await​(java.lang.Long taskId, long intervalInMillis, long maxAwaitInMillis)
    Given a task id, waits for that task to either move to either SUCCEEDED or FAILED.
    GridJob awaitJob​(java.lang.Long jobId, long intervalInMillis, long maxAwaitInMillis)
    Given a job id, waits for the job to either move to either SUCCEEDED or FAILED.
    GridJob getGridJobById​(long jobId)
    Given a job id, returns the GridJob object.
    java.util.Map<java.lang.Long,​GridTask> getGridTasksByIds​(java.util.Collection<java.lang.Long> taskIds)
    Given task ids, returns the associated GridTask objects.
    void insertJobs​(java.util.Collection<GridJob> jobs)
    Inserts the given GridJobs (and the tasks they contain) into the database
    void insertTasks​(java.util.Collection<GridTask> tasks)
    Inserts the given GridTasks into the database
    GridJob newJob​(java.lang.String jobType, java.lang.String jobName)
    Creates a new job in memory which can have tasks added in memory, and then the whole thing can be inserted into the database.
    GridTask newTask​(java.lang.String taskType)
    Creates a new task in memory which can be inserted, or added to a job
    TaskPerformerConfig newTaskPerformerConfig()
    Returns a new TaskPerformerConfig which can be used to spawn new TaskPerformerThreads.
    void queueTasks​(java.lang.String queueName, java.util.Collection<GridTask> tasks)
    Enqueues the given tasks into a "grid queue" with the given name.
    void removeFromQueue​(java.lang.Long taskId)
    Cuts the given GridTask out of its parent queue, ensuring that pointers to that task will point afterward to that task's task_depend.
    java.util.Collection<TaskPerformerThread> startTaskPerformerThreads​(TaskPerformerConfig config)
    Spawns TaskPerformerThread threads to process tasks as defined in the given TaskPerformerConfig.
    void stopTaskPerformerThreads​(java.lang.String taskType, int maxNumberThreadsToStop)
    Stops the number of TaskPerformerThread threads for the provided taskType.
  • Method Details

    • await

      GridTask await​(java.lang.Long taskId, long intervalInMillis, long maxAwaitInMillis) throws GridTaskWaitException
      Given a task id, waits for that task to either move to either SUCCEEDED or FAILED. Polls at the given interval, up to the given max amount of time.
      Parameters:
      taskId - surrogate id of the task to wait on
      intervalInMillis - polling interval to check on status, in milliseconds
      maxAwaitInMillis - max time to wait on the task before throwing an exception
      Returns:
      the GridTask with the given id if it entered an end state in time
      Throws:
      GridTaskWaitException - thrown if the interval elapses without the task completing
    • awaitJob

      GridJob awaitJob​(java.lang.Long jobId, long intervalInMillis, long maxAwaitInMillis) throws GridJobWaitException
      Given a job id, waits for the job to either move to either SUCCEEDED or FAILED. Polls at the given interval, up to the given max amount of time.
      Parameters:
      jobId - surrogate id of the job to wait on
      intervalInMillis - polling interval to check on status, in milliseconds
      maxAwaitInMillis - max time to wait on the task before throwing an exception
      Returns:
      the GridJob with the given id if it entered an end state in time
      Throws:
      GridJobWaitException - thrown if the interval elapses without the task completing
    • queueTasks

      void queueTasks​(java.lang.String queueName, java.util.Collection<GridTask> tasks)
      Enqueues the given tasks into a "grid queue" with the given name. A grid queue is simply a set of tasks where each task depends on the last. The grid framework will track the last task in such a queue given a queue name, and when queuing new tasks will attach them to the end of the queue and update this tail pointer
      Parameters:
      queueName - some string which identifies the queue - if it does not exist, it will be created
      tasks - tasks to place in the queue
    • removeFromQueue

      void removeFromQueue​(java.lang.Long taskId)
      Cuts the given GridTask out of its parent queue, ensuring that pointers to that task will point afterward to that task's task_depend. The task itself is not removed; its dependency and queue_name are nullified.
      Parameters:
      taskId - id of task to remove from queue
    • insertJobs

      void insertJobs​(java.util.Collection<GridJob> jobs)
      Inserts the given GridJobs (and the tasks they contain) into the database
      Parameters:
      jobs - jobs to be inserted
    • insertTasks

      void insertTasks​(java.util.Collection<GridTask> tasks)
      Inserts the given GridTasks into the database
      Parameters:
      tasks - tasks to be inserted
    • newTask

      GridTask newTask​(java.lang.String taskType)
      Creates a new task in memory which can be inserted, or added to a job
      Parameters:
      taskType - task type
      Returns:
      newGridTask
    • newJob

      GridJob newJob​(java.lang.String jobType, java.lang.String jobName)
      Creates a new job in memory which can have tasks added in memory, and then the whole thing can be inserted into the database.
      Parameters:
      jobType - job type (informational, describes the type of job)
      jobName - job name (informational, describes this specific job)
      Returns:
      new GridJob
    • getGridJobById

      GridJob getGridJobById​(long jobId)
      Given a job id, returns the GridJob object. Note that this will not contain the collection of tasks under the job, but will contain job summary information only.
      Parameters:
      jobId - job id
      Returns:
      GridJob with the associated id from the databsae
    • getGridTasksByIds

      java.util.Map<java.lang.Long,​GridTask> getGridTasksByIds​(java.util.Collection<java.lang.Long> taskIds)
      Given task ids, returns the associated GridTask objects.
      Parameters:
      taskIds - task ids
      Returns:
      Map of task id to GridTask
    • newTaskPerformerConfig

      TaskPerformerConfig newTaskPerformerConfig()
      Returns a new TaskPerformerConfig which can be used to spawn new TaskPerformerThreads.
    • startTaskPerformerThreads

      java.util.Collection<TaskPerformerThread> startTaskPerformerThreads​(TaskPerformerConfig config)
      Spawns TaskPerformerThread threads to process tasks as defined in the given TaskPerformerConfig. These threads can be halted any time via TaskPerformerThread.halt().
      Parameters:
      config - task performer configuration, including number of threads, TaskPerformer, etc.
      Returns:
      spawned threads (already started prior to return) iff GridService is active on the current node otherwise empty collection
    • stopTaskPerformerThreads

      void stopTaskPerformerThreads​(java.lang.String taskType, int maxNumberThreadsToStop)
      Stops the number of TaskPerformerThread threads for the provided taskType.
      Parameters:
      taskType - Task type for which threads needs to be stopped
      maxNumberThreadsToStop - number of threads to be stopped.