Search in sources :

Example 11 with CloudImageDescription

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

the class CloudProvider method getResourceDescription.

public CloudMethodResourceDescription getResourceDescription(String instanceTypeName, String imageName) {
    CloudMethodResourceDescription result = null;
    CloudInstanceTypeDescription type = typeManager.getType(instanceTypeName);
    if (type != null) {
        CloudImageDescription image = imgManager.getImage(imageName);
        if (image != null) {
            result = new CloudMethodResourceDescription(type, image);
            result.setValue(cost.getMachineCostPerHour(result));
        } else {
            LOGGER.warn(WARN_NO_VALID_IMAGE);
        }
    } else {
        LOGGER.warn(WARN_NO_VALID_INSTANCE);
    }
    return result;
}
Also used : CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription)

Example 12 with CloudImageDescription

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

the class CloudMethodWorker method getMonitoringData.

@Override
public String getMonitoringData(String prefix) {
    StringBuilder sb = new StringBuilder();
    sb.append(prefix).append(super.getMonitoringData(prefix));
    String providerName = provider.getName();
    if (providerName == null) {
        providerName = "";
    }
    sb.append(prefix).append("<Provider>").append(providerName).append("</Provider>").append("\n");
    CloudImageDescription image = ((CloudMethodResourceDescription) description).getImage();
    String imageName = "";
    if (image != null) {
        imageName = image.getImageName();
    }
    sb.append(prefix).append("<Image>").append(imageName).append("</Image>").append("\n");
    return sb.toString();
}
Also used : CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription)

Example 13 with CloudImageDescription

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

the class CloudImageManager method getCompatibleImages.

/**
 * Finds all the images provided by the Cloud Provider which fulfill the resource description.
 *
 * @param requested
 *            description of the features that the image must provide
 * @return The best image provided by the Cloud Provider which fulfills the resource description
 */
public List<CloudImageDescription> getCompatibleImages(MethodResourceDescription requested) {
    // logger.debug("REQUESTED: " + requested.toString());
    List<CloudImageDescription> compatiblesList = new LinkedList<>();
    for (CloudImageDescription cid : images.values()) {
        // logger.debug("CID: " + cid.toString());
        // OS CHECK
        String imageOSType = cid.getOperatingSystemType();
        String reqOSType = requested.getOperatingSystemType();
        if (!imageOSType.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !reqOSType.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !imageOSType.equals(reqOSType)) {
            continue;
        }
        String imageOSDistr = cid.getOperatingSystemDistribution();
        String reqOSDistr = requested.getOperatingSystemDistribution();
        if (!imageOSDistr.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !reqOSDistr.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !imageOSDistr.equals(reqOSDistr)) {
            continue;
        }
        String imageOSVersion = cid.getOperatingSystemVersion();
        String reqOSVersion = requested.getOperatingSystemVersion();
        if (!imageOSVersion.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !reqOSVersion.equals(CloudMethodResourceDescription.UNASSIGNED_STR) && !imageOSVersion.equals(reqOSVersion)) {
            continue;
        }
        // SOFTWARE CHECK
        if (!cid.getAppSoftware().containsAll(requested.getAppSoftware())) {
            continue;
        }
        // CHECK QUEUES
        List<String> req_queues = requested.getHostQueues();
        List<String> image_queues = cid.getQueues();
        // Disjoint = true if the two specified collections have no elements in common.
        if (!req_queues.isEmpty() && Collections.disjoint(req_queues, image_queues)) {
            continue;
        }
        compatiblesList.add(cid);
    }
    return compatiblesList;
}
Also used : CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) LinkedList(java.util.LinkedList)

Example 14 with CloudImageDescription

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

the class CloudManagerTest method createProvider.

private static CloudProvider createProvider(CloudManager cm) {
    String providerName = "Provider" + (int) (Math.random() * 10000);
    Map<String, String> properties = new HashMap<>();
    CloudProvider cp = null;
    try {
        cp = cm.registerCloudProvider(providerName, 0, RUNTIME_CONNECTOR, null, null, properties);
    } catch (Exception e) {
        fail("Could not create the Cloud Provider");
    }
    String imageName = "IMAGE" + (int) (Math.random() * 10000);
    CloudImageDescription cid = new CloudImageDescription(imageName, new HashMap<>());
    cp.addCloudImage(cid);
    String typeName = "TYPE" + (int) (Math.random() * 10000);
    float type1Memory = (float) Math.random() * 5;
    MethodResourceDescription mrd1 = new MethodResourceDescription();
    mrd1.setMemorySize(type1Memory);
    CloudInstanceTypeDescription citd = new CloudInstanceTypeDescription(typeName, mrd1);
    cp.addInstanceType(citd);
    return cp;
}
Also used : HashMap(java.util.HashMap) CloudProvider(es.bsc.compss.types.CloudProvider) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription)

Example 15 with CloudImageDescription

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

the class ResourceManagerTest method addProvider.

private static CloudProvider addProvider() {
    String providerName = "Provider" + (int) (Math.random() * 10000);
    Map<String, String> properties = new HashMap<>();
    CloudProvider cp = null;
    try {
        cp = ResourceManager.registerCloudProvider(providerName, 0, RUNTIME_CONNECTOR, null, null, properties);
    } catch (Exception e) {
        fail("Could not create the Cloud Provider");
    }
    String imageName = "IMAGE" + (int) (Math.random() * 10000);
    CloudImageDescription cid = new CloudImageDescription(imageName, new HashMap<>());
    cp.addCloudImage(cid);
    String typeName = "TYPE" + (int) (Math.random() * 10000);
    float type1Memory = (float) Math.random() * 5;
    MethodResourceDescription mrd1 = new MethodResourceDescription();
    mrd1.setMemorySize(type1Memory);
    CloudInstanceTypeDescription citd = new CloudInstanceTypeDescription(typeName, mrd1);
    cp.addInstanceType(citd);
    return cp;
}
Also used : HashMap(java.util.HashMap) CloudProvider(es.bsc.compss.types.CloudProvider) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription)

Aggregations

CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)31 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)23 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)22 HashMap (java.util.HashMap)15 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)12 Test (org.junit.Test)12 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)9 FakeNode (es.bsc.compss.types.fake.FakeNode)7 CloudProvider (es.bsc.compss.types.CloudProvider)6 MethodConfiguration (es.bsc.compss.types.resources.configuration.MethodConfiguration)3 ConstructConfigurationException (es.bsc.compss.exceptions.ConstructConfigurationException)2 es.bsc.compss.types.project.jaxb (es.bsc.compss.types.project.jaxb)2 LinkedList (java.util.LinkedList)2 ConnectorException (es.bsc.compss.connectors.ConnectorException)1 NoResourceAvailableException (es.bsc.compss.exceptions.NoResourceAvailableException)1 ResourceCreationRequest (es.bsc.compss.types.ResourceCreationRequest)1 Implementation (es.bsc.compss.types.implementations.Implementation)1 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)1 ProjectFileValidationException (es.bsc.compss.types.project.exceptions.ProjectFileValidationException)1 ShutdownListener (es.bsc.compss.types.resources.ShutdownListener)1