Modifier and Type | Field and Description |
---|---|
private ScriptingAdaptor |
adaptor |
private java.lang.String |
adaptorName |
private SchedulerConnectionFactory |
connectionFactory |
private java.util.Map<java.lang.String,SchedulerConnection> |
connections |
private static org.slf4j.Logger |
LOGGER |
private XenonEngine |
xenonEngine |
Constructor and Description |
---|
ScriptingJobs(ScriptingAdaptor adaptor,
XenonEngine xenonEngine,
SchedulerConnectionFactory connectionFactory) |
Modifier and Type | Method and Description |
---|---|
private void |
addConnection(SchedulerConnection connection) |
JobStatus |
cancelJob(Job job)
Cancel a job.
|
void |
close(Scheduler scheduler)
Close a Scheduler.
|
void |
end() |
private SchedulerConnection |
getConnection(Scheduler scheduler) |
private SchedulerConnection[] |
getConnections(Job[] jobs) |
java.lang.String |
getDefaultQueueName(Scheduler scheduler)
Get the name of the default queue for the
scheduler . |
Job[] |
getJobs(Scheduler scheduler,
java.lang.String... queueNames)
Get all jobs currently in (one ore more) queues of
scheduler . |
JobStatus |
getJobStatus(Job job)
Get the status of a Job.
|
private void |
getJobStatus(SchedulerConnection connection,
Job[] in,
JobStatus[] out) |
JobStatus[] |
getJobStatuses(Job... jobs)
Get the status of all specified
jobs . |
QueueStatus |
getQueueStatus(Scheduler scheduler,
java.lang.String queueName)
Get the status of the
queue of scheduler . |
QueueStatus[] |
getQueueStatuses(Scheduler scheduler,
java.lang.String... queueNames)
Get the status of all
queues of scheduler . |
Streams |
getStreams(Job job)
Returns the standard streams of a job.
|
boolean |
isOpen(Scheduler scheduler)
Test if the connection to a Scheduler is open.
|
Scheduler |
newScheduler(java.lang.String scheme,
java.lang.String location,
Credential credential,
java.util.Map<java.lang.String,java.lang.String> properties)
Create a new Scheduler that represents a (possibly remote) job
scheduler at the
location , using the scheme
and credentials to get access. |
private void |
removeConnection(SchedulerConnection connection) |
private void |
selectJobs(SchedulerConnection connection,
Job[] in,
Job[] out) |
Job |
submitJob(Scheduler scheduler,
JobDescription description)
Submit a job to a Scheduler.
|
JobStatus |
waitUntilDone(Job job,
long timeout)
Wait until a job is done or until a timeout expires.
|
JobStatus |
waitUntilRunning(Job job,
long timeout)
Wait for as long a job is waiting in a queue, or until a timeout expires.
|
private static final org.slf4j.Logger LOGGER
private final ScriptingAdaptor adaptor
private final XenonEngine xenonEngine
private final java.lang.String adaptorName
private final SchedulerConnectionFactory connectionFactory
private final java.util.Map<java.lang.String,SchedulerConnection> connections
public ScriptingJobs(ScriptingAdaptor adaptor, XenonEngine xenonEngine, SchedulerConnectionFactory connectionFactory)
private SchedulerConnection getConnection(Scheduler scheduler) throws NoSuchSchedulerException
NoSuchSchedulerException
private void addConnection(SchedulerConnection connection)
private void removeConnection(SchedulerConnection connection)
public boolean isOpen(Scheduler scheduler) throws XenonException
Jobs
isOpen
in interface Jobs
scheduler
- the Scheduler to test.true
if the connection to the Scheduler is still open, false
otherwise.XenonException
- If the test failed.public Scheduler newScheduler(java.lang.String scheme, java.lang.String location, Credential credential, java.util.Map<java.lang.String,java.lang.String> properties) throws XenonException
Jobs
location
, using the scheme
and credentials
to get access. Make sure to always close
Scheduler
instances by calling close(Scheduler)
when
you no longer need them, otherwise their associated resources remain
allocated.newScheduler
in interface Jobs
scheme
- the scheme used to access the Scheduler.location
- the location of the Scheduler.credential
- the Credentials to use to get access to the Scheduler.properties
- optional properties to configure the Scheduler when it is created.UnknownPropertyException
- If a unknown property was provided.InvalidPropertyException
- If a known property was provided with an invalid value.InvalidLocationException
- If the location was invalid.InvalidCredentialException
- If the credential is invalid to access the location.XenonException
- If the creation of the Scheduler failed.public java.lang.String getDefaultQueueName(Scheduler scheduler) throws XenonException
Jobs
scheduler
.getDefaultQueueName
in interface Jobs
scheduler
- the Scheduler.null
if no default queue is available.NoSuchSchedulerException
- If the scheduler is not known.XenonException
- If the Scheduler failed to get its status.public void close(Scheduler scheduler) throws XenonException
Jobs
close
in interface Jobs
scheduler
- the Scheduler to close.NoSuchSchedulerException
- If the scheduler is not known.XenonException
- If the Scheduler failed to close.public QueueStatus getQueueStatus(Scheduler scheduler, java.lang.String queueName) throws XenonException
Jobs
queue
of scheduler
.getQueueStatus
in interface Jobs
scheduler
- the Scheduler.queueName
- the name of the queue.NoSuchSchedulerException
- If the scheduler is not known.NoSuchQueueException
- If the queue does not exist in the scheduler.XenonException
- If the Scheduler failed to get its status.public QueueStatus[] getQueueStatuses(Scheduler scheduler, java.lang.String... queueNames) throws XenonException
Jobs
queues
of scheduler
.
Note that this method will only throw an exception when this exception will influence all status requests. For example, if
the scheduler is invalid or not reachable.
Exceptions that only refer to a single queue are returned in the QueueStatus returned for that queue.getQueueStatuses
in interface Jobs
scheduler
- the Scheduler.queueNames
- the names of the queues.NoSuchSchedulerException
- If the scheduler is not known.XenonException
- If the Scheduler failed to get the statusses.public Job[] getJobs(Scheduler scheduler, java.lang.String... queueNames) throws XenonException
Jobs
scheduler
.
If no queue names are specified, the jobs for all queues are returned.
Note that jobs submitted by other users or other schedulers may also be returned.getJobs
in interface Jobs
scheduler
- the Scheduler.queueNames
- the names of the queues.NoSuchSchedulerException
- If the scheduler is not known.NoSuchQueueException
- If the queue does not exist in the scheduler.XenonException
- If the Scheduler failed to get jobs.public Job submitJob(Scheduler scheduler, JobDescription description) throws XenonException
Jobs
submitJob
in interface Jobs
scheduler
- the Scheduler.description
- the description of the job to submit.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.public JobStatus getJobStatus(Job job) throws XenonException
Jobs
getJobStatus
in interface Jobs
job
- the job.NoSuchJobException
- If the job is not known.XenonException
- If the status of the job could not be retrieved.private SchedulerConnection[] getConnections(Job[] jobs)
private void selectJobs(SchedulerConnection connection, Job[] in, Job[] out)
private void getJobStatus(SchedulerConnection connection, Job[] in, JobStatus[] out)
public JobStatus[] getJobStatuses(Job... jobs)
Jobs
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.
getJobStatuses
in interface Jobs
jobs
- the jobs for which to retrieve the status.public JobStatus cancelJob(Job job) throws XenonException
Jobs
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.
cancelJob
in interface Jobs
job
- the job to kill.NoSuchJobException
- If the job is not known.XenonException
- If the status of the job could not be retrieved.public void end()
public Streams getStreams(Job job) throws XenonException
Jobs
getStreams
in interface Jobs
job
- the interactive job for which to retrieve the streams.XenonException
- if the job is not interactive.public JobStatus waitUntilDone(Job job, long timeout) throws XenonException
Jobs
This method will wait until a job is done, killed, or produces an error, or until a timeout expires. If the timeout expires, the job will continue to run normally.
The timeout is in milliseconds and must be >= 0, where 0 means an infinite timeout.
A JobStatus is returned that can be used to determine why the call returned.
waitUntilDone
in interface Jobs
job
- the job.timeout
- the maximum time to wait for the job in milliseconds.NoSuchJobException
- If the job is not known.XenonException
- If the status of the job could not be retrieved.public JobStatus waitUntilRunning(Job job, long timeout) throws XenonException
Jobs
This method will return as soon as the job is no longer waiting in the queue. This is generally the case when it starts running, but it may also be killed or produce an error. If the timeout expires, the job will continue to be queued normally.
The timeout is in milliseconds and must be >= 0, where 0 means an infinite timeout.
A JobStatus is returned that can be used to determine why the call returned.
waitUntilRunning
in interface Jobs
job
- the job.timeout
- the maximum time to wait in milliseconds.NoSuchJobException
- If the job is not known.XenonException
- If the status of the job could not be retrieved.