Search in sources :

Example 1 with ProcessorType

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

the class ResourcesFileTest method computeNodeCreationWithGATAndRead.

@Test
public void computeNodeCreationWithGATAndRead() 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";
    float memSize = 32.5f;
    float storageSize = 256.0f;
    String osType = OSTypeType.LINUX.value();
    String adaptorName = "gat";
    // int minPort = 20;
    // int maxPort = 40;
    // String executor ="ssh";
    boolean batch = true;
    String queue = "default";
    List<String> queues = new ArrayList<String>();
    queues.add(queue);
    boolean interactive = true;
    String gatprop = "sshtrillead";
    String user = "user";
    String xsd_path = new File(SCHEMA_PATH).toURI().getPath();
    // Instantiate ResourcesFile
    ResourcesFile resources = new ResourcesFile(xsd_path, LOGGER);
    resources.addComputeNode(nodeName, procName, cu, arch, speed, null, -1f, ResourcesFile.createProcessorProperty(key, value), adaptorName, batch, queues, interactive, gatprop, user, memSize, null, storageSize, null, osType, null, null);
    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(key, resources.getProcessorProperty(procExtracted).getKey());
    assertEquals(value, resources.getProcessorProperty(procExtracted).getValue());
    assertEquals(memSize, resources.getMemorySize(cn), 0);
    assertEquals(storageSize, resources.getStorageSize(cn), 0);
    assertEquals(osType, resources.getOperatingSystemType(cn));
    assertEquals(String.class, resources.getAdaptorProperties(cn, adaptorName).getClass());
    assertEquals(gatprop, resources.getAdaptorProperties(cn, adaptorName));
    assertEquals(queue, resources.getAdaptorQueues(cn, adaptorName).get(0));
}
Also used : ComputeNodeType(es.bsc.compss.types.resources.jaxb.ComputeNodeType) ProcessorType(es.bsc.compss.types.resources.jaxb.ProcessorType) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) ArrayList(java.util.ArrayList) File(java.io.File) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) Test(org.junit.Test)

Example 2 with ProcessorType

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

the class ResourcesFileTest method computeNodeCreationWithNIOAndRead.

@Test
public void computeNodeCreationWithNIOAndRead() throws SAXException, JAXBException, ResourcesFileValidationException {
    int cu = 5;
    float speed = 2.6f;
    String nodeName = "blablahost";
    String procName = "Proc1";
    String arch = "amd64";
    String type = "GPU";
    float internalMemorySize = 0.01f;
    String key = "procKey";
    String value = "procValue";
    float memSize = 32.5f;
    float storageSize = 256.0f;
    String osType = OSTypeType.LINUX.value();
    String adaptorName = "nio";
    int minPort = 20;
    int maxPort = 40;
    String executor = "ssh";
    // boolean batch = true;
    // String queue = "default";
    // boolean interactive = true;
    // String gatprop = "sshtrillead";
    String user = "user";
    String xsd_path = new File(SCHEMA_PATH).toURI().getPath();
    // Instantiate ResourcesFile
    ResourcesFile resources = new ResourcesFile(xsd_path, LOGGER);
    resources.addComputeNode(nodeName, procName, cu, arch, speed, type, internalMemorySize, ResourcesFile.createProcessorProperty(key, value), adaptorName, maxPort, minPort, executor, user, memSize, null, storageSize, null, osType, null, null);
    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(type, resources.getProcessorType(procExtracted));
    assertEquals(internalMemorySize, resources.getProcessorMemorySize(procExtracted), 0);
    assertEquals(key, resources.getProcessorProperty(procExtracted).getKey());
    assertEquals(value, resources.getProcessorProperty(procExtracted).getValue());
    assertEquals(memSize, resources.getMemorySize(cn), 0);
    assertEquals(storageSize, resources.getStorageSize(cn), 0);
    assertEquals(osType, resources.getOperatingSystemType(cn));
    assertEquals(NIOAdaptorProperties.class, resources.getAdaptorProperties(cn, adaptorName).getClass());
    assertEquals(minPort, ((NIOAdaptorProperties) resources.getAdaptorProperties(cn, adaptorName)).getMinPort());
    assertEquals(maxPort, ((NIOAdaptorProperties) resources.getAdaptorProperties(cn, adaptorName)).getMaxPort());
    assertEquals(executor, ((NIOAdaptorProperties) resources.getAdaptorProperties(cn, adaptorName)).getRemoteExecutionCommand());
}
Also used : ComputeNodeType(es.bsc.compss.types.resources.jaxb.ComputeNodeType) ProcessorType(es.bsc.compss.types.resources.jaxb.ProcessorType) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) File(java.io.File) ResourcesFile(es.bsc.compss.types.resources.ResourcesFile) Test(org.junit.Test)

Example 3 with ProcessorType

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

the class Validator method validateInstance.

private void validateInstance(InstanceTypeType instance) throws InvalidElementException {
    // Validate inner elements
    List<Object> innerElements = instance.getProcessorOrMemoryOrStorage();
    if (innerElements != null) {
        List<String> processorNames = new ArrayList<String>();
        boolean processorTagFound = false;
        boolean memoryTagFound = false;
        boolean storageTagFound = false;
        boolean priceTagFound = false;
        for (Object obj : innerElements) {
            if (obj instanceof ProcessorType) {
                processorTagFound = true;
                ProcessorType p = (ProcessorType) obj;
                if (processorNames.contains(p.getName())) {
                    throw new InvalidElementException("Instance", "Attribute Processor " + p.getName(), "Appears more than once");
                } else {
                    processorNames.add(p.getName());
                    validateProcessor(((ProcessorType) obj));
                }
            } else if (obj instanceof MemoryType) {
                if (memoryTagFound) {
                    throw new InvalidElementException("Instance", "Attribute Memory", "Appears more than once");
                } else {
                    memoryTagFound = true;
                    validateMemory(((MemoryType) obj));
                }
            } else if (obj instanceof StorageType) {
                if (storageTagFound) {
                    throw new InvalidElementException("Instance", "Attribute Storage", "Appears more than once");
                } else {
                    storageTagFound = true;
                    validateStorage(((StorageType) obj));
                }
            } else if (obj instanceof PriceType) {
                if (priceTagFound) {
                    throw new InvalidElementException("Instance", "Attribute Price", "Appears more than once");
                } else {
                    priceTagFound = true;
                    validatePrice(((PriceType) obj));
                }
            } else {
                throw new InvalidElementException("Instance", "Attribute " + obj.getClass(), "Incorrect attribute");
            }
        }
        // Check minimum appearences
        if (!processorTagFound) {
            throw new InvalidElementException("Insntace", "Attribute Processor", "Doesn't appear");
        }
    } else {
        // Empty inner elements
        throw new InvalidElementException("InstanceType", "", "Content is empty");
    }
}
Also used : StorageType(es.bsc.compss.types.resources.jaxb.StorageType) ProcessorType(es.bsc.compss.types.resources.jaxb.ProcessorType) ArrayList(java.util.ArrayList) InvalidElementException(es.bsc.compss.types.resources.exceptions.InvalidElementException) PriceType(es.bsc.compss.types.resources.jaxb.PriceType) MemoryType(es.bsc.compss.types.resources.jaxb.MemoryType)

Example 4 with ProcessorType

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

the class Validator method validateComputeNode.

/**
 * Validates the given ComputeNodeType @cn with the current ResourcesFileType The content is correct if no exception
 * is raised
 *
 * @param cn
 * @throws InvalidElementException
 */
public void validateComputeNode(ComputeNodeType cn) throws InvalidElementException {
    // Check that name isn't used
    int num = 0;
    for (String c : rf.getComputeNodes_names()) {
        if (c.equals(cn.getName())) {
            num = num + 1;
        }
    }
    if (num > 1) {
        // ComputeNode already exists
        throw new InvalidElementException("ComputeNode", cn.getName(), "Name already in use");
    }
    // Check inner elements
    List<Object> innerElements = cn.getProcessorOrAdaptorsOrMemory();
    if (innerElements != null) {
        List<String> processorNames = new ArrayList<String>();
        boolean processorTagFound = false;
        boolean adaptorsTagFound = false;
        boolean memoryTagFound = false;
        boolean storageTagFound = false;
        boolean osTagFound = false;
        boolean softwareTagFound = false;
        boolean sharedDisksTagFound = false;
        boolean priceTagFound = false;
        for (Object obj : innerElements) {
            if (obj instanceof ProcessorType) {
                ProcessorType p = (ProcessorType) obj;
                if (processorNames.contains(p.getName())) {
                    throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute Processor" + p.getName(), "Appears more than once");
                } else {
                    processorTagFound = true;
                    processorNames.add(p.getName());
                    validateProcessor(p);
                }
            } else if (obj instanceof AdaptorsListType) {
                if (adaptorsTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
                } else {
                    adaptorsTagFound = true;
                    validateAdaptors(((AdaptorsListType) obj));
                }
            } else if (obj instanceof MemoryType) {
                if (memoryTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
                } else {
                    memoryTagFound = true;
                    validateMemory(((MemoryType) obj));
                }
            } else if (obj instanceof StorageType) {
                if (storageTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
                } else {
                    storageTagFound = true;
                    validateStorage(((StorageType) obj));
                }
            } else if (obj instanceof OSType) {
                if (osTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
                } else {
                    osTagFound = true;
                    validateOS(((OSType) obj));
                }
            } else if (obj instanceof SoftwareListType) {
                if (softwareTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
                } else {
                    softwareTagFound = true;
                    validateSoftwareList(((SoftwareListType) obj));
                }
            } else if (obj instanceof AttachedDisksListType) {
                if (sharedDisksTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
                } else {
                    sharedDisksTagFound = true;
                    validateAttachedDisksList(((AttachedDisksListType) obj));
                }
            } else if (obj instanceof PriceType) {
                if (priceTagFound) {
                    // Second occurency, throw exception
                    throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Appears more than once");
                } else {
                    priceTagFound = true;
                    validatePrice(((PriceType) obj));
                }
            } else {
                throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute " + obj.getClass(), "Incorrect attribute");
            }
        }
        // Check minimum appearences
        if (!processorTagFound) {
            throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute Processor", "Doesn't appear");
        }
        if (!adaptorsTagFound) {
            throw new InvalidElementException("ComputeNode " + cn.getName(), "Attribute Adaptors", "Doesn't appear");
        }
    } else {
        // Empty inner elements
        throw new InvalidElementException("ComputeNode " + cn.getName(), "", "Content is empty");
    }
}
Also used : AdaptorsListType(es.bsc.compss.types.resources.jaxb.AdaptorsListType) StorageType(es.bsc.compss.types.resources.jaxb.StorageType) ProcessorType(es.bsc.compss.types.resources.jaxb.ProcessorType) ArrayList(java.util.ArrayList) SoftwareListType(es.bsc.compss.types.resources.jaxb.SoftwareListType) OSType(es.bsc.compss.types.resources.jaxb.OSType) AttachedDisksListType(es.bsc.compss.types.resources.jaxb.AttachedDisksListType) InvalidElementException(es.bsc.compss.types.resources.exceptions.InvalidElementException) PriceType(es.bsc.compss.types.resources.jaxb.PriceType) MemoryType(es.bsc.compss.types.resources.jaxb.MemoryType)

Example 5 with ProcessorType

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

ProcessorType (es.bsc.compss.types.resources.jaxb.ProcessorType)5 ResourcesFile (es.bsc.compss.types.resources.ResourcesFile)3 ComputeNodeType (es.bsc.compss.types.resources.jaxb.ComputeNodeType)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 InvalidElementException (es.bsc.compss.types.resources.exceptions.InvalidElementException)2 MemoryType (es.bsc.compss.types.resources.jaxb.MemoryType)2 PriceType (es.bsc.compss.types.resources.jaxb.PriceType)2 StorageType (es.bsc.compss.types.resources.jaxb.StorageType)2 AdaptorType (es.bsc.compss.types.resources.jaxb.AdaptorType)1 AdaptorsListType (es.bsc.compss.types.resources.jaxb.AdaptorsListType)1 AttachedDisksListType (es.bsc.compss.types.resources.jaxb.AttachedDisksListType)1 OSType (es.bsc.compss.types.resources.jaxb.OSType)1 ProcessorPropertyType (es.bsc.compss.types.resources.jaxb.ProcessorPropertyType)1 SoftwareListType (es.bsc.compss.types.resources.jaxb.SoftwareListType)1 LinkedList (java.util.LinkedList)1