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
Fields Modifier and Type Field Description static int
STATUS_UPDATE_PERIOD
Seconds 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 Constructor Description JobManager(URL baseUrl)
Create a job manager. -
Method Summary
Modifier and Type Method Description void
addJob(Job job)
Adds a job to the listener.void
addOutput(String projectId, int id, String output, InputStream input)
Add to the output files of a job.void
addProvenance(int id, List<String> path, String value)
Add to the provenance of a job.void
appendLog(int id, String logToAppend)
Add to the log of a job.JobMachineAllocated
checkMachineLease(int id, int waitTime)
Check if the job is still allocated to a machine.void
extendJobMachineLease(int id, double runTime)
Extend the lease of the job.ChipCoordinates
getChipCoordinates(int id, String machineName, int chipX, int chipY)
Get a description of where a chip actually is.SpinnakerMachine
getJobMachine(int id, int nCores, int nChips, int nBoards, double runTime)
Get a machine for running a job.Response
getJobProcessManager()
Get the implementation code of the Job Process Manager.SpinnakerMachine
getLargestJobMachine(int id, double runTime)
Get the largest machine that could run a job.Job
getNextJob(String executerId)
Get the job manager to find out what its next job will be.Response
getSetupScript()
Get the setup script to be executed.void
releaseMachine(int id, String machineName)
Drop the allocation of a machine to a job.void
setExecutorExited(String executorId, String logToAppend)
Mark the executor as having exited.void
setJobError(String projectId, int id, String error, String logToAppend, String baseDirectory, List<String> outputs, RemoteStackTrace stackTrace)
Mark the job as finished with an error.void
setJobFinished(String projectId, int id, String logToAppend, String baseDirectory, List<String> outputs)
Mark the job as successfully finished.void
setMachinePower(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:
- Constant Field Values
-
-
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:NMPIQueueListener
Adds a job to the listener.- Specified by:
addJob
in interfaceNMPIQueueListener
- Parameters:
job
- The job to add.- Throws:
IOException
- If anything goes wrong.
-
getNextJob
Description copied from interface:JobManagerInterface
Get the job manager to find out what its next job will be.- Specified by:
getNextJob
in interfaceJobManagerInterface
- Parameters:
executerId
- The executor to talk about.- Returns:
- The job discovered.
-
getLargestJobMachine
Description copied from interface:JobManagerInterface
Get the largest machine that could run a job.- Specified by:
getLargestJobMachine
in 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:JobManagerInterface
Get a machine for running a job. Typically, only one ofnCores
,nChips
andnBoards
will be specified.- Specified by:
getJobMachine
in 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:JobManagerInterface
Drop the allocation of a machine to a job.- Specified by:
releaseMachine
in interfaceJobManagerInterface
- Parameters:
id
- The job IDmachineName
- The name of the machine to stop using.
-
setMachinePower
Description copied from interface:JobManagerInterface
Set the power status of a job's machine.- Specified by:
setMachinePower
in 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:JobManagerInterface
Get a description of where a chip actually is.- Specified by:
getChipCoordinates
in 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:JobManagerInterface
Extend the lease of the job.- Specified by:
extendJobMachineLease
in 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:JobManagerInterface
Check if the job is still allocated to a machine.- Specified by:
checkMachineLease
in 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:JobManagerInterface
Add to the log of a job.- Specified by:
appendLog
in interfaceJobManagerInterface
- Parameters:
id
- The job IDlogToAppend
- The string to append to the log.
-
addOutput
Description copied from interface:JobManagerInterface
Add to the output files of a job.- Specified by:
addOutput
in 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:JobManagerInterface
Add to the provenance of a job.- Specified by:
addProvenance
in 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:JobManagerInterface
Mark the job as successfully finished.- Specified by:
setJobFinished
in 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:JobManagerInterface
Mark the job as finished with an error.- Specified by:
setJobError
in 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
Description copied from interface:JobManagerInterface
Get the implementation code of the Job Process Manager.- Specified by:
getJobProcessManager
in interfaceJobManagerInterface
- Returns:
- a response containing the ZIP file.
-
getSetupScript
Description copied from interface:JobManagerInterface
Get the setup script to be executed.- Specified by:
getSetupScript
in interfaceJobManagerInterface
- Returns:
- a response containing the setup script
- Throws:
IOException
- if something goes wrong
-