Search in sources :

Example 76 with PermissionException

use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.

the class RestSmartProxyImpl method uploadInputfiles.

/**
 * @throws NotConnectedException
 * @throws PermissionException
 * @see AbstractSmartProxy#uploadInputfiles(TaskFlowJob, String)
 */
@Override
public boolean uploadInputfiles(TaskFlowJob job, String localInputFolderPath) throws NotConnectedException, PermissionException {
    String userSpace = getLocalUserSpace();
    String inputSpace = job.getInputSpace();
    if (!inputSpace.startsWith(userSpace)) {
        // NOTE: only works for USERSPACE urls
        logger.warn("RestSmartProxy does not support data transfers outside USERSPACE.");
        return false;
    }
    String remotePath = inputSpace.substring(userSpace.length() + (userSpace.endsWith("/") ? 0 : 1));
    String jname = job.getName();
    logger.debug("Pushing files for job " + jname + " from " + localInputFolderPath + " to " + remotePath);
    TaskFlowJob tfj = job;
    for (Task t : tfj.getTasks()) {
        logger.debug("Pushing files for task " + t.getName());
        List<String> includes = Lists.newArrayList();
        List<String> excludes = Lists.newArrayList();
        List<InputSelector> inputFilesList = t.getInputFilesList();
        if (inputFilesList != null) {
            for (InputSelector is : inputFilesList) {
                addfileSelection(is.getInputFiles(), includes, excludes);
            }
        }
        LocalDirSource source = new LocalDirSource(localInputFolderPath);
        source.setIncludes(includes);
        source.setExcludes(excludes);
        RemoteDestination dest = new RemoteDestination(USER, remotePath);
        restDataSpaceClient.upload(source, dest);
    }
    logger.debug("Finished push operation from " + localInputFolderPath + " to " + remotePath);
    return true;
}
Also used : Task(org.ow2.proactive.scheduler.common.task.Task) AwaitedTask(org.ow2.proactive.scheduler.smartproxy.common.AwaitedTask) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) RemoteDestination(org.ow2.proactive.scheduler.rest.ds.RemoteDestination) InputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector) LocalDirSource(org.ow2.proactive.scheduler.rest.ds.LocalDirSource)

Example 77 with PermissionException

use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.

the class RestSmartProxyImpl method createFolder.

@Override
protected void createFolder(String fUri) throws NotConnectedException, PermissionException {
    RemoteSource remoteSource = new RemoteSource(USER, fUri);
    remoteSource.setType(FileType.FOLDER);
    restDataSpaceClient.create(remoteSource);
}
Also used : RemoteSource(org.ow2.proactive.scheduler.rest.ds.RemoteSource)

Example 78 with PermissionException

use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.

the class RestSmartProxyImpl method removeJobIO.

@Override
protected void removeJobIO(Job job, String pushURL, String pullURL, String newFolderName) {
    pushURL = pushURL + "/" + newFolderName;
    RemoteSource remoteSource = new RemoteSource(IDataSpaceClient.Dataspace.USER, pushURL);
    try {
        restDataSpaceClient.delete(remoteSource);
    } catch (NotConnectedException | PermissionException e) {
        logger.debug("Error in removeJobIO push for job " + job.getName());
    }
    pullURL = pullURL + "/" + newFolderName;
    remoteSource.setPath(pullURL);
    try {
        restDataSpaceClient.delete(remoteSource);
    } catch (NotConnectedException | PermissionException e) {
        logger.debug("Error in removeJobIO pull for job " + job.getName());
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) RemoteSource(org.ow2.proactive.scheduler.rest.ds.RemoteSource) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException)

Example 79 with PermissionException

use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.

the class RestSmartProxyTest method waitForJobFinishState.

private JobState waitForJobFinishState(String jobIdAsString) throws InterruptedException, NotConnectedException, UnknownJobException, PermissionException {
    JobState jobState = restSmartProxy.getJobState(jobIdAsString);
    Thread.sleep(ONE_SECOND);
    while (jobState.getStatus().isJobAlive()) {
        jobState = restSmartProxy.getJobState(jobIdAsString);
        Thread.sleep(ONE_SECOND);
    }
    return jobState;
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState)

Example 80 with PermissionException

use of org.ow2.proactive.scheduler.common.exception.PermissionException in project scheduling by ow2-proactive.

the class SchedulerClient method getTaskResult.

@Override
public TaskResult getTaskResult(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    TaskResultImpl taskResult = null;
    try {
        TaskResultData taskResultData = restApi().taskResult(sid, jobId, taskName);
        taskResult = (TaskResultImpl) toTaskResult(JobIdImpl.makeJobId(jobId), taskResultData);
        if (taskResult.value() == null) {
            Serializable value = restApi().valueOfTaskResult(sid, jobId, taskName);
            if (value != null) {
                taskResult.setValue(value);
            }
        }
    } catch (Throwable t) {
        throwUJEOrNCEOrPEOrUTE(exception(t));
    }
    return taskResult;
}
Also used : Serializable(java.io.Serializable) TaskResultImpl(org.ow2.proactive.scheduler.rest.data.TaskResultImpl) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData)

Aggregations

PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)64 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)62 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)46 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)46 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)44 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)39 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)34 Path (javax.ws.rs.Path)32 Produces (javax.ws.rs.Produces)30 GET (javax.ws.rs.GET)26 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)25 JobState (org.ow2.proactive.scheduler.common.job.JobState)21 GZIP (org.jboss.resteasy.annotations.GZIP)17 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)17 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)16 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)16 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)16 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)16 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)15