Search in sources :

Example 1 with DataSpacesFileObject

use of org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject in project scheduling by ow2-proactive.

the class TaskProActiveDataspaces method copyInputDataToScratch.

@Override
public void copyInputDataToScratch(List<InputSelector> inputSelectors) throws FileSystemException, InterruptedException {
    if (inputSelectors == null) {
        logger.debug("Input selector is empty, no file to copy");
        return;
    }
    ArrayList<DataSpacesFileObject> inputSpaceFiles = new ArrayList<>();
    ArrayList<DataSpacesFileObject> outputSpaceFiles = new ArrayList<>();
    ArrayList<DataSpacesFileObject> globalSpaceFiles = new ArrayList<>();
    ArrayList<DataSpacesFileObject> userSpaceFiles = new ArrayList<>();
    ArrayList<DataSpacesFileObject> inputSpaceCacheFiles = new ArrayList<>();
    ArrayList<DataSpacesFileObject> outputSpaceCacheFiles = new ArrayList<>();
    ArrayList<DataSpacesFileObject> globalSpaceCacheFiles = new ArrayList<>();
    ArrayList<DataSpacesFileObject> userSpaceCacheFiles = new ArrayList<>();
    findFilesToCopyFromInput(inputSelectors, inputSpaceFiles, outputSpaceFiles, globalSpaceFiles, userSpaceFiles, inputSpaceCacheFiles, outputSpaceCacheFiles, globalSpaceCacheFiles, userSpaceCacheFiles);
    String inputSpaceUri = virtualResolve(INPUT);
    String outputSpaceUri = virtualResolve(OUTPUT);
    String globalSpaceUri = virtualResolve(GLOBAL);
    String userSpaceUri = virtualResolve(USER);
    boolean cacheTransferPresent = !inputSpaceCacheFiles.isEmpty() || !outputSpaceCacheFiles.isEmpty() || !globalSpaceCacheFiles.isEmpty() || !userSpaceCacheFiles.isEmpty();
    if (cacheTransferPresent && CACHE != null) {
        cacheTransferLock.lockInterruptibly();
        try {
            Map<String, DataSpacesFileObject> filesToCopyToCache = createFolderHierarchySequentially(CACHE, inputSpaceUri, inputSpaceCacheFiles, outputSpaceUri, outputSpaceCacheFiles, globalSpaceUri, globalSpaceCacheFiles, userSpaceUri, userSpaceCacheFiles);
            long startTime = System.currentTimeMillis();
            List<Future<Boolean>> transferFuturesCache = doCopyInputDataToSpace(CACHE, filesToCopyToCache);
            handleResultsWhileTransferringFile(transferFuturesCache, "CACHE", startTime);
        } finally {
            if (cacheTransferPresent) {
                cacheTransferLock.unlock();
            }
        }
    } else if (cacheTransferPresent) {
        logDataspacesStatus("CACHE dataspace is not available while file transfers to cache were required. Check the Node logs for errors.", DataspacesStatusLevel.ERROR);
    }
    Map<String, DataSpacesFileObject> filesToCopyToScratch = createFolderHierarchySequentially(SCRATCH, inputSpaceUri, inputSpaceFiles, outputSpaceUri, outputSpaceFiles, globalSpaceUri, globalSpaceFiles, userSpaceUri, userSpaceFiles);
    long startTime = System.currentTimeMillis();
    List<Future<Boolean>> transferFuturesScratch = doCopyInputDataToSpace(SCRATCH, filesToCopyToScratch);
    handleResultsWhileTransferringFile(transferFuturesScratch, "LOCAL", startTime);
}
Also used : DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString)

Example 2 with DataSpacesFileObject

use of org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject in project scheduling by ow2-proactive.

the class TaskProActiveDataspaces method copyScratchDataToOutput.

@Override
public void copyScratchDataToOutput(List<OutputSelector> outputSelectors) throws FileSystemException {
    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;
            default:
        }
        results.clear();
    }
    if (toBeThrown != null) {
        throw toBeThrown;
    }
}
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 DataSpacesFileObject

use of org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject in project scheduling by ow2-proactive.

the class TaskProActiveDataspaces method handleOutput.

private void handleOutput(final DataSpacesFileObject dataspaceDestination, String spaceName, org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector selector, List<DataSpacesFileObject> results) throws FileSystemException {
    long startTime = System.currentTimeMillis();
    Utils.findFiles(SCRATCH, selector, results);
    if (logger.isDebugEnabled()) {
        if (results == null || results.size() == 0) {
            logger.debug("No file found to copy from LOCAL space to " + spaceName + " space");
        } else {
            logger.debug("Files that will be copied from LOCAL space to " + spaceName + " space :");
        }
    }
    String base = SCRATCH.getVirtualURI();
    Map<String, DataSpacesFileObject> filesToCopy = new HashMap<>(results.size());
    createFolderHierarchySequentially(dataspaceDestination, base, results, filesToCopy);
    ArrayList<Future<Boolean>> transferFutures = new ArrayList<>(results.size());
    for (Map.Entry<String, DataSpacesFileObject> entry : filesToCopy.entrySet()) {
        transferFutures.add(parallelFileCopy(entry.getValue(), dataspaceDestination, entry.getKey(), false));
    }
    handleResultsWhileTransferringFile(transferFutures, spaceName, startTime);
}
Also used : HashMap(java.util.HashMap) DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with DataSpacesFileObject

use of org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject 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 DataSpacesFileObject

use of org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject in project scheduling by ow2-proactive.

the class ServerJobAndTaskLogs method removePreciousLogs.

private void removePreciousLogs(JobId jobId, String jobOwner, Credentials credentials) {
    if (spacesSupport == null) {
        logger.warn("DataSpaces not initialized, cannot remove precious logs for job " + jobId);
        return;
    }
    try {
        Validate.notBlank(jobOwner);
        DataSpacesFileObject userspace = spacesSupport.getUserSpace(jobOwner, credentials);
        Validate.notNull(userspace, "Cannot find user space for user " + jobOwner + ". User spaces are probably not configured properly.");
        deleteAllLogFiles(jobId, userspace);
        deleteLogsFolderIfEmpty(jobId, userspace);
    } catch (Exception e) {
        logger.warn("Error occurred when trying to remove precious logs for job " + jobId, e);
    }
}
Also used : DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject) FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) IOException(java.io.IOException)

Aggregations

DataSpacesFileObject (org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject)15 FileSystemException (org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException)9 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)5 ArrayList (java.util.ArrayList)5 Future (java.util.concurrent.Future)3 ImmediateService (org.objectweb.proactive.annotation.ImmediateService)2 FileSelector (org.objectweb.proactive.extensions.dataspaces.api.FileSelector)2 File (java.io.File)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 KeyException (java.security.KeyException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 FileType (org.objectweb.proactive.extensions.dataspaces.api.FileType)1 UserCredentials (org.objectweb.proactive.extensions.dataspaces.api.UserCredentials)1 SpaceInstanceInfo (org.objectweb.proactive.extensions.dataspaces.core.SpaceInstanceInfo)1 NamingService (org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService)1 SpaceAlreadyRegisteredException (org.objectweb.proactive.extensions.dataspaces.exceptions.SpaceAlreadyRegisteredException)1