use of org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector in project scheduling by ow2-proactive.
the class TaskLauncherTest method taskLogsAreNotCopiedToUserSpace_PreciousLogsDisabled.
@Test
public void taskLogsAreNotCopiedToUserSpace_PreciousLogsDisabled() throws Exception {
ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy")));
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setPreciousLogs(false);
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
final TaskDataspaces dataspacesMock = mock(TaskDataspaces.class);
when(dataspacesMock.getScratchFolder()).thenReturn(tmpFolder.newFolder());
runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory() {
@Override
public TaskDataspaces createTaskDataspaces(TaskId taskId, NamingService namingService, boolean isRunAsUser) {
return dataspacesMock;
}
}), executableContainer);
verify(dataspacesMock, times(1)).copyScratchDataToOutput(Matchers.<List<OutputSelector>>any());
}
use of org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector in project scheduling by ow2-proactive.
the class TaskLauncherTest method taskLogsAreCopiedToUserSpace.
@Test
public void taskLogsAreCopiedToUserSpace() throws Exception {
ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("print('hello'); result='hello'", "groovy")));
TaskLauncherInitializer initializer = new TaskLauncherInitializer();
initializer.setPreciousLogs(true);
initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
final TaskDataspaces dataspacesMock = mock(TaskDataspaces.class);
when(dataspacesMock.getScratchFolder()).thenReturn(tmpFolder.newFolder());
runTaskLauncher(createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory() {
@Override
public TaskDataspaces createTaskDataspaces(TaskId taskId, NamingService namingService, boolean isRunAsUser) {
return dataspacesMock;
}
}), executableContainer);
verify(dataspacesMock, times(2)).copyScratchDataToOutput(Matchers.<List<OutputSelector>>any());
}
use of org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector in project scheduling by ow2-proactive.
the class TaskLauncher method copyTaskLogsToUserSpace.
private void copyTaskLogsToUserSpace(File taskLogFile, TaskDataspaces dataspaces) {
if (initializer.isPreciousLogs()) {
try {
FileSelector taskLogFileSelector = new FileSelector(taskLogFile.getName());
taskLogFileSelector.setIncludes(new TaskLoggerRelativePathGenerator(taskId).getRelativePath());
dataspaces.copyScratchDataToOutput(Collections.singletonList(new OutputSelector(taskLogFileSelector, OutputAccessMode.TransferToUserSpace)));
} catch (FileSystemException e) {
logger.warn("Cannot copy logs of task to user data spaces", e);
}
}
}
use of org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector in project scheduling by ow2-proactive.
the class TaskLauncherInitializer method getFilteredOutputFiles.
public List<OutputSelector> getFilteredOutputFiles(Map<String, Serializable> variables) {
List<OutputSelector> filteredTaskOutputFiles = new ArrayList<>();
if (taskOutputFiles != null) {
for (OutputSelector is : taskOutputFiles) {
OutputSelector filteredOutputSelector = new OutputSelector(is.getOutputFiles(), is.getMode());
Set<String> includes = filteredOutputSelector.getOutputFiles().getIncludes();
Set<String> excludes = filteredOutputSelector.getOutputFiles().getExcludes();
Set<String> filteredIncludes = filteredSelector(includes, variables);
Set<String> filteredExcludes = filteredSelector(excludes, variables);
filteredOutputSelector.getOutputFiles().setIncludes(filteredIncludes);
filteredOutputSelector.getOutputFiles().setExcludes(filteredExcludes);
filteredTaskOutputFiles.add(filteredOutputSelector);
}
}
return filteredTaskOutputFiles;
}
use of org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector in project scheduling by ow2-proactive.
the class SchedulerDBManager method toInternalTasks.
private Collection<InternalTask> toInternalTasks(boolean loadFullState, InternalJob internalJob, List<TaskData> taskRuntimeDataList) {
Map<DBTaskId, InternalTask> tasks = new HashMap<>(taskRuntimeDataList.size());
try {
for (TaskData taskData : taskRuntimeDataList) {
InternalTask internalTask = taskData.toInternalTask(internalJob, loadFullState);
if (loadFullState) {
internalTask.setParallelEnvironment(taskData.getParallelEnvironment());
internalTask.setGenericInformation(taskData.getGenericInformation());
for (SelectionScriptData scriptData : taskData.getSelectionScripts()) {
internalTask.addSelectionScript(scriptData.createSelectionScript());
}
if (taskData.getCleanScript() != null) {
internalTask.setCleaningScript(taskData.getCleanScript().createSimpleScript());
}
if (taskData.getPreScript() != null) {
internalTask.setPreScript(taskData.getPreScript().createSimpleScript());
}
if (taskData.getPostScript() != null) {
internalTask.setPostScript(taskData.getPostScript().createSimpleScript());
}
if (taskData.getFlowScript() != null) {
internalTask.setFlowScript(taskData.getFlowScript().createFlowScript());
}
for (SelectorData selectorData : taskData.getDataspaceSelectors()) {
if (selectorData.isInput()) {
InputSelector selector = selectorData.createInputSelector();
internalTask.addInputFiles(selector.getInputFiles(), selector.getMode());
} else {
OutputSelector selector = selectorData.createOutputSelector();
internalTask.addOutputFiles(selector.getOutputFiles(), selector.getMode());
}
}
}
tasks.put(taskData.getId(), internalTask);
}
} catch (InvalidScriptException e) {
throw new DatabaseManagerException("Failed to initialize loaded script", e);
}
for (TaskData taskData : taskRuntimeDataList) {
InternalTask internalTask = tasks.get(taskData.getId());
if (!taskData.getDependentTasks().isEmpty()) {
for (DBTaskId dependent : taskData.getDependentTasks()) {
internalTask.addDependence(tasks.get(dependent));
}
}
if (loadFullState) {
if (taskData.getIfBranch() != null) {
internalTask.setIfBranch(tasks.get(taskData.getIfBranch().getId()));
}
if (!taskData.getJoinedBranches().isEmpty()) {
List<InternalTask> branches = new ArrayList<>(taskData.getJoinedBranches().size());
for (DBTaskId joinedBranch : taskData.getJoinedBranches()) {
branches.add(tasks.get(joinedBranch));
}
internalTask.setJoinedBranches(branches);
}
internalTask.setName(internalTask.getName());
}
}
return tasks.values();
}
Aggregations