Search in sources :

Example 1 with ServiceConfiguration

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;
}
Also used : ServiceResourceDescription(es.bsc.compss.types.resources.ServiceResourceDescription) ServiceConfiguration(es.bsc.compss.types.resources.configuration.ServiceConfiguration) ServiceWorker(es.bsc.compss.types.resources.ServiceWorker) ConstructConfigurationException(es.bsc.compss.exceptions.ConstructConfigurationException)

Example 2 with ServiceConfiguration

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");
    }
}
Also used : ServiceResourceDescription(es.bsc.compss.types.resources.ServiceResourceDescription) ServiceConfiguration(es.bsc.compss.types.resources.configuration.ServiceConfiguration) MethodConfiguration(es.bsc.compss.types.resources.configuration.MethodConfiguration) FakeMethodAdaptor(es.bsc.compss.comm.fake.FakeMethodAdaptor) ServiceWorker(es.bsc.compss.types.resources.ServiceWorker) ExtendedCloudMethodWorker(es.bsc.compss.types.ExtendedCloudMethodWorker) MethodWorker(es.bsc.compss.types.resources.MethodWorker) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) FakeServiceAdaptor(es.bsc.compss.comm.fake.FakeServiceAdaptor) Test(org.junit.Test)

Aggregations

ServiceResourceDescription (es.bsc.compss.types.resources.ServiceResourceDescription)2 ServiceWorker (es.bsc.compss.types.resources.ServiceWorker)2 ServiceConfiguration (es.bsc.compss.types.resources.configuration.ServiceConfiguration)2 FakeMethodAdaptor (es.bsc.compss.comm.fake.FakeMethodAdaptor)1 FakeServiceAdaptor (es.bsc.compss.comm.fake.FakeServiceAdaptor)1 ConstructConfigurationException (es.bsc.compss.exceptions.ConstructConfigurationException)1 ExtendedCloudMethodWorker (es.bsc.compss.types.ExtendedCloudMethodWorker)1 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)1 MethodWorker (es.bsc.compss.types.resources.MethodWorker)1 MethodConfiguration (es.bsc.compss.types.resources.configuration.MethodConfiguration)1 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)1 Test (org.junit.Test)1