Search in sources :

Example 11 with ResourcesFile

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

the class ResourceLoader method loadFiles.

private static void loadFiles() throws ResourcesFileValidationException, ProjectFileValidationException {
    LOGGER.info("ResourceLoader loading files");
    // Load resources
    try {
        LOGGER.debug("ResourceLoader loading resources.xml");
        ResourceLoader.resources = new ResourcesFile(new File(resources_XML), resources_XSD, LOGGER);
    } catch (SAXException | JAXBException e) {
        throw new ResourcesFileValidationException(e);
    }
    // Load project
    try {
        LOGGER.debug("ResourceLoader loading project.xml");
        ResourceLoader.project = new ProjectFile(new File(project_XML), project_XSD, LOGGER);
    } catch (SAXException | JAXBException e) {
        throw new ProjectFileValidationException(e);
    }
}
Also used : ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) JAXBException(javax.xml.bind.JAXBException) ResourcesFileValidationException(es.bsc.compss.types.resources.exceptions.ResourcesFileValidationException) ProjectFile(es.bsc.compss.types.project.ProjectFile) ProjectFileValidationException(es.bsc.compss.types.project.exceptions.ProjectFileValidationException) ProjectFile(es.bsc.compss.types.project.ProjectFile) File(java.io.File) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) SAXException(org.xml.sax.SAXException)

Example 12 with ResourcesFile

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

the class ResourcesFileTest method creation_XMLstring_XSDschema.

@Test
public void creation_XMLstring_XSDschema() throws URISyntaxException, JAXBException, SAXException, ResourcesFileValidationException {
    // Instantiate XSD Schema
    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema xsd = sf.newSchema(new File(SCHEMA_PATH));
    // Get default resources file
    String defaultResources = buildXMLString();
    // Instantiate ResourcesFile
    ResourcesFile resources = new ResourcesFile(defaultResources, xsd, LOGGER);
    // Checkers
    assertNotNull(resources);
    int numWorkers_byName = resources.getComputeNodes_names().size();
    assertEquals("Should have a worker", numWorkers_byName, 1);
    int numWorkers_byList = resources.getComputeNodes_list().size();
    assertEquals("Should have a worker", numWorkers_byList, 1);
    int numWorkers_byHashMap = resources.getComputeNodes_hashMap().size();
    assertEquals("Should have a worker", numWorkers_byHashMap, 1);
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) Schema(javax.xml.validation.Schema) File(java.io.File) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) Test(org.junit.Test)

Example 13 with ResourcesFile

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

the class ResourcesFileTest method XMLtoString.

@Test
public void XMLtoString() throws URISyntaxException, SAXException, JAXBException, ResourcesFileValidationException {
    // Get XSD Schema path
    String xsd_path = new File(SCHEMA_PATH).toURI().getPath();
    // Get default resources file
    File defaultResources = new File(DEFAULT_XML_PATH);
    // Instantiate ResourcesFile
    ResourcesFile resources = new ResourcesFile(defaultResources, xsd_path, LOGGER);
    // Checkers
    assertNotNull(resources);
    String real_xml = resources.getString();
    String ideal_xml = buildXMLString();
    assertEquals("To string method doesn't produce the correct dump", real_xml, ideal_xml);
}
Also used : ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) File(java.io.File) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) Test(org.junit.Test)

Example 14 with ResourcesFile

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

the class ResourcesFileTest method creation_XMLfile_XSDschema.

/*
     * *************************************************************** 
     * CONSTRUCTOR TESTS
     ***************************************************************/
@Test
public void creation_XMLfile_XSDschema() throws URISyntaxException, JAXBException, SAXException, ResourcesFileValidationException {
    // Instantiate XSD Schema
    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema xsd = sf.newSchema(new File(SCHEMA_PATH));
    // Get default resources file
    File defaultResources = new File(DEFAULT_XML_PATH);
    // Instantiate ResourcesFile
    ResourcesFile resources = new ResourcesFile(defaultResources, xsd, LOGGER);
    // Checkers
    assertNotNull(resources);
    int numWorkers_byName = resources.getComputeNodes_names().size();
    assertEquals("Should have a worker", numWorkers_byName, 1);
    int numWorkers_byList = resources.getComputeNodes_list().size();
    assertEquals("Should have a worker", numWorkers_byList, 1);
    int numWorkers_byHashMap = resources.getComputeNodes_hashMap().size();
    assertEquals("Should have a worker", numWorkers_byHashMap, 1);
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) Schema(javax.xml.validation.Schema) File(java.io.File) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) Test(org.junit.Test)

Example 15 with ResourcesFile

use of es.bsc.compss.types.resources.ResourcesFile 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

ResourcesFile (es.bsc.compss.types.resources.ResourcesFile)15 File (java.io.File)15 Test (org.junit.Test)14 ComputeNodeType (es.bsc.compss.types.resources.jaxb.ComputeNodeType)3 ProcessorType (es.bsc.compss.types.resources.jaxb.ProcessorType)3 Schema (javax.xml.validation.Schema)2 SchemaFactory (javax.xml.validation.SchemaFactory)2 ProjectFile (es.bsc.compss.types.project.ProjectFile)1 ProjectFileValidationException (es.bsc.compss.types.project.exceptions.ProjectFileValidationException)1 ResourcesFileValidationException (es.bsc.compss.types.resources.exceptions.ResourcesFileValidationException)1 AdaptorType (es.bsc.compss.types.resources.jaxb.AdaptorType)1 ProcessorPropertyType (es.bsc.compss.types.resources.jaxb.ProcessorPropertyType)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 JAXBException (javax.xml.bind.JAXBException)1 SAXException (org.xml.sax.SAXException)1