public interface JobClient
| Modifier and Type | Method and Description |
|---|---|
void |
abortJob(String jobid)
Aborts execution of a job.
|
String |
copyJob(String jobid,
JobCreationData data,
boolean shallow)
Creates a new job by copying an existing job.
|
String |
createJob(JobCreationData data)
Creates a new job.
|
String |
createJobAttachment(String jobid,
JobAttachmentCreationData att)
Creates a job attachment for a given job.
|
void |
deleteAllJobs()
Deletes all jobs.
|
boolean |
deleteJob(String jobid)
Deletes a job.
|
boolean |
deleteJobAttachment(String jobid,
String attid)
Deletes a job attachment.
|
void |
deleteJobAttachments(String jobid)
Deletes all job attachments of a given job.
|
InputStream |
downloadJobAttachment(String jobid,
String attid)
Downloads job attachment contents as a stream.
|
void |
downloadJobAttachment(String jobid,
String attid,
File file)
Downloads job attachment contents and stores them as a file.
|
<T> T |
downloadJobAttachment(String jobid,
String attid,
com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<T> type)
Downloads job attachment contents as a JSON object.
|
<T> T |
downloadJobAttachment(String jobid,
String attid,
com.fasterxml.jackson.databind.ObjectMapper mapper,
com.fasterxml.jackson.core.type.TypeReference<T> type)
Downloads job attachment contents as a JSON object.
|
void |
downloadJobAttachment(String jobid,
String attid,
OutputStream stream)
Downloads job attachment contents and copies them to an output stream.
|
InputStream |
downloadLog(String jobid)
Downloads the log as a stream.
|
void |
downloadLog(String jobid,
File file)
Downloads the log and stores it as a file.
|
void |
downloadLog(String jobid,
OutputStream stream)
Downloads the log and copies it to an output stream.
|
void |
executeJob(String jobid)
Submits a job for execution.
|
List<? extends Job> |
getAllJobs()
Returns all the jobs.
|
JobFailureInfo |
getFailureInfo(String jobid)
Returns job failure information for the given job.
|
Job |
getJob(String jobid)
Returns a given job.
|
JobAttachment |
getJobAttachment(String jobid,
String attid)
Returns the job attachment (if any) of a given job.
|
List<? extends JobAttachment> |
getJobAttachments(String jobid)
Returns the list of job attachments for a job.
|
List<? extends JobAttachment> |
getJobAttachments(String jobid,
JobAttachmentType type)
Returns the list of job attachments of a given type for a job.
|
JobExecutionStatus |
getJobExecutionStatus(String jobid)
Returns the job execution status.
|
List<? extends JobLogItem> |
getJobLogItems(String jobid)
Returns the list of the log items of a given job.
|
List<? extends JobLogItem> |
getJobLogItems(String jobid,
long start)
Returns the list of the log items of a given job starting at a given index
(included).
|
List<? extends JobLogItem> |
getJobLogItems(String jobid,
long start,
boolean continuous)
Returns the list of log items of a given job starting at a given index
(included).
|
void |
killJob(String jobid)
Kills the execution of a job.
|
JobAttachmentCreationData |
newInputJobAttachment(String name)
Creates new input attachment data to be added to a job.
|
JobCreationData |
newJobCreationData()
Creates a new object to create and initialize a new job.
|
JobRequestBuilder |
newRequest()
Creates a new job request builder using this client.
|
String |
recreateJob(String jobid,
JobCreationData data,
boolean execute)
Creates a new job by replacing an existing job.
|
void |
uploadJobAttachment(String jobid,
String attid,
AttachmentContentWriter writer)
Uploads job attachment contents with a custom writer.
|
void |
uploadJobAttachment(String jobid,
String attid,
File file)
Uploads job attachment contents as a file.
|
void |
uploadJobAttachment(String jobid,
String attid,
InputStream stream)
Uploads job attachment contents as a stream.
|
void |
uploadJobAttachment(String jobid,
String attid,
com.fasterxml.jackson.databind.ObjectMapper mapper,
Object obj)
Uploads job attachment contents as a JSON stream.
|
void deleteAllJobs()
throws OperationException
OperationException - if any other remote exception was raised.List<? extends Job> getAllJobs() throws OperationException
OperationException - if any other remote exception was raised.String createJob(JobCreationData data) throws OperationException, SubscriptionException, ValidationException
opl
or cplex). There are two ways to manage the application ID:
<ul>
<li>
The application ID can be specified explicitly at creation time. In this
case, the attachments can be declared and uploaded incrementally. When
the job is submitted, the list of attachments must be compatible with the
application ID, otherwise an exception will be returned.
</li>
<li>
The application ID can be left unspecified at creation time. In this case, the full
list of attachments must be declared, and the application ID will be deduced
from the attachment extensions.
</li>
<ul>
Note that when the attachments are declared and length is specified, the subscription limits are also pre-checked so that an exception will be raised before actually uploading the content.
data - The data used to initialize the job.SubscriptionException - if the subscription is invalid or a limit was reached.ValidationException - if the application or attachments are invalid.OperationException - if any other remote exception is raised such as a system
issue or authentication issue.String copyJob(String jobid, JobCreationData data, boolean shallow) throws OperationException, SubscriptionException, ValidationException, JobNotFoundException
jobid - The job ID of the job to copy.data - The data used to override the template value or null if not specified.shallow - Indicates if a shallow copy is requested. If true, the job contents point to the existing job.JobNotFoundException - if the job was not found.SubscriptionException - if the subscription is invalid or a limit was reached.ValidationException - if the application or attachments are invalid.OperationException - if any other remote exception is raised such as a system
issue or authentication issue.recreateJob(String, JobCreationData, boolean)String recreateJob(String jobid, JobCreationData data, boolean execute) throws OperationException, SubscriptionException, ValidationException, JobNotFoundException
This can be used to resubmit a failed job for example. The existing job cannot currently be running or waiting for execution. All creation data is copied over to the new job. Input attachments are declared in the new job and the contents are transferred to the new job. Output attachments are ignored. Optionally, job creation data can be passed to override the parameters and declare additional input attachments. The existing job is automatically deleted.
jobid - The job ID of the template job.data - The data used to override the existing values, or null if not specified.execute - Indicates if the job should be immediately submitted for execution.JobNotFoundException - if the job was not found.SubscriptionException - if the subscription is invalid or a limit was reached.ValidationException - if the application or attachments are invalid.OperationException - if any other remote exception is raised, such as a system
issue or authentication issue.Job getJob(String jobid) throws OperationException, JobNotFoundException
jobid - The job ID.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.boolean deleteJob(String jobid) throws OperationException
jobid - The job ID.true if it was deleted, false
otherwise.OperationException - if any other remote exception was raised.JobExecutionStatus getJobExecutionStatus(String jobid) throws OperationException, JobNotFoundException
FAILED, additional information will be available in the
failure property of the job.jobid - The job ID.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.getJob(String)void executeJob(String jobid) throws OperationException, JobNotFoundException, SubscriptionException, ValidationException
CREATED (for example, it is running or has already completed),
an exception will be returned.jobid - The job ID.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.SubscriptionException - if the subscription is invalid or a limit was reached.ValidationException - if the application or attachments are invalid.void abortJob(String jobid) throws OperationException, JobNotFoundException
jobid - The job ID.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.void killJob(String jobid) throws OperationException, JobNotFoundException
jobid - The job ID.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.List<? extends JobAttachment> getJobAttachments(String jobid) throws OperationException, JobNotFoundException
jobid - The job ID.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.List<? extends JobAttachment> getJobAttachments(String jobid, JobAttachmentType type) throws OperationException, JobNotFoundException
jobid - The job ID.type - The type of the job attachment (an input attachment or an output attachment).OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.void deleteJobAttachments(String jobid) throws OperationException, JobNotFoundException
jobid - The job ID.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.String createJobAttachment(String jobid, JobAttachmentCreationData att) throws OperationException, JobNotFoundException, SubscriptionException, ValidationException
jobid - The job ID.att - The attachment data used to initialize the attachment.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.SubscriptionException - if the subscription is invalid or a limit was reached.ValidationException - if the application or attachments are invalid.JobAttachment getJobAttachment(String jobid, String attid) throws OperationException, JobNotFoundException, AttachmentNotFoundException
jobid - The job ID.attid - The job attachment ID.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.AttachmentNotFoundException - if the attachment was not found.boolean deleteJobAttachment(String jobid, String attid) throws OperationException, JobNotFoundException
jobid - The job ID.attid - The attachment ID.true if the job attachment was deleted.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.void uploadJobAttachment(String jobid, String attid, File file) throws IOException, OperationException, JobNotFoundException, AttachmentNotFoundException, SubscriptionException
jobid - The job ID.attid - The attachment ID.file - The content as a file.IOException - if an exception occurred while accessing the file.JobNotFoundException - if the job was not found.AttachmentNotFoundException - if the attachment was not found.SubscriptionException - if the subscription is invalid or a limit was reached.OperationException - if any other remote exception was raised.void uploadJobAttachment(String jobid, String attid, InputStream stream) throws IOException, OperationException, JobNotFoundException, AttachmentNotFoundException, SubscriptionException
jobid - The job ID.attid - The attachment ID.stream - The content as a stream.IOException - if an exception occurred while accessing the stream.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.AttachmentNotFoundException - if the attachment was not found.SubscriptionException - if the subscription is invalid or a limit was reached.void uploadJobAttachment(String jobid, String attid, AttachmentContentWriter writer) throws IOException, OperationException, JobNotFoundException, AttachmentNotFoundException, SubscriptionException
jobid - The job ID.attid - The attachment ID.writer - The content writer.IOException - if an exception occurred while accessing the stream.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.AttachmentNotFoundException - if the attachment was not found.SubscriptionException - if the subscription is invalid or a limit was reached.void uploadJobAttachment(String jobid, String attid, com.fasterxml.jackson.databind.ObjectMapper mapper, Object obj) throws IOException, OperationException, JobNotFoundException, AttachmentNotFoundException, SubscriptionException
jobid - The job ID.attid - The attachment ID.mapper - The JSON mapper.obj - The object to be serialized as JSON.IOException - if an exception occurred while serializing the object.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.AttachmentNotFoundException - if the attachment was not found.SubscriptionException - if the subscription is invalid or a limit was reached.void downloadJobAttachment(String jobid, String attid, File file) throws IOException, OperationException, JobNotFoundException, AttachmentNotFoundException
jobid - The job ID.attid - The attachment ID.file - The content as a file.IOException - if an exception occurred while accessing the file.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.AttachmentNotFoundException - if the attachment was not found.void downloadJobAttachment(String jobid, String attid, OutputStream stream) throws IOException, OperationException, JobNotFoundException, AttachmentNotFoundException
jobid - The job ID.attid - The attachment ID.stream - The content as a stream.IOException - if an exception occurred while accessing the stream.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.AttachmentNotFoundException - if the attachment was not found.<T> T downloadJobAttachment(String jobid, String attid, com.fasterxml.jackson.databind.ObjectMapper mapper, com.fasterxml.jackson.core.type.TypeReference<T> type) throws IOException, OperationException, JobNotFoundException, AttachmentNotFoundException
T - The type of the return object.jobid - The job ID.attid - The attachment ID.mapper - The JSON mapper.type - The type to deserialize.IOException - if an exception occurred while accessing the stream.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.AttachmentNotFoundException - if the attachment was not found.<T> T downloadJobAttachment(String jobid, String attid, com.fasterxml.jackson.databind.ObjectMapper mapper, Class<T> type) throws IOException, OperationException, JobNotFoundException, AttachmentNotFoundException
T - The type of the return object.jobid - The job ID.attid - The attachment ID.mapper - The JSON mapper.type - The type to deserialize.IOException - if an exception occurred while accessing the stream.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.AttachmentNotFoundException - if the attachment was not found.InputStream downloadJobAttachment(String jobid, String attid) throws IOException, OperationException, JobNotFoundException, AttachmentNotFoundException
jobid - The job ID.attid - The attachment ID.IOException - if an exception occurred while accessing the stream.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.AttachmentNotFoundException - if the attachment was not found.void downloadLog(String jobid, File file) throws IOException, OperationException, JobNotFoundException
jobid - The job ID.file - The log file.IOException - if an exception occurred while accessing the file.JobNotFoundException - if the job was not found.OperationException - if any other remote exception was raised.void downloadLog(String jobid, OutputStream stream) throws IOException, OperationException, JobNotFoundException
jobid - The job ID.stream - The log stream.IOException - if an exception occurred while accessing the stream.JobNotFoundException - if the job was not found.OperationException - if any other remote exception was raised.InputStream downloadLog(String jobid) throws IOException, OperationException, JobNotFoundException
jobid - The job ID.IOException - if an exception occurred while accessing the stream.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.JobFailureInfo getFailureInfo(String jobid) throws OperationException, JobNotFoundException
jobid - The job ID.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.List<? extends JobLogItem> getJobLogItems(String jobid) throws OperationException, JobNotFoundException
Each job generates log items with an index sequence number starting at 0. This list can be very large and only a maximum number of log items, defined internally by the service, will be returned at once.
The returned list is always ordered by sequence index. To know if more log items are available, specify the next starting sequence index.
jobid - The job ID.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.getJobLogItems(String, long),
getJobLogItems(String, long, boolean)List<? extends JobLogItem> getJobLogItems(String jobid, long start) throws OperationException, JobNotFoundException
Each job generates log items with an index sequence number starting at 0. This list can be very large and only a maximum number of log items, defined internally by the service, will be returned at once.
The returned list is always ordered by sequence index. To know if more log items are available, specify the starting sequence index.
jobid - The job ID.start - The start index.OperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.getJobLogItems(String, long, boolean)List<? extends JobLogItem> getJobLogItems(String jobid, long start, boolean continuous) throws OperationException, JobNotFoundException
This list can be very large and only a maximum number of log items, defined internally by the service, will be returned at once. The returned list is always ordered by sequence index. To know if more log items are available, specify the starting sequence index as the last sequence index + 1.
The continuous mode is designed to iterate over the log items as they become available until the job ends to retrieve and display the live logs. If the continuous flag is set, the server will return the next elements with no gap. It will also set the missing flag of a log item if the log item is still not available after an internal timeout. It will also set the log item stop flag when the sequence is completed. Here is a code snippet showing how to use the continuous mode.
boolean stop = false;
long index = 0;
while (!stop) {
List<? extends JobLogItem> items = jobclient.getJobLogItems(jobid, index, true);
if ((items != null) && !items.isEmpty()) {
display(items);
JobLogItem last = items.get(items.size() - 1);
stop = last.stop();
index = last.getSeqid() + 1;
} else {
Thread.sleep(1000); // no new log so wait a little
}
}
jobid - The job ID.start - The start index.continuous - Indicates if server will try to return log elements in a continuous sequenceOperationException - if any other remote exception was raised.JobNotFoundException - if the job was not found.JobCreationData newJobCreationData()
JobAttachmentCreationData newInputJobAttachment(String name)
name - The attachment name.JobRequestBuilder newRequest()
Copyright © 2015–2017 IBM Corporation. Licensed under the Apache License, Version 2.0.