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