use of org.ow2.proactive.scheduler.common.task.TaskId 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.TaskId 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.TaskId in project scheduling by ow2-proactive.
the class TaskLoggerTest method createFileAppenderTest.
@Test
public void createFileAppenderTest() throws Exception {
JobId jobid = new JobIdImpl(1000, "job");
TaskId taskId = TaskIdImpl.createTaskId(jobid, "task", 42L);
taskLogger = new TaskLogger(taskId, "myhost");
File logFolder = tempFolder.newFolder("logfolder");
File logAppender = taskLogger.createFileAppender(logFolder);
System.out.println(logAppender.getParentFile().getName());
assertEquals(logAppender.getParentFile().getName(), jobid.value());
assertEquals(logAppender.getName(), new TaskLoggerRelativePathGenerator(taskId).getFileName());
}
use of org.ow2.proactive.scheduler.common.task.TaskId in project scheduling by ow2-proactive.
the class TaskContextVariableExtractorTest method createTaskLauncherInitializer.
private TaskLauncherInitializer createTaskLauncherInitializer() {
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
TaskId taskId = createTaskId();
taskLauncherInitializer.setTaskId(taskId);
taskLauncherInitializer.setIterationIndex(iterationIndexValue);
taskLauncherInitializer.setJobOwner(jobOwnerValue);
taskLauncherInitializer.setReplicationIndex(taskReplicationValue);
return taskLauncherInitializer;
}
use of org.ow2.proactive.scheduler.common.task.TaskId 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);
}
}
}
Aggregations