|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.harvard.cfa.vo.tapclient.tap.Job
edu.harvard.cfa.vo.tapclient.tap.AsyncJob
public class AsyncJob
An object used for executing an asynchronous data query.
AsyncJob asyncJob = new AsyncJob(service); System.out.println("Set the parameters"); asyncJob.setParameter("QUERY", "SELECT TOP 10 * FROM TAP_SCHEMA.columns"); asyncJob.setParameter("LANG", "ADQL"); asyncJob.setParameter("FORMAT", "votable"); asyncJob.setParameter("MAXREC", "1000"); System.out.println("Run the job"); asyncJob.run(); while (! asyncJob.isFinished()) { Thread.sleep(5000); System.out.println("Update the job status"); asyncJob.synchronize(); } if (asyncJob.isCompleted()) { System.out.println("Job has completed"); // ListresultList = asyncJob.getResults(); Result result = asyncJob.getResult(); InputStream resultStream = null; try { resultStream = result.openStream(); // ... } finally { try { resultStream.close(); } catch (Exception ignore) { } } } else if (asyncJob.isError()) { System.out.println("Job has an error"); Error error = asyncJob.getError(); System.out.println("The service has encountered a "+error.getType()+" error: "+error.getMessage()); if (error.isDetailedErrorAvailable()) { System.out.println("Additional details follow:"); InputStream errorStream = null; try { errorStream = error.openStream(); // ... } finally { try { errorStream.close(); } catch (Exception ignore) { } } } } else if (asyncJob.isAborted()) { System.out.println("The service has 'ABORTED' this job."); } else if (asyncJob.isHeld()) { System.out.println("The service has 'HELD' this job. Please run this job again at a later time."); }
Field Summary | |
---|---|
static java.lang.String |
ADQL_LANG
|
static java.lang.String |
VOTABLE_FORMAT
|
Fields inherited from class edu.harvard.cfa.vo.tapclient.tap.Job |
---|
inlineContent, parameters |
Constructor Summary | |
---|---|
AsyncJob(TapService service)
Creates an asynchronous job object associated with the TAP service at TapService. |
|
AsyncJob(TapService service,
java.lang.String jobId)
Creates an asynchronous job object associated with the TAP service and job at service and jobId. |
Method Summary | |
---|---|
void |
abort()
Sends a request to the TAP service to abort this job. |
protected void |
createJobOnServer()
|
void |
delete()
Sends a request to the TAP service to delete this job and all of its resources. |
java.util.Calendar |
getDestruction()
Returns the destruction of this job as returned by the TAP service |
java.util.Calendar |
getEndTime()
Returns the end time of this job as returned by the TAP service |
Error |
getError()
Returns the error summary of this job as returned by the TAP service |
java.lang.Integer |
getExecutionDuration()
Returns the execution duration of this job as returned by the TAP service |
java.lang.String |
getJobId()
Returns the job id of this job as returned by the TAP service |
java.lang.Object |
getJobInfo()
Returns the job info of this job as returned by the TAP service |
java.lang.String |
getOwnerId()
Returns the owner id of this job as returned by the TAP service |
java.util.Map<java.lang.String,java.lang.String> |
getParameters()
Returns the parameters of this job as returned by the TAP service |
java.lang.String |
getPhase()
Returns the execution phase of this job as returned by the TAP service |
java.util.Calendar |
getQuote()
Returns the quote of this job as returned by the TAP service |
Result |
getResult()
Returns the main result of this job |
java.util.Set<Result> |
getResults()
Returns the results of this job as returned by the TAP service |
java.lang.String |
getRunId()
Returns the run id of this job as returned by the TAP service |
java.util.Calendar |
getStartTime()
Returns the start time of this job as returned by the TAP service |
void |
handleJobSummaryResponse(java.io.InputStream inputStream)
|
boolean |
isAborted()
Returns true is the execution phase of the job is ABORTED |
boolean |
isCompleted()
Returns true is the execution phase of the job is COMPLETED |
boolean |
isError()
Returns true is the execution phase of the job is ERROR |
boolean |
isFinished()
Returns true if the job has an execution phase that is completed, error, aborted, or held. |
boolean |
isHeld()
Returns true is the execution phase of the job is HELD. |
void |
list(java.io.PrintStream output)
|
protected net.ivoa.xml.uws.v10.JobDocument |
parseJobDocument(java.io.InputStream inputStream)
|
protected void |
readJobFromServer()
|
void |
run()
Sends a request to the TAP service to run this job. |
void |
setDestruction(java.util.Calendar newValue)
Sets the destruction of this job. |
void |
setExecutionDuration(java.lang.Integer newValue)
Sets the execution duration of this job. |
void |
setParameter(java.lang.String id,
java.lang.String value)
Sets a parameter of this job. |
void |
setPhase(java.lang.String newValue)
Sets the execution phase of this job. |
void |
synchronize()
Propagates parameter updates to the server and refreshes the state of this object with the server response. |
protected void |
updateDestructionOnServer()
|
protected void |
updateExecutionDurationOnServer()
|
protected void |
updateExecutionPhaseOnServer(java.lang.String phaseValue)
|
protected void |
updateParametersOnServer()
|
Methods inherited from class edu.harvard.cfa.vo.tapclient.tap.Job |
---|
addInlineUpload, addUpload, setFormat, setInlineUpload, setLang, setMaxRec, setParameter, setQuery, setRunId, setUpload |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ADQL_LANG
public static final java.lang.String VOTABLE_FORMAT
Constructor Detail |
---|
public AsyncJob(TapService service)
public AsyncJob(TapService service, java.lang.String jobId)
Method Detail |
---|
public void run() throws HttpException, ResponseFormatException, java.io.IOException
HttpException
- if the service response to the run request is an unexpected HTTP status.
ResponseFormatException
- if an error occurs parsing the service response into a UWS job summary document.
java.io.IOException
- if an error occurs creating an input stream.public void abort() throws HttpException, ResponseFormatException, java.io.IOException
HttpException
- if the service response to the abort request is an unexpected HTTP status.
ResponseFormatException
- if an error occurs parsing the service response into a UWS job summary document.
java.io.IOException
- if an error occurs creating an input stream.public void delete() throws HttpException, ResponseFormatException, java.io.IOException
HttpException
- if the service response to the delete request is an unexpected HTTP status.
ResponseFormatException
- if an error occurs parsing the service response into a UWS job list document.
java.io.IOException
- if an error occurs creating an input stream.public java.lang.String getJobId()
public java.lang.String getRunId()
public java.lang.String getOwnerId()
public java.lang.String getPhase()
public boolean isFinished()
public boolean isCompleted()
public boolean isError()
public boolean isAborted()
public boolean isHeld()
public java.util.Calendar getQuote()
public java.util.Calendar getStartTime()
public java.util.Calendar getEndTime()
public java.lang.Integer getExecutionDuration()
public java.util.Calendar getDestruction()
public java.util.Map<java.lang.String,java.lang.String> getParameters()
public java.util.Set<Result> getResults()
public Result getResult()
public Error getError()
public java.lang.Object getJobInfo()
public void setPhase(java.lang.String newValue)
newValue
- the run idpublic void setExecutionDuration(java.lang.Integer newValue)
newValue
- the execution duration in secondspublic void setDestruction(java.util.Calendar newValue)
newValue
- the destruction timestamppublic void setParameter(java.lang.String id, java.lang.String value)
setParameter
in class Job
id
- the parameter identifiervalue
- the parameter valuepublic void handleJobSummaryResponse(java.io.InputStream inputStream) throws java.io.IOException, org.apache.xmlbeans.XmlException
java.io.IOException
org.apache.xmlbeans.XmlException
protected net.ivoa.xml.uws.v10.JobDocument parseJobDocument(java.io.InputStream inputStream) throws javax.xml.stream.XMLStreamException, org.apache.xmlbeans.XmlException, java.io.IOException
javax.xml.stream.XMLStreamException
org.apache.xmlbeans.XmlException
java.io.IOException
public void synchronize() throws HttpException, ResponseFormatException, java.io.IOException
java.io.IOException
- if an error occurs with communicating with the server.
HttpException
ResponseFormatException
protected void createJobOnServer() throws HttpException, ResponseFormatException, java.io.IOException, org.apache.xmlbeans.XmlException
HttpException
ResponseFormatException
java.io.IOException
org.apache.xmlbeans.XmlException
protected void updateParametersOnServer() throws HttpException, ResponseFormatException, java.io.IOException, org.apache.xmlbeans.XmlException
HttpException
ResponseFormatException
java.io.IOException
org.apache.xmlbeans.XmlException
protected void updateExecutionDurationOnServer() throws HttpException, ResponseFormatException, java.io.IOException, org.apache.xmlbeans.XmlException
HttpException
ResponseFormatException
java.io.IOException
org.apache.xmlbeans.XmlException
protected void updateDestructionOnServer() throws HttpException, ResponseFormatException, java.io.IOException, org.apache.xmlbeans.XmlException
HttpException
ResponseFormatException
java.io.IOException
org.apache.xmlbeans.XmlException
protected void updateExecutionPhaseOnServer(java.lang.String phaseValue) throws HttpException, ResponseFormatException, java.io.IOException, org.apache.xmlbeans.XmlException
HttpException
ResponseFormatException
java.io.IOException
org.apache.xmlbeans.XmlException
protected void readJobFromServer() throws HttpException, ResponseFormatException, java.io.IOException, org.apache.xmlbeans.XmlException
HttpException
ResponseFormatException
java.io.IOException
org.apache.xmlbeans.XmlException
public void list(java.io.PrintStream output)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |