Class Spalloc
java.lang.Object
uk.ac.manchester.spinnaker.alloc.db.SQLQueries
uk.ac.manchester.spinnaker.alloc.db.DatabaseAwareBean
uk.ac.manchester.spinnaker.alloc.allocator.Spalloc
- All Implemented Interfaces:
SpallocAPI
@Service public class Spalloc extends DatabaseAwareBean implements SpallocAPI
The core implementation of the Spalloc service.
- Author:
- Donal Fellows
-
Nested Class Summary
Nested classes/interfaces inherited from class uk.ac.manchester.spinnaker.alloc.db.DatabaseAwareBean
DatabaseAwareBean.AbstractSQL
Nested classes/interfaces inherited from interface uk.ac.manchester.spinnaker.alloc.allocator.SpallocAPI
SpallocAPI.BoardLocation, SpallocAPI.CreateBoard, SpallocAPI.CreateDescriptor, SpallocAPI.CreateDimensions, SpallocAPI.CreateDimensionsAt, SpallocAPI.CreateNumBoards, SpallocAPI.CreateVisitor<T>, SpallocAPI.HasBoardCoords, SpallocAPI.Job, SpallocAPI.Jobs, SpallocAPI.Machine, SpallocAPI.SubMachine, SpallocAPI.Waitable
-
Field Summary
Fields inherited from class uk.ac.manchester.spinnaker.alloc.db.SQLQueries
ADD_BLACKLISTED_CHIP, ADD_BLACKLISTED_CORE, ADD_BLACKLISTED_LINK, ADD_USER_TO_GROUP, ADJUST_QUOTA, ALLOCATE_BOARDS_BOARD, ALLOCATE_BOARDS_JOB, BUMP_IMPORTANCE, CHECK_LOCATION, checkRectangle, checkRectangleAt, CLEAR_BLACKLISTED_CHIPS, CLEAR_BLACKLISTED_CORES, CLEAR_BLACKLISTED_LINKS, COMPLETED_BLACKLIST_WRITE, COMPLETED_BOARD_INFO_READ, COMPLETED_GET_SERIAL_REQ, COUNT_CHANGES_FOR_JOB, COUNT_FUNCTIONING_BOARDS, COUNT_MACHINE_THINGS, COUNT_POWERED_BOARDS, countConnected, CREATE_BLACKLIST_READ, CREATE_BLACKLIST_WRITE, CREATE_GROUP, CREATE_GROUP_IF_NOT_EXISTS, CREATE_SERIAL_READ_REQ, CREATE_TEMP_READ_REQ, CREATE_USER, DEALLOCATE_BMP_BOARDS_JOB, DECREMENT_QUOTA, DELETE_ALLOC_RECORD, DELETE_BLACKLIST_OP, DELETE_GROUP, DELETE_JOB_RECORD, DELETE_MACHINE_TAGS, DELETE_NMPI_JOB, DELETE_NMPI_SESSION, DELETE_PENDING, DELETE_TASK, DELETE_USER, DESTROY_JOB, ERROR_PENDING, FAILED_BLACKLIST_OP, FIND_BOARD_BY_ID, FIND_BOARD_BY_NAME_AND_CFB, FIND_BOARD_BY_NAME_AND_IP_ADDRESS, FIND_BOARD_BY_NAME_AND_XYZ, FIND_EXPIRED_JOBS, FIND_FREE_BOARD, FIND_LOCATION, findBoardByGlobalChip, findBoardByIPAddress, findBoardByJobChip, findBoardByLogicalCoords, findBoardByPhysicalCoords, findRectangle, findRectangleAt, FINISHED_PENDING, GET_ALL_BMP_BOARDS, GET_ALL_BMPS, GET_ALL_BOARDS, GET_ALL_BOARDS_OF_ALL_MACHINES, GET_ALL_MACHINES, GET_AVAILABLE_BOARD_NUMBERS, GET_BLACKLIST_READS, GET_BLACKLIST_WRITES, GET_BLACKLISTED_CHIPS, GET_BLACKLISTED_CORES, GET_BLACKLISTED_LINKS, GET_BMP_ADDRESS, GET_BMP_BOARD_NUMBERS, GET_BOARD_ADDRESS, GET_BOARD_BY_COORDS, GET_BOARD_CONNECT_INFO, GET_BOARD_JOB, GET_BOARD_NUMBERS, GET_BOARD_POWER_INFO, GET_BOARD_REPORTS, GET_CHANGES, GET_COMPLETED_BLACKLIST_OP, GET_CONSOLIDATION_TARGETS, GET_CURRENT_USAGE, GET_DEAD_BOARDS, GET_FUNCTIONING_FIELD, GET_GROUP_BY_ID, GET_GROUP_BY_NAME, GET_GROUP_BY_NAME_AND_MEMBER, GET_GROUP_NAMES_OF_USER, GET_GROUP_QUOTA, GET_JOB, GET_JOB_BOARD_COORDS, GET_JOB_BOARDS, GET_JOB_CHIP_DIMENSIONS, GET_JOB_IDS, GET_JOB_NMPI_JOB, GET_JOB_SESSION, GET_JOB_USAGE_AND_QUOTA, GET_LIVE_BOARDS, GET_LIVE_JOB_IDS, GET_LOCAL_USER_DETAILS, GET_MACHINE_BY_ID, GET_MACHINE_JOBS, GET_MACHINE_REPORTS, GET_MACHINE_WRAPS, GET_MEMBERSHIP, GET_MEMBERSHIPS_OF_USER, GET_NAMED_MACHINE, GET_ROOT_BMP_ADDRESS, GET_ROOT_COORDS, GET_ROOT_OF_BOARD, GET_SERIAL_INFO_REQS, GET_SUM_BOARDS_POWERED, GET_TAGS, GET_TEMP_INFO_REQS, GET_USER_AUTHORITIES, GET_USER_DETAILS, GET_USER_DETAILS_BY_NAME, GET_USER_DETAILS_BY_SUBJECT, GET_USER_ID, GET_USER_QUOTA, GET_USERS_OF_GROUP, getAllocationTasks, getConnectedBoards, getDeadLinks, getJobsWithChanges, getPerimeterLinks, getReportedBoards, GROUP_SYNC_ADD_GROUPS, GROUP_SYNC_DROP_TEMP_TABLE, GROUP_SYNC_INSERT_TEMP_ROW, GROUP_SYNC_MAKE_TEMP_TABLE, GROUP_SYNC_REMOVE_GROUPS, INSERT_BMP, INSERT_BOARD, INSERT_BOARD_REPORT, INSERT_JOB, INSERT_LINK, INSERT_MACHINE_SPINN_5, INSERT_REQ_BOARD, INSERT_REQ_N_BOARDS, INSERT_REQ_SIZE, INSERT_REQ_SIZE_BOARD, INSERT_TAG, IS_BOARD_BLACKLIST_CURRENT, IS_USER_LOCKED, issueChangeForJob, KILL_JOB_ALLOC_TASK, LIST_ALL_GROUPS, LIST_ALL_GROUPS_OF_TYPE, LIST_ALL_USERS, LIST_ALL_USERS_OF_TYPE, LIST_LIVE_JOBS, LIST_MACHINE_NAMES, LOAD_DIR_INFO, MARK_BOARD_BLACKLIST_CHANGED, MARK_BOARD_BLACKLIST_SYNCHED, MARK_CONSOLIDATED, MARK_LOGIN_FAILURE, MARK_LOGIN_SUCCESS, NOTE_DESTROY_REASON, READ_HISTORICAL_ALLOCS, READ_HISTORICAL_JOBS, REMOVE_USER_FROM_GROUP, SET_BOARD_POWER_OFF, SET_BOARD_POWER_ON, SET_BOARD_SERIAL_IDS, SET_COLLAB_QUOTA, SET_FUNCTIONING_FIELD, SET_JOB_NMPI_JOB, SET_JOB_SESSION, SET_MACHINE_STATE, SET_MAX_COORDS, SET_STATE_DESTROYED, SET_STATE_PENDING, SET_USER_DISABLED, SET_USER_LOCKED, SET_USER_NAME, SET_USER_PASS, SET_USER_TRUST, UNLOCK_LOCKED_USERS, UPDATE_GROUP, UPDATE_KEEPALIVE, WRITE_HISTORICAL_ALLOCS, WRITE_HISTORICAL_JOBS
-
Constructor Summary
Constructors Constructor Description Spalloc()
-
Method Summary
Modifier and Type Method Description SpallocAPI.Job
createJob(String owner, SpallocAPI.CreateDescriptor descriptor, String machineName, List<String> tags, Duration keepaliveInterval, byte[] originalRequest)
Create a job for a user that is only in one group.SpallocAPI.Job
createJobForNMPIJob(String owner, int nmpiJobId, SpallocAPI.CreateDescriptor descriptor, String machineName, List<String> tags, Duration keepaliveInterval, byte[] originalRequest)
Create a job for interactive use in an NMPI Collab Session.SpallocAPI.Job
createJobInCollabSession(String owner, String nmpiCollab, SpallocAPI.CreateDescriptor descriptor, String machineName, List<String> tags, Duration keepaliveInterval, byte[] originalRequest)
Create a job for interactive use in an NMPI Collab Session.SpallocAPI.Job
createJobInGroup(String owner, String groupName, SpallocAPI.CreateDescriptor descriptor, String machineName, List<String> tags, Duration keepaliveInterval, byte[] req)
Create a job for a user in a specific local group.Optional<SpallocAPI.Job>
getJob(Permit permit, int id)
Get a specific job.Optional<JobDescription>
getJobInfo(Permit permit, int id)
Get a specific job.SpallocAPI.Jobs
getJobs(boolean deleted, int limit, int start)
List the jobs.Optional<SpallocAPI.Machine>
getMachine(String name, boolean allowOutOfService)
Get a specific machine.Optional<MachineDescription>
getMachineInfo(String machine, boolean allowOutOfService, Permit permit)
Get info about a specific machine.Map<String,SpallocAPI.Machine>
getMachines(boolean allowOutOfService)
List the machines.List<JobListEntryRecord>
listJobs(Permit permit)
List the active jobs.List<MachineListEntryRecord>
listMachines(boolean allowOutOfService)
List the machines.void
purgeDownCache()
Purge the cache of what boards are down.void
reportProblem(String address, HasChipLocation coreLocation, String description, Permit permit)
Tells the service that there may be a problem with a board at a particular address.Methods inherited from class uk.ac.manchester.spinnaker.alloc.db.DatabaseAwareBean
execute, executeRead, getConnection, getHistoricalConnection, isHistoricalDBAvailable
-
Constructor Details
-
Spalloc
public Spalloc()
-
-
Method Details
-
getMachines
Description copied from interface:SpallocAPI
List the machines.- Specified by:
getMachines
in interfaceSpallocAPI
- Parameters:
allowOutOfService
- Whether to include machines marked as out of service.- Returns:
- A mapping from names to machines (which are live objects).
-
listMachines
Description copied from interface:SpallocAPI
List the machines.- Specified by:
listMachines
in interfaceSpallocAPI
- Parameters:
allowOutOfService
- Whether to include machines marked as out of service.- Returns:
- A description of all the machines.
-
getMachine
Description copied from interface:SpallocAPI
Get a specific machine.- Specified by:
getMachine
in interfaceSpallocAPI
- 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 interfaceSpallocAPI
- 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
Description copied from interface:SpallocAPI
List the jobs.- Specified by:
getJobs
in interfaceSpallocAPI
- 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
Description copied from interface:SpallocAPI
List the active jobs.- Specified by:
listJobs
in interfaceSpallocAPI
- 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 interfaceSpallocAPI
- 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 interfaceSpallocAPI
- 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 IllegalArgumentExceptionDescription 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 interfaceSpallocAPI
- 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, ornull
if they want to select by tags.tags
- The tags of the machine the user wants to allocate on, ornull
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 interfaceSpallocAPI
- 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, ornull
if they want to select by tags.tags
- The tags of the machine the user wants to allocate on, ornull
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 interfaceSpallocAPI
- 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, ornull
if they want to select by tags.tags
- The tags of the machine the user wants to allocate on, ornull
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 interfaceSpallocAPI
- 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, ornull
if they want to select by tags.tags
- The tags of the machine the user wants to allocate on, ornull
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 interfaceSpallocAPI
-
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 interfaceSpallocAPI
- 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 aHasCoreLocation
. If the problem is at the board level, this isnull
.description
- Optional problem description. May benull
.permit
- Who is making the request.
-