All Implemented Interfaces:
SpallocAPI

@Service
public class Spalloc
extends DatabaseAwareBean
implements SpallocAPI
The core implementation of the Spalloc service.
Author:
Donal Fellows
  • Constructor Details

  • Method Details

    • getMachines

      public Map<String,​SpallocAPI.Machine> getMachines​(boolean allowOutOfService)
      Description copied from interface: SpallocAPI
      List the machines.
      Specified by:
      getMachines in interface SpallocAPI
      Parameters:
      allowOutOfService - Whether to include machines marked as out of service.
      Returns:
      A mapping from names to machines (which are live objects).
    • listMachines

      public List<MachineListEntryRecord> listMachines​(boolean allowOutOfService)
      Description copied from interface: SpallocAPI
      List the machines.
      Specified by:
      listMachines in interface SpallocAPI
      Parameters:
      allowOutOfService - Whether to include machines marked as out of service.
      Returns:
      A description of all the machines.
    • getMachine

      public Optional<SpallocAPI.Machine> getMachine​(String name, boolean allowOutOfService)
      Description copied from interface: SpallocAPI
      Get a specific machine.
      Specified by:
      getMachine in interface SpallocAPI
      Parameters:
      name - The name of the machine to get.
      allowOutOfService - Whether to include machines marked as out of service.
      Returns:
      A machine, on which more operations can be done.
    • getMachineInfo

      public Optional<MachineDescription> getMachineInfo​(String machine, boolean allowOutOfService, Permit permit)
      Description copied from interface: SpallocAPI
      Get info about a specific machine.
      Specified by:
      getMachineInfo in interface SpallocAPI
      Parameters:
      machine - The name of the machine to get.
      allowOutOfService - Whether to include machines marked as out of service.
      permit - Encodes what the caller may do.
      Returns:
      A machine description model.
    • getJobs

      public SpallocAPI.Jobs getJobs​(boolean deleted, int limit, int start)
      Description copied from interface: SpallocAPI
      List the jobs.
      Specified by:
      getJobs in interface SpallocAPI
      Parameters:
      deleted - Whether to include deleted jobs in the list.
      limit - Maximum number of jobs in the returned list. Used for paging.
      start - How many jobs to skip past. Used for paging.
      Returns:
      A list of jobs.
    • listJobs

      public List<JobListEntryRecord> listJobs​(Permit permit)
      Description copied from interface: SpallocAPI
      List the active jobs.
      Specified by:
      listJobs in interface SpallocAPI
      Parameters:
      permit - Encodes what the caller may do.
      Returns:
      A description of all the active jobs.
    • getJob

      @PostFilter("#permit.admin or #permit.nmpiexec or #permit.name == filterObject.owner.orElse(null)") public Optional<SpallocAPI.Job> getJob​(Permit permit, int id)
      Description copied from interface: SpallocAPI
      Get a specific job. Only owners or admins can see full job details or manipulate the job.
      Specified by:
      getJob in interface SpallocAPI
      Parameters:
      permit - Encodes what the caller may do.
      id - The identifier of the job.
      Returns:
      A job object on which more operations can be done, or empty if the job isn't there or isn't available to you.
    • getJobInfo

      @PostFilter("#permit.admin or #permit.nmpiexec or #permit.name == filterObject.owner.orElse(null)") public Optional<JobDescription> getJobInfo​(Permit permit, int id)
      Description copied from interface: SpallocAPI
      Get a specific job. Only owners or admins can see full job details or manipulate the job.
      Specified by:
      getJobInfo in interface SpallocAPI
      Parameters:
      permit - Encodes what the caller may do.
      id - The identifier of the job.
      Returns:
      A job description, or empty if the job isn't there (or isn't available to you).
    • createJobInGroup

      public SpallocAPI.Job createJobInGroup​(String owner, String groupName, SpallocAPI.CreateDescriptor descriptor, String machineName, List<String> tags, Duration keepaliveInterval, byte[] req) throws IllegalArgumentException
      Description copied from interface: SpallocAPI
      Create a job for a user in a specific local group. Note that jobs cannot be created on machines that are out of service, but marking a machine as out of service does not stop the jobs that are already running on it.
      Specified by:
      createJobInGroup in interface SpallocAPI
      Parameters:
      owner - Who is making this job.
      groupName - What group is associated with this job for accounting purposes.
      descriptor - What sort of allocation is desired?
      machineName - The name of the machine the user wants to allocate on, or null if they want to select by tags.
      tags - The tags of the machine the user wants to allocate on, or null if they want to select by name.
      keepaliveInterval - The maximum interval between keepalive requests or the job becomes eligible for automated deletion.
      req - The serialized original request, which will be stored in the database for later retrieval.
      Returns:
      The job created.
      Throws:
      IllegalArgumentException - if the job could not be created.
    • createJob

      public SpallocAPI.Job createJob​(String owner, SpallocAPI.CreateDescriptor descriptor, String machineName, List<String> tags, Duration keepaliveInterval, byte[] originalRequest)
      Description copied from interface: SpallocAPI
      Create a job for a user that is only in one group. Note that jobs cannot be created on machines that are out of service, but marking a machine as out of service does not stop the jobs that are already running on it.
      Specified by:
      createJob in interface SpallocAPI
      Parameters:
      owner - Who is making this job.
      descriptor - What sort of allocation is desired?
      machineName - The name of the machine the user wants to allocate on, or null if they want to select by tags.
      tags - The tags of the machine the user wants to allocate on, or null if they want to select by name.
      keepaliveInterval - The maximum interval between keepalive requests or the job becomes eligible for automated deletion.
      originalRequest - The serialized original request, which will be stored in the database for later retrieval.
      Returns:
      The job created.
    • createJobInCollabSession

      public SpallocAPI.Job createJobInCollabSession​(String owner, String nmpiCollab, SpallocAPI.CreateDescriptor descriptor, String machineName, List<String> tags, Duration keepaliveInterval, byte[] originalRequest)
      Description copied from interface: SpallocAPI
      Create a job for interactive use in an NMPI Collab Session. Note that jobs cannot be created on machines that are out of service, but marking a machine as out of service does not stop the jobs that are already running on it.
      Specified by:
      createJobInCollabSession in interface SpallocAPI
      Parameters:
      owner - Who is making this job.
      nmpiCollab - The NMPI Collab to manage a session in, and from which the quota will be used.
      descriptor - What sort of allocation is desired?
      machineName - The name of the machine the user wants to allocate on, or null if they want to select by tags.
      tags - The tags of the machine the user wants to allocate on, or null if they want to select by name.
      keepaliveInterval - The maximum interval between keepalive requests or the job becomes eligible for automated deletion.
      originalRequest - The serialized original request, which will be stored in the database for later retrieval.
      Returns:
      The job created.
    • createJobForNMPIJob

      public SpallocAPI.Job createJobForNMPIJob​(String owner, int nmpiJobId, SpallocAPI.CreateDescriptor descriptor, String machineName, List<String> tags, Duration keepaliveInterval, byte[] originalRequest)
      Description copied from interface: SpallocAPI
      Create a job for interactive use in an NMPI Collab Session. Note that jobs cannot be created on machines that are out of service, but marking a machine as out of service does not stop the jobs that are already running on it.
      Specified by:
      createJobForNMPIJob in interface SpallocAPI
      Parameters:
      owner - Who is making this job.
      nmpiJobId - The NMPI Job to allocate the quota used to. The collab of the Job will be used for internal accounting purposes.
      descriptor - What sort of allocation is desired?
      machineName - The name of the machine the user wants to allocate on, or null if they want to select by tags.
      tags - The tags of the machine the user wants to allocate on, or null if they want to select by name.
      keepaliveInterval - The maximum interval between keepalive requests or the job becomes eligible for automated deletion.
      originalRequest - The serialized original request, which will be stored in the database for later retrieval.
      Returns:
      The job created.
    • purgeDownCache

      public void purgeDownCache()
      Description copied from interface: SpallocAPI
      Purge the cache of what boards are down.
      Specified by:
      purgeDownCache in interface SpallocAPI
    • reportProblem

      public void reportProblem​(String address, HasChipLocation coreLocation, String description, Permit permit)
      Description copied from interface: SpallocAPI
      Tells the service that there may be a problem with a board at a particular address.
      Specified by:
      reportProblem in interface SpallocAPI
      Parameters:
      address - The IP address of the board. Note that we haven't yet identified which machine has the board.
      coreLocation - Where on the board is the problem. If the problem is at the core level, it's a HasCoreLocation. If the problem is at the board level, this is null.
      description - Optional problem description. May be null.
      permit - Who is making the request.