use of es.bsc.compss.types.resources.configuration.ServiceConfiguration 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.configuration.ServiceConfiguration 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");
}
}
Aggregations