Package ome.api
Interface JobHandle
-
- All Superinterfaces:
ServiceInterface
,StatefulServiceInterface
public interface JobHandle extends StatefulServiceInterface
Allows submission of asynchronous jobs.NOTE: The calling order for the service is as follows:
- submit(
Job
) or attach(long) - any of the other methods
- close()
close()
does not cancel or otherwise change the Job state. SeecancelJob()
.- Since:
- 3.0-Beta2
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CANCELLED
static java.lang.String
ERROR
static java.lang.String
FINISHED
static java.lang.String
QUEUED
static java.lang.String
REQUEUED
static java.lang.String
RESUBMITTED
static java.lang.String
RUNNING
static java.lang.String
SUBMITTED
static java.lang.String
WAITING
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ome.model.jobs.JobStatus
attach(long jobId)
void
cancelJob()
Marks a job for cancellation.ome.model.jobs.Job
getJob()
boolean
jobError()
Returns true if theJob
has thrown an error.java.sql.Timestamp
jobFinished()
java.lang.String
jobMessage()
boolean
jobRunning()
Returns true if theJob
is running, i.e.ome.model.jobs.JobStatus
jobStatus()
java.lang.String
setMessage(java.lang.String message)
Sets the job's message string, and returns the previous value.java.lang.String
setStatus(java.lang.String status)
Updates theJobStatus
for the current job.java.lang.String
setStatusAndMessage(java.lang.String status, java.lang.String message)
LikesetStatus(String)
but also sets the message.long
submit(ome.model.jobs.Job job)
Submits aJob
and returns its database id.-
Methods inherited from interface ome.api.StatefulServiceInterface
activate, close, getCurrentEventContext, passivate
-
-
-
-
Field Detail
-
SUBMITTED
static final java.lang.String SUBMITTED
- See Also:
- Constant Field Values
-
RESUBMITTED
static final java.lang.String RESUBMITTED
- See Also:
- Constant Field Values
-
QUEUED
static final java.lang.String QUEUED
- See Also:
- Constant Field Values
-
REQUEUED
static final java.lang.String REQUEUED
- See Also:
- Constant Field Values
-
RUNNING
static final java.lang.String RUNNING
- See Also:
- Constant Field Values
-
ERROR
static final java.lang.String ERROR
- See Also:
- Constant Field Values
-
WAITING
static final java.lang.String WAITING
- See Also:
- Constant Field Values
-
FINISHED
static final java.lang.String FINISHED
- See Also:
- Constant Field Values
-
CANCELLED
static final java.lang.String CANCELLED
- See Also:
- Constant Field Values
-
-
Method Detail
-
submit
long submit(ome.model.jobs.Job job)
Submits aJob
and returns its database id. The only fields directly on status which are editable are message, scheduledFor and status. The latter two must be sensible.- Parameters:
job
- Not null- Returns:
- id
-
attach
ome.model.jobs.JobStatus attach(long jobId) throws ome.conditions.ApiUsageException
- Returns:
- the current
JobStatus
for theid
- Throws:
ome.conditions.ApiUsageException
- if theid
does not exist.
-
getJob
ome.model.jobs.Job getJob()
- Returns:
- the current
Job
-
jobStatus
ome.model.jobs.JobStatus jobStatus()
- Returns:
- the current
JobStatus
. Will never return null.
-
jobFinished
java.sql.Timestamp jobFinished()
- Returns:
- null if the
Job
is not finished, otherwise theTimestamp
for when it completed.
-
jobMessage
java.lang.String jobMessage()
- Returns:
- current message for job. May be set during processing.
-
jobRunning
boolean jobRunning()
Returns true if theJob
is running, i.e. has an attachedProcess
.
-
jobError
boolean jobError()
Returns true if theJob
has thrown an error.
-
cancelJob
void cancelJob()
Marks a job for cancellation. Not every processor will check for the cancelled flag for a running job, but no non-running job will start if it has been cancelled.
-
setStatus
java.lang.String setStatus(java.lang.String status)
Updates theJobStatus
for the current job. The previous status is returned as a string. If the status isCANCELLED
, this method is equivalent tocancelJob()
.
-
setStatusAndMessage
java.lang.String setStatusAndMessage(java.lang.String status, java.lang.String message)
LikesetStatus(String)
but also sets the message.
-
setMessage
java.lang.String setMessage(java.lang.String message)
Sets the job's message string, and returns the previous value.- Parameters:
message
-- Returns:
- the previous message value
-
-