Search in sources :

Example 1 with DataSpaceNodeConfigurationAgent

use of org.ow2.proactive.resourcemanager.nodesource.dataspace.DataSpaceNodeConfigurationAgent in project scheduling by ow2-proactive.

the class RMNodeStarter method closeDataSpaceOnShutdown.

private void closeDataSpaceOnShutdown(final Node node) {
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                DataSpaceNodeConfigurationAgent conf = (DataSpaceNodeConfigurationAgent) PAActiveObject.newActive(DataSpaceNodeConfigurationAgent.class.getName(), null, node);
                BooleanWrapper closeNodeConfiguration = conf.closeNodeConfiguration();
                PAFuture.waitFor(closeNodeConfiguration, DATASPACE_CLOSE_TIMEOUT);
                if (closeNodeConfiguration.getBooleanValue()) {
                    logger.debug("Dataspaces are successfully closed for node " + node.getNodeInformation().getURL());
                }
            } catch (Throwable t) {
                logger.debug("Cannot close data spaces configuration", t);
            }
        }
    }));
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) DataSpaceNodeConfigurationAgent(org.ow2.proactive.resourcemanager.nodesource.dataspace.DataSpaceNodeConfigurationAgent)

Example 2 with DataSpaceNodeConfigurationAgent

use of org.ow2.proactive.resourcemanager.nodesource.dataspace.DataSpaceNodeConfigurationAgent in project scheduling by ow2-proactive.

the class DataSpaceNodeConfigurationAgentTest method testCacheLockingConcurrency.

@Test
public void testCacheLockingConcurrency() throws Exception {
    // set a very small cache cleaning period (100ms)
    System.setProperty(DataSpaceNodeConfigurationAgent.NODE_DATASPACE_CACHE_CLEANING_PERIOD, "100");
    DataSpaceNodeConfigurationAgent nodeConfigurationAgent = (DataSpaceNodeConfigurationAgent) PAActiveObject.newActive(DataSpaceNodeConfigurationAgent.class.getName(), null);
    boolean result = nodeConfigurationAgent.configureNode();
    PAActiveObject.terminateActiveObject(nodeConfigurationAgent, false);
    // submit a main thread which will hold the cache read lock for a long time (40s)
    Future future = executor.submit(new Runnable() {

        @Override
        public void run() {
            lockAndWait(20000);
        }
    });
    Thread.sleep(2000);
    Future[] futures = new Future[NB_TASKS - 1];
    for (int i = 0; i < NB_TASKS - 1; i++) {
        futures[i] = executor.submit(new Runnable() {

            @Override
            public void run() {
                lockAndWait(500);
            }
        });
    }
    // wait for the main thread to finish
    future.get();
    for (int i = 0; i < NB_TASKS - 1; i++) {
        // ensure all small threads are terminated at this time (they were not blocked by the cache cleaning thread)
        Assert.assertTrue(futures[i].isDone());
    }
}
Also used : DataSpaceNodeConfigurationAgent(org.ow2.proactive.resourcemanager.nodesource.dataspace.DataSpaceNodeConfigurationAgent)

Example 3 with DataSpaceNodeConfigurationAgent

use of org.ow2.proactive.resourcemanager.nodesource.dataspace.DataSpaceNodeConfigurationAgent in project scheduling by ow2-proactive.

the class RMNodeStarter method configureNodeForDataSpace.

public static boolean configureNodeForDataSpace(Node node) throws ActiveObjectCreationException, NodeException {
    DataSpaceNodeConfigurationAgent nodeConfigurationAgent = (DataSpaceNodeConfigurationAgent) PAActiveObject.newActive(DataSpaceNodeConfigurationAgent.class.getName(), null, node);
    boolean result = nodeConfigurationAgent.configureNode();
    PAActiveObject.terminateActiveObject(nodeConfigurationAgent, false);
    return result;
}
Also used : DataSpaceNodeConfigurationAgent(org.ow2.proactive.resourcemanager.nodesource.dataspace.DataSpaceNodeConfigurationAgent)

Example 4 with DataSpaceNodeConfigurationAgent

use of org.ow2.proactive.resourcemanager.nodesource.dataspace.DataSpaceNodeConfigurationAgent in project scheduling by ow2-proactive.

the class NodeDataspace method init.

public void init(TaskId taskId, String namingServiceUrl) throws Exception {
    dataSpaceNodeConfigurationAgent = (DataSpaceNodeConfigurationAgent) PAActiveObject.newActive(DataSpaceNodeConfigurationAgent.class.getName(), null, PAActiveObject.getNode());
    if (!dataSpaceNodeConfigurationAgent.configureNode()) {
        throw new IllegalStateException("Could not configure node for dataspaces");
    }
    NamingService namingServiceStub = NamingService.createNamingServiceStub(namingServiceUrl);
    taskProActiveDataspaces = new TaskProActiveDataspaces(taskId, namingServiceStub, false);
    System.out.println("Node scratch folder is " + getScratchFolder());
}
Also used : NamingService(org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService) TaskProActiveDataspaces(org.ow2.proactive.scheduler.task.data.TaskProActiveDataspaces) DataSpaceNodeConfigurationAgent(org.ow2.proactive.resourcemanager.nodesource.dataspace.DataSpaceNodeConfigurationAgent)

Aggregations

DataSpaceNodeConfigurationAgent (org.ow2.proactive.resourcemanager.nodesource.dataspace.DataSpaceNodeConfigurationAgent)4 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)1 NamingService (org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService)1 TaskProActiveDataspaces (org.ow2.proactive.scheduler.task.data.TaskProActiveDataspaces)1