Search in sources :

Example 11 with DataSpacesFileObject

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

the class SchedulerSpacesSupport method registerUserSpace.

/**
 * This method creates a dedicated USER space for the user which successfully connected
 * This USER space is a subspace of the scheduler default USER space,
 * A sub-folder named with the username is created to contain the USER space
 *
 * @param username the username of an identified user
 */
public void registerUserSpace(String username) {
    if (this.userGlobalSpaces.get(username) == null) {
        DataSpacesFileObject userSpace;
        String userSpaceName = SchedulerConstants.USERSPACE_NAME + "_" + username;
        if (!PASchedulerProperties.DATASPACE_DEFAULTUSER_URL.isSet()) {
            logger.warn("URL of the root USER space is not set, cannot create a USER space for " + username);
            return;
        }
        String localpath = PASchedulerProperties.DATASPACE_DEFAULTUSER_LOCALPATH.getValueAsStringOrNull();
        String hostname = PASchedulerProperties.DATASPACE_DEFAULTUSER_HOSTNAME.getValueAsStringOrNull();
        try {
            DataSpaceServiceStarter.getDataSpaceServiceStarter().createSpaceWithUserNameSubfolder(username, SchedulerConstants.SCHEDULER_DATASPACE_APPLICATION_ID, userSpaceName, PASchedulerProperties.DATASPACE_DEFAULTUSER_URL.getValueAsString(), localpath, hostname, false, true);
            // immediately retrieve the User Space
            userSpace = PADataSpaces.resolveOutput(userSpaceName);
            logger.info("USER space for user " + username + " is at " + userSpace.getAllRealURIs());
        } catch (Exception e) {
            logger.warn("", e);
            return;
        }
        // register the user GlobalSpace to the frontend state
        this.userGlobalSpaces.put(username, userSpace);
    }
}
Also used : DataSpacesFileObject(org.objectweb.proactive.extensions.dataspaces.api.DataSpacesFileObject)

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