Search in sources :

Example 1 with ConstructConfigurationException

use of es.bsc.compss.exceptions.ConstructConfigurationException in project compss by bsc-wdc.

the class GATAdaptor method constructConfiguration.

@Override
public Configuration constructConfiguration(Object project_properties, Object resources_properties) throws ConstructConfigurationException {
    String brokerAdaptorName = System.getProperty(COMPSsConstants.GAT_BROKER_ADAPTOR);
    String project_brokerAdaptor = (String) project_properties;
    String resources_brokerAdaptor = (String) resources_properties;
    if (project_brokerAdaptor != null) {
        if (resources_brokerAdaptor != null) {
            // Both
            if (project_brokerAdaptor.equals(resources_brokerAdaptor)) {
                // Equal, set any of them
                brokerAdaptorName = project_brokerAdaptor;
            } else {
                // Specified Broker adaptors don't match
                throw new ConstructConfigurationException("GATAdaptor: BrokerAdaptor defined in resources.xml and" + " project.xml donesn't match");
            }
        } else {
            // Only project
            brokerAdaptorName = project_brokerAdaptor;
        }
    } else {
        if (resources_brokerAdaptor != null) {
            // Only resources
            brokerAdaptorName = resources_brokerAdaptor;
        } else {
            // No broker adaptor specified, load default
            logger.debug("GAT Broker Adaptor not specified. Setting default value " + brokerAdaptorName);
        }
    }
    GATConfiguration config = new GATConfiguration(this.getClass().getName(), brokerAdaptorName);
    return config;
}
Also used : ConstructConfigurationException(es.bsc.compss.exceptions.ConstructConfigurationException) GATConfiguration(es.bsc.compss.gat.master.configuration.GATConfiguration)

Example 2 with ConstructConfigurationException

use of es.bsc.compss.exceptions.ConstructConfigurationException in project compss by bsc-wdc.

the class NIOAdaptor method constructConfiguration.

@Override
public Configuration constructConfiguration(Object project_properties, Object resources_properties) throws ConstructConfigurationException {
    NIOConfiguration config = new NIOConfiguration(this.getClass().getName());
    es.bsc.compss.types.project.jaxb.NIOAdaptorProperties props_project = (es.bsc.compss.types.project.jaxb.NIOAdaptorProperties) project_properties;
    es.bsc.compss.types.resources.jaxb.NIOAdaptorProperties props_resources = (es.bsc.compss.types.resources.jaxb.NIOAdaptorProperties) resources_properties;
    // Get ports
    int min_project = (props_project != null) ? props_project.getMinPort() : -1;
    int min_resources = -1;
    if (props_resources != null) {
        min_resources = props_resources.getMinPort();
    } else {
        // MinPort on resources is mandatory
        throw new ConstructConfigurationException("Resources file doesn't contain a minimum port value");
    }
    int max_project = (props_project != null) ? props_project.getMaxPort() : -1;
    int max_resources = (props_resources != null) ? props_resources.getMaxPort() : -1;
    // Merge port ranges
    int min_final = -1;
    if (min_project < 0) {
        min_final = min_resources;
    } else if (min_project < min_resources) {
        LOGGER.warn("resources.xml MinPort is more restrictive than project.xml. Loading resources.xml values");
        min_final = min_resources;
    } else {
        min_final = min_project;
    }
    int max_final = -1;
    if (max_project < 0) {
        if (max_resources < 0) {
            // No max port defined
            LOGGER.warn("MaxPort not defined in resources.xml/project.xml. Loading no limit");
        } else {
            LOGGER.warn("resources.xml MaxPort is more restrictive than project.xml. Loading resources.xml values");
            max_final = max_resources;
        }
    } else if (max_resources < 0) {
        max_final = max_project;
    } else if (max_project < max_resources) {
        max_final = max_project;
    } else {
        LOGGER.warn("resources.xml MaxPort is more restrictive than project.xml. Loading resources.xml values");
        max_final = max_resources;
    }
    LOGGER.info("NIO Min Port: " + min_final);
    LOGGER.info("NIO MAX Port: " + max_final);
    config.setMinPort(min_final);
    config.setMaxPort(max_final);
    // Add remote execution command
    String remoteExecutionCommand = props_resources.getRemoteExecutionCommand();
    if (remoteExecutionCommand == null || remoteExecutionCommand.isEmpty()) {
        remoteExecutionCommand = NIOConfiguration.DEFAULT_REMOTE_EXECUTION_COMMAND;
    }
    if (!NIOConfiguration.AVAILABLE_REMOTE_EXECUTION_COMMANDS.contains(remoteExecutionCommand)) {
        throw new ConstructConfigurationException("Invalid remote execution command on resources file");
    }
    config.setRemoteExecutionCommand(remoteExecutionCommand);
    return config;
}
Also used : NIOConfiguration(es.bsc.compss.nio.master.configuration.NIOConfiguration) ConstructConfigurationException(es.bsc.compss.exceptions.ConstructConfigurationException)

Example 3 with ConstructConfigurationException

use of es.bsc.compss.exceptions.ConstructConfigurationException in project compss by bsc-wdc.

the class ResourceLoader method loadService.

private static boolean loadService(ServiceType s_project, es.bsc.compss.types.resources.jaxb.ServiceType s_resources) {
    // Get service adaptor name from properties
    String serviceAdaptorName = COMPSsConstants.SERVICE_ADAPTOR;
    // Add the name
    String wsdl = s_project.getWsdl();
    /* Add properties given by the resources file **************************************** */
    String serviceName = s_resources.getName();
    String namespace = s_resources.getNamespace();
    String port = s_resources.getPort();
    ServiceResourceDescription srd = new ServiceResourceDescription(serviceName, namespace, port, Integer.MAX_VALUE);
    ServiceConfiguration config = null;
    try {
        config = (ServiceConfiguration) Comm.constructConfiguration(serviceAdaptorName, s_project, s_resources);
    } catch (ConstructConfigurationException cce) {
        ErrorManager.warn("Service configuration constructor failed", cce);
        return false;
    }
    // If we have reached this point the mp is SURELY not null
    /* Add properties given by the project file **************************************** */
    int limitOfTasks = s_project.getLimitOfTasks();
    if (limitOfTasks >= 0) {
        config.setLimitOfTasks(limitOfTasks);
    } else {
        config.setLimitOfTasks(Integer.MAX_VALUE);
    }
    /* Pass all the information to the ResourceManager to insert it into the Runtime ** */
    LOGGER.debug("Adding service worker " + wsdl);
    ServiceWorker newResource = new ServiceWorker(wsdl, srd, config);
    ResourceManager.addStaticResource(newResource);
    return true;
}
Also used : ServiceResourceDescription(es.bsc.compss.types.resources.ServiceResourceDescription) ServiceConfiguration(es.bsc.compss.types.resources.configuration.ServiceConfiguration) ServiceWorker(es.bsc.compss.types.resources.ServiceWorker) ConstructConfigurationException(es.bsc.compss.exceptions.ConstructConfigurationException)

Example 4 with ConstructConfigurationException

use of es.bsc.compss.exceptions.ConstructConfigurationException in project compss by bsc-wdc.

the class ResourceLoader method loadComputeNode.

private static boolean loadComputeNode(ComputeNodeType cn_project, es.bsc.compss.types.resources.jaxb.ComputeNodeType cn_resources) {
    // Add the name
    String name = cn_project.getName();
    /* Add properties given by the resources file **************************************** */
    MethodResourceDescription mrd = new MethodResourceDescription();
    List<es.bsc.compss.types.resources.jaxb.ProcessorType> processors = resources.getProcessors(cn_resources);
    if (processors != null) {
        for (es.bsc.compss.types.resources.jaxb.ProcessorType p : processors) {
            String procName = p.getName();
            int computingUnits = resources.getProcessorComputingUnits(p);
            String architecture = resources.getProcessorArchitecture(p);
            float speed = resources.getProcessorSpeed(p);
            String type = resources.getProcessorType(p);
            float internalMemory = resources.getProcessorMemorySize(p);
            ProcessorPropertyType procProp = resources.getProcessorProperty(p);
            String propKey = (procProp != null) ? procProp.getKey() : "";
            String propValue = (procProp != null) ? procProp.getValue() : "";
            mrd.addProcessor(procName, computingUnits, architecture, speed, type, internalMemory, propKey, propValue);
        }
    }
    mrd.setMemorySize(resources.getMemorySize(cn_resources));
    mrd.setMemoryType(resources.getMemoryType(cn_resources));
    mrd.setStorageSize(resources.getStorageSize(cn_resources));
    mrd.setStorageType(resources.getStorageType(cn_resources));
    mrd.setOperatingSystemType(resources.getOperatingSystemType(cn_resources));
    mrd.setOperatingSystemDistribution(resources.getOperatingSystemDistribution(cn_resources));
    mrd.setOperatingSystemVersion(resources.getOperatingSystemVersion(cn_resources));
    List<String> apps = resources.getApplications(cn_resources);
    if (apps != null) {
        for (String appName : apps) {
            mrd.addApplication(appName);
        }
    }
    es.bsc.compss.types.resources.jaxb.PriceType p = resources.getPrice(cn_resources);
    if (p != null) {
        mrd.setPriceTimeUnit(p.getTimeUnit());
        mrd.setPricePerUnit(p.getPricePerUnit());
    }
    // Add Shared Disks (Name, mountpoint)
    Map<String, String> sharedDisks = resources.getSharedDisks(cn_resources);
    if (sharedDisks != null) {
        List<String> declaredSharedDisks = resources.getSharedDisks_names();
        for (String diskName : sharedDisks.keySet()) {
            if (declaredSharedDisks == null || !declaredSharedDisks.contains(diskName)) {
                ErrorManager.warn("SharedDisk " + diskName + " defined in the ComputeNode " + name + " is not defined in the resources.xml. Skipping");
                sharedDisks.remove(diskName);
            // TODO: Check the disk information (size and type)
            }
        }
    }
    // Add the adaptors properties (queue types and adaptor properties)
    // TODO Support multiple adaptor properties
    String loadedAdaptor = System.getProperty(COMPSsConstants.COMM_ADAPTOR);
    List<String> queues_project = project.getAdaptorQueues(cn_project, loadedAdaptor);
    List<String> queues_resources = resources.getAdaptorQueues(cn_resources, loadedAdaptor);
    if (queues_project == null) {
        // Has no tag adaptors on project, get default resources complete
        for (String queue : queues_resources) {
            mrd.addHostQueue(queue);
        }
    } else {
        // Project defines a subset of queues
        for (String queue : queues_resources) {
            if (queues_project.contains(queue)) {
                mrd.addHostQueue(queue);
            }
        }
    }
    Object adaptorProperties_project = project.getAdaptorProperties(cn_project, loadedAdaptor);
    Object adaptorProperties_resources = resources.getAdaptorProperties(cn_resources, loadedAdaptor);
    MethodConfiguration config = null;
    try {
        config = (MethodConfiguration) Comm.constructConfiguration(loadedAdaptor, adaptorProperties_project, adaptorProperties_resources);
    } catch (ConstructConfigurationException cce) {
        ErrorManager.warn("Adaptor " + loadedAdaptor + " configuration constructor failed", cce);
        return false;
    }
    // If we have reached this point the config is SURELY not null
    /* Add properties given by the project file **************************************** */
    config.setHost(cn_project.getName());
    config.setUser(project.getUser(cn_project));
    config.setInstallDir(project.getInstallDir(cn_project));
    config.setWorkingDir(project.getWorkingDir(cn_project));
    int limitOfTasks = project.getLimitOfTasks(cn_project);
    if (limitOfTasks >= 0) {
        config.setLimitOfTasks(limitOfTasks);
    } else {
        config.setLimitOfTasks(mrd.getTotalCPUComputingUnits());
    }
    config.setTotalComputingUnits(mrd.getTotalCPUComputingUnits());
    config.setTotalGPUComputingUnits(mrd.getTotalGPUComputingUnits());
    config.setTotalFPGAComputingUnits(mrd.getTotalFPGAComputingUnits());
    config.setTotalOTHERComputingUnits(mrd.getTotalOTHERComputingUnits());
    ApplicationType app = project.getApplication(cn_project);
    if (app != null) {
        config.setAppDir(app.getAppDir());
        config.setLibraryPath(app.getLibraryPath());
        config.setClasspath(app.getClasspath());
        config.setPythonpath(app.getPythonpath());
    }
    /* Pass all the information to the ResourceManager to insert it into the Runtime ** */
    LOGGER.debug("Adding method worker " + name);
    MethodWorker methodWorker = createMethodWorker(name, mrd, sharedDisks, config);
    ResourceManager.addStaticResource(methodWorker);
    // If we have reached this point the method worker has been correctly created
    return true;
}
Also used : MethodWorker(es.bsc.compss.types.resources.MethodWorker) ConstructConfigurationException(es.bsc.compss.exceptions.ConstructConfigurationException) ProcessorPropertyType(es.bsc.compss.types.resources.jaxb.ProcessorPropertyType) es.bsc.compss.types.project.jaxb(es.bsc.compss.types.project.jaxb) MethodConfiguration(es.bsc.compss.types.resources.configuration.MethodConfiguration) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription)

Example 5 with ConstructConfigurationException

use of es.bsc.compss.exceptions.ConstructConfigurationException in project compss by bsc-wdc.

the class WSAdaptor method constructConfiguration.

@Override
public Configuration constructConfiguration(Object project_properties, Object resources_properties) throws ConstructConfigurationException {
    es.bsc.compss.types.project.jaxb.ServiceType s_project = (es.bsc.compss.types.project.jaxb.ServiceType) project_properties;
    es.bsc.compss.types.resources.jaxb.ServiceType s_resources = (es.bsc.compss.types.resources.jaxb.ServiceType) resources_properties;
    String wsdl = null;
    if (s_project != null) {
        wsdl = s_project.getWsdl();
    } else if (s_resources != null) {
        wsdl = s_resources.getWsdl();
    } else {
        // No wsdl (service unique key), throw exception
        throw new ConstructConfigurationException("Cannot configure service because no WSDL provided");
    }
    WSConfiguration config = new WSConfiguration(this.getClass().getName(), wsdl);
    if (s_project != null) {
        config.setLimitOfTasks(s_project.getLimitOfTasks());
    }
    if (s_resources != null) {
        config.setServiceName(s_resources.getName());
        config.setNamespace(s_resources.getNamespace());
        String servicePort = s_resources.getPort();
        if (servicePort != null && !servicePort.isEmpty()) {
            config.setPort(s_resources.getPort());
        }
        PriceType p = s_resources.getPrice();
        if (p != null) {
            config.setPricePerUnitTime(p.getPricePerUnit());
            config.setPriceUnitTime(p.getTimeUnit());
        }
    }
    return config;
}
Also used : ConstructConfigurationException(es.bsc.compss.exceptions.ConstructConfigurationException) WSConfiguration(es.bsc.compss.ws.master.configuration.WSConfiguration) PriceType(es.bsc.compss.types.resources.jaxb.PriceType)

Aggregations

ConstructConfigurationException (es.bsc.compss.exceptions.ConstructConfigurationException)7 es.bsc.compss.types.project.jaxb (es.bsc.compss.types.project.jaxb)2 MethodConfiguration (es.bsc.compss.types.resources.configuration.MethodConfiguration)2 GATConfiguration (es.bsc.compss.gat.master.configuration.GATConfiguration)1 NIOConfiguration (es.bsc.compss.nio.master.configuration.NIOConfiguration)1 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)1 MethodWorker (es.bsc.compss.types.resources.MethodWorker)1 ServiceResourceDescription (es.bsc.compss.types.resources.ServiceResourceDescription)1 ServiceWorker (es.bsc.compss.types.resources.ServiceWorker)1 ServiceConfiguration (es.bsc.compss.types.resources.configuration.ServiceConfiguration)1 CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)1 PriceType (es.bsc.compss.types.resources.jaxb.PriceType)1 ProcessorPropertyType (es.bsc.compss.types.resources.jaxb.ProcessorPropertyType)1 WSConfiguration (es.bsc.compss.ws.master.configuration.WSConfiguration)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1