use of org.ow2.proactive.scheduler.core.db.TaskData in project scheduling by ow2-proactive.
the class TestTaskAttributes method testAttributes.
@Test
public void testAttributes() throws Exception {
JavaTask task = createDefaultTask("task");
task.setOnTaskError(OnTaskError.CANCEL_JOB);
task.setDescription("desc");
// TODO: create test using valid flow
// task.setFlowBlock(FlowBlock.START);
task.setMaxNumberOfExecution(7);
task.setPreciousLogs(true);
task.setPreciousResult(true);
task.setRunAsMe(true);
task.setWallTime(123);
InternalTask taskData = saveSingleTask(task).getTask(task.getName());
Assert.assertEquals(OnTaskError.CANCEL_JOB, taskData.getOnTaskErrorProperty().getValue());
Assert.assertEquals("desc", taskData.getDescription());
// Assert.assertEquals(FlowBlock.START, taskData.getFlowBlock());
Assert.assertEquals(7, taskData.getMaxNumberOfExecution());
Assert.assertEquals("task", taskData.getName());
Assert.assertEquals(true, taskData.isPreciousLogs());
Assert.assertEquals(true, taskData.isPreciousResult());
Assert.assertEquals(true, taskData.isRunAsMe());
Assert.assertEquals(123, taskData.getWallTime());
}
use of org.ow2.proactive.scheduler.core.db.TaskData in project scheduling by ow2-proactive.
the class TerminationDataTest method testHandleTerminationForTaskNodeFailureTermination.
@Test
public void testHandleTerminationForTaskNodeFailureTermination() throws IOException, ClassNotFoundException {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId jobId = new JobIdImpl(666, "readableName");
InternalTask internalTask = new InternalScriptTask(job);
TaskId taskId = TaskIdImpl.createTaskId(jobId, "task-name", 777L);
internalTask.setId(taskId);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
RunningTaskData taskData = new RunningTaskData(internalTask, "user", null, launcher);
terminationData.addTaskData(null, taskData, TerminationData.TerminationStatus.NODEFAILED, null);
terminationData.handleTermination(service);
Mockito.verify(launcher, Mockito.times(0)).kill();
}
use of org.ow2.proactive.scheduler.core.db.TaskData in project scheduling by ow2-proactive.
the class EnabledListenJobLogsSupport method listenJobLogs.
@Override
public synchronized void listenJobLogs(JobId jobId, AppenderProvider appenderProvider) throws UnknownJobException {
jlogger.info(jobId, "listening logs");
// create the appender to the remote listener
Appender clientAppender = null;
try {
clientAppender = appenderProvider.getAppender();
} catch (LogForwardingException e) {
jlogger.error(jobId, "cannot create an appender", e);
throw new InternalException("Cannot create an appender for job " + jobId, e);
}
boolean logIsAlreadyInitialized = jobsToBeLogged.contains(jobId);
initJobLogging(jobId, clientAppender);
JobResult result = dbManager.loadJobResult(jobId);
if (result == null) {
throw new UnknownJobException(jobId);
}
// for finished tasks, add logs events "manually"
Collection<TaskResult> allRes = result.getAllResults().values();
for (TaskResult tr : allRes) {
this.flushTaskLogs(tr, clientAppender, jobId);
}
for (RunningTaskData taskData : liveJobs.getRunningTasks(jobId)) {
jlogger.debug(jobId, "Handling log initialization for task " + taskData.getTask().getName());
try {
TaskLauncher taskLauncher = taskData.getLauncher();
if (logIsAlreadyInitialized) {
jlogger.debug(jobId, "Call getStoredLogs");
taskLauncher.getStoredLogs(appenderProvider);
} else {
jlogger.debug(jobId, "Call activateLogs");
taskLauncher.activateLogs(lfs.getAppenderProvider());
}
} catch (Exception e) {
tlogger.error(taskData.getTask().getId(), "cannot create an appender provider", e);
}
}
if (!result.getJobInfo().getStatus().isJobAlive()) {
jlogger.info(jobId, "cleaning loggers for already finished job");
cleanLoggers(jobId);
}
}
use of org.ow2.proactive.scheduler.core.db.TaskData in project scheduling by ow2-proactive.
the class ListTaskStatesCommandTest method testCommandJobIdOnly.
@Test
public void testCommandJobIdOnly() throws Exception {
when(restApi.getJobTaskStates(anyString(), eq(jobId))).thenReturn(new RestPage(taskData, taskData.size()));
executeTest(jobId);
String out = capturedOutput.toString();
System.out.println(out);
assertThat(out, containsString("ID NAME"));
assertThat(out, containsString("task1"));
assertThat(out, containsString("task2"));
assertThat(out, containsString("task3"));
assertThat(out, containsString("task4"));
assertThat(out, containsString("task5"));
assertThat(out, containsString("task6"));
}
use of org.ow2.proactive.scheduler.core.db.TaskData in project scheduling by ow2-proactive.
the class TerminationDataTest method testAddTaskData.
@Test
public void testAddTaskData() {
assertThat(terminationData.isEmpty(), is(true));
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId jobId = new JobIdImpl(666, "readableName");
InternalTask internalTask = new InternalScriptTask(job);
TaskId taskId = TaskIdImpl.createTaskId(jobId, "task-name", 777L);
internalTask.setId(taskId);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
RunningTaskData taskData = new RunningTaskData(internalTask, "user", null, null);
terminationData.addTaskData(null, taskData, TerminationData.TerminationStatus.NORMAL, null);
assertThat(terminationData.isEmpty(), is(false));
assertThat(terminationData.taskTerminated(jobId, "task-name"), is(true));
}
Aggregations