use of es.bsc.compss.types.resources.ServiceResourceDescription in project compss by bsc-wdc.
the class ResourceLoader method loadService.
private static boolean loadService(ServiceType s_project, es.bsc.compss.types.resources.jaxb.ServiceType s_resources) {
// Get service adaptor name from properties
String serviceAdaptorName = COMPSsConstants.SERVICE_ADAPTOR;
// Add the name
String wsdl = s_project.getWsdl();
/* Add properties given by the resources file **************************************** */
String serviceName = s_resources.getName();
String namespace = s_resources.getNamespace();
String port = s_resources.getPort();
ServiceResourceDescription srd = new ServiceResourceDescription(serviceName, namespace, port, Integer.MAX_VALUE);
ServiceConfiguration config = null;
try {
config = (ServiceConfiguration) Comm.constructConfiguration(serviceAdaptorName, s_project, s_resources);
} catch (ConstructConfigurationException cce) {
ErrorManager.warn("Service configuration constructor failed", cce);
return false;
}
// If we have reached this point the mp is SURELY not null
/* Add properties given by the project file **************************************** */
int limitOfTasks = s_project.getLimitOfTasks();
if (limitOfTasks >= 0) {
config.setLimitOfTasks(limitOfTasks);
} else {
config.setLimitOfTasks(Integer.MAX_VALUE);
}
/* Pass all the information to the ResourceManager to insert it into the Runtime ** */
LOGGER.debug("Adding service worker " + wsdl);
ServiceWorker newResource = new ServiceWorker(wsdl, srd, config);
ResourceManager.addStaticResource(newResource);
return true;
}
use of es.bsc.compss.types.resources.ServiceResourceDescription in project compss by bsc-wdc.
the class ResourceManagerTest method testStaticWorkersOperations.
@Test
public void testStaticWorkersOperations() {
// Add Method Resource 1
MethodResourceDescription mrd1 = new MethodResourceDescription();
Float memory1 = 10f + (float) Math.random();
mrd1.setMemorySize(memory1);
MethodConfiguration mc1 = null;
try {
mc1 = (MethodConfiguration) Comm.constructConfiguration(FakeMethodAdaptor.class.getName(), null, null);
} catch (Exception e) {
}
String worker1Name = "Worker" + (int) (Math.random() * 10000);
MethodWorker mw1 = createMethodWorker(worker1Name, mrd1, new HashMap<>(), mc1);
ResourceManager.addStaticResource(mw1);
if (ResourceManager.getTotalNumberOfWorkers() != 1) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getStaticResources().contains(mw1)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(worker1Name) != mw1) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getWorker(worker1Name).getName().equals(worker1Name)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (((MethodResourceDescription) ResourceManager.getWorker(worker1Name).getDescription()).getMemorySize() != mrd1.getMemorySize()) {
fail("ResourceManager is not properly adding Method Workers");
}
// Add Method Resource 2
MethodResourceDescription mrd2 = new MethodResourceDescription();
Float memory2 = 10f + (float) Math.random();
mrd2.setMemorySize(memory2);
MethodConfiguration mc2 = null;
try {
mc2 = (MethodConfiguration) Comm.constructConfiguration(FakeMethodAdaptor.class.getName(), null, null);
} catch (Exception e) {
}
String worker2Name = "Worker" + (int) (Math.random() * 10000);
MethodWorker mw2 = createMethodWorker(worker2Name, mrd2, new HashMap<>(), mc2);
ResourceManager.addStaticResource(mw2);
if (ResourceManager.getTotalNumberOfWorkers() != 2) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getStaticResources().contains(mw2)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(worker2Name) != mw2) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getWorker(worker2Name).getName().equals(worker2Name)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (((MethodResourceDescription) ResourceManager.getWorker(worker2Name).getDescription()).getMemorySize() != mrd2.getMemorySize()) {
fail("ResourceManager is not properly adding Method Workers");
}
// Add Service Resource 1
ServiceResourceDescription srd1 = new ServiceResourceDescription("service1", "namespace1", "port1", 2);
ServiceConfiguration sc1 = null;
try {
sc1 = (ServiceConfiguration) Comm.constructConfiguration(FakeServiceAdaptor.class.getName(), null, null);
} catch (Exception e) {
}
String wsdl1 = "WSDL" + (int) (Math.random() * 10000);
ServiceWorker sw1 = createServiceWorker(wsdl1, srd1, sc1);
ResourceManager.addStaticResource(sw1);
if (ResourceManager.getTotalNumberOfWorkers() != 3) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getStaticResources().contains(sw1)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(wsdl1) != sw1) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!ResourceManager.getWorker(wsdl1).getName().equals(wsdl1)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (!((ServiceResourceDescription) ResourceManager.getWorker(wsdl1).getDescription()).getNamespace().equals(srd1.getNamespace())) {
fail("ResourceManager is not properly adding Method Workers");
}
ResourceManager.removeWorker(sw1);
if (ResourceManager.getTotalNumberOfWorkers() != 2) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getStaticResources().contains(sw1)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(wsdl1) != null) {
fail("ResourceManager is not properly adding Method Workers");
}
ResourceManager.removeWorker(mw1);
if (ResourceManager.getTotalNumberOfWorkers() != 1) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getStaticResources().contains(worker1Name)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(worker1Name) != null) {
fail("ResourceManager is not properly adding Method Workers");
}
ResourceManager.removeWorker(mw2);
if (ResourceManager.getTotalNumberOfWorkers() != 0) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getStaticResources().contains(worker2Name)) {
fail("ResourceManager is not properly adding Method Workers");
}
if (ResourceManager.getWorker(worker2Name) != null) {
fail("ResourceManager is not properly adding Method Workers");
}
}
use of es.bsc.compss.types.resources.ServiceResourceDescription 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;
}
Aggregations