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);
}
}
}));
}
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());
}
}
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;
}
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());
}
Aggregations