Search in sources :

Example 1 with InputOutputSpaceConfiguration

use of org.objectweb.proactive.extensions.dataspaces.core.InputOutputSpaceConfiguration in project scheduling by ow2-proactive.

the class TaskProActiveDataspaces method initDataSpaces.

private void initDataSpaces() throws Exception {
    long startTime = System.currentTimeMillis();
    // configure node for application
    String appId = taskId.toString();
    // prepare scratch, input, output
    Node node = PAActiveObject.getNode();
    logger.info("Configuring dataspaces for app " + appId + " on " + node.getNodeInformation().getName());
    DataSpacesNodes.configureApplication(node, appId, namingService);
    SCRATCH = PADataSpaces.resolveScratchForAO();
    logger.info("SCRATCH space is " + SCRATCH.getRealURI());
    // Set the scratch folder writable for everyone
    if (!SCRATCH.setWritable(true, false)) {
        logger.warn("Missing permission to change write permissions to " + getScratchFolder());
    }
    InputOutputSpaceConfiguration cacheConfiguration = DataSpaceNodeConfigurationAgent.getCacheSpaceConfiguration();
    if (cacheConfiguration != null) {
        final String cacheName = cacheConfiguration.getName();
        cacheSpaceInstanceInfo = new SpaceInstanceInfo(appId, cacheConfiguration);
        try {
            namingService.register(cacheSpaceInstanceInfo);
        } catch (SpaceAlreadyRegisteredException e) {
            // this is a rare case where the cache space has already been registered for the same task and there was a node failure.
            namingService.unregister(cacheSpaceInstanceInfo.getMountingPoint());
            namingService.register(cacheSpaceInstanceInfo);
        }
        CACHE = initDataSpace(new Callable<DataSpacesFileObject>() {

            @Override
            public DataSpacesFileObject call() throws Exception {
                return PADataSpaces.resolveOutput(cacheName);
            }
        }, "CACHE", false);
    } else {
        logger.error("No Cache space configuration found, cache space is disabled.");
    }
    UserCredentials userCredentials;
    if (decrypter != null) {
        CredData credData = decrypter.decrypt();
        userCredentials = new UserCredentials(credData.getLogin(), credData.getPassword(), credData.getDomain(), credData.getKey());
    } else {
        logger.warn("No decryter found");
        userCredentials = new UserCredentials();
    }
    INPUT = initDataSpace(new Callable<DataSpacesFileObject>() {

        @Override
        public DataSpacesFileObject call() throws Exception {
            return PADataSpaces.resolveDefaultInput();
        }
    }, "INPUT", true);
    OUTPUT = initDataSpace(new Callable<DataSpacesFileObject>() {

        @Override
        public DataSpacesFileObject call() throws Exception {
            return PADataSpaces.resolveDefaultOutput();
        }
    }, "OUTPUT", false);
    GLOBAL = initDataSpace(new Callable<DataSpacesFileObject>() {

        @Override
        public DataSpacesFileObject call() throws Exception {
            return PADataSpaces.resolveOutput(SchedulerConstants.GLOBALSPACE_NAME);
        }
    }, "GLOBAL", false);
    USER = initDataSpace(new Callable<DataSpacesFileObject>() {

        @Override
        public DataSpacesFileObject call() throws Exception {
            return PADataSpaces.resolveOutput(SchedulerConstants.USERSPACE_NAME, userCredentials);
        }
    }, "USER", false);
    logger.info("Time needed to mount data spaces: " + (System.currentTimeMillis() - startTime) + " ms");
}
Also used : InputOutputSpaceConfiguration(org.objectweb.proactive.extensions.dataspaces.core.InputOutputSpaceConfiguration) SpaceInstanceInfo(org.objectweb.proactive.extensions.dataspaces.core.SpaceInstanceInfo) SpaceAlreadyRegisteredException(org.objectweb.proactive.extensions.dataspaces.exceptions.SpaceAlreadyRegisteredException) Node(org.objectweb.proactive.core.node.Node) CredData(org.ow2.proactive.authentication.crypto.CredData) UserCredentials(org.objectweb.proactive.extensions.dataspaces.api.UserCredentials) Throwables.getStackTraceAsString(com.google.common.base.Throwables.getStackTraceAsString) Callable(java.util.concurrent.Callable)

Example 2 with InputOutputSpaceConfiguration

use of org.objectweb.proactive.extensions.dataspaces.core.InputOutputSpaceConfiguration in project scheduling by ow2-proactive.

the class DataSpaceServiceStarter method createSpace.

/**
 * Helper method used to create a space configuration and register it into the naming service
 * This helper can eventually configure the local Node for the provided application ID, if the dataspace needs to be user locally.
 * It will only register the dataspace in the naming service otherwise
 * @param appID the Application ID
 * @param name the name of the dataspace
 * @param urlsproperty the space-delimited url list property of the Virtual File Systems (for different protocols)
 * @param path the path to the dataspace in the localfilesystem
 * @param hostname the host where the file server is deployed
 * @param inputConfiguration if the configuration is an InputSpace configuration (read-only)
 * @param localConfiguration if the local node needs to be configured for the provided application
 */
public void createSpace(String appID, String name, String urlsproperty, String path, String hostname, boolean inputConfiguration, boolean localConfiguration) throws FileSystemException, URISyntaxException, ProActiveException, MalformedURLException {
    if (!serviceStarted) {
        throw new IllegalStateException("DataSpace service is not started");
    }
    if (!spacesConfigurations.containsKey(appID)) {
        if (localConfiguration) {
            if (appidConfigured != null) {
                logger.warn("Node " + schedulerNode.getNodeInformation().getURL() + " was configured for appid = " + appidConfigured + ", reconfiguring...");
            }
            DataSpacesNodes.configureApplication(schedulerNode, appID, namingService);
            logger.debug("Node " + schedulerNode.getNodeInformation().getURL() + " configured for appid = " + appID);
            appidConfigured = appID;
        } else {
            namingService.registerApplication(appID, new HashSet<SpaceInstanceInfo>());
        }
        spacesConfigurations.put(appID, new HashSet<String>());
    }
    if (spacesConfigurations.get(appID).contains(name) && !PADataSpaces.DEFAULT_IN_OUT_NAME.equals(name)) {
        throw new SpaceAlreadyRegisteredException("Space " + name + " for appid=" + appID + " is already registered");
    }
    InputOutputSpaceConfiguration spaceConf = null;
    // Converts the property to an ArrayList
    ArrayList<String> finalurls = new ArrayList<>(Arrays.asList(Tools.dataSpaceConfigPropertyToUrls(urlsproperty)));
    if (inputConfiguration) {
        spaceConf = InputOutputSpaceConfiguration.createInputSpaceConfiguration(finalurls, path, hostname != null ? hostname : localhostname, name);
    } else {
        spaceConf = InputOutputSpaceConfiguration.createOutputSpaceConfiguration(finalurls, path, hostname != null ? hostname : localhostname, name);
    }
    namingService.register(new SpaceInstanceInfo(appID, spaceConf));
    spacesConfigurations.get(appID).add(spaceConf.getName());
    logger.debug("Space " + name + " for appid = " + appID + " with urls = " + finalurls + " registered");
}
Also used : InputOutputSpaceConfiguration(org.objectweb.proactive.extensions.dataspaces.core.InputOutputSpaceConfiguration) SpaceInstanceInfo(org.objectweb.proactive.extensions.dataspaces.core.SpaceInstanceInfo) SpaceAlreadyRegisteredException(org.objectweb.proactive.extensions.dataspaces.exceptions.SpaceAlreadyRegisteredException) ArrayList(java.util.ArrayList)

Aggregations

InputOutputSpaceConfiguration (org.objectweb.proactive.extensions.dataspaces.core.InputOutputSpaceConfiguration)2 SpaceInstanceInfo (org.objectweb.proactive.extensions.dataspaces.core.SpaceInstanceInfo)2 SpaceAlreadyRegisteredException (org.objectweb.proactive.extensions.dataspaces.exceptions.SpaceAlreadyRegisteredException)2 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)1 ArrayList (java.util.ArrayList)1 Callable (java.util.concurrent.Callable)1 Node (org.objectweb.proactive.core.node.Node)1 UserCredentials (org.objectweb.proactive.extensions.dataspaces.api.UserCredentials)1 CredData (org.ow2.proactive.authentication.crypto.CredData)1