Class JobManager
java.lang.Object
uk.ac.manchester.spinnaker.nmpi.jobmanager.JobManager
- All Implemented Interfaces:
JobManagerInterface,NMPIQueueListener
@Service("service")
public class JobManager
extends Object
implements NMPIQueueListener, JobManagerInterface
The manager of jobs; synchronises and manages all the ongoing and future
processes and machines.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSeconds between status updates.Fields inherited from interface uk.ac.manchester.spinnaker.nmpi.model.job.JobManagerInterface
APPLICATION_JSON, APPLICATION_OCTET_STREAM, APPLICATION_ZIP, JOB_PROCESS_MANAGER, PATH, SETUP_SCRIPT, TEXT_PLAIN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a job to the listener.voidaddOutput(String projectId, int id, String output, InputStream input) Add to the output files of a job.voidaddProvenance(int id, List<String> path, String value) Add to the provenance of a job.voidAdd to the log of a job.checkMachineLease(int id, int waitTime) Check if the job is still allocated to a machine.voidextendJobMachineLease(int id, double runTime) Extend the lease of the job.getChipCoordinates(int id, String machineName, int chipX, int chipY) Get a description of where a chip actually is.getJobMachine(int id, int nCores, int nChips, int nBoards, double runTime) Get a machine for running a job.jakarta.ws.rs.core.ResponseGet the implementation code of the Job Process Manager.getLargestJobMachine(int id, double runTime) Get the largest machine that could run a job.getNextJob(String executerId) Get the job manager to find out what its next job will be.jakarta.ws.rs.core.ResponseGet the setup script to be executed.voidreleaseMachine(int id, String machineName) Drop the allocation of a machine to a job.voidsetExecutorExited(String executorId, String logToAppend) Mark the executor as having exited.voidsetJobError(String projectId, int id, String error, String logToAppend, String baseDirectory, List<String> outputs, RemoteStackTrace stackTrace) Mark the job as finished with an error.voidsetJobFinished(String projectId, int id, String logToAppend, String baseDirectory, List<String> outputs) Mark the job as successfully finished.voidsetMachinePower(int id, String machineName, boolean powerOn) Set the power status of a job's machine.
-
Field Details
-
STATUS_UPDATE_PERIOD
public static final int STATUS_UPDATE_PERIODSeconds between status updates.- See Also:
-
-
Constructor Details
-
JobManager
Create a job manager.- Parameters:
baseUrl- The URL of the REST service of the manager.
-
-
Method Details
-
addJob
Description copied from interface:NMPIQueueListenerAdds a job to the listener.- Specified by:
addJobin interfaceNMPIQueueListener- Parameters:
job- The job to add.- Throws:
IOException- If anything goes wrong.
-
getNextJob
Description copied from interface:JobManagerInterfaceGet the job manager to find out what its next job will be.- Specified by:
getNextJobin interfaceJobManagerInterface- Parameters:
executerId- The executor to talk about.- Returns:
- The job discovered.
-
getLargestJobMachine
Description copied from interface:JobManagerInterfaceGet the largest machine that could run a job.- Specified by:
getLargestJobMachinein interfaceJobManagerInterface- Parameters:
id- The job ID.runTime- How much resource to allocate. Can be omitted, in which case it is set to -1.- Returns:
- The machine descriptor.
-
getJobMachine
Description copied from interface:JobManagerInterfaceGet a machine for running a job. Typically, only one ofnCores,nChipsandnBoardswill be specified.- Specified by:
getJobMachinein interfaceJobManagerInterface- Parameters:
id- The job ID.nCores- The number of cores wanted. Can be omitted, in which case it is set to -1.nChips- The number of chips wanted. Can be omitted, in which case it is set to -1.nBoards- The number of boards wanted. Can be omitted, in which case it is set to -1.runTime- How much resource to allocate. Can be omitted, in which case it is set to -1.- Returns:
- The machine descriptor.
-
releaseMachine
Description copied from interface:JobManagerInterfaceDrop the allocation of a machine to a job.- Specified by:
releaseMachinein interfaceJobManagerInterface- Parameters:
id- The job IDmachineName- The name of the machine to stop using.
-
setMachinePower
Description copied from interface:JobManagerInterfaceSet the power status of a job's machine.- Specified by:
setMachinePowerin interfaceJobManagerInterface- Parameters:
id- The job IDmachineName- The name of the machine to control the power of.powerOn- True of the machine is to be switched on; false to switch it off.
-
getChipCoordinates
Description copied from interface:JobManagerInterfaceGet a description of where a chip actually is.- Specified by:
getChipCoordinatesin interfaceJobManagerInterface- Parameters:
id- The job IDmachineName- The name of the machine to control the power of.chipX- The virtual X coordinate of the chip.chipY- The virtual Y coordinate of the chip.- Returns:
- The coordinates of the chip
-
extendJobMachineLease
public void extendJobMachineLease(int id, double runTime) Description copied from interface:JobManagerInterfaceExtend the lease of the job.- Specified by:
extendJobMachineLeasein interfaceJobManagerInterface- Parameters:
id- The job IDrunTime- How long has the job actually run. Can be omitted, in which case it is set to -1.
-
checkMachineLease
Description copied from interface:JobManagerInterfaceCheck if the job is still allocated to a machine.- Specified by:
checkMachineLeasein interfaceJobManagerInterface- Parameters:
id- The job IDwaitTime- How long should the lease time be. Can be omitted, in which case it is set to 1000.- Returns:
- Whether the job is allocated.
-
appendLog
Description copied from interface:JobManagerInterfaceAdd to the log of a job.- Specified by:
appendLogin interfaceJobManagerInterface- Parameters:
id- The job IDlogToAppend- The string to append to the log.
-
addOutput
Description copied from interface:JobManagerInterfaceAdd to the output files of a job.- Specified by:
addOutputin interfaceJobManagerInterface- Parameters:
projectId- The ID of the project owning the job.id- The job IDoutput- The name of the file to write to.input- The contents of the file, streamed.
-
addProvenance
Description copied from interface:JobManagerInterfaceAdd to the provenance of a job.- Specified by:
addProvenancein interfaceJobManagerInterface- Parameters:
id- The job IDpath- The path into the JSON provenance doc.value- The value to set at that point.
-
setJobFinished
public void setJobFinished(String projectId, int id, String logToAppend, String baseDirectory, List<String> outputs) Description copied from interface:JobManagerInterfaceMark the job as successfully finished.- Specified by:
setJobFinishedin interfaceJobManagerInterface- Parameters:
projectId- The ID of the project owning the job.id- The id of the job.logToAppend- The job log data.baseDirectory- The base of filenames.outputs- The list of output files.
-
setJobError
public void setJobError(String projectId, int id, String error, String logToAppend, String baseDirectory, List<String> outputs, RemoteStackTrace stackTrace) Description copied from interface:JobManagerInterfaceMark the job as finished with an error.- Specified by:
setJobErrorin interfaceJobManagerInterface- Parameters:
projectId- The project owning the job.id- The id of the job.error- The error message.logToAppend- The job log data.baseDirectory- The base of filenames.outputs- The list of output files.stackTrace- The stack trace of the exception that caused the error.
-
setExecutorExited
Mark the executor as having exited.- Parameters:
executorId- The ID of the executor in questionlogToAppend- The log messages
-
getJobProcessManager
public jakarta.ws.rs.core.Response getJobProcessManager()Description copied from interface:JobManagerInterfaceGet the implementation code of the Job Process Manager.- Specified by:
getJobProcessManagerin interfaceJobManagerInterface- Returns:
- a response containing the ZIP file.
-
getSetupScript
Description copied from interface:JobManagerInterfaceGet the setup script to be executed.- Specified by:
getSetupScriptin interfaceJobManagerInterface- Returns:
- a response containing the setup script
- Throws:
IOException- if something goes wrong
-