|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.vo.UwsJob
public class UwsJob
Job submitted using the Universal Worker Service pattern. Instances of this class represent UWS jobs which have been created.
Nested Class Summary | |
---|---|
static class |
UwsJob.UnexpectedResponseException
Exception which may be thrown if a UWS HTTP request receives a response code which is not as mandated by UWS, but not obviously an error. |
Field Summary | |
---|---|
static int |
HTTP_CHUNK_SIZE
Chunk size for HTTP transfer encoding; if <=0, don't chunk. |
static boolean |
TRIM_TEXT
Whether to trim whitespace from line text responses (like job/phase). |
Constructor Summary | |
---|---|
UwsJob(URL jobUrl)
Constructor. |
Method Summary | |
---|---|
void |
addPhaseWatcher(Runnable watcher)
Adds a callback which will be invoked whenever this job's phase is read by readPhase() . |
void |
attemptDelete()
Attempts to delete this query's UWS job. |
static UwsJob |
createJob(String jobListUrl,
Map<String,String> stringParamMap,
Map<String,HttpStreamParam> streamParamMap)
Submits a job to a UWS service and returns a new UwsJob object. |
boolean |
getDeleteOnExit()
Indicates whether this job will be deleted when the JVM exits, if it has not been deleted before. |
String |
getJobId()
Returns the server-assigned job-id for this job. |
URL |
getJobUrl()
Returns the URL for this job. |
String |
getLastPhase()
Returns the most recently read job phase. |
long |
getLastPhaseTime()
Returns the epoch at which the job phase was last read. |
void |
postDelete()
Posts deletion of this job to the server. |
static HttpURLConnection |
postForm(URL url,
Map<String,String> stringParams,
Map<String,HttpStreamParam> streamParams)
General form posting method. |
static HttpURLConnection |
postMultipartForm(URL url,
Map<String,String> stringMap,
Map<String,HttpStreamParam> streamMap,
String boundary)
Performs an HTTP form POST with a name->value map and a name->stream map of parameters. |
void |
postPhase(String phase)
Posts a phase for this job. |
static HttpURLConnection |
postUnipartForm(URL url,
Map<String,String> paramMap)
Performs an HTTP form POST with a name->value map of parameters. |
UwsJobInfo |
readJob()
Reads XML text from the job URL which describes the server's record of the current state of the job, and returns the result as a UwsJobInfo object. |
void |
readPhase()
Reads the current UWS phase for this job from the server and stores the result. |
void |
removePhaseWatcher(Runnable watcher)
Removes a callback previously added by addPhaseWatcher(java.lang.Runnable) . |
void |
setDeleteOnExit(boolean delete)
Determines whether this job will be deleted when the JVM exits, if it has not been deleted before. |
void |
start()
Starts the job by posting the RUN phase. |
static byte[] |
toPostedBytes(Map<String,String> paramMap)
Encodes a name->value mapping as an array of bytes suitable for "application/x-www-form-urlencoded" transmission. |
String |
toString()
|
String |
waitForFinish(long poll)
Blocks until the job has reached a completion phase. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static int HTTP_CHUNK_SIZE
public static boolean TRIM_TEXT
Constructor Detail |
---|
public UwsJob(URL jobUrl)
jobUrl
- the UWS {jobs}/(job-id) URL containing
the details of this jobMethod Detail |
---|
public URL getJobUrl()
public String getLastPhase()
public long getLastPhaseTime()
System.currentTimeMillis()
at that epoch.
getLastPhase()
public void postPhase(String phase) throws IOException
phase
- UWS job phase to assign
IOException
public void start() throws IOException
UwsJob.UnexpectedResponseException
- if HTTP responses other than
UWS mandated ones occur
IOException
public String waitForFinish(long poll) throws IOException, InterruptedException
poll
- polling time in milliseconds to assess job completion
UwsJob.UnexpectedResponseException
- if HTTP responses other than
UWS mandated ones occur
IOException
InterruptedException
public void readPhase() throws IOException
getLastPhase()
method, and the associated
getLastPhaseTime
value is also set.
IOException
public void addPhaseWatcher(Runnable watcher)
readPhase()
. Note that the runnable will not
in general be invoked from the AWT event dispatch thread.
watcher
- runnable to be notified on job phase changepublic void removePhaseWatcher(Runnable watcher)
addPhaseWatcher(java.lang.Runnable)
.
Has no effect if watcher
is not currently registered.
watcher
- runnable to be removedpublic UwsJobInfo readJob() throws IOException, SAXException
IOException
SAXException
public void postDelete() throws IOException
IOException
- if job deletion failed for some reasonpublic void attemptDelete()
public void setDeleteOnExit(boolean delete)
delete
- true to delete on exit, false otherwisepublic boolean getDeleteOnExit()
public String getJobId()
public String toString()
toString
in class Object
public static UwsJob createJob(String jobListUrl, Map<String,String> stringParamMap, Map<String,HttpStreamParam> streamParamMap) throws IOException
jobListUrl
- base (job list) URL for UWS servicestringParamMap
- map of text parametersstreamParamMap
- map of streamed parameters
UwsJob.UnexpectedResponseException
- if a non-303 response was received
IOException
- if some other IOException occurspublic static HttpURLConnection postForm(URL url, Map<String,String> stringParams, Map<String,HttpStreamParam> streamParams) throws IOException
url
- destination URLstringParams
- name->value map for POST parameters;
values will be URL encoded as requiredstreamParams
- name->parameter map for POST parameters
IOException
public static HttpURLConnection postUnipartForm(URL url, Map<String,String> paramMap) throws IOException
url
- destination URLparamMap
- name->value map of parameters; values will be
encoded as required
IOException
public static HttpURLConnection postMultipartForm(URL url, Map<String,String> stringMap, Map<String,HttpStreamParam> streamMap, String boundary) throws IOException
stringMap
- name->value map of parametersstreamMap
- name->stream map of parametersboundary
- multipart boundary; if null a default value is used
IOException
public static byte[] toPostedBytes(Map<String,String> paramMap)
paramMap
- name->value mapping
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |