use of org.ow2.proactive.scheduler.task.utils.VariablesMap in project scheduling by ow2-proactive.
the class ForkEnvironmentScriptExecutor method executeForkEnvironmentScript.
/**
* Executes a fork environment script.
*
* @param context The task context to execute the script in.
* @param outputSink Standard output sink.
* @param errorSink Error output sink.
* @return Returns a ScriptResult.
* @throws Exception
*/
public ScriptResult executeForkEnvironmentScript(TaskContext context, PrintStream outputSink, PrintStream errorSink) throws Exception {
VariablesMap variables = new VariablesMap();
variables.setInheritedMap(taskContextVariableExtractor.getAllNonTaskVariables(context));
variables.setScopeMap(taskContextVariableExtractor.getScopeVariables(context));
Map<String, String> thirdPartyCredentials = forkedTaskVariablesManager.extractThirdPartyCredentials(context);
ScriptHandler scriptHandler = ScriptLoader.createLocalHandler();
Script<?> script = context.getInitializer().getForkEnvironment().getEnvScript();
SchedulerNodeClient schedulerNodeClient = forkedTaskVariablesManager.createSchedulerNodeClient(context);
RemoteSpace userSpaceClient = forkedTaskVariablesManager.createDataSpaceNodeClient(context, schedulerNodeClient, IDataSpaceClient.Dataspace.USER);
RemoteSpace globalSpaceClient = forkedTaskVariablesManager.createDataSpaceNodeClient(context, schedulerNodeClient, IDataSpaceClient.Dataspace.GLOBAL);
forkedTaskVariablesManager.addBindingsToScriptHandler(scriptHandler, context, variables, thirdPartyCredentials, schedulerNodeClient, userSpaceClient, globalSpaceClient, Collections.<String, String>emptyMap());
forkedTaskVariablesManager.replaceScriptParameters(script, thirdPartyCredentials, variables, errorSink);
ScriptResult scriptResult = scriptHandler.handle(script, outputSink, errorSink);
if (scriptResult.errorOccured()) {
throw new Exception("Failed to execute fork environment script", scriptResult.getException());
}
return scriptResult;
}
use of org.ow2.proactive.scheduler.task.utils.VariablesMap in project scheduling by ow2-proactive.
the class RMProxyActiveObject method cleanCallBack.
/**
* Called when a script has returned (call is made as an active object call)
* <p>
* Check the nodes to release and release the one that have to (clean script has returned)
* Take care when renaming this method, method name is linked to
* {@link #handleCleaningScript(NodeSet, Script, VariablesMap, Map, TaskId, Credentials)}
*/
@ImmediateService
public synchronized void cleanCallBack(Future<ScriptResult<?>> future, NodeSet nodes) {
String nodeUrl = nodes.get(0).getNodeInformation().getURL();
ScriptResult<?> sResult = null;
TaskId taskId = nodesTaskId.get(nodes);
try {
sResult = future.get();
} catch (Exception e) {
logger.error("Exception occurred while executing cleaning script on node " + nodeUrl + ":", e);
}
printCleaningScriptInformations(nodes, sResult, taskId);
releaseNodes(nodes);
}
Aggregations