Search in sources :

Example 1 with ProcessorPropertyType

use of es.bsc.compss.types.resources.jaxb.ProcessorPropertyType in project compss by bsc-wdc.

the class ResourceLoader method createInstance.

private static CloudInstanceTypeDescription createInstance(es.bsc.compss.types.resources.jaxb.InstanceTypeType instance) {
    // Add the name
    // String name = instance.getName();
    String type = instance.getName();
    MethodResourceDescription mrd = new MethodResourceDescription();
    List<es.bsc.compss.types.resources.jaxb.ProcessorType> processors = resources.getProcessors(instance);
    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 procType = 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, procType, internalMemory, propKey, propValue);
        }
    }
    mrd.setMemorySize(resources.getMemorySize(instance));
    mrd.setMemoryType(resources.getMemoryType(instance));
    mrd.setStorageSize(resources.getStorageSize(instance));
    mrd.setStorageType(resources.getStorageType(instance));
    es.bsc.compss.types.resources.jaxb.PriceType p = resources.getPrice(instance);
    if (p != null) {
        mrd.setPriceTimeUnit(p.getTimeUnit());
        mrd.setPricePerUnit(p.getPricePerUnit());
    }
    return new CloudInstanceTypeDescription(type, mrd);
}
Also used : ProcessorPropertyType(es.bsc.compss.types.resources.jaxb.ProcessorPropertyType) es.bsc.compss.types.project.jaxb(es.bsc.compss.types.project.jaxb) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription)

Example 2 with ProcessorPropertyType

use of es.bsc.compss.types.resources.jaxb.ProcessorPropertyType 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 3 with ProcessorPropertyType

use of es.bsc.compss.types.resources.jaxb.ProcessorPropertyType in project compss by bsc-wdc.

the class ResourcesFileTest method staticProcessorAdaptorComputeNodeCreationAndRead.

@Test
public void staticProcessorAdaptorComputeNodeCreationAndRead() throws SAXException, JAXBException, ResourcesFileValidationException {
    int cu = 5;
    float speed = 2.6f;
    String nodeName = "blablahost";
    String procName = "Proc1";
    String arch = "amd64";
    String key = "procKey";
    String value = "procValue";
    String adaptorName = "nio";
    boolean batch = false;
    boolean interactive = true;
    String gatprop = "gat_prop";
    String user = "user";
    ProcessorPropertyType pp = ResourcesFile.createProcessorProperty(key, value);
    ProcessorType proc = ResourcesFile.createProcessor(procName, cu, arch, speed, "CPU", 0.0f, pp);
    AdaptorType ad = ResourcesFile.createAdaptor(adaptorName, batch, null, interactive, gatprop, user);
    String xsd_path = new File(SCHEMA_PATH).toURI().getPath();
    // Instantiate ResourcesFile
    ResourcesFile resources = new ResourcesFile(xsd_path, LOGGER);
    List<ProcessorType> processors = new LinkedList<ProcessorType>();
    processors.add(proc);
    List<AdaptorType> adaptors = new LinkedList<AdaptorType>();
    adaptors.add(ad);
    resources.addComputeNode(nodeName, processors, adaptors);
    ComputeNodeType cn = resources.getComputeNode(nodeName);
    ProcessorType procExtracted = resources.getProcessors(cn).get(0);
    assertEquals(procName, procExtracted.getName());
    assertEquals(cu, resources.getProcessorComputingUnits(procExtracted));
    assertEquals(arch, resources.getProcessorArchitecture(procExtracted));
    assertEquals(speed, resources.getProcessorSpeed(procExtracted), 0);
    assertEquals("CPU", resources.getProcessorType(procExtracted));
    assertEquals(-1.0f, resources.getProcessorMemorySize(procExtracted), 0);
    assertEquals(key, resources.getProcessorProperty(procExtracted).getKey());
    assertEquals(value, resources.getProcessorProperty(procExtracted).getValue());
}
Also used : AdaptorType(es.bsc.compss.types.resources.jaxb.AdaptorType) ComputeNodeType(es.bsc.compss.types.resources.jaxb.ComputeNodeType) ProcessorType(es.bsc.compss.types.resources.jaxb.ProcessorType) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) ProcessorPropertyType(es.bsc.compss.types.resources.jaxb.ProcessorPropertyType) LinkedList(java.util.LinkedList) File(java.io.File) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) Test(org.junit.Test)

Aggregations

ProcessorPropertyType (es.bsc.compss.types.resources.jaxb.ProcessorPropertyType)3 es.bsc.compss.types.project.jaxb (es.bsc.compss.types.project.jaxb)2 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)2 ConstructConfigurationException (es.bsc.compss.exceptions.ConstructConfigurationException)1 MethodWorker (es.bsc.compss.types.resources.MethodWorker)1 ResourcesFile (es.bsc.compss.types.resources.ResourcesFile)1 MethodConfiguration (es.bsc.compss.types.resources.configuration.MethodConfiguration)1 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)1 AdaptorType (es.bsc.compss.types.resources.jaxb.AdaptorType)1 ComputeNodeType (es.bsc.compss.types.resources.jaxb.ComputeNodeType)1 ProcessorType (es.bsc.compss.types.resources.jaxb.ProcessorType)1 File (java.io.File)1 LinkedList (java.util.LinkedList)1 Test (org.junit.Test)1