Search in sources :

Example 11 with OutputSelector

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());
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) OutputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector) TaskDataspaces(org.ow2.proactive.scheduler.task.data.TaskDataspaces) NamingService(org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Test(org.junit.Test)

Example 12 with OutputSelector

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());
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) OutputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector) TaskDataspaces(org.ow2.proactive.scheduler.task.data.TaskDataspaces) NamingService(org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Test(org.junit.Test)

Example 13 with OutputSelector

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);
        }
    }
}
Also used : FileSystemException(org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException) OutputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector) FileSelector(org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector) TaskLoggerRelativePathGenerator(org.ow2.proactive.scheduler.common.util.TaskLoggerRelativePathGenerator)

Example 14 with OutputSelector

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;
}
Also used : OutputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector) ArrayList(java.util.ArrayList)

Example 15 with OutputSelector

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();
}
Also used : InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) HashMap(java.util.HashMap) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) ArrayList(java.util.ArrayList) DatabaseManagerException(org.ow2.proactive.db.DatabaseManagerException) DBTaskId(org.ow2.proactive.scheduler.core.db.TaskData.DBTaskId) OutputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector) InputSelector(org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector)

Aggregations

OutputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector)17 Test (org.junit.Test)7 FileSelector (org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector)5 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)5 SimpleScript (org.ow2.proactive.scripting.SimpleScript)4 TaskScript (org.ow2.proactive.scripting.TaskScript)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 InputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.InputSelector)3 NamingService (org.objectweb.proactive.extensions.dataspaces.core.naming.NamingService)2 FileSystemException (org.objectweb.proactive.extensions.dataspaces.exceptions.FileSystemException)2 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)2 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)2 AwaitedTask (org.ow2.proactive.scheduler.smartproxy.common.AwaitedTask)2 TaskDataspaces (org.ow2.proactive.scheduler.task.data.TaskDataspaces)2 SelectionScript (org.ow2.proactive.scripting.SelectionScript)2 HashMap (java.util.HashMap)1 FileObject (org.apache.commons.vfs2.FileObject)1 FileSelector (org.apache.commons.vfs2.FileSelector)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1