use of es.bsc.compss.types.resources.description.CloudInstanceTypeDescription in project compss by bsc-wdc.
the class CloudProviderTest method testCreateTwoVMTwoResources.
@Test
public void testCreateTwoVMTwoResources() {
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);
if (cp.getCurrentVMCount() != 2) {
fail("Cloud Provider is not properly accounting the number of requested VMs");
}
String vmName = "VM" + (int) (Math.random() * 1000);
CloudMethodWorker cmw = new CloudMethodWorker(vmName, cp, cmrd, new FakeNode(vmName), 0, 0, 0, 0, new HashMap<>());
String vmName2 = "VM" + (int) (Math.random() * 1000);
CloudMethodWorker cmw2 = new CloudMethodWorker(vmName2, cp, cmrd, new FakeNode(vmName2), 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, cmw2, 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() != 2) {
fail("Cloud Provider is not properly registering the hosted workers");
}
if (!workers.contains(cmw)) {
fail("Cloud Provider is not properly registering the hosted workers");
}
if (!workers.contains(cmw2)) {
fail("Cloud Provider is not properly registering the hosted workers");
}
}
use of es.bsc.compss.types.resources.description.CloudInstanceTypeDescription in project compss by bsc-wdc.
the class CloudProviderTest method testOneInstanceType.
@Test
public void testOneInstanceType() {
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 type1Name = "TYPE" + (int) (Math.random() * 10000);
float type1Memory = (float) Math.random() * 5;
MethodResourceDescription mrd1 = new MethodResourceDescription();
mrd1.setMemorySize(type1Memory);
CloudInstanceTypeDescription citd = new CloudInstanceTypeDescription(type1Name, mrd1);
cp.addInstanceType(citd);
Set<String> instanceNames = cp.getAllInstanceTypeNames();
if (!instanceNames.contains(type1Name)) {
fail("Cloud Provider is not storing properly the Images. Cannot find the template name with one single template.");
}
if (instanceNames.size() != 1) {
fail("Cloud Provider is not storing properly the Images. only one template is supposed to be in the group.");
}
CloudInstanceTypeDescription retrieved1 = cp.getInstanceType(type1Name);
try {
checkRetrievedType(retrieved1, type1Name, type1Memory);
} catch (Exception e) {
fail("Cloud Provider is not storing properly the Images. The provider " + e.getMessage() + " on the one single template scenario.");
}
}
use of es.bsc.compss.types.resources.description.CloudInstanceTypeDescription in project compss by bsc-wdc.
the class CloudProvider method computeSimultaneousCounts.
private int[][] computeSimultaneousCounts(CloudMethodResourceDescription cloudDescription) {
int coreCount = CoreManager.getCoreCount();
int[][] simultaneousCounts = new int[coreCount][];
for (int coreId = 0; coreId < coreCount; coreId++) {
int implCount = CoreManager.getNumberCoreImplementations(coreId);
simultaneousCounts[coreId] = new int[implCount];
}
for (java.util.Map.Entry<CloudInstanceTypeDescription, int[]> typeEntry : cloudDescription.getTypeComposition().entrySet()) {
CloudInstanceTypeDescription citd = typeEntry.getKey();
int count = typeEntry.getValue()[0];
for (int coreId = 0; coreId < coreCount; coreId++) {
for (int implId = 0; implId < simultaneousCounts[coreId].length; implId++) {
simultaneousCounts[coreId][implId] += citd.getSlotsImpl()[coreId][implId] * count;
}
}
}
return simultaneousCounts;
}
use of es.bsc.compss.types.resources.description.CloudInstanceTypeDescription in project compss by bsc-wdc.
the class CloudManager method getCurrentState.
public String getCurrentState(String prefix) {
StringBuilder sb = new StringBuilder();
// Current state
sb.append(prefix).append("CLOUD = [").append("\n");
sb.append(prefix).append("\t").append("CURRENT_STATE = [").append("\n");
for (CloudProvider cp : providers.values()) {
sb.append(cp.getCurrentState(prefix + "\t" + "\t"));
}
sb.append(prefix).append("\t").append("]").append("\n");
// Pending requests
sb.append(prefix).append("\t").append("PENDING_REQUESTS = [").append("\n");
for (CloudProvider cp : providers.values()) {
for (ResourceCreationRequest rcr : cp.getPendingRequests()) {
Map<CloudInstanceTypeDescription, int[]> composition = rcr.getRequested().getTypeComposition();
// REQUEST ARE COMPOSED OF A SINGLE INSTANCE TYPE
for (CloudInstanceTypeDescription citd : composition.keySet()) {
sb.append(prefix).append("\t").append("\t").append("REQUEST = ").append(citd.getName()).append("\n");
}
}
}
sb.append(prefix).append("\t").append("]").append("\n");
sb.append(prefix).append("]");
return sb.toString();
}
Aggregations