Class QuotaManager


@Service
public class QuotaManager
extends DatabaseAwareBean
Manages user quotas.
Author:
Donal Fellows
  • Constructor Details

  • Method Details

    • mayCreateJob

      public boolean mayCreateJob​(int groupId)
      Can the user (in a specific group) create another job at this point? If not, they're currently out of resources.
      Parameters:
      groupId - What group will the job be accounted against.
      Returns:
      True if they can make a job. False if they can't.
    • mayLetJobContinue

      public boolean mayLetJobContinue​(int jobId)
      Has the execution of a job remained within its group's resource allocation at this point?
      Parameters:
      jobId - What job is consuming resources?
      Returns:
      True if the job can continue to run. False if it can't.
    • shouldKillJob

      public boolean shouldKillJob​(int jobId)
      Has the execution of a job exceeded its group's resource allocation at this point?
      Parameters:
      jobId - What job is consuming resources?
      Returns:
      False if the job should be killed. True otherwise.
    • addQuota

      public Optional<QuotaManager.AdjustedQuota> addQuota​(int groupId, int delta)
      Adjust a group's quota.
      Parameters:
      groupId - Which group's quota to change
      delta - Amount to change by, in board-seconds
      Returns:
      Information about what group's quota was adjusted and what it has become.
    • consolidateQuotas

      @Scheduled(cron="#{quotaProperties.consolidationSchedule}") public void consolidateQuotas()
      Consolidates usage from finished jobs onto quotas. Runs hourly.