Class TorqueScheduler
- java.lang.Object
-
- nl.esciencecenter.xenon.schedulers.Scheduler
-
- nl.esciencecenter.xenon.adaptors.schedulers.ScriptingScheduler
-
- nl.esciencecenter.xenon.adaptors.schedulers.torque.TorqueScheduler
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class TorqueScheduler extends ScriptingScheduler
Interface to the TORQUE command line tools. Will run commands to submit/list/cancel jobs and get the status of queues.
-
-
Field Summary
Fields Modifier and Type Field Description private JobSeenMap
jobsSeenMap
private static org.slf4j.Logger
LOGGER
private TorqueXmlParser
parser
private java.lang.String[]
queueNames
-
Fields inherited from class nl.esciencecenter.xenon.adaptors.schedulers.ScriptingScheduler
pollDelay, subFileSystem, subScheduler
-
Fields inherited from class nl.esciencecenter.xenon.schedulers.Scheduler
properties
-
-
Constructor Summary
Constructors Constructor Description TorqueScheduler(java.lang.String uniqueID, java.lang.String location, Credential credential, XenonPropertyDescription[] valid, java.util.Map<java.lang.String,java.lang.String> prop)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JobStatus
cancelJob(java.lang.String jobIdentifier)
Cancel a job.java.lang.String
getDefaultQueueName()
Get the name of the default queue.java.lang.String[]
getJobs(java.lang.String... queueNames)
Get all job identifier of jobs currently in (one ore more) queues.JobStatus
getJobStatus(java.lang.String jobIdentifier)
Get the status of a Job.private JobStatus
getJobStatus(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> qstatInfo, java.lang.String job)
Get job status.JobStatus[]
getJobStatuses(java.lang.String... jobs)
Get the status of all specifiedjobs
.private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
getQstatInfo()
java.lang.String[]
getQueueNames()
Get the queue names supported by this Scheduler.QueueStatus
getQueueStatus(java.lang.String queueName)
Get the status of thequeue
.QueueStatus[]
getQueueStatuses(java.lang.String... queueNames)
Get the status of allqueues
.private void
jobsFromStatus(java.lang.String statusOutput, java.util.List<java.lang.String> result)
private java.lang.String[]
queryQueueNames()
protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
queryQueues(java.lang.String... queueNames)
java.lang.String
submitBatchJob(JobDescription description)
Submit a batch job.Streams
submitInteractiveJob(JobDescription description)
Submit an interactive job (optional operation).-
Methods inherited from class nl.esciencecenter.xenon.adaptors.schedulers.ScriptingScheduler
checkQueueNames, checkWorkingDirectory, close, getDefaultRuntime, getFileSystem, getQueueStatuses, getWorkingDirectory, isOpen, runCheckedCommand, runCommand, sleep, startInteractiveCommand, translateError, waitUntilDone, waitUntilRunning
-
Methods inherited from class nl.esciencecenter.xenon.schedulers.Scheduler
assertNonNullOrEmpty, assertPositive, create, create, create, create, equals, getAdaptorDescription, getAdaptorDescriptions, getAdaptorName, getAdaptorNames, getCredential, getLocation, getProperties, hashCode
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
parser
private final TorqueXmlParser parser
-
jobsSeenMap
private final JobSeenMap jobsSeenMap
-
queueNames
private final java.lang.String[] queueNames
-
-
Constructor Detail
-
TorqueScheduler
TorqueScheduler(java.lang.String uniqueID, java.lang.String location, Credential credential, XenonPropertyDescription[] valid, java.util.Map<java.lang.String,java.lang.String> prop) throws XenonException
- Throws:
XenonException
-
-
Method Detail
-
queryQueueNames
private java.lang.String[] queryQueueNames() throws XenonException
- Throws:
XenonException
-
getQueueNames
public java.lang.String[] getQueueNames()
Description copied from class:Scheduler
Get the queue names supported by this Scheduler.- Specified by:
getQueueNames
in classScheduler
- Returns:
- the queue names supported by this Scheduler.
-
getDefaultQueueName
public java.lang.String getDefaultQueueName()
Description copied from class:Scheduler
Get the name of the default queue.- Specified by:
getDefaultQueueName
in classScheduler
- Returns:
- the name of the default queue for this scheduler, or
null
if no default queue is available.
-
jobsFromStatus
private void jobsFromStatus(java.lang.String statusOutput, java.util.List<java.lang.String> result) throws XenonException
- Throws:
XenonException
-
getJobs
public java.lang.String[] getJobs(java.lang.String... queueNames) throws XenonException
Description copied from class:Scheduler
Get all job identifier of jobs currently in (one ore more) queues. If no queue names are specified, the job identifiers for all queues are returned. Note that job identifiers of jobs submitted by other users or other schedulers may also be returned.- Specified by:
getJobs
in classScheduler
- Parameters:
queueNames
- the names of the queues.- Returns:
- an array containing the resulting job identifiers .
- Throws:
NotConnectedException
- If scheduler is closed.NoSuchQueueException
- If the queue does not exist in the scheduler.XenonException
- If the Scheduler failed to get jobs.
-
getQueueStatus
public QueueStatus getQueueStatus(java.lang.String queueName) throws XenonException
Description copied from class:Scheduler
Get the status of thequeue
.- Specified by:
getQueueStatus
in classScheduler
- Parameters:
queueName
- the name of the queue.- Returns:
- the resulting QueueStatus.
- Throws:
NoSuchQueueException
- If the queue does not exist in the scheduler.XenonException
- If the Scheduler failed to get its status.
-
getQueueStatuses
public QueueStatus[] getQueueStatuses(java.lang.String... queueNames) throws XenonException
Description copied from class:Scheduler
Get the status of allqueues
. Note that this method will only throw an exception when this exception will influence all status requests. For example, if the scheduler is no longer connected. Exceptions that only refer to a single queue are returned in the QueueStatus returned for that queue.- Specified by:
getQueueStatuses
in classScheduler
- Parameters:
queueNames
- the names of the queues.- Returns:
- an array containing the resulting QueueStatus.
- Throws:
XenonException
- If the Scheduler failed to get the statuses.
-
queryQueues
protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> queryQueues(java.lang.String... queueNames) throws XenonException
- Throws:
XenonException
-
submitBatchJob
public java.lang.String submitBatchJob(JobDescription description) throws XenonException
Description copied from class:Scheduler
Submit a batch job.- Specified by:
submitBatchJob
in classScheduler
- Parameters:
description
- the description of the batch job to submit.- Returns:
- the job identifier representing the running job.
- Throws:
IncompleteJobDescriptionException
- If the description did not contain the required information.InvalidJobDescriptionException
- If the description contains illegal or conflicting values.UnsupportedJobDescriptionException
- If the description is not legal for this scheduler.XenonException
- If the Scheduler failed to get submit the job.
-
submitInteractiveJob
public Streams submitInteractiveJob(JobDescription description) throws XenonException
Description copied from class:Scheduler
Submit an interactive job (optional operation).- Specified by:
submitInteractiveJob
in classScheduler
- Parameters:
description
- the description of the interactive job to submit.- Returns:
- a
Streams
object containing the job identifier and the standard streams of a job. - Throws:
IncompleteJobDescriptionException
- If the description did not contain the required information.InvalidJobDescriptionException
- If the description contains illegal or conflicting values.UnsupportedJobDescriptionException
- If the description is not legal for this scheduler.XenonException
- If the Scheduler failed to get submit the job.
-
cancelJob
public JobStatus cancelJob(java.lang.String jobIdentifier) throws XenonException
Description copied from class:Scheduler
Cancel a job.A status is returned that indicates the state of the job after the cancel. If the job was already done it cannot be cancelled.
A
JobStatus
is returned that can be used to determine the state of the job after cancelJob returns. Note that it may take some time before the job has actually terminated. ThewaitUntilDone
method can be used to wait until the job is terminated.- Specified by:
cancelJob
in classScheduler
- Parameters:
jobIdentifier
- the identifier of job to kill.- Returns:
- the status of the Job.
- Throws:
NoSuchJobException
- If the job is not known.XenonException
- If the status of the job could not be retrieved.
-
getQstatInfo
private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getQstatInfo() throws XenonException
- Throws:
XenonException
-
getJobStatus
private JobStatus getJobStatus(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> qstatInfo, java.lang.String job) throws XenonException
Get job status. First checks given qstat info map, but also runs additional qacct and qdel commands if needed.- Parameters:
qstatInfo
- the info to get the job status from.job
- the job to get the status for.- Returns:
- the JobStatus of the job.
- Throws:
XenonException
- in case the info is not valid.XenonException
- in case an additional command fails to run.
-
getJobStatus
public JobStatus getJobStatus(java.lang.String jobIdentifier) throws XenonException
Description copied from class:Scheduler
Get the status of a Job.- Specified by:
getJobStatus
in classScheduler
- Parameters:
jobIdentifier
- the job identifier of the job to get the status for.- Returns:
- the status of the Job.
- Throws:
NoSuchJobException
- If the job is not known.XenonException
- If the status of the job could not be retrieved.
-
getJobStatuses
public JobStatus[] getJobStatuses(java.lang.String... jobs) throws XenonException
Description copied from class:Scheduler
Get the status of all specifiedjobs
.The array of
JobStatus
contains one entry for each of thejobs
. The order of the elements in the returnedJobStatus
array corresponds to the order in which thejobs
are passed as parameters. If ajob
isnull
, the corresponding entry in theJobStatus
array will also benull
. If the retrieval of theJobStatus
fails for a job, the exception will be stored in the correspondingJobsStatus
entry.- Overrides:
getJobStatuses
in classScheduler
- Parameters:
jobs
- the job identifiers for which to retrieve the status.- Returns:
- an array of the resulting JobStatuses.
- Throws:
XenonException
- If an I/O error occurred
-
-