use of org.ow2.proactive.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.
the class SchedulerClient method submit.
@Override
public JobId submit(URL job, Map<String, String> variables, Map<String, String> requestHeaderParams) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
JobIdData jobIdData = null;
try {
URLConnection urlConnection = job.openConnection();
for (Map.Entry<String, String> requestHeaderEntry : requestHeaderParams.entrySet()) {
urlConnection.addRequestProperty(requestHeaderEntry.getKey(), requestHeaderEntry.getValue());
}
InputStream is = urlConnection.getInputStream();
jobIdData = restApiClient().submitXml(sid, is, variables);
} catch (Exception e) {
throwNCEOrPEOrSCEOrJCE(e);
}
return jobId(jobIdData);
}
use of org.ow2.proactive.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.
the class SchedulerClient method submitFromCatalog.
@Override
public JobId submitFromCatalog(String catalogRestURL, String bucketName, String workflowName, Map<String, String> variables) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
JobIdData jobIdData = null;
HttpGet httpGet = new HttpGet(catalogRestURL + "/buckets/" + bucketName + "/resources/" + workflowName + "/raw");
httpGet.addHeader("sessionid", sid);
try (CloseableHttpClient httpclient = HttpClients.createDefault();
CloseableHttpResponse response = httpclient.execute(httpGet)) {
jobIdData = restApiClient().submitXml(sid, response.getEntity().getContent(), variables);
} catch (Exception e) {
throwNCEOrPEOrSCEOrJCE(e);
}
return jobId(jobIdData);
}
use of org.ow2.proactive.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.
the class DataSpaceClient method list.
@Override
public ListFile list(IRemoteSource source) throws NotConnectedException, PermissionException {
StringBuffer uriTmpl = (new StringBuffer()).append(restDataspaceUrl).append(source.getDataspace().value());
ResteasyClient client = new ResteasyClientBuilder().httpEngine(httpEngine).build();
ResteasyWebTarget target = client.target(uriTmpl.toString()).path(source.getPath()).queryParam("comp", "list");
List<String> includes = source.getIncludes();
if (includes != null && !includes.isEmpty()) {
target = target.queryParam("includes", includes.toArray(new Object[includes.size()]));
}
List<String> excludes = source.getExcludes();
if (excludes != null && !excludes.isEmpty()) {
target = target.queryParam("excludes", excludes.toArray(new Object[excludes.size()]));
}
Response response = null;
try {
response = target.request().header("sessionid", sessionId).get();
if (response.getStatus() != HttpURLConnection.HTTP_OK) {
if (response.getStatus() == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new NotConnectedException("User not authenticated or session timeout.");
} else {
throw new RuntimeException(String.format("Cannot list the specified location: %s", source.getPath()));
}
}
return response.readEntity(ListFile.class);
} finally {
if (response != null) {
response.close();
}
}
}
use of org.ow2.proactive.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.
the class DataSpaceClient method upload.
@Override
public boolean upload(final ILocalSource source, final IRemoteDestination destination) throws NotConnectedException, PermissionException {
if (log.isDebugEnabled()) {
log.debug("Uploading from " + source + " to " + destination);
}
StringBuffer uriTmpl = (new StringBuffer()).append(restDataspaceUrl).append(destination.getDataspace().value());
ResteasyClient client = new ResteasyClientBuilder().httpEngine(httpEngine).build();
ResteasyWebTarget target = client.target(uriTmpl.toString()).path(destination.getPath());
Response response = null;
try {
response = target.request().header("sessionid", sessionId).put(Entity.entity(new StreamingOutput() {
@Override
public void write(OutputStream outputStream) throws IOException, WebApplicationException {
source.writeTo(outputStream);
}
}, new Variant(MediaType.APPLICATION_OCTET_STREAM_TYPE, (Locale) null, source.getEncoding())));
if (response.getStatus() != HttpURLConnection.HTTP_CREATED) {
if (response.getStatus() == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new NotConnectedException("User not authenticated or session timeout.");
} else {
throw new RuntimeException("File upload failed. Status code:" + response.getStatus());
}
}
if (log.isDebugEnabled()) {
log.debug("Upload from " + source + " to " + destination + " performed with success");
}
return true;
} catch (IOException ioe) {
throw Throwables.propagate(ioe);
} finally {
if (response != null) {
response.close();
}
}
}
use of org.ow2.proactive.resourcemanager.exception.NotConnectedException in project scheduling by ow2-proactive.
the class RMRest method rmDisconnect.
/**
* Disconnects from resource manager and releases all the nodes taken by
* user for computations.
*
* @param sessionId
* a valid session id
* @throws NotConnectedException
*/
@Override
@POST
@Path("disconnect")
@Produces("application/json")
public void rmDisconnect(@HeaderParam("sessionid") String sessionId) throws NotConnectedException {
RMProxyUserInterface rm = checkAccess(sessionId);
rm.disconnect();
sessionStore.terminate(sessionId);
}
Aggregations