Search in sources :

Example 6 with CloudMethodWorker

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

the class ExternalAdaptationManager method cloudRemove.

private void cloudRemove(String providerName, String name) {
    if (providerName != null && name != null) {
        CloudProvider cp = ResourceManager.getCloudProvider(providerName);
        if (cp != null) {
            CloudMethodWorker cmw = cp.getHostedWorker(name);
            if (cmw != null) {
                ResourceManager.reduceCloudWorker(cmw, cmw.getDescription());
                RUNTIME_LOGGER.info(LOG_PREFIX + "Submited external request for removing " + name + " in " + providerName);
                writePipe(resultPipe, ACK);
            } else {
                RUNTIME_LOGGER.error(LOG_PREFIX + "ERROR: resource " + name + " not found in " + providerName);
                writePipe(resultPipe, "ERROR: Error creating resource " + name + " not found in " + providerName);
            }
        } else {
            RUNTIME_LOGGER.error(LOG_PREFIX + "ERROR: Provider " + providerName + " not found.");
            writePipe(resultPipe, "ERROR: Provider " + providerName + " not found");
        }
    } else {
        RUNTIME_LOGGER.error(LOG_PREFIX + "ERROR: One of the parameters is incorrect (" + name + "," + providerName + ")");
        writePipe(resultPipe, "ERROR: One of the parameters is incorrect (" + name + "," + providerName + ")");
    }
}
Also used : CloudProvider(es.bsc.compss.types.CloudProvider) CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker)

Example 7 with CloudMethodWorker

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

the class WorkerPool method defineCriticalSet.

/**
 * Selects a subset of the critical set able to execute all the cores
 */
public void defineCriticalSet() {
    synchronized (this) {
        int coreCount = CoreManager.getCoreCount();
        boolean[] runnable = new boolean[coreCount];
        for (int coreId = 0; coreId < coreCount; coreId++) {
            runnable[coreId] = false;
        }
        String resourceName;
        for (Worker<? extends WorkerResourceDescription> res : staticSet.values()) {
            List<Integer> cores = res.getExecutableCores();
            for (int i = 0; i < cores.size(); i++) {
                runnable[cores.get(i)] = true;
            }
        }
        for (CloudMethodWorker resource : criticalOrder) {
            resourceName = resource.getName();
            List<Integer> executableCores = resource.getExecutableCores();
            boolean needed = false;
            for (int i = 0; i < executableCores.size() && !needed; i++) {
                needed = needed || !runnable[executableCores.get(i)];
            }
            if (needed) {
                for (int i = 0; i < executableCores.size(); i++) {
                    runnable[executableCores.get(i)] = true;
                }
            } else {
                criticalSet.remove(resourceName);
                criticalOrder.remove(resource);
                nonCriticalSet.put(resourceName, resource);
            }
        }
    }
}
Also used : CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker)

Example 8 with CloudMethodWorker

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

the class WorkerPool method getCurrentState.

public String getCurrentState(String prefix) {
    StringBuilder sb = new StringBuilder();
    // Resources
    sb.append(prefix).append("RESOURCES = [").append("\n");
    for (Worker<? extends WorkerResourceDescription> r : staticSet.values()) {
        sb.append(prefix).append("\t").append("RESOURCE = [").append("\n");
        // Adds resource information
        sb.append(r.getResourceLinks(prefix + "\t\t"));
        sb.append(prefix).append("\t").append("\t").append("SET = Static").append("\n");
        sb.append(prefix).append("\t").append("]").append("\n");
    }
    for (CloudMethodWorker r : criticalSet.values()) {
        sb.append(prefix).append("\t").append("RESOURCE = [").append("\n");
        // Adds resource information
        sb.append(r.getResourceLinks(prefix + "\t\t"));
        sb.append(prefix).append("\t").append("\t").append("SET = Critical").append("\n");
        sb.append(prefix).append("\t").append("]").append("\n");
    }
    for (CloudMethodWorker r : nonCriticalSet.values()) {
        sb.append(prefix).append("\t").append("RESOURCE = [").append("\n");
        // Adds resource information
        sb.append(r.getResourceLinks(prefix + "\t\t"));
        sb.append(prefix).append("\t").append("\t").append("SET = Non-Critical").append("\n");
        sb.append(prefix).append("\t").append("]").append("\n");
    }
    sb.append(prefix).append("]").append("\n");
    /*
         * //Cores sb.append(prefix).append("CORES = [").append("\n"); for (int i = 0; i < CoreManager.getCoreCount();
         * i++) { sb.append(prefix).append("\t").append("CORE = [").append("\n");
         * sb.append(prefix).append("\t").append("\t").append("ID = ").append(i).append("\n");
         * sb.append(prefix).append("\t").append("\t").append("MAXTASKCOUNT = ").append(coreMaxTaskCount[i]).append("\n"
         * ); sb.append(prefix).append("\t").append("\t").append("TORESOURCE = [").append("\n"); for (Worker<?,?> r :
         * coreToResource[i]) {
         * sb.append(prefix).append("\t").append("\t").append("\t").append("RESOURCE = [").append("\n");
         * sb.append(prefix).append("\t").append("\t").append("\t").append("\t").append("NAME = ").append(r.getName()).
         * append("\n");
         * sb.append(prefix).append("\t").append("\t").append("\t").append("\t").append("SIMTASKS = ").append(r.
         * getSimultaneousTasks()[i]).append("\n");
         * sb.append(prefix).append("\t").append("\t").append("\t").append("]").append("\n"); }
         * sb.append(prefix).append("\t").append("\t").append("]").append("\n");
         * sb.append(prefix).append("\t").append("]").append("\n"); } sb.append(prefix).append("]").append("\n");
         */
    return sb.toString();
}
Also used : CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker)

Example 9 with CloudMethodWorker

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

the class CloudProviderTest method testCreateTwoVMOneResource.

@Test
public void testCreateTwoVMOneResource() {
    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);
    CloudMethodWorker cmw = new CloudMethodWorker(vmName, cp, cmrd, new FakeNode(vmName), 0, 0, 0, 0, new HashMap<>());
    CloudMethodResourceDescription granted = new CloudMethodResourceDescription(citd, cid);
    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.size() != 1) {
        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");
    }
    granted = new CloudMethodResourceDescription(citd, cid);
    cp.confirmedCreation(crc2, cmw, granted);
    if (cp.getCurrentVMCount() != 2) {
        fail("Cloud Provider is not properly accounting the number of requested VMs");
    }
    pendingRequests = cp.getPendingRequests();
    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 10 with CloudMethodWorker

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

the class CloudProviderTest method testDestroyOneVMOneResource.

@Test
public void testDestroyOneVMOneResource() {
    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);
    ExtendedCloudMethodWorker cmw = new ExtendedCloudMethodWorker(vmName, cp, cmrd, new FakeNode(vmName), 0, new HashMap<>());
    CloudMethodResourceDescription granted = new CloudMethodResourceDescription(citd, cid);
    cp.confirmedCreation(crc, cmw, granted);
    CloudMethodResourceDescription 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");
    }
    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.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

CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)22 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)12 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)10 CloudImageDescription (es.bsc.compss.types.resources.description.CloudImageDescription)9 HashMap (java.util.HashMap)8 FakeNode (es.bsc.compss.types.fake.FakeNode)7 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)7 Test (org.junit.Test)7 JSONObject (org.json.JSONObject)3 ConnectorException (es.bsc.compss.connectors.ConnectorException)2 BlockedActionException (es.bsc.compss.scheduler.exceptions.BlockedActionException)2 UnassignedActionException (es.bsc.compss.scheduler.exceptions.UnassignedActionException)2 CloudProvider (es.bsc.compss.types.CloudProvider)2 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)2 LinkedList (java.util.LinkedList)2 VM (es.bsc.compss.connectors.VM)1 FailedActionException (es.bsc.compss.scheduler.exceptions.FailedActionException)1 InvalidSchedulingException (es.bsc.compss.scheduler.exceptions.InvalidSchedulingException)1 Profile (es.bsc.compss.scheduler.types.Profile)1 StopWorkerAction (es.bsc.compss.scheduler.types.allocatableactions.StopWorkerAction)1