Class 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 Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • jobsSeenMap

        private final JobSeenMap jobsSeenMap
      • queueNames

        private final java.lang.String[] queueNames
    • Method Detail

      • getQueueNames

        public java.lang.String[] getQueueNames()
        Description copied from class: Scheduler
        Get the queue names supported by this Scheduler.
        Specified by:
        getQueueNames in class Scheduler
        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 class Scheduler
        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 class Scheduler
        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.
      • getQueueStatuses

        public QueueStatus[] getQueueStatuses​(java.lang.String... queueNames)
                                       throws XenonException
        Description copied from class: Scheduler
        Get the status of all queues. 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 class Scheduler
        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
      • 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. The waitUntilDone method can be used to wait until the job is terminated.

        Specified by:
        cancelJob in class Scheduler
        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 class Scheduler
        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 specified jobs.

        The array of JobStatus contains one entry for each of the jobs. The order of the elements in the returned JobStatus array corresponds to the order in which the jobs are passed as parameters. If a job is null, the corresponding entry in the JobStatus array will also be null. If the retrieval of the JobStatus fails for a job, the exception will be stored in the corresponding JobsStatus entry.

        Overrides:
        getJobStatuses in class Scheduler
        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