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);
}
}
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);
}
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);
}
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);
}
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());
}
Aggregations