Search in sources :

Example 1 with FileSystemException

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

the class TaskProActiveDataspaces method findFilesToCopyFromInput.

private Future<List<DataSpacesFileObject>> findFilesToCopyFromInput(final DataSpacesFileObject space, final String spaceName, final InputSelector inputSelector, final org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector selector) {
    return executorTransfer.submit(new Callable<List<DataSpacesFileObject>>() {

        @Override
        public List<DataSpacesFileObject> call() throws Exception {
            List<DataSpacesFileObject> results = new ArrayList<>();
            if (!checkInputSpaceConfigured(space, spaceName, inputSelector)) {
                return results;
            }
            logger.debug("Selector used is " + selector);
            try {
                Utils.findFiles(space, selector, results);
                if (results.isEmpty()) {
                    // we detected that there was no new file in the list
                    String message = "No file is transferred from " + spaceName + " space at " + space.getRealURI() + "  for selector " + inputSelector;
                    logDataspacesStatus(message, DataspacesStatusLevel.WARNING);
                    logger.warn(message);
                }
            } catch (FileSystemException e) {
                logger.warn("Error occurred while transferring files", e);
                String message = "Could not contact " + spaceName + " space at " + space.getRealURI() + ". An error occurred while resolving selector " + inputSelector;
                logDataspacesStatus(message, DataspacesStatusLevel.ERROR);
                logDataspacesStatus(getStackTraceAsString(e), DataspacesStatusLevel.ERROR);
                logger.error(message, e);
                throw new FileSystemException(message);
            } catch (NullPointerException e) {
                // nothing to do
                return results;
            }
            return results;
        }
    });
}
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) 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 2 with FileSystemException

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

the class TaskProActiveDataspaces method copyScratchDataToOutput.

@Override
public void copyScratchDataToOutput(List<OutputSelector> outputSelectors) throws FileSystemException {
    try {
        if (outputSelectors == null) {
            logger.debug("Output selector is empty, no file to copy");
            return;
        }
        SCRATCH.refresh();
        checkOutputSpacesConfigured(outputSelectors);
        ArrayList<DataSpacesFileObject> results = new ArrayList<>();
        FileSystemException toBeThrown = null;
        for (OutputSelector os : outputSelectors) {
            org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector selector = new org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector();
            selector.setIncludes(os.getOutputFiles().getIncludes());
            selector.setExcludes(os.getOutputFiles().getExcludes());
            switch(os.getMode()) {
                case TransferToOutputSpace:
                    if (OUTPUT != null) {
                        toBeThrown = copyScratchDataToOutput(OUTPUT, "OUTPUT", os, selector, results);
                    }
                    break;
                case TransferToGlobalSpace:
                    if (GLOBAL != null) {
                        toBeThrown = copyScratchDataToOutput(GLOBAL, "GLOBAL", os, selector, results);
                    }
                    break;
                case TransferToUserSpace:
                    if (USER != null) {
                        toBeThrown = copyScratchDataToOutput(USER, "USER", os, selector, results);
                        break;
                    }
                case none:
                    break;
            }
            results.clear();
        }
        if (toBeThrown != null) {
            throw toBeThrown;
        }
    } finally {
        // display dataspaces error and warns if any
        displayDataspacesStatus();
    }
}
Also used : DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject) FileSelector(org.objectweb.proactive.extensions.dataspaces.api.FileSelector) ArrayList(java.util.ArrayList) FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) OutputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector)

Example 3 with FileSystemException

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

the class TaskProActiveDataspaces method copyScratchDataToOutput.

private FileSystemException copyScratchDataToOutput(DataSpacesFileObject dataspace, String spaceName, OutputSelector outputSelector, org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector selector, List<DataSpacesFileObject> results) {
    try {
        int sizeBeforeHandlingOutput = results.size();
        handleOutput(dataspace, spaceName, selector, results);
        if (results.size() == sizeBeforeHandlingOutput) {
            String message = "No file is transferred to " + spaceName + " space at " + dataspace.getRealURI() + " for selector " + outputSelector;
            logDataspacesStatus(message, DataspacesStatusLevel.WARNING);
            logger.warn(message);
        }
    } catch (FileSystemException fse) {
        String message = "Error while transferring to " + spaceName + " space at " + dataspace.getRealURI() + " for selector " + outputSelector;
        logDataspacesStatus(message, DataspacesStatusLevel.ERROR);
        logDataspacesStatus(getStackTraceAsString(fse), DataspacesStatusLevel.ERROR);
        logger.error(message, fse);
        return fse;
    }
    return null;
}
Also used : FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString)

Example 4 with FileSystemException

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

the class TaskProActiveDataspaces method initDataSpace.

private DataSpacesFileObject initDataSpace(Callable<DataSpacesFileObject> dataSpaceBuilder, String dataSpaceName, boolean input) throws Exception {
    try {
        DataSpacesFileObject result = dataSpaceBuilder.call();
        result = resolveToExisting(result, dataSpaceName, input);
        result = createTaskIdFolder(result, dataSpaceName);
        // before the transfer
        if (result != null) {
            result.refresh();
        }
        return result;
    } catch (FileSystemException fse) {
        String message = dataSpaceName + " space is disabled";
        logger.warn(message, fse);
        logDataspacesStatus(message, DataspacesStatusLevel.WARNING);
        logDataspacesStatus(getStackTraceAsString(fse), DataspacesStatusLevel.WARNING);
    }
    return null;
}
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 5 with FileSystemException

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

the class TaskProActiveDataspaces method handleResultsWhileTransferringFile.

protected void handleResultsWhileTransferringFile(List<Future<Boolean>> transferFutures, String destinationSpaceName, long startTime) throws FileSystemException {
    StringBuilder message = new StringBuilder();
    String nl = System.lineSeparator();
    for (Future<Boolean> future : transferFutures) {
        try {
            future.get();
        } catch (InterruptedException | ExecutionException e) {
            logger.error("Exception while fetching dataspace transfer result ", e);
            message.append(StackTraceUtil.getStackTrace(e)).append(nl);
        }
    }
    logger.info("Time needed to copy files to " + destinationSpaceName + " : " + (System.currentTimeMillis() - startTime) + " ms");
    if (message.length() > 0) {
        throw new FileSystemException("Exception(s) occurred when transferring input file: " + nl + message.toString());
    }
}
Also used : FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString) ExecutionException(java.util.concurrent.ExecutionException)

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