in src/main/java/com/revo/deployr/client/broker/worker/PooledTaskWorker.java [51:165]
public RTaskResult call() throws RClientException,
RSecurityException,
RDataException,
RGridException {
RTaskResult taskResult = null;
long timeOnCall = 0L;
long timeOnServer = 0L;
try {
ProjectExecutionOptions options =
ROptionsTranslator.translate(task.options);
/*
* Flag pooled task execution as phantom execution
* to minimize server-side database resource usage.
*/
if(options == null)
options = new ProjectExecutionOptions();
options.phantom = true;
long startTime = System.currentTimeMillis();
RProjectExecution execResult = null;
if (task.code != null) {
execResult = rProject.executeCode(task.code,
options);
} else if (task.external != null) {
execResult = rProject.executeExternal(task.external,
options);
} else {
execResult = rProject.executeScript(task.filename,
task.directory,
task.author,
task.version,
options);
}
timeOnCall = System.currentTimeMillis() - startTime;
String generatedConsole = execResult.about().console;
List<URL> generatedPlots = new ArrayList<URL>();
if (execResult.about().results != null) {
for (RProjectResult result : execResult.about().results) {
generatedPlots.add(result.about().url);
}
}
List<URL> generatedFiles = new ArrayList<URL>();
if (execResult.about().artifacts != null) {
for (RProjectFile artifact : execResult.about().artifacts) {
// generatedFiles.add(artifact.download());
generatedFiles.add(artifact.about().url);
}
}
List<RData> generatedObjects = execResult.about().workspaceObjects;
List<URL> storedFiles = new ArrayList<URL>();
if (execResult.about().repositoryFiles != null) {
for (RRepositoryFile repoFile : execResult.about().repositoryFiles) {
// storedFiles.add(repoFile.download());
storedFiles.add(repoFile.about().url);
}
}
taskResult = new RTaskResultImpl(execResult.about().id,
RTaskType.POOLED,
true,
execResult.about().timeCode,
execResult.about().timeTotal,
timeOnCall, null,
false,
generatedConsole,
generatedPlots,
generatedFiles,
generatedObjects,
storedFiles);
} catch (Exception ex) {
if (ex.getCause() instanceof InterruptedException) {
try {
/*
* If RTaskToken.cancel() raises InterruptedException
* then ensure any corresponding execution on RProject is
* also cancelled.
*/
rProject.interruptExecution();
} catch (Exception iex) {
}
}
taskResult = new RTaskResultImpl(null,
RTaskType.POOLED,
false,
0L,
0L,
0L, ex);
} finally {
/*
* Callback to PooledTaskBroker to release
* RProject back into pool for other tasks.
*/
rBroker.callback(task, taskResult);
}
return taskResult;
}