Search in sources :

Example 6 with CloudMethodResourceDescription

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

the class Test method cloudManagerTest.

/*
     * *********************************** CLOUD MANAGER TEST IMPLEMENTATION ***********************************
     */
private static void cloudManagerTest() {
    // Print Out CloudManager static structures
    System.out.println("[LOG] CloudManager Static Structures definition");
    // Check for each implementation the correctness of its resources
    coreCount = CoreManager.getCoreCount();
    CloudProvider cp = ResourceManager.getCloudProvider("BSC");
    for (int coreId = 0; coreId < coreCount; coreId++) {
        System.out.println("[LOG] Checking Core" + coreId);
        for (Implementation impl : CoreManager.getCoreImplementations(coreId)) {
            if (impl.getTaskType().equals(TaskType.METHOD)) {
                System.out.println("[LOG]\t Checking Implementation: " + impl.getImplementationId());
                System.out.println("\t\t Checking obtained compatible cloud images");
                MethodImplementation mImpl = (MethodImplementation) impl;
                for (CloudImageDescription cid_gci : cp.getCompatibleImages(mImpl.getRequirements())) {
                    System.out.println("\t\t\t Checking compatible Image: " + cid_gci.getImageName());
                    String res = checkImplementationAssignedToCloudImage(mImpl.getRequirements(), cid_gci);
                    if (res != null) {
                        String error = "[ERROR] Implementation: Core = " + coreId + " Impl = " + impl.getImplementationId() + ". ";
                        error = error.concat("Implementation and cloud image not matching on: " + res);
                        System.out.println(error);
                        System.exit(-1);
                    }
                }
                System.out.println("\t\t Checking obtained compatible cloud types");
                for (CloudInstanceTypeDescription type : cp.getCompatibleTypes(new CloudMethodResourceDescription(mImpl.getRequirements()))) {
                    if (type.getResourceDescription().canHostSimultaneously(mImpl.getRequirements()) < 1) {
                        continue;
                    }
                    System.out.println("\t\t\t Checking compatible Type: " + type.getName());
                    String res = checkImplementationAssignedToType(mImpl.getRequirements(), type.getResourceDescription());
                    if (res != null) {
                        String error = "[ERROR] Implementation: Core = " + coreId + " Impl = " + impl.getImplementationId() + ". ";
                        error = error.concat("Implementation and type not matching on: " + res);
                        System.out.println(error);
                        System.exit(-1);
                    }
                }
            }
        }
    }
    // Return success value
    System.out.println("[LOG] * CloudManager test passed");
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) 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) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 7 with CloudMethodResourceDescription

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

the class ResourceManager method printResourcesState.

/**
 * Prints out the resources state
 */
public static void printResourcesState() {
    RESOURCES_LOGGER.info("TIMESTAMP = " + String.valueOf(System.currentTimeMillis()));
    StringBuilder resourceState = new StringBuilder();
    resourceState.append("RESOURCES_INFO = [").append("\n");
    synchronized (pool) {
        for (Worker<? extends WorkerResourceDescription> resource : pool.findAllResources()) {
            resourceState.append("\t").append("RESOURCE = [").append("\n");
            resourceState.append("\t\t").append("NAME = ").append(resource.getName()).append("\n");
            resourceState.append("\t\t").append("TYPE = ").append(resource.getType().toString()).append("\n");
            if (resource.getType() == Type.SERVICE) {
                resourceState.append("\t\t").append("CPUS = 0\n");
                resourceState.append("\t\t").append("MEMORY = 0\n");
            } else {
                MethodResourceDescription mrd = (MethodResourceDescription) resource.getDescription();
                resourceState.append("\t\t").append("CPUS = ").append(mrd.getTotalCPUComputingUnits()).append("\n");
                resourceState.append("\t\t").append("MEMORY = ").append(mrd.getMemorySize()).append("\n");
            }
            int[] coreSlots = resource.getSimultaneousTasks();
            resourceState.append("\t\t").append("CAN_RUN = [").append("\n");
            for (int i = 0; i < coreSlots.length; i++) {
                resourceState.append("\t\t\t").append("CORE = [").append("\n");
                resourceState.append("\t\t\t").append("\t").append("COREID = ").append(i).append("\n");
                resourceState.append("\t\t\t").append("\t").append("NUM_SLOTS = ").append(coreSlots[i]).append("\n");
                resourceState.append("\t\t\t").append("]").append("\n");
            }
            // End CAN_RUN
            resourceState.append("\t\t").append("]").append("\n");
            // End RESOURCE
            resourceState.append("\t").append("]\n");
        }
    }
    // END RESOURCES_INFO
    resourceState.append("]").append("\n");
    resourceState.append("CLOUD_INFO = [").append("\n");
    if (cloudManager.isUseCloud()) {
        resourceState.append("\t").append("CURRENT_CLOUD_VM_COUNT = ").append(cloudManager.getCurrentVMCount()).append("\n");
        try {
            resourceState.append("\t").append("CREATION_TIME = ").append(Long.toString(cloudManager.getNextCreationTime())).append("\n");
        } catch (Exception ex) {
            resourceState.append("\t").append("CREATION_TIME = ").append(120000l).append("\n");
        }
        resourceState.append("\t").append("PENDING_RESOURCES = [").append("\n");
        for (ResourceCreationRequest rcr : cloudManager.getPendingRequests()) {
            resourceState.append("\t\t").append("RESOURCE = [").append("\n");
            CloudMethodResourceDescription cmrd = rcr.getRequested();
            resourceState.append("\t\t\t").append("NAME = ").append(cmrd.getName()).append("\n");
            resourceState.append("\t\t\t").append("TYPE = ").append(Type.WORKER.toString()).append("\n");
            resourceState.append("\t\t\t").append("CPUS = ").append(cmrd.getTotalCPUComputingUnits()).append("\n");
            resourceState.append("\t\t\t").append("MEMORY = ").append(cmrd.getMemorySize()).append("\n");
            resourceState.append("\t\t\t").append("CAN_RUN = [").append("\n");
            int[][] simTasks = rcr.requestedSimultaneousTaskCount();
            for (int coreId = 0; coreId < simTasks.length; coreId++) {
                int coreSlots = 0;
                for (int implId = 0; implId < simTasks[coreId].length; implId++) {
                    coreSlots = Math.max(coreSlots, simTasks[coreId][implId]);
                }
                resourceState.append("\t\t\t\t").append("CORE = [").append("\n");
                resourceState.append("\t\t\t\t\t").append("COREID = ").append(coreId).append("\n");
                resourceState.append("\t\t\t\t\t").append("NUM_SLOTS = ").append(coreSlots).append("\n");
                resourceState.append("\t\t\t\t").append("]").append("\n");
            }
            // End CAN_RUN
            resourceState.append("\t\t\t").append("]").append("\n");
            // End RESOURCE
            resourceState.append("\t\t").append("]").append("\n");
        }
        // End PENDING_RESOURCES
        resourceState.append("\t").append("]").append("\n");
    }
    // END CLOUD_INFO
    resourceState.append("]");
    RESOURCES_LOGGER.info(resourceState.toString());
}
Also used : ResourceCreationRequest(es.bsc.compss.types.ResourceCreationRequest) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) NoResourceAvailableException(es.bsc.compss.exceptions.NoResourceAvailableException) ProjectFileValidationException(es.bsc.compss.types.project.exceptions.ProjectFileValidationException) InitNodeException(es.bsc.compss.exceptions.InitNodeException) ConnectorException(es.bsc.compss.connectors.ConnectorException) ResourcesFileValidationException(es.bsc.compss.types.resources.exceptions.ResourcesFileValidationException)

Example 8 with CloudMethodResourceDescription

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

the class ResourceManager method addCloudWorker.

/**
 * Adds a cloud worker
 *
 * @param origin
 * @param worker
 * @param granted
 */
public static void addCloudWorker(ResourceCreationRequest origin, CloudMethodWorker worker, CloudMethodResourceDescription granted) {
    synchronized (pool) {
        CloudProvider cloudProvider = origin.getProvider();
        cloudProvider.confirmedCreation(origin, worker, granted);
        worker.updatedFeatures();
        pool.addDynamicResource(worker);
        pool.defineCriticalSet();
        int[] maxTaskCount = worker.getSimultaneousTasks();
        for (int coreId = 0; coreId < maxTaskCount.length; coreId++) {
            poolCoreMaxConcurrentTasks[coreId] += maxTaskCount[coreId];
        }
    }
    ResourceUpdate<MethodResourceDescription> ru = new PerformedIncrease<>(worker.getDescription());
    resourceUser.updatedResource(worker, ru);
    // Log new resource
    RESOURCES_LOGGER.info("TIMESTAMP = " + String.valueOf(System.currentTimeMillis()));
    RESOURCES_LOGGER.info("INFO_MSG = [New resource available in the pool. Name = " + worker.getName() + "]");
    RUNTIME_LOGGER.info("New resource available in the pool. 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 9 with CloudMethodResourceDescription

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

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

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