use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException in project scheduling by ow2-proactive.
the class SchedulerClient method getTaskIds.
@Override
public Page<TaskId> getTaskIds(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit) throws NotConnectedException, PermissionException {
RestPage<TaskStateData> page = null;
try {
page = restApi().getTaskStates(sid, from, to, mytasks, running, pending, finished, offset, limit, null);
} catch (NotConnectedRestException e) {
throw new NotConnectedException(e);
} catch (PermissionRestException e) {
throw new PermissionException(e);
}
List<TaskId> lTaskIds = new ArrayList<TaskId>(page.getList().size());
for (TaskStateData taskStateData : page.getList()) {
TaskInfoData taskInfo = taskStateData.getTaskInfo();
TaskIdData taskIdData = taskInfo.getTaskId();
JobId jobId = new JobIdImpl(taskInfo.getJobId().getId(), taskInfo.getJobId().getReadableName());
TaskId taskId = TaskIdImpl.createTaskId(jobId, taskIdData.getReadableName(), taskIdData.getId());
lTaskIds.add(taskId);
}
return new Page<TaskId>(lTaskIds, page.getSize());
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException in project scheduling by ow2-proactive.
the class SchedulerClient method getJobInfo.
@Override
public JobInfo getJobInfo(String jobId) throws UnknownJobException, NotConnectedException, PermissionException {
JobInfoData jobInfoData = null;
try {
jobInfoData = restApi().jobInfo(sid, jobId);
} catch (NotConnectedRestException e) {
throw new NotConnectedException(e);
} catch (PermissionRestException e) {
throw new PermissionException(e);
} catch (UnknownJobRestException e) {
throw new UnknownJobException(e);
}
JobInfoImpl jobInfoImpl = new JobInfoImpl();
JobId newJobId = JobIdImpl.makeJobId(jobId);
jobInfoImpl.setJobId(newJobId);
jobInfoImpl.setJobOwner(jobInfoData.getJobOwner());
jobInfoImpl.setFinishedTime(jobInfoData.getFinishedTime());
jobInfoImpl.setRemovedTime(jobInfoData.getRemovedTime());
jobInfoImpl.setStartTime(jobInfoData.getStartTime());
jobInfoImpl.setInErrorTime(jobInfoData.getInErrorTime());
jobInfoImpl.setSubmittedTime(jobInfoData.getSubmittedTime());
jobInfoImpl.setNumberOfFinishedTasks(jobInfoData.getNumberOfFinishedTasks());
jobInfoImpl.setNumberOfPendingTasks(jobInfoData.getNumberOfPendingTasks());
jobInfoImpl.setNumberOfRunningTasks(jobInfoData.getNumberOfRunningTasks());
jobInfoImpl.setNumberOfInErrorTasks(jobInfoData.getNumberOfInErrorTasks());
jobInfoImpl.setNumberOfFaultyTasks(jobInfoData.getNumberOfFaultyTasks());
jobInfoImpl.setTotalNumberOfTasks(jobInfoData.getTotalNumberOfTasks());
jobInfoImpl.setJobPriority(JobPriority.findPriority(jobInfoData.getPriority().toString()));
jobInfoImpl.setJobStatus(JobStatus.findPriority(jobInfoData.getStatus().toString()));
if (jobInfoData.isToBeRemoved())
jobInfoImpl.setToBeRemoved();
jobInfoImpl.setGenericInformation(jobInfoData.getGenericInformation());
jobInfoImpl.setVariables(jobInfoData.getVariables());
return jobInfoImpl;
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException in project scheduling by ow2-proactive.
the class SchedulerClient method getTaskStates.
@Override
public Page<TaskState> getTaskStates(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit, SortSpecifierContainer sortParams) throws NotConnectedException, PermissionException {
RestPage<TaskStateData> page = null;
SortSpecifierContainer sortContainer = new SortSpecifierContainer(sortParams.toString());
try {
page = restApi().getTaskStates(sid, from, to, mytasks, running, pending, finished, offset, limit, sortContainer);
} catch (NotConnectedRestException e) {
throw new NotConnectedException(e);
} catch (PermissionRestException e) {
throw new PermissionException(e);
}
List<TaskState> lTaskStates = new ArrayList<TaskState>(page.getList().size());
for (TaskStateData taskStateData : page.getList()) {
lTaskStates.add(new TaskStateImpl(taskStateData));
}
return new Page<TaskState>(lTaskStates, page.getSize());
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException in project scheduling by ow2-proactive.
the class RestDataspaceImpl method delete.
/**
* Delete file(s) from the specified location in the <i>dataspace</i>. The
* format of the DELETE URI is:
* <p>
* {@code http://<rest-server-path>/data/<dataspace>/<path-name>}
* <p>
* Example:
* {@code http://localhost:8080/rest/rest/data/user/my-files/my-text-file.txt}
* <ul>
* <li>dataspace: can have two possible values, 'user' or 'global',
* depending on the target <i>DATASPACE</i></li>
* <li>path-name: location of the file(s) to be deleted.</li>
* </ul>
* <b>Notes:</b>
* <ul>
* <li>Only empty directories can be deleted.</li>
* <li>File names or regular expressions can be used as 'includes' and
* 'excludes' query parameters, in order to select which files to be deleted
* inside the specified directory (path-name).</li>
* </ul>
*/
@DELETE
@Path("/{dataspace}/{path-name:.*}")
public Response delete(@HeaderParam("sessionid") String sessionId, @PathParam("dataspace") String dataspace, @PathParam("path-name") String pathname, @QueryParam("includes") List<String> includes, @QueryParam("excludes") List<String> excludes) throws NotConnectedRestException, PermissionRestException {
Session session = checkSessionValidity(sessionId);
try {
checkPathParams(dataspace, pathname);
FileObject fo = resolveFile(session, dataspace, pathname);
if (!fo.exists()) {
return Response.status(Response.Status.NO_CONTENT).build();
}
if (fo.getType() == FileType.FOLDER) {
logger.debug(String.format("Deleting directory %s in %s", pathname, dataspace));
return deleteDir(fo, includes, excludes);
} else {
logger.debug(String.format("Deleting file %s in %s", pathname, dataspace));
fo.close();
return fo.delete() ? noContentRes() : serverErrorRes("Cannot delete the file: %s", pathname);
}
} catch (Throwable error) {
logger.error(String.format("Cannot delete %s in %s.", pathname, dataspace), error);
throw rethrow(error);
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException in project scheduling by ow2-proactive.
the class RestDataspaceImpl method retrieve.
/**
* Retrieves single or multiple files from specified location of the server.
* The format of the GET URI is:
* <P>
* {@code http://<rest-server-path>/data/<dataspace>/<path-name>}
* <p>
* Example:
* <p>
* {@code http://localhost:8080/rest/rest/data/user/my-files/my-text-file.txt}
* <ul>
* <li>dataspace: can have two possible values, 'user' or 'global',
* depending on the target <i>DATASPACE</i></li>
* <li>path-name: location from which the file will be retrieved.</li>
* </ul>
* <b>Notes:</b>
* <ul>
* <li>If 'list' is specified as the 'comp' query parameter, an
* {@link ListFile} type object will be return in JSON format. It will contain a list of files and folder contained in the selected
* path.
* </li>
* <li>If 'recursive' is specified as the 'comp' query parameter, an
* {@link ListFile} type object will be return in JSON format. It will contain a list of files and folder contained in the selected
* path and all subfolders.
* </li>
* <li>If the pathname represents a file its contents will be returned as:
* <ul>
* <li>an octet stream, if its a compressed file or the client doesn't
* accept encoded content</li>
* <li>a 'gzip' encoded stream, if the client accepts 'gzip' encoded content
* </li>
* <li>a 'zip' encoded stream, if the client accepts 'zip' encoded contents</li>
* </ul>
* </li>
* <li>If the pathname represents a directory, its contents will be returned
* as 'zip' encoded stream.</li>
* <li>file names or regular expressions can be used as 'includes' and
* 'excludes' query parameters, in order to select which files to be
* returned can be used to select the files returned.</li>
* </ul>
*/
@GET
@Path("/{dataspace}/{path-name:.*}")
public Response retrieve(@HeaderParam("sessionid") String sessionId, @HeaderParam("Accept-Encoding") String encoding, @PathParam("dataspace") String dataspace, @PathParam("path-name") String pathname, @QueryParam("comp") String component, @QueryParam("includes") List<String> includes, @QueryParam("excludes") List<String> excludes) throws NotConnectedRestException, PermissionRestException {
Session session = checkSessionValidity(sessionId);
try {
checkPathParams(dataspace, pathname);
FileObject fo = resolveFile(session, dataspace, pathname);
if (!fo.exists()) {
return notFoundRes();
}
if (!Strings.isNullOrEmpty(component)) {
return componentResponse(component, fo, includes, excludes);
}
if (fo.getType() == FileType.FILE) {
if (VFSZipper.isZipFile(fo)) {
logger.debug(String.format("Retrieving file %s in %s", pathname, dataspace));
return fileComponentResponse(fo);
} else if (Strings.isNullOrEmpty(encoding) || encoding.contains("*") || encoding.contains("gzip")) {
logger.debug(String.format("Retrieving file %s as gzip in %s", pathname, dataspace));
return gzipComponentResponse(pathname, fo);
} else if (encoding.contains("zip")) {
logger.debug(String.format("Retrieving file %s as zip in %s", pathname, dataspace));
return zipComponentResponse(fo, null, null);
} else {
logger.debug(String.format("Retrieving file %s in %s", pathname, dataspace));
return fileComponentResponse(fo);
}
} else {
// folder
if (Strings.isNullOrEmpty(encoding) || encoding.contains("*") || encoding.contains("zip")) {
logger.debug(String.format("Retrieving folder %s as zip in %s", pathname, dataspace));
return zipComponentResponse(fo, includes, excludes);
} else {
return badRequestRes("Folder retrieval only supported with zip encoding.");
}
}
} catch (Throwable error) {
logger.error(String.format("Cannot retrieve %s in %s.", pathname, dataspace), error);
throw rethrow(error);
}
}
Aggregations