Search in sources :

Example 86 with NotConnectedException

use of org.ow2.proactive.scheduler.common.exception.NotConnectedException 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 87 with NotConnectedException

use of org.ow2.proactive.scheduler.common.exception.NotConnectedException 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 88 with NotConnectedException

use of org.ow2.proactive.scheduler.common.exception.NotConnectedException 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 89 with NotConnectedException

use of org.ow2.proactive.scheduler.common.exception.NotConnectedException 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 90 with NotConnectedException

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

the class RMCore method setBusyNode.

/**
 * Set a node state to busy. Set the node to busy, and move the node to the
 * internal busy nodes list. An event informing the node state's change is
 * thrown to RMMonitoring.
 *
 * @param owner
 * @param nodeUrl node to set
 */
public void setBusyNode(final String nodeUrl, Client owner) throws NotConnectedException {
    final RMNode rmNode = this.allNodes.get(nodeUrl);
    if (rmNode == null) {
        logger.error("Unknown node " + nodeUrl);
        return;
    }
    if (!clients.containsKey(owner.getId())) {
        logger.warn(nodeUrl + " cannot set busy as the client disconnected " + owner);
        throw new NotConnectedException("Client " + owner + " is not connected to the resource manager");
    }
    // If the node is already busy no need to go further
    if (rmNode.isBusy()) {
        return;
    }
    // Get the previous state of the node needed for the event
    final NodeState previousNodeState = rmNode.getState();
    rmNode.setBusy(owner);
    this.eligibleNodes.remove(rmNode);
    persistUpdatedRMNodeIfRecoveryEnabled(rmNode);
    // create the event
    this.registerAndEmitNodeEvent(rmNode.createNodeEvent(RMEventType.NODE_STATE_CHANGED, previousNodeState, owner.getName()));
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) NodeState(org.ow2.proactive.resourcemanager.common.NodeState) NotConnectedException(org.ow2.proactive.resourcemanager.exception.NotConnectedException)

Aggregations

NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)68 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)64 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)51 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)48 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)46 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)40 Path (javax.ws.rs.Path)39 Produces (javax.ws.rs.Produces)37 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)36 GET (javax.ws.rs.GET)28 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)27 JobState (org.ow2.proactive.scheduler.common.job.JobState)21 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)19 GZIP (org.jboss.resteasy.annotations.GZIP)18 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)18 IOException (java.io.IOException)17 ArrayList (java.util.ArrayList)17 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)17 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)16 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)16