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();
}
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);
}
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");
}
}
}
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;
}
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;
}
Aggregations