Class AllocatorTask

All Implemented Interfaces:
PowerController

@Service
public class AllocatorTask
extends DatabaseAwareBean
implements PowerController
The allocation engine. Allocations are performed by running suitable (non-trivial) SQL queries on a periodic basis, putting jobs that cannot be allocated back on the queue for a later attempt (and increasing their priority when it does so). This class is also responsible for destroying jobs that are not kept alive sufficiently frequently, and eventually migrating records of dead jobs to long-term storage ("tombstoning").
  • Constructor Details

  • Method Details

    • setBMPController

      public void setBMPController​(BMPController bmpController)
    • updateJob

      public void updateJob​(int jobId, JobState sourceState, JobState targetState)
      Perform update on a job now as a result of a change.
      Parameters:
      jobId - The job to update.
      sourceState - The change source state.
      targetState - The change target state.
    • scheduleAllocateNow

      public void scheduleAllocateNow()
      Ask for allocation to happen now.
    • allocate

      public void allocate()
      Allocate all current requests for resources.
    • expireJobs

      public void expireJobs()
      Destroy jobs that have missed their keepalive.
    • tombstone

      public void tombstone()
      Migrates long dead jobs to the historical data DB.
    • destroyJob

      public void destroyJob​(int id, String reason)
      Description copied from interface: PowerController
      Destroy a job. The power controller has the responsibility because it releases any resources held by the job.
      Specified by:
      destroyJob in interface PowerController
      Parameters:
      id - The ID of the job.
      reason - Why is the job being destroyed.
    • setPower

      public boolean setPower​(int jobId, PowerState power, JobState targetState)
      Description copied from interface: PowerController
      Issue a power change for a job.
      Specified by:
      setPower in interface PowerController
      Parameters:
      jobId - The ID of the allocated job.
      power - What state to change the job's boards' power to.
      targetState - What state are we aiming to put the job into once the power has been switched. Should be JobState.READY or JobState.QUEUED. NB: Use PowerController.destroyJob(int, String) to move to JobState.DESTROYED.
      Returns:
      Whether any change has been requested.