Search in sources :

Example 26 with CloudMethodResourceDescription

use of es.bsc.compss.types.resources.description.CloudMethodResourceDescription 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 27 with CloudMethodResourceDescription

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

the class ResourceManagerTest method createResourceDescriptionFromProvider.

private CloudMethodResourceDescription createResourceDescriptionFromProvider(CloudProvider cp1) {
    CloudImageDescription cid = null;
    CloudInstanceTypeDescription citd = null;
    for (String imageName : cp1.getAllImageNames()) {
        cid = cp1.getImage(imageName);
        break;
    }
    for (String instanceType : cp1.getAllInstanceTypeNames()) {
        citd = cp1.getInstanceType(instanceType);
        break;
    }
    return new CloudMethodResourceDescription(citd, cid);
}
Also used : CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription)

Example 28 with CloudMethodResourceDescription

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

the class ResourceManagerTest method testMultipleCloudWorkersOperations.

@Test
public void testMultipleCloudWorkersOperations() {
    ResourceManager.setCloudVMsBoundaries(3, 5, 8);
    CloudProvider cp1 = addProvider();
    CloudProvider cp2 = addProvider();
    CloudMethodResourceDescription cmrd1 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr1 = cp1.requestResourceCreation(cmrd1);
    CloudMethodResourceDescription cmrd2 = createResourceDescriptionFromProvider(cp2);
    ResourceCreationRequest rcr2 = cp2.requestResourceCreation(cmrd1);
    CloudMethodResourceDescription cmrd3 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr3 = cp1.requestResourceCreation(cmrd3);
    if (ResourceManager.getPendingCreationRequests().size() != 3 || !ResourceManager.getPendingCreationRequests().contains(rcr1) || !ResourceManager.getPendingCreationRequests().contains(rcr2) || !ResourceManager.getPendingCreationRequests().contains(rcr3)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    String vmName1 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw1 = new ExtendedCloudMethodWorker(vmName1, cp1, cmrd1, new FakeNode(vmName1), 0, new HashMap<>());
    ResourceManager.addCloudWorker(rcr1, cmw1, cmrd1);
    if (ResourceManager.getPendingCreationRequests().size() != 2 || ResourceManager.getPendingCreationRequests().contains(rcr1)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName1) != cmw1 || ResourceManager.getWorker(vmName1) != cmw1) {
        fail("ResourceManager is not properly adding the new cloud resources");
    }
    String vmName2 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw2 = new ExtendedCloudMethodWorker(vmName2, cp2, cmrd2, new FakeNode(vmName2), 0, new HashMap<>());
    ResourceManager.addCloudWorker(rcr2, cmw2, cmrd2);
    if (ResourceManager.getPendingCreationRequests().size() != 1 || ResourceManager.getPendingCreationRequests().contains(rcr2)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getDynamicResources().size() != 2 || ResourceManager.getAllWorkers().size() != 2 || ResourceManager.getDynamicResource(vmName2) != cmw2 || ResourceManager.getWorker(vmName2) != cmw2) {
        fail("ResourceManager is not properly adding the new cloud resources");
    }
    CloudMethodResourceDescription reduction1 = new CloudMethodResourceDescription(cmrd1);
    ResourceManager.reduceResource(cmw1, new PendingReduction<>(reduction1));
    ResourceManager.terminateCloudResource(cmw1, reduction1);
    if (ResourceManager.getPendingCreationRequests().size() != 1) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getCurrentVMCount() != 2) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName1) != null || ResourceManager.getWorker(vmName1) != null) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (!cmw1.isTerminated()) {
        fail("ResourceManager is not properly requesting the resource shutdown");
    }
    String vmName3 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw3 = new ExtendedCloudMethodWorker(vmName3, cp1, cmrd3, new FakeNode(vmName3), 0, new HashMap<>());
    ResourceManager.addCloudWorker(rcr3, cmw3, cmrd3);
    if (!ResourceManager.getPendingCreationRequests().isEmpty()) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getDynamicResources().size() != 2 || ResourceManager.getAllWorkers().size() != 2 || ResourceManager.getDynamicResource(vmName3) != cmw3 || ResourceManager.getWorker(vmName3) != cmw3) {
        fail("ResourceManager is not properly adding the new cloud resources");
    }
    CloudMethodResourceDescription reduction2 = new CloudMethodResourceDescription(cmrd2);
    ResourceManager.reduceResource(cmw2, new PendingReduction<>(reduction2));
    ResourceManager.terminateCloudResource(cmw2, reduction2);
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName2) != null || ResourceManager.getWorker(vmName2) != null) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (!cmw2.isTerminated()) {
        fail("ResourceManager is not properly requesting the resource shutdown");
    }
    if (ResourceManager.getCurrentVMCount() != 1) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    CloudMethodResourceDescription cmrd4 = createResourceDescriptionFromProvider(cp1);
    ResourceCreationRequest rcr4 = cp1.requestResourceCreation(cmrd4);
    if (ResourceManager.getPendingCreationRequests().size() != 1 || !ResourceManager.getPendingCreationRequests().contains(rcr4)) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getCurrentVMCount() != 2) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
        if (entry.getValue()[0] != 1) {
            fail("ResourceManager is not properly keeping track of the amount of instances of each type");
        }
    }
    ResourceManager.increasedCloudWorker(rcr4, cmw3, cmrd4);
    if (!ResourceManager.getPendingCreationRequests().isEmpty()) {
        fail("ResourceManager is not properly registering the pending resouce creations");
    }
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName3) != cmw3 || ResourceManager.getWorker(vmName3) != cmw3) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (ResourceManager.getCurrentVMCount() != 2) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
        if (entry.getValue()[0] != 2) {
            fail("ResourceManager is not properly keeping track of the amount of instances of each type");
        }
    }
    CloudMethodResourceDescription reduction4 = new CloudMethodResourceDescription(cmrd4);
    ResourceManager.reduceResource(cmw3, new PendingReduction<>(reduction4));
    ResourceManager.terminateCloudResource(cmw3, reduction4);
    if (ResourceManager.getDynamicResources().size() != 1 || ResourceManager.getAllWorkers().size() != 1 || ResourceManager.getDynamicResource(vmName3) != cmw3 || ResourceManager.getWorker(vmName3) != cmw3) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (ResourceManager.getCurrentVMCount() != 1) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
        if (entry.getValue()[0] != 1) {
            fail("ResourceManager is not properly keeping track of the amount of instances of each type");
        }
    }
    CloudMethodResourceDescription reduction3 = new CloudMethodResourceDescription(cmrd3);
    ResourceManager.reduceResource(cmw3, new PendingReduction<>(reduction3));
    ResourceManager.terminateCloudResource(cmw3, reduction3);
    if (!ResourceManager.getDynamicResources().isEmpty() || !ResourceManager.getAllWorkers().isEmpty() || ResourceManager.getDynamicResource(vmName3) != null || ResourceManager.getWorker(vmName3) != null) {
        fail("ResourceManager is not properly removing the new cloud resources");
    }
    if (ResourceManager.getCurrentVMCount() != 0) {
        fail("ResourceManager is not properly keeping track of the created VMs");
    }
    for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> entry : cmw3.getDescription().getTypeComposition().entrySet()) {
        if (entry.getValue()[0] != 0) {
            fail("ResourceManager is not properly keeping track of the amount of instances of each type");
        }
    }
}
Also used : ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest) CloudProvider(es.bsc.compss.types.CloudProvider) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) HashMap(java.util.HashMap) Map(java.util.Map) ExtendedCloudMethodWorker(es.bsc.compss.types.ExtendedCloudMethodWorker) FakeNode(es.bsc.compss.types.fake.FakeNode) Test(org.junit.Test)

Example 29 with CloudMethodResourceDescription

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

the class Converter method toCloudMethodResourceDescription.

/**
 *********************************************************************
 ************************ CONN TO COMPSs *****************************
 * *********************************************************************
 */
/**
 * @param vr
 * @param requested
 * @return
 */
public static CloudMethodResourceDescription toCloudMethodResourceDescription(VirtualResource vr, CloudMethodResourceDescription requested) {
    CloudMethodResourceDescription cmrd = new CloudMethodResourceDescription();
    cmrd.setName(vr.getIp());
    setHardwareInResourceDescription(cmrd, vr.getHd(), requested);
    setSoftwareInResourceDescription(cmrd, vr.getSd(), requested);
    CloudImageDescription cid = getCloudImageDescription(vr.getHd(), vr.getSd(), requested);
    cmrd.setImage(cid);
    return cmrd;
}
Also used : CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription)

Example 30 with CloudMethodResourceDescription

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

the class ResourceOptimizer method getUnfulfilledConstraints.

// Removes from the list all the Constraints fulfilled by existing
// resources
@SuppressWarnings("unchecked")
private static List<ConstraintsCore>[] getUnfulfilledConstraints() {
    int coreCount = CoreManager.getCoreCount();
    List<ConstraintsCore>[] unfulfilledConstraints = new LinkedList[coreCount];
    int[] maxSimTasks = ResourceManager.getTotalSlots();
    for (int coreId = 0; coreId < coreCount; coreId++) {
        unfulfilledConstraints[coreId] = new LinkedList<>();
        if (maxSimTasks[coreId] == 0) {
            List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
            for (Implementation impl : impls) {
                if (impl.getTaskType() == TaskType.METHOD) {
                    MethodResourceDescription requirements = (MethodResourceDescription) impl.getRequirements();
                    CloudMethodResourceDescription cd = new CloudMethodResourceDescription(requirements);
                    ConstraintsCore cc = new ConstraintsCore(cd, coreId, unfulfilledConstraints[coreId]);
                    unfulfilledConstraints[coreId].add(cc);
                }
            }
        }
    }
    return unfulfilledConstraints;
}
Also used : CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) LinkedList(java.util.LinkedList) List(java.util.List) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) LinkedList(java.util.LinkedList) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation)

Aggregations

CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)45 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)23 CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)21 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)16 HashMap (java.util.HashMap)14 Test (org.junit.Test)14 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)12 FakeNode (es.bsc.compss.types.fake.FakeNode)11 CloudProvider (es.bsc.compss.types.CloudProvider)9 ResourceCreationRequest (es.bsc.compss.types.ResourceCreationRequest)7 Implementation (es.bsc.compss.types.implementations.Implementation)5 ConnectorException (es.bsc.compss.connectors.ConnectorException)4 ExtendedCloudMethodWorker (es.bsc.compss.types.ExtendedCloudMethodWorker)4 Map (java.util.Map)4 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)3 VM (es.bsc.compss.connectors.VM)2 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)2 PerformedIncrease (es.bsc.compss.types.resources.updates.PerformedIncrease)2 VirtualResource (es.bsc.conn.types.VirtualResource)2 LinkedList (java.util.LinkedList)2