Search in sources :

Example 6 with ConstructConfigurationException

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

the class Comm method constructConfiguration.

/**
 * Initializes the internal adaptor and constructs a comm configuration
 *
 * @param adaptorName
 * @param project_properties
 * @param resources_properties
 * @return
 * @throws ConstructConfigurationException
 */
public static Configuration constructConfiguration(String adaptorName, Object project_properties, Object resources_properties) throws ConstructConfigurationException {
    // Check if adaptor has already been used
    CommAdaptor adaptor = adaptors.get(adaptorName);
    if (adaptor == null) {
        // Create a new adaptor instance
        try {
            Constructor<?> constrAdaptor = Class.forName(adaptorName).getConstructor();
            adaptor = (CommAdaptor) constrAdaptor.newInstance();
        } catch (NoSuchMethodException | SecurityException | ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            throw new ConstructConfigurationException(e);
        }
        // Initialize adaptor
        adaptor.init();
        // Add adaptor to used adaptors
        adaptors.put(adaptorName, adaptor);
    }
    if (DEBUG) {
        LOGGER.debug("Adaptor Name: " + adaptorName);
    }
    // Construct properties
    return adaptor.constructConfiguration(project_properties, resources_properties);
}
Also used : ConstructConfigurationException(es.bsc.compss.exceptions.ConstructConfigurationException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 7 with ConstructConfigurationException

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

the class ResourceLoader method createImage.

private static CloudImageDescription createImage(ImageType im_project, es.bsc.compss.types.resources.jaxb.ImageType im_resources, Map<String, String> properties) {
    String imageName = im_project.getName();
    LOGGER.debug("Loading Image" + imageName);
    CloudImageDescription cid = new CloudImageDescription(imageName, properties);
    /* Add properties given by the resources file **************************************** */
    cid.setOperatingSystemType(resources.getOperatingSystemType(im_resources));
    cid.setOperatingSystemDistribution(resources.getOperatingSystemDistribution(im_resources));
    cid.setOperatingSystemVersion(resources.getOperatingSystemVersion(im_resources));
    List<String> apps = resources.getApplications(im_resources);
    if (apps != null) {
        for (String appName : apps) {
            cid.addApplication(appName);
        }
    }
    es.bsc.compss.types.resources.jaxb.PriceType p = resources.getPrice(im_resources);
    if (p != null) {
        cid.setPriceTimeUnit(p.getTimeUnit());
        cid.setPricePerUnit(p.getPricePerUnit());
    }
    cid.setCreationTime(resources.getCreationTime(im_resources));
    // Add Shared Disks (Name, mountpoint)
    Map<String, String> sharedDisks = resources.getSharedDisks(im_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 Image " + imageName + " is not defined in the resources.xml. Skipping");
                sharedDisks.remove(diskName);
            // TODO: Check the disk information (size and type)
            }
        }
    }
    cid.setSharedDisks(sharedDisks);
    // 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(im_project, loadedAdaptor);
    List<String> queues_resources = resources.getAdaptorQueues(im_resources, loadedAdaptor);
    for (String queue : queues_resources) {
        if (queues_project.contains(queue)) {
            cid.addQueue(queue);
        }
    }
    Object adaptorProperties_project = project.getAdaptorProperties(im_project, loadedAdaptor);
    Object adaptorProperties_resources = resources.getAdaptorProperties(im_resources, loadedAdaptor);
    MethodConfiguration config = null;
    try {
        config = (MethodConfiguration) Comm.constructConfiguration(loadedAdaptor, adaptorProperties_project, adaptorProperties_resources);
    } catch (ConstructConfigurationException cce) {
        ErrorManager.warn("Adaptor configuration constructor failed", cce);
        return null;
    }
    // If we have reached this point the mp is SURELY not null
    /* Add properties given by the project file **************************************** */
    config.setHost(im_project.getName());
    config.setUser(project.getUser(im_project));
    config.setInstallDir(project.getInstallDir(im_project));
    config.setWorkingDir(project.getWorkingDir(im_project));
    config.setLimitOfTasks(project.getLimitOfTasks(im_project));
    ApplicationType app = project.getApplication(im_project);
    if (app != null) {
        config.setAppDir(app.getAppDir());
        config.setLibraryPath(app.getLibraryPath());
        config.setClasspath(app.getClasspath());
        config.setPythonpath(app.getClasspath());
    }
    List<PackageType> packages = project.getPackages(im_project);
    for (PackageType pack : packages) {
        cid.addPackage(pack.getSource(), pack.getTarget());
        SoftwareListType software = pack.getIncludedSoftware();
        if (software != null) {
            cid.addAllApplications(software.getApplication());
        }
    }
    // Add configuration to image
    cid.setConfig(config);
    return cid;
}
Also used : CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) ConstructConfigurationException(es.bsc.compss.exceptions.ConstructConfigurationException) es.bsc.compss.types.project.jaxb(es.bsc.compss.types.project.jaxb) MethodConfiguration(es.bsc.compss.types.resources.configuration.MethodConfiguration)

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