Search in sources :

Example 6 with DataSpacesFileObject

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

the class TaskProActiveDataspaces method findFilesToCopyFromInput.

private void findFilesToCopyFromInput(List<InputSelector> inputSelectors, ArrayList<DataSpacesFileObject> inResults, ArrayList<DataSpacesFileObject> outResults, ArrayList<DataSpacesFileObject> globResults, ArrayList<DataSpacesFileObject> userResults, ArrayList<DataSpacesFileObject> inResultsCache, ArrayList<DataSpacesFileObject> outResultsCache, ArrayList<DataSpacesFileObject> globResultsCache, ArrayList<DataSpacesFileObject> userResultsCache) throws FileSystemException, InterruptedException {
    long startTime = System.currentTimeMillis();
    ArrayList<Future<List<DataSpacesFileObject>>> inResultsFutures = new ArrayList<>();
    ArrayList<Future<List<DataSpacesFileObject>>> outResultsFutures = new ArrayList<>();
    ArrayList<Future<List<DataSpacesFileObject>>> globResultsFutures = new ArrayList<>();
    ArrayList<Future<List<DataSpacesFileObject>>> userResultsFutures = new ArrayList<>();
    ArrayList<Future<List<DataSpacesFileObject>>> inResultsCacheFutures = new ArrayList<>();
    ArrayList<Future<List<DataSpacesFileObject>>> outResultsCacheFutures = new ArrayList<>();
    ArrayList<Future<List<DataSpacesFileObject>>> globResultsCacheFutures = new ArrayList<>();
    ArrayList<Future<List<DataSpacesFileObject>>> userResultsCacheFutures = new ArrayList<>();
    for (InputSelector is : inputSelectors) {
        org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector selector = new org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector();
        selector.setIncludes(is.getInputFiles().getIncludes());
        selector.setExcludes(is.getInputFiles().getExcludes());
        switch(is.getMode()) {
            case TransferFromInputSpace:
                inResultsFutures.add(findFilesToCopyFromInput(INPUT, "INPUT", is, selector));
                break;
            case TransferFromOutputSpace:
                outResultsFutures.add(findFilesToCopyFromInput(OUTPUT, "OUTPUT", is, selector));
                break;
            case TransferFromGlobalSpace:
                globResultsFutures.add(findFilesToCopyFromInput(GLOBAL, "GLOBAL", is, selector));
                break;
            case TransferFromUserSpace:
                userResultsFutures.add(findFilesToCopyFromInput(USER, "USER", is, selector));
                break;
            case CacheFromInputSpace:
                inResultsCacheFutures.add(findFilesToCopyFromInput(INPUT, "INPUT", is, selector));
                break;
            case CacheFromOutputSpace:
                outResultsCacheFutures.add(findFilesToCopyFromInput(OUTPUT, "OUTPUT", is, selector));
                break;
            case CacheFromGlobalSpace:
                globResultsCacheFutures.add(findFilesToCopyFromInput(GLOBAL, "GLOBAL", is, selector));
                break;
            case CacheFromUserSpace:
                userResultsCacheFutures.add(findFilesToCopyFromInput(USER, "USER", is, selector));
            case none:
                // do nothing
                break;
        }
    }
    addFilesResultToList(inResultsFutures, inResults);
    addFilesResultToList(outResultsFutures, outResults);
    addFilesResultToList(globResultsFutures, globResults);
    addFilesResultToList(userResultsFutures, userResults);
    addFilesResultToList(inResultsCacheFutures, inResultsCache);
    addFilesResultToList(outResultsCacheFutures, outResultsCache);
    addFilesResultToList(globResultsCacheFutures, globResultsCache);
    addFilesResultToList(userResultsCacheFutures, userResultsCache);
    logger.info("Time needed to create list of files to copy: " + (System.currentTimeMillis() - startTime) + " ms");
}
Also used : DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject) FileSelector(org.objectweb.proactive.extensions.dataspaces.api.FileSelector) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) InputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector)

Example 7 with DataSpacesFileObject

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

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

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

Example 10 with DataSpacesFileObject

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

the class TestDataSpaceConfiguration method runStarter.

public Boolean runStarter() throws Exception {
    File spFile = new File(IOSPACE);
    File spFileWithUserDir = new File(IOSPACE, username);
    spFile.mkdirs();
    spFileWithUserDir.mkdirs();
    spFileWithUserDir.deleteOnExit();
    spFile.deleteOnExit();
    filesServerIn = new FileSystemServerDeployer("space", IOSPACE, true, true);
    String[] spaceurls = filesServerIn.getVFSRootURLs();
    String[] userdirUrls = DataSpaceServiceStarter.urlsWithUserDir(spaceurls, username);
    ArrayList<String> expected = new ArrayList<>();
    expected.addAll(Arrays.asList(spaceurls));
    ArrayList<String> expectedWithUserDir = new ArrayList<>();
    expectedWithUserDir.addAll(Arrays.asList(userdirUrls));
    PASchedulerProperties.DATASPACE_DEFAULTINPUT_URL.updateProperty(DataSpaceServiceStarter.urlsToDSConfigProperty(spaceurls));
    PASchedulerProperties.DATASPACE_DEFAULTINPUT_LOCALPATH.updateProperty(IOSPACE);
    PASchedulerProperties.DATASPACE_DEFAULTINPUT_HOSTNAME.updateProperty(HOSTNAME);
    PASchedulerProperties.DATASPACE_DEFAULTOUTPUT_URL.updateProperty(DataSpaceServiceStarter.urlsToDSConfigProperty(spaceurls));
    PASchedulerProperties.DATASPACE_DEFAULTOUTPUT_LOCALPATH.updateProperty(IOSPACE);
    PASchedulerProperties.DATASPACE_DEFAULTOUTPUT_HOSTNAME.updateProperty(HOSTNAME);
    PASchedulerProperties.DATASPACE_DEFAULTGLOBAL_URL.updateProperty(DataSpaceServiceStarter.urlsToDSConfigProperty(spaceurls));
    PASchedulerProperties.DATASPACE_DEFAULTGLOBAL_LOCALPATH.updateProperty(IOSPACE);
    PASchedulerProperties.DATASPACE_DEFAULTGLOBAL_HOSTNAME.updateProperty(HOSTNAME);
    PASchedulerProperties.DATASPACE_DEFAULTUSER_URL.updateProperty(DataSpaceServiceStarter.urlsToDSConfigProperty(spaceurls));
    PASchedulerProperties.DATASPACE_DEFAULTUSER_LOCALPATH.updateProperty(IOSPACE);
    PASchedulerProperties.DATASPACE_DEFAULTUSER_HOSTNAME.updateProperty(HOSTNAME);
    DataSpaceServiceStarter dsServiceStarter = DataSpaceServiceStarter.getDataSpaceServiceStarter();
    dsServiceStarter.startNamingService();
    Set<SpaceInstanceInfo> predefinedSpaces = new HashSet<>();
    NamingService namingService = dsServiceStarter.getNamingService();
    TaskDataSpaceApplication jdsa = new TaskDataSpaceApplication(appid, dsServiceStarter.getNamingService());
    jdsa.startDataSpaceApplication(null, null, null, null, username, null);
    DataSpacesNodes.configureApplication(PAActiveObject.getNode(), appid, dsServiceStarter.getNamingServiceURL());
    DataSpacesFileObject INPUT = PADataSpaces.resolveDefaultInput();
    DataSpacesFileObject OUTPUT = PADataSpaces.resolveDefaultOutput();
    DataSpacesFileObject GLOBAL = PADataSpaces.resolveOutput(SchedulerConstants.GLOBALSPACE_NAME);
    DataSpacesFileObject USER = PADataSpaces.resolveOutput(SchedulerConstants.USERSPACE_NAME);
    Assert.assertEquals(expectedWithUserDir, INPUT.getAllRealURIs());
    Assert.assertEquals(expectedWithUserDir, OUTPUT.getAllRealURIs());
    Assert.assertEquals(expected, GLOBAL.getAllRealURIs());
    Assert.assertEquals(expectedWithUserDir, USER.getAllRealURIs());
    jdsa.terminateDataSpaceApplication();
    return true;
}
Also used : FileSystemServerDeployer(org.objectweb.proactive.extensions.vfsprovider.FileSystemServerDeployer) DataSpaceServiceStarter(org.ow2.proactive.scheduler.core.DataSpaceServiceStarter) SpaceInstanceInfo(org.objectweb.proactive.extensions.dataspaces.core.SpaceInstanceInfo) DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject) ArrayList(java.util.ArrayList) TaskDataSpaceApplication(org.ow2.proactive.scheduler.job.TaskDataSpaceApplication) NamingService(org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService) File(java.io.File) HashSet(java.util.HashSet)

Aggregations

DataSpacesFileObject (org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject)11 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)5 ArrayList (java.util.ArrayList)5 FileSystemException (org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException)5 Future (java.util.concurrent.Future)3 FileSelector (org.objectweb.proactive.extensions.dataspaces.api.FileSelector)2 File (java.io.File)1 URISyntaxException (java.net.URISyntaxException)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 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 FileSystemServerDeployer (org.objectweb.proactive.extensions.vfsprovider.FileSystemServerDeployer)1 InputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector)1 OutputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector)1 DataSpaceServiceStarter (org.ow2.proactive.scheduler.core.DataSpaceServiceStarter)1