Search in sources :

Example 1 with BaseScratchSpaceConfiguration

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

the class DataSpaceNodeConfigurationAgent method configureNode.

public boolean configureNode() {
    try {
        Node node = PAActiveObject.getActiveObjectNode(PAActiveObject.getStubOnThis());
        logger.info("Start configuration of data space for node " + node.getNodeInformation().getURL());
        // configure node for Data Spaces
        String baseScratchDir = getBaseScratchDir();
        final BaseScratchSpaceConfiguration scratchConf = new BaseScratchSpaceConfiguration((String) null, baseScratchDir);
        DataSpacesNodes.configureNode(node, scratchConf);
        logger.info("Data space configuration for node " + node.getNodeInformation().getURL() + " successful");
    } catch (Throwable t) {
        logger.error("Cannot configure dataSpace", t);
        return false;
    }
    startCacheSpace();
    return true;
}
Also used : Node(org.objectweb.proactive.core.node.Node) BaseScratchSpaceConfiguration(org.objectweb.proactive.extensions.dataspaces.core.BaseScratchSpaceConfiguration)

Example 2 with BaseScratchSpaceConfiguration

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

the class DataSpaceServiceStarter method startNamingService.

/**
 * StartNaming service and default file system server if needed.
 *
 * @throws Exception
 */
public void startNamingService() throws Exception {
    schedulerNode = PAActiveObject.getNode();
    localhostname = java.net.InetAddress.getLocalHost().getHostName();
    namingServiceDeployer = new NamingServiceDeployer(true);
    namingServiceURL = namingServiceDeployer.getNamingServiceURL();
    namingService = NamingService.createNamingServiceStub(namingServiceURL);
    // configure node for Data Spaces
    final BaseScratchSpaceConfiguration scratchConf = new BaseScratchSpaceConfiguration((String) null, DEFAULT_LOCAL_SCRATCH);
    DataSpacesNodes.configureNode(schedulerNode, scratchConf);
    // set default INPUT/OUTPUT spaces if needed
    PASchedulerProperties[][] confs = { { PASchedulerProperties.DATASPACE_DEFAULTINPUT_URL, PASchedulerProperties.DATASPACE_DEFAULTINPUT_LOCALPATH, PASchedulerProperties.DATASPACE_DEFAULTINPUT_HOSTNAME }, { PASchedulerProperties.DATASPACE_DEFAULTOUTPUT_URL, PASchedulerProperties.DATASPACE_DEFAULTOUTPUT_LOCALPATH, PASchedulerProperties.DATASPACE_DEFAULTOUTPUT_HOSTNAME }, { PASchedulerProperties.DATASPACE_DEFAULTGLOBAL_URL, PASchedulerProperties.DATASPACE_DEFAULTGLOBAL_LOCALPATH, PASchedulerProperties.DATASPACE_DEFAULTGLOBAL_HOSTNAME }, { PASchedulerProperties.DATASPACE_DEFAULTUSER_URL, PASchedulerProperties.DATASPACE_DEFAULTUSER_LOCALPATH, PASchedulerProperties.DATASPACE_DEFAULTUSER_HOSTNAME } };
    String[] spacesNames = { "DefaultInputSpace", "DefaultOutputSpace", "GlobalSpace", "UserSpaces" };
    String[] humanReadableNames = { "default INPUT space", "default OUTPUT space", "shared GLOBAL space", "USER spaces" };
    String[] default_paths = { DEFAULT_LOCAL_INPUT, DEFAULT_LOCAL_OUTPUT, DEFAULT_LOCAL_GLOBAL, DEFAULT_LOCAL_USER };
    for (int i = 0; i < confs.length; i++) {
        // variable used to precise exception
        String spaceDir = null;
        if (confs[i][0].isSet() && confs[i][0].getValueAsString().trim().isEmpty()) {
            logger.info("Unsetting property : " + confs[i][0].getKey());
            confs[i][0].unSet();
        }
        if (!confs[i][0].isSet()) {
            // if URL is set, if not we start a server ourselves
            try {
                logger.debug("Starting " + humanReadableNames[i] + " server...");
                if (!confs[i][1].isSet()) {
                    // check if the localpath is set, if not we use the default path
                    spaceDir = default_paths[i];
                    confs[i][1].updateProperty(spaceDir);
                } else {
                    // otherwise, we build a FileServer on the provided path
                    logger.debug("Using property-defined path at " + confs[i][1].getValueAsString());
                    spaceDir = confs[i][1].getValueAsString();
                }
                File dir = new File(spaceDir);
                if (!dir.exists()) {
                    dir.mkdirs();
                }
                FileSystemServerDeployer server = startServer(spacesNames[i], humanReadableNames[i], spaceDir);
                servers.add(server);
                confs[i][0].updateProperty(buildServerUrlList(server.getVFSRootURLs()));
                // use the hostname property if it is set, otherwise, use the local hostname
                if (!confs[i][2].isSet()) {
                    confs[i][2].updateProperty(localhostname);
                }
                logger.debug(humanReadableNames[i] + " server local path is " + spaceDir);
            } catch (IllegalArgumentException iae) {
                throw new IllegalArgumentException("Directory '" + spaceDir + "' cannot be accessed. Check if directory exists or if you have read/write rights.");
            }
        }
    }
    Set<SpaceInstanceInfo> predefinedSpaces = new HashSet<>();
    namingService.registerApplication(SchedulerConstants.SCHEDULER_DATASPACE_APPLICATION_ID, predefinedSpaces);
    serviceStarted = true;
    try {
        // register the Global space
        createSpace(SchedulerConstants.SCHEDULER_DATASPACE_APPLICATION_ID, SchedulerConstants.GLOBALSPACE_NAME, PASchedulerProperties.DATASPACE_DEFAULTGLOBAL_URL.getValueAsString(), PASchedulerProperties.DATASPACE_DEFAULTGLOBAL_LOCALPATH.getValueAsString(), localhostname, false, true);
    } catch (Exception e) {
        logger.error("", e);
    }
}
Also used : FileSystemServerDeployer(org.objectweb.proactive.extensions.vfsprovider.FileSystemServerDeployer) SpaceInstanceInfo(org.objectweb.proactive.extensions.dataspaces.core.SpaceInstanceInfo) FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) SpaceAlreadyRegisteredException(org.objectweb.proactive.extensions.dataspaces.exceptions.SpaceAlreadyRegisteredException) IOException(java.io.IOException) ProActiveException(org.objectweb.proactive.core.ProActiveException) NamingServiceDeployer(org.objectweb.proactive.extensions.dataspaces.core.naming.NamingServiceDeployer) File(java.io.File) BaseScratchSpaceConfiguration(org.objectweb.proactive.extensions.dataspaces.core.BaseScratchSpaceConfiguration) HashSet(java.util.HashSet)

Aggregations

BaseScratchSpaceConfiguration (org.objectweb.proactive.extensions.dataspaces.core.BaseScratchSpaceConfiguration)2 File (java.io.File)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 HashSet (java.util.HashSet)1 ProActiveException (org.objectweb.proactive.core.ProActiveException)1 Node (org.objectweb.proactive.core.node.Node)1 SpaceInstanceInfo (org.objectweb.proactive.extensions.dataspaces.core.SpaceInstanceInfo)1 NamingServiceDeployer (org.objectweb.proactive.extensions.dataspaces.core.naming.NamingServiceDeployer)1 FileSystemException (org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException)1 SpaceAlreadyRegisteredException (org.objectweb.proactive.extensions.dataspaces.exceptions.SpaceAlreadyRegisteredException)1 FileSystemServerDeployer (org.objectweb.proactive.extensions.vfsprovider.FileSystemServerDeployer)1