Search in sources :

Example 41 with MethodResourceDescription

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

the class ResourceManager method increasedCloudWorker.

/**
 * Increases the capabilities of a given cloud worker
 *
 * @param origin
 * @param worker
 * @param extension
 */
public static void increasedCloudWorker(ResourceCreationRequest origin, CloudMethodWorker worker, CloudMethodResourceDescription extension) {
    synchronized (pool) {
        CloudProvider cloudProvider = origin.getProvider();
        cloudProvider.confirmedCreation(origin, worker, extension);
        int[] maxTaskCount = worker.getSimultaneousTasks();
        for (int coreId = 0; coreId < maxTaskCount.length; coreId++) {
            poolCoreMaxConcurrentTasks[coreId] -= maxTaskCount[coreId];
        }
        worker.increaseFeatures(extension);
        maxTaskCount = worker.getSimultaneousTasks();
        for (int coreId = 0; coreId < maxTaskCount.length; coreId++) {
            poolCoreMaxConcurrentTasks[coreId] += maxTaskCount[coreId];
        }
        pool.defineCriticalSet();
    }
    ResourceUpdate<MethodResourceDescription> ru = new PerformedIncrease<>(extension);
    resourceUser.updatedResource(worker, ru);
    // Log modified resource
    RESOURCES_LOGGER.info("TIMESTAMP = " + String.valueOf(System.currentTimeMillis()));
    RESOURCES_LOGGER.info("INFO_MSG = [Resource modified. Name = " + worker.getName() + "]");
    RUNTIME_LOGGER.info("Resource modified. Name = " + worker.getName());
}
Also used : CloudProvider(es.bsc.compss.types.CloudProvider) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) PerformedIncrease(es.bsc.compss.types.resources.updates.PerformedIncrease)

Example 42 with MethodResourceDescription

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

the class CloudProviderTest method testRefusedTwoTurnOn.

@Test
public void testRefusedTwoTurnOn() {
    Map<String, String> properties = new HashMap<>();
    CloudProvider cp = null;
    try {
        cp = new CloudProvider(PROVIDER_NAME, 0, RUNTIME_CONNECTOR, null, null, properties);
    } catch (Exception e) {
        fail("Could not create the Cloud Provider");
        return;
    }
    if (cp.getCurrentVMCount() != 0) {
        fail("Cloud Provider is not properly intialized the number of requested VMs should be 0");
    }
    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);
    CloudMethodResourceDescription cmrd = new CloudMethodResourceDescription(citd, cid);
    ResourceCreationRequest crc = cp.requestResourceCreation(cmrd);
    if (!FakeConnector.getProcessedRequests().contains(crc)) {
        fail("Turn on has not reached the connector");
    }
    CloudMethodResourceDescription cmrd2 = new CloudMethodResourceDescription(citd, cid);
    cmrd2.addInstance(citd);
    ResourceCreationRequest crc2 = cp.requestResourceCreation(cmrd2);
    if (!FakeConnector.getProcessedRequests().contains(crc)) {
        fail("Turn on has not reached the connector");
    }
    if (cp.getCurrentVMCount() != 3) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    cp.refusedCreation(crc2);
    if (cp.getCurrentVMCount() != 1) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    List<ResourceCreationRequest> pendingRequests = cp.getPendingRequests();
    if (!pendingRequests.contains(crc)) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
    if (pendingRequests.size() != 1) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
    cp.refusedCreation(crc);
    if (cp.getCurrentVMCount() != 0) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    if (!pendingRequests.isEmpty()) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
}
Also used : HashMap(java.util.HashMap) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) Test(org.junit.Test)

Example 43 with MethodResourceDescription

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

the class CloudProviderTest method testDestroyTwoVMOneResource.

@Test
public void testDestroyTwoVMOneResource() {
    Map<String, String> properties = new HashMap<>();
    CloudProvider cp = null;
    try {
        cp = new CloudProvider(PROVIDER_NAME, 0, RUNTIME_CONNECTOR, null, null, properties);
    } catch (Exception e) {
        fail("Could not create the Cloud Provider");
        return;
    }
    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);
    CloudMethodResourceDescription cmrd = new CloudMethodResourceDescription(citd, cid);
    ResourceCreationRequest crc = cp.requestResourceCreation(cmrd);
    CloudMethodResourceDescription cmrd2 = new CloudMethodResourceDescription(citd, cid);
    ResourceCreationRequest crc2 = cp.requestResourceCreation(cmrd2);
    String vmName = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw = new ExtendedCloudMethodWorker(vmName, cp, cmrd, new FakeNode(vmName), 0, new HashMap<>());
    CloudMethodResourceDescription granted = new CloudMethodResourceDescription(citd, cid);
    cp.confirmedCreation(crc, cmw, granted);
    granted = new CloudMethodResourceDescription(citd, cid);
    cmw.getDescription().increase(granted);
    cp.confirmedCreation(crc2, cmw, granted);
    CloudMethodResourceDescription reduction = new CloudMethodResourceDescription(citd, cid);
    cmw.getDescription().reduce(reduction);
    cp.requestResourceReduction(cmw, reduction);
    if (cp.getCurrentVMCount() != 1) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    Set<CloudMethodWorker> workers = cp.getHostedWorkers();
    if (workers.size() != 1) {
        fail("Cloud Provider is not properly registering the hosted workers");
    }
    if (!workers.contains(cmw)) {
        fail("Cloud Provider is not properly registering the hosted workers");
    }
    reduction = new CloudMethodResourceDescription(citd, cid);
    cmw.getDescription().reduce(reduction);
    cp.requestResourceReduction(cmw, reduction);
    if (cp.getCurrentVMCount() != 0) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    workers = cp.getHostedWorkers();
    if (!workers.isEmpty()) {
        fail("Cloud Provider is not properly registering the hosted workers");
    }
}
Also used : HashMap(java.util.HashMap) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) FakeNode(es.bsc.compss.types.fake.FakeNode) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) Test(org.junit.Test)

Example 44 with MethodResourceDescription

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

the class CloudProviderTest method testCreateOneVMOneResourceDifferentDescription.

@Test
public void testCreateOneVMOneResourceDifferentDescription() {
    Map<String, String> properties = new HashMap<>();
    CloudProvider cp = null;
    try {
        cp = new CloudProvider(PROVIDER_NAME, 0, RUNTIME_CONNECTOR, null, null, properties);
    } catch (Exception e) {
        fail("Could not create the Cloud Provider");
        return;
    }
    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);
    CloudMethodResourceDescription cmrd = new CloudMethodResourceDescription(citd, cid);
    ResourceCreationRequest crc = cp.requestResourceCreation(cmrd);
    String vmName = "VM" + (int) (Math.random() * 1000);
    CloudMethodWorker cmw = new CloudMethodWorker(vmName, cp, cmrd, new FakeNode(vmName), 0, 0, 0, 0, new HashMap<>());
    CloudMethodResourceDescription granted = new CloudMethodResourceDescription(citd, cid);
    granted.addInstance(citd);
    cp.confirmedCreation(crc, cmw, granted);
    if (cp.getCurrentVMCount() != 2) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    List<ResourceCreationRequest> pendingRequests = cp.getPendingRequests();
    Set<CloudMethodWorker> workers = cp.getHostedWorkers();
    if (!pendingRequests.isEmpty()) {
        fail("Cloud Provider is not properly registering the pending creations requests");
    }
    if (workers.size() != 1) {
        fail("Cloud Provider is not properly registering the hosted workers");
    }
    if (!workers.contains(cmw)) {
        fail("Cloud Provider is not properly registering the hosted workers");
    }
}
Also used : HashMap(java.util.HashMap) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) FakeNode(es.bsc.compss.types.fake.FakeNode) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) Test(org.junit.Test)

Example 45 with MethodResourceDescription

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

the class CloudProviderTest method testDestroyTwoVMTwoResources.

@Test
public void testDestroyTwoVMTwoResources() {
    Map<String, String> properties = new HashMap<>();
    CloudProvider cp = null;
    try {
        cp = new CloudProvider(PROVIDER_NAME, 0, RUNTIME_CONNECTOR, null, null, properties);
    } catch (Exception e) {
        fail("Could not create the Cloud Provider");
        return;
    }
    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);
    CloudMethodResourceDescription cmrd = new CloudMethodResourceDescription(citd, cid);
    ResourceCreationRequest crc = cp.requestResourceCreation(cmrd);
    CloudMethodResourceDescription cmrd2 = new CloudMethodResourceDescription(citd, cid);
    ResourceCreationRequest crc2 = cp.requestResourceCreation(cmrd2);
    String vmName = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw = new ExtendedCloudMethodWorker(vmName, cp, cmrd, new FakeNode(vmName), 0, new HashMap<>());
    String vmName2 = "VM" + (int) (Math.random() * 1000);
    ExtendedCloudMethodWorker cmw2 = new ExtendedCloudMethodWorker(vmName, cp, cmrd2, new FakeNode(vmName2), 0, new HashMap<>());
    CloudMethodResourceDescription granted = new CloudMethodResourceDescription(citd, cid);
    cp.confirmedCreation(crc, cmw, granted);
    granted = new CloudMethodResourceDescription(citd, cid);
    cp.confirmedCreation(crc2, cmw2, granted);
    CloudMethodResourceDescription reduction = new CloudMethodResourceDescription(citd, cid);
    cmw.getDescription().reduce(reduction);
    cp.requestResourceReduction(cmw, reduction);
    if (cp.getCurrentVMCount() != 1) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    Set<CloudMethodWorker> workers = cp.getHostedWorkers();
    if (workers.size() != 1) {
        fail("Cloud Provider is not properly registering the hosted workers");
    }
    if (!workers.contains(cmw2)) {
        fail("Cloud Provider is not properly registering the hosted workers");
    }
    reduction = new CloudMethodResourceDescription(citd, cid);
    cmw2.getDescription().reduce(reduction);
    cp.requestResourceReduction(cmw2, reduction);
    if (cp.getCurrentVMCount() != 0) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    workers = cp.getHostedWorkers();
    if (!workers.isEmpty()) {
        fail("Cloud Provider is not properly registering the hosted workers");
    }
}
Also used : HashMap(java.util.HashMap) CloudImageDescription(es.bsc.compss.types.resources.description.CloudImageDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) FakeNode(es.bsc.compss.types.fake.FakeNode) CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) Test(org.junit.Test)

Aggregations

MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)51 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)26 Test (org.junit.Test)23 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)21 Implementation (es.bsc.compss.types.implementations.Implementation)20 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)19 HashMap (java.util.HashMap)17 CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)12 JSONObject (org.json.JSONObject)10 ResourceScheduler (es.bsc.compss.components.impl.ResourceScheduler)9 FakeNode (es.bsc.compss.types.fake.FakeNode)7 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)7 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)4 CloudProvider (es.bsc.compss.types.CloudProvider)4 Processor (es.bsc.compss.types.resources.components.Processor)4 MethodWorker (es.bsc.compss.types.resources.MethodWorker)3 LinkedList (java.util.LinkedList)3 ResourceCreationRequest (es.bsc.compss.types.ResourceCreationRequest)2 FakeWorker (es.bsc.compss.types.fake.FakeWorker)2 AbstractMethodImplementation (es.bsc.compss.types.implementations.AbstractMethodImplementation)2