@Override
public void submit(JobId id) throws IOException, InterruptedException {
if (id == null) {
throw new IllegalArgumentException("id must not be null"); //$NON-NLS-1$
}
HttpPut request = new HttpPut();
URI uri = createUri(String.format("jobs/%s/execute", id.getToken()));
request.setURI(uri);
if (LOG.isDebugEnabled()) {
LOG.debug("Submitting job: method=put, uri={}", uri);
}
HttpResponse response = http.execute(request);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
JobStatus status = extractJobStatus(request, response);
if (status.getKind() == JobStatus.Kind.ERROR) {
throw toException(request, response, status, MessageFormat.format(
"Failed to submit job: {0} ({1})",
id.getToken(),
request.getURI()));
}
} else {
throw toException(request, response, MessageFormat.format(
"Failed to submit job: {0} ({1})",
id.getToken(),
request.getURI()));
}
}