use of es.bsc.compss.types.resources.MethodResourceDescription 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.MethodResourceDescription 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.MethodResourceDescription in project compss by bsc-wdc.
the class TestAvailable method availableResourcesTest.
/*
* *************************************** AVAILABLE RESOURCES TEST IMPLEMENTATION
*
* Resource 4 CPU CUs (internalMemory=1), 3GPUs CUS (internalMemory=2), 3 FPGA CUs, 3 OTHER CUs CE1 -> 2 CPU CUs, 2
* GPU CUs (internalMemory=1), 1 FPGA CU) CE2 -> 1 CPU CUs, 1 FPGA , 2 OTHER CUs , nodeMemSize= 2.0) CE3 -> 1 CPU
* CUs, 2 GPU CU (internalMemory=3) CE4 -> 1 CPU CUs (internalMemory=3); ***************************************
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void availableResourcesTest() {
// Get CoreCount
coreCount = CoreManager.getCoreCount();
// Loading Core names from the interface
idToSignatures = new LinkedList[coreCount];
for (int coreId = 0; coreId < coreCount; coreId++) {
idToSignatures[coreId] = new LinkedList<String>();
}
for (Entry<String, Integer> entry : CoreManager.getSignaturesToId().entrySet()) {
String signature = entry.getKey();
Integer coreId = entry.getValue();
idToSignatures[coreId].add(signature);
}
// Search for the specific CoreElement ids
boolean found_ce1 = false;
boolean found_ce2 = false;
boolean found_ce3 = false;
boolean found_ce4 = false;
int ce1 = 0;
int ce2 = 0;
int ce3 = 0;
int ce4 = 0;
coreToName = new String[coreCount];
for (int i = 0; i < coreCount; i++) {
int cutValue = idToSignatures[i].getFirst().indexOf("(");
coreToName[i] = idToSignatures[i].getFirst().substring(0, cutValue);
if (coreToName[i].equals(NAME_CORE_ELEMENT_1)) {
ce1 = i;
found_ce1 = true;
}
if (coreToName[i].equals(NAME_CORE_ELEMENT_2)) {
ce2 = i;
found_ce2 = true;
}
if (coreToName[i].equals(NAME_CORE_ELEMENT_3)) {
ce3 = i;
found_ce3 = true;
}
if (coreToName[i].equals(NAME_CORE_ELEMENT_4)) {
ce4 = i;
found_ce4 = true;
}
}
// Check results
if (!found_ce1) {
System.out.println("[ERROR] " + NAME_CORE_ELEMENT_1 + " not found.");
System.exit(-1);
}
if (!found_ce2) {
System.out.println("[ERROR] " + NAME_CORE_ELEMENT_2 + " not found.");
System.exit(-1);
}
if (!found_ce3) {
System.out.println("[ERROR] " + NAME_CORE_ELEMENT_3 + " not found.");
System.exit(-1);
}
if (!found_ce4) {
System.out.println("[ERROR] " + NAME_CORE_ELEMENT_4 + " not found.");
System.exit(-1);
}
Worker worker = ResourceManager.getWorker(NAME_WORKER);
System.out.println("Worker " + NAME_WORKER + ": " + worker.getDescription());
/*
* ************************************************* Check internal memory
* ***********************************************
*/
ActionOrchestrator orchestrator = COMPSsRuntimeImpl.getOrchestrator();
Action a = new Action(orchestrator, ce3);
if (a.findAvailableWorkers().containsKey(worker)) {
System.out.println("[ERROR] Available resources internalMemorySize filter inside Processor annotation is not working");
System.exit(-1);
}
a = new Action(orchestrator, ce4);
if (a.findAvailableWorkers().containsKey(worker)) {
System.out.println("[ERROR] Available resources processorInternalMemorySize filter is not working");
System.exit(-1);
}
/*
* ************************************************* Reserve and free for GPU and FPGA computingUnits test
* ***********************************************
*/
System.out.println("Worker " + NAME_WORKER + ": " + worker.getDescription());
System.out.println("Implementation 1: " + CoreManager.getCoreImplementations(ce1).get(0));
MethodResourceDescription consumed1 = (MethodResourceDescription) worker.runTask(CoreManager.getCoreImplementations(ce1).get(0).getRequirements());
System.out.println("CONSUMED: " + consumed1);
// Check Consumed: 2 CPUs 2 GPUs 1 FPGA
if (!checkDescription(consumed1, 2, 2, 1, 0)) {
System.out.println("[ERROR] consumed resources for CPU + GPU + FPGA is not working");
System.exit(-1);
}
;
MethodResourceDescription remaining = ((MethodWorker) worker).getAvailable();
System.out.println("REMAINING: " + remaining);
// Check Remaining: 2CPUs 1GPU , 2FPGA 3 OTHER
if (!checkDescription(remaining, 2, 1, 2, 3)) {
System.out.println("[ERROR] remaining resources for CPU + GPU + FPGA is not working");
System.exit(-1);
}
MethodResourceDescription consumed2 = (MethodResourceDescription) worker.runTask(CoreManager.getCoreImplementations(ce2).get(0).getRequirements());
System.out.println("CONSUMED: " + consumed2);
// Check consumed 1 CPU 2 OTHER 1 FPGA
if (!checkDescription(consumed2, 1, 0, 1, 2)) {
System.out.println("[ERROR] consumed resources for CPU + OTHER + FPGA is not working");
System.exit(-1);
}
remaining = ((MethodWorker) worker).getAvailable();
System.out.println("REMAINING: " + remaining);
// Check remaining 1CPU 1 GPU, 1 OTHER, 1 FPGA.
if (!checkDescription(remaining, 1, 1, 1, 1)) {
System.out.println("[ERROR] remaining resources for CPU + OTHER + FPGA is not working");
System.exit(-1);
}
a = new Action(orchestrator, ce1);
if (a.findAvailableWorkers().containsKey(worker)) {
System.out.println("[ERROR] Available resources for CPU + GPU + FPGA reserve is not working");
System.exit(-1);
}
a = new Action(orchestrator, ce2);
if (a.findAvailableWorkers().containsKey(worker)) {
System.out.println("[ERROR] Available resources for CPU + OTHER + FPGA reserve is not working");
System.exit(-1);
}
worker.endTask(consumed1);
a = new Action(orchestrator, ce1);
if (!a.findAvailableWorkers().containsKey(worker)) {
System.out.println("[ERROR] Available resources for CPU + GPU + FPGA free is not working");
System.exit(-1);
}
worker.endTask(consumed2);
a = new Action(orchestrator, ce2);
if (!a.findAvailableWorkers().containsKey(worker)) {
System.out.println("[ERROR] Available resources for CPU + OTHER + FPGA free is not working");
System.exit(-1);
}
// System.out.println("FREE");
// System.out.println("FREE");
// System.out.println("TOTAL: " + ((MethodWorker)worker).getAvailable());
// System.out.println();
System.out.println("[LOG] * Multi-processors test passed");
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class TestCompatible method checkResourcesAssignedToImpl.
private static String checkResourcesAssignedToImpl(Implementation impl, Worker<?> resource) {
if ((impl.getTaskType().equals(TaskType.METHOD) && resource.getType().equals(Resource.Type.SERVICE)) || (impl.getTaskType().equals(TaskType.SERVICE) && resource.getType().equals(Resource.Type.WORKER))) {
return "types";
}
if (resource.getType() == Worker.Type.WORKER) {
MethodImplementation mImpl = (MethodImplementation) impl;
MethodResourceDescription iDescription = mImpl.getRequirements();
MethodWorker worker = (MethodWorker) resource;
MethodResourceDescription wDescription = (MethodResourceDescription) worker.getDescription();
/*
* *********************************************************************************************************
* COMPUTING UNITS
**********************************************************************************************************/
if ((iDescription.getTotalCPUComputingUnits() >= MethodResourceDescription.ONE_INT) && (wDescription.getTotalCPUComputingUnits() >= MethodResourceDescription.ONE_INT) && (wDescription.getTotalCPUComputingUnits() < iDescription.getTotalCPUComputingUnits())) {
return "computingUnits";
}
/*
* *********************************************************************************************************
* PROCESSOR
***********************************************************************************************************/
for (Processor ip : iDescription.getProcessors()) {
// Check if processor can be executed in worker
boolean canBeHosted = false;
for (Processor wp : wDescription.getProcessors()) {
// Static checks
if (!ip.getName().equals(MethodResourceDescription.UNASSIGNED_STR) && !wp.getName().equals(MethodResourceDescription.UNASSIGNED_STR) && !wp.getName().equals(ip.getName())) {
// System.out.println("DUE TO: " + ip.getName() + " != " + wp.getName());
continue;
}
if (ip.getSpeed() != MethodResourceDescription.UNASSIGNED_FLOAT && wp.getSpeed() != MethodResourceDescription.UNASSIGNED_FLOAT && wp.getSpeed() < ip.getSpeed()) {
// System.out.println("DUE TO: " + ip.getSpeed() + " != " + wp.getSpeed());
continue;
}
if (!ip.getArchitecture().equals(MethodResourceDescription.UNASSIGNED_STR) && !wp.getArchitecture().equals(MethodResourceDescription.UNASSIGNED_STR) && !wp.getArchitecture().equals(ip.getArchitecture())) {
// System.out.println("DUE TO: " + ip.getArchitecture() + " != " + wp.getArchitecture());
continue;
}
if ((!ip.getPropName().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wp.getPropName().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!ip.getPropName().equals(wp.getPropName()))) {
// System.out.println("DUE TO: " + ip.getPropName() + " != " + wp.getPropName());
continue;
}
if ((!ip.getPropValue().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wp.getPropValue().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!ip.getPropValue().equals(wp.getPropValue()))) {
// System.out.println("DUE TO: " + ip.getPropValue() + " != " + wp.getPropValue());
continue;
}
// Dynamic checks
if (wp.getComputingUnits() >= ip.getComputingUnits()) {
canBeHosted = true;
break;
} else {
// System.out.println("DUE TO: " + ip.getComputingUnits() + " != " + wp.getComputingUnits());
}
}
if (!canBeHosted) {
return "processor";
}
}
/*
* *********************************************************************************************************
* MEMORY
***********************************************************************************************************/
if ((iDescription.getMemorySize() != MethodResourceDescription.UNASSIGNED_FLOAT) && (wDescription.getMemorySize() != MethodResourceDescription.UNASSIGNED_FLOAT) && (wDescription.getMemorySize() < iDescription.getMemorySize())) {
return "memorySize";
}
if ((!iDescription.getMemoryType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!iDescription.getMemoryType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wDescription.getMemoryType().equals(iDescription.getMemoryType()))) {
return "memoryType";
}
/*
* *********************************************************************************************************
* STORAGE
***********************************************************************************************************/
if ((iDescription.getStorageSize() != MethodResourceDescription.UNASSIGNED_FLOAT) && (wDescription.getStorageSize() != MethodResourceDescription.UNASSIGNED_FLOAT) && (wDescription.getStorageSize() < iDescription.getStorageSize())) {
return "storageSize";
}
if ((!iDescription.getStorageType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!iDescription.getStorageType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wDescription.getStorageType().equals(iDescription.getStorageType()))) {
return "storageType";
}
/*
* *********************************************************************************************************
* OPERATING SYSTEM
***********************************************************************************************************/
if ((!iDescription.getOperatingSystemType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!iDescription.getOperatingSystemType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wDescription.getOperatingSystemType().equals(iDescription.getOperatingSystemType()))) {
return "operatingSystemType";
}
if ((!iDescription.getOperatingSystemDistribution().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!iDescription.getOperatingSystemDistribution().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wDescription.getOperatingSystemDistribution().equals(iDescription.getOperatingSystemDistribution()))) {
return "operatingSystemDistribution";
}
if ((!iDescription.getOperatingSystemVersion().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!iDescription.getOperatingSystemVersion().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wDescription.getOperatingSystemVersion().equals(iDescription.getOperatingSystemVersion()))) {
return "operatingSystemVersion";
}
/*
* *********************************************************************************************************
* APPLICATION SOFTWARE
***********************************************************************************************************/
if (!(iDescription.getAppSoftware().isEmpty()) && !(wDescription.getAppSoftware().containsAll(iDescription.getAppSoftware()))) {
return "appSoftware";
}
/*
* *********************************************************************************************************
* HOST QUEUE
***********************************************************************************************************/
if (!(iDescription.getHostQueues().isEmpty()) && !(wDescription.getHostQueues().containsAll(iDescription.getHostQueues()))) {
return "hostQueues";
}
} else if (resource.getType() == Worker.Type.SERVICE) {
ServiceImplementation sImpl = (ServiceImplementation) impl;
ServiceResourceDescription iDescription = sImpl.getRequirements();
ServiceWorker worker = (ServiceWorker) resource;
ServiceResourceDescription wDescription = (ServiceResourceDescription) worker.getDescription();
if (!wDescription.getServiceName().equals(iDescription.getServiceName())) {
return "ServiceName";
}
if (!wDescription.getNamespace().equals(iDescription.getNamespace())) {
return "Namespace";
}
if (!wDescription.getPort().equals(iDescription.getPort())) {
return "Port";
}
} else {
return "Unknown resource type";
}
/*
* ************************************************************************************************************
* ALL CONSTAINT VALUES OK
*************************************************************************************************************/
return null;
}
use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class COMPSsRuntimeImpl method registerCoreElement.
/**
* Registers a new CoreElement in the COMPSs Runtime
*/
@Override
public void registerCoreElement(String coreElementSignature, String implSignature, String implConstraints, String implType, String... implTypeArgs) {
LOGGER.info("Registering CoreElement " + coreElementSignature);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("\t - Implementation: " + implSignature);
LOGGER.debug("\t - Constraints : " + implConstraints);
LOGGER.debug("\t - Type : " + implType);
LOGGER.debug("\t - ImplTypeArgs : ");
for (String implTypeArg : implTypeArgs) {
LOGGER.debug("\t\t Arg: " + implTypeArg);
}
}
MethodResourceDescription mrd = new MethodResourceDescription(implConstraints);
MethodType mt;
switch(implType) {
case "METHOD":
mt = MethodType.METHOD;
break;
case "MPI":
mt = MethodType.MPI;
break;
case "DECAF":
mt = MethodType.DECAF;
break;
case "BINARY":
mt = MethodType.BINARY;
break;
case "OMPSS":
mt = MethodType.OMPSS;
break;
case "OPENCL":
mt = MethodType.OPENCL;
break;
default:
ErrorManager.error("Unrecognised method type " + implType);
return;
}
td.registerNewCoreElement(coreElementSignature, implSignature, mrd, mt, implTypeArgs);
}
Aggregations