Search in sources :

Example 6 with FileSystemException

use of org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException in project scheduling by ow2-proactive.

the class TaskLauncher method copyTaskLogsToUserSpace.

private void copyTaskLogsToUserSpace(File taskLogFile, TaskDataspaces dataspaces) {
    if (initializer.isPreciousLogs()) {
        try {
            FileSelector taskLogFileSelector = new FileSelector(taskLogFile.getName());
            taskLogFileSelector.setIncludes(new TaskLoggerRelativePathGenerator(taskId).getRelativePath());
            dataspaces.copyScratchDataToOutput(Collections.singletonList(new OutputSelector(taskLogFileSelector, OutputAccessMode.TransferToUserSpace)));
        } catch (FileSystemException e) {
            logger.warn("Cannot copy logs of task to user data spaces", e);
        }
    }
}
Also used : FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) OutputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector) FileSelector(org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector) TaskLoggerRelativePathGenerator(org.ow2.proactive.scheduler.common.util.TaskLoggerRelativePathGenerator)

Example 7 with FileSystemException

use of org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException in project scheduling by ow2-proactive.

the class TaskProActiveDataspaces method setFolderRightsForRunAsUserMode.

/**
 * Sets open file permissions for folder copied in RunAsMe mode.
 * The method will set as well recursively the permissions on the parents folder.
 */
private void setFolderRightsForRunAsUserMode(DataSpacesFileObject object) throws FileSystemException {
    if (runAsUser) {
        setRWPermission(object);
        if (linuxOS) {
            object.setExecutable(true, false);
        }
        DataSpacesFileObject parentObject = null;
        try {
            parentObject = object.getParent();
        } catch (Exception ignored) {
        // in case getParent throws an exception instead of null, we prefer to ignore it and not propagate the permissions further.
        }
        if (parentObject != null) {
            setFolderRightsForRunAsUserMode(parentObject);
        }
    }
}
Also used : DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject) FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) URISyntaxException(java.net.URISyntaxException) SpaceAlreadyRegisteredException(org.objectweb.proactive.extensions.dataspaces.exceptions.SpaceAlreadyRegisteredException) ExecutionException(java.util.concurrent.ExecutionException)

Example 8 with FileSystemException

use of org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException in project scheduling by ow2-proactive.

the class TaskProActiveDataspaces method addFilesResultToList.

private void addFilesResultToList(List<Future<List<DataSpacesFileObject>>> futures, ArrayList<DataSpacesFileObject> results) throws InterruptedException, FileSystemException {
    StringBuilder message = new StringBuilder();
    String nl = System.lineSeparator();
    for (Future<List<DataSpacesFileObject>> future : futures) {
        try {
            results.addAll(future.get());
        } catch (InterruptedException | ExecutionException e) {
            logger.error("Exception while selecting input files to copy ", e);
            message.append(StackTraceUtil.getStackTrace(e)).append(nl);
        }
    }
    if (message.length() > 0) {
        throw new FileSystemException("Exception(s) occurred when selecting input files to copy: " + nl + message.toString());
    }
}
Also used : FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) ArrayList(java.util.ArrayList) List(java.util.List) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString) ExecutionException(java.util.concurrent.ExecutionException)

Example 9 with FileSystemException

use of org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException in project scheduling by ow2-proactive.

the class TaskProActiveDataspaces method createTaskIdFolder.

private DataSpacesFileObject createTaskIdFolder(DataSpacesFileObject space, String spaceName) {
    if (space != null) {
        String realURI = space.getRealURI();
        // Look for the TASKID pattern at the end of the dataspace URI
        if (realURI.contains(SchedulerConstants.TASKID_DIR_DEFAULT_NAME)) {
            // resolve the taskid subfolder
            DataSpacesFileObject tidOutput;
            try {
                tidOutput = space.resolveFile(taskId.toString());
                // create this subfolder
                tidOutput.createFolder();
            } catch (FileSystemException e) {
                logger.info("Error when creating the TASKID folder in " + realURI, e);
                logger.info(spaceName + " space is disabled");
                return null;
            }
            // assign it to the space
            space = tidOutput;
            logger.info(SchedulerConstants.TASKID_DIR_DEFAULT_NAME + " pattern found, changed " + spaceName + " space to : " + space.getRealURI());
        }
    }
    return space;
}
Also used : FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString)

Example 10 with FileSystemException

use of org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException in project scheduling by ow2-proactive.

the class TaskProActiveDataspaces method createFolderHierarchySequentially.

/*
     * Create the folder hierarchy and select the files to copy
     * from the specified list of FileObjects.
     */
protected void createFolderHierarchySequentially(DataSpacesFileObject destination, String spaceUri, List<DataSpacesFileObject> spaceFiles, Map<String, DataSpacesFileObject> filesToCopy) throws FileSystemException {
    boolean isDebugEnabled = logger.isDebugEnabled();
    boolean isFolderHierarchyCreationEnabled = isCreateFolderHierarchySequentiallyEnabled();
    long startTime = System.currentTimeMillis();
    for (DataSpacesFileObject fileObject : spaceFiles) {
        String relativePath = relativize(spaceUri, fileObject);
        if (isFolderHierarchyCreationEnabled) {
            try {
                DataSpacesFileObject target = destination.resolveFile(relativePath);
                createFolderHierarchy(isDebugEnabled, fileObject, target);
            } catch (FileSystemException e) {
                String message = "Could not create folder hierarchy for " + relativePath + " on " + destination.getRealURI();
                logger.warn(message);
                logDataspacesStatus(message, DataspacesStatusLevel.WARNING);
            }
        }
        DataSpacesFileObject oldFileObject = filesToCopy.put(relativePath, fileObject);
        if (oldFileObject != null) {
            String message = fileObject.getRealURI() + " will be copied instead of " + oldFileObject.getRealURI() + ".\n " + "Precedence order is output space, input space, user space, global space.";
            logger.warn(message);
            logDataspacesStatus(message, DataspacesStatusLevel.WARNING);
        }
    }
    logger.info("Time needed to build folder hierarchy: " + (System.currentTimeMillis() - startTime) + " ms");
}
Also used : FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString)

Aggregations

FileSystemException (org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException)10 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)7 DataSpacesFileObject (org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject)5 ExecutionException (java.util.concurrent.ExecutionException)4 ArrayList (java.util.ArrayList)3 URISyntaxException (java.net.URISyntaxException)2 List (java.util.List)2 SpaceAlreadyRegisteredException (org.objectweb.proactive.extensions.dataspaces.exceptions.SpaceAlreadyRegisteredException)2 OutputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector)2 FileSelector (org.objectweb.proactive.extensions.dataspaces.api.FileSelector)1 FileSelector (org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector)1 TaskLoggerRelativePathGenerator (org.ow2.proactive.scheduler.common.util.TaskLoggerRelativePathGenerator)1