public class TAPSyncJob
extends java.lang.Object
This class represent a TAP synchronous job. A such job must execute an ADQL query and return immediately its result.
The execution of a such job is limited to a short time. Once this time elapsed, the job is stopped. For a longer job, an asynchronous job should be used.
If an error occurs it must be propagated ; it will be written later in the HTTP response on a top level.
Modifier and Type | Class and Description |
---|---|
protected class |
TAPSyncJob.SyncThread
Thread which will process the job execution.
|
Modifier and Type | Field and Description |
---|---|
protected TAPExecutionReport |
execReport
Report of the query execution.
|
protected java.lang.String |
ID
ID of this job.
|
protected static java.lang.String |
lastId
Last generated ID of a synchronous job.
|
protected ServiceConnection |
service
Description of the TAP service in charge of this synchronous job.
|
protected TAPParameters |
tapParams
Parameters of the execution.
|
protected TAPSyncJob.SyncThread |
thread
The thread in which the query execution will be done.
|
protected long |
waitForStop
The time (in ms) to wait the end of the thread after an interruption.
|
Constructor and Description |
---|
TAPSyncJob(ServiceConnection service,
TAPParameters params)
Create a synchronous TAP job.
|
TAPSyncJob(ServiceConnection service,
TAPParameters params,
java.lang.String requestID)
Create a synchronous TAP job.
|
Modifier and Type | Method and Description |
---|---|
protected void |
deleteUploads(TAPParameters tapParams)
Delete all uploaded files.
|
protected java.lang.String |
generateId()
This function lets generating a unique ID.
|
TAPExecutionReport |
getExecReport()
Get the report of the execution of this job.
|
java.lang.String |
getID()
Get the ID of this synchronous job.
|
TAPParameters |
getTapParams()
Get the TAP parameters provided by the user and which will be used for the execution of this job.
|
boolean |
start(javax.servlet.http.HttpServletResponse response)
Start the execution of this job in order to execute the given ADQL query.
|
protected long waitForStop
protected static java.lang.String lastId
protected final ServiceConnection service
protected final java.lang.String ID
protected final TAPParameters tapParams
protected TAPSyncJob.SyncThread thread
protected TAPExecutionReport execReport
public TAPSyncJob(ServiceConnection service, TAPParameters params) throws java.lang.NullPointerException
service
- Description of the TAP service which is in charge of this synchronous job.params
- Parameters of the query to execute. It must mainly contain the ADQL query to execute.java.lang.NullPointerException
- If one of the parameters is NULL.public TAPSyncJob(ServiceConnection service, TAPParameters params, java.lang.String requestID) throws java.lang.NullPointerException
service
- Description of the TAP service which is in charge of this synchronous job.params
- Parameters of the query to execute. It must mainly contain the ADQL query to execute.requestID
- ID of the HTTP request which has initiated the creation of this job.
Note: if NULL, empty or already used, a job ID will be generated thanks to generateId()
.java.lang.NullPointerException
- If one of the 2 first parameters is NULL.protected java.lang.String generateId()
This function lets generating a unique ID.
By default: "S"+System.currentTimeMillis()+UpperCharacter (UpperCharacter: one upper-case character: A, B, C, ....)
note: DO NOT USE in this function any of the following functions: ServiceConnection.getLogger()
,
ServiceConnection.getFileManager()
and ServiceConnection.getFactory()
. All of them will return NULL, because this job does not
yet know its jobs list (which is needed to know the UWS and so, all of the objects returned by these functions).
public final java.lang.String getID()
public final TAPParameters getTapParams()
public final TAPExecutionReport getExecReport()
public boolean start(javax.servlet.http.HttpServletResponse response) throws java.lang.IllegalStateException, java.io.IOException, TAPException
Start the execution of this job in order to execute the given ADQL query.
The execution itself will be processed by an ADQLExecutor
inside a thread (TAPSyncJob.SyncThread
).
Important: No error should be written in this function. If any error occurs it should be thrown, in order to be manager on a top level.
response
- Response in which the result must be written.java.lang.IllegalStateException
- If this synchronous job has already been started before.java.io.IOException
- If any error occurs while writing the query result in the given HttpServletResponse
.TAPException
- If any error occurs while executing the ADQL query.TAPSyncJob.SyncThread
protected void deleteUploads(TAPParameters tapParams)
tapParams
- Input parameters (listing all uploaded files, if any).