public class AsyncThread extends JobThread
Modifier and Type | Field and Description |
---|---|
protected ADQLExecutor |
executor
The only object which knows how to execute an ADQL query.
|
errorWriter, fatalError, finished, job, lastError, taskDescription, tg
Constructor and Description |
---|
AsyncThread(TAPJob j,
ADQLExecutor executor,
ServiceErrorWriter errorWriter)
Build a TAP asynchronous job execution.
|
Modifier and Type | Method and Description |
---|---|
TAPJob |
getTAPJob()
Get the description of the job that this thread is executing.
|
boolean |
isReadyForExecution()
Check whether this thread is able to start right now.
|
protected void |
jobWork()
Does the job work (i.e.
|
createResult, createResult, getDefaultTaskDescription, getError, getFileManager, getJob, getResultOutput, getResultSize, isFinished, publishResult, run, setError, setError
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
protected final ADQLExecutor executor
public AsyncThread(TAPJob j, ADQLExecutor executor, ServiceErrorWriter errorWriter) throws java.lang.NullPointerException
j
- Description of the job to execute.executor
- The object to use for the ADQL execution itself.errorWriter
- The object to use to format and to write an execution error for the user.java.lang.NullPointerException
- If the job parameter or the ADQLExecutor
is missing.public final boolean isReadyForExecution()
Check whether this thread is able to start right now.
Basically, this function asks to the ADQLExecutor
to get a database connection. If no DB connection is available,
then this thread can not start and this function return FALSE. In all the other cases, TRUE is returned.
Warning: This function will indirectly open and keep a database connection, so that the job can be started just after its call. If it turns out that the execution won't start just after this call, the DB connection should be closed in some way in order to save database resources.
protected void jobWork() throws UWSException, java.lang.InterruptedException
JobThread
Does the job work (i.e. making a long computation or executing a query on a Database).
Important:
Thread.isInterrupted()
) and then to send an InterruptedException
.
Otherwise the UWSJob.stop()
method will have no effect, as for UWSJob.abort()
and JobThread.setError(ErrorSummary)
.
Notes:
UWSException
is thrown the JobThread
will automatically publish the exception in this job
thanks to the UWSJob.error(ErrorSummary)
method or the UWSJob.setErrorSummary(ErrorSummary)
method,
and so it will set its phase to ExecutionPhase.ERROR
.InterruptedException
is thrown the JobThread
will automatically set the phase to ExecutionPhase.ABORTED
jobWork
in class JobThread
UWSException
- If there is any kind of error which must be propagated.java.lang.InterruptedException
- If the thread has been interrupted or if any method throws this exception.public final TAPJob getTAPJob()