use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerDBManager method updateTaskData.
private int updateTaskData(final TaskState task, Session session) {
Query taskUpdateQuery = session.getNamedQuery("updateTaskData");
TaskInfo taskInfo = task.getTaskInfo();
return taskUpdateQuery.setParameter("taskStatus", taskInfo.getStatus()).setParameter("numberOfExecutionLeft", taskInfo.getNumberOfExecutionLeft()).setParameter("numberOfExecutionOnFailureLeft", taskInfo.getNumberOfExecutionOnFailureLeft()).setParameter("inErrorTime", taskInfo.getInErrorTime()).setParameter("taskId", taskId(task.getId())).executeUpdate();
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class JobDescriptorImpl method isEntryPoint.
/**
* Tags all startable tasks as entry point
* a startable task : has no dependency, and is not target of an if control flow action
*
* @param t a Task
* @param otherTasks the other tasks contained in the job containing task t
* @return true if t is an entry point among all tasks in otherTasks, or false
*/
private boolean isEntryPoint(InternalTask t, List<InternalTask> otherTasks) {
List<TaskState> deps = t.getDependences();
boolean entryPoint = false;
// an entry point has no dependency
if (deps == null || deps.size() == 0) {
entryPoint = true;
} else {
return false;
}
// a entry point is not target of an if
for (Task t2 : otherTasks) {
if (t.equals(t2)) {
continue;
}
FlowScript sc = t2.getFlowScript();
if (sc != null) {
String actionType = sc.getActionType();
if (FlowActionType.parse(actionType).equals(FlowActionType.IF)) {
String tIf = sc.getActionTarget();
String tElse = sc.getActionTargetElse();
String tJoin = sc.getActionContinuation();
if (tIf != null && tIf.equals(t.getName())) {
return false;
}
if (tElse != null && tElse.equals(t.getName())) {
return false;
}
if (tJoin != null && tJoin.equals(t.getName())) {
return false;
}
}
}
}
return entryPoint;
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class TestKilledJobResult method test.
@Test
public void test() throws Throwable {
TaskFlowJob job = new TaskFlowJob();
JavaTask task1 = new JavaTask();
task1.setName("task1");
task1.setExecutableClassName(TestJavaTask1.class.getName());
job.addTask(task1);
JavaTask task2 = new JavaTask();
task2.setName("task2");
task2.setExecutableClassName(TestJavaTask2.class.getName());
job.addTask(task2);
task2.addDependence(task1);
log("Submit job");
JobId jobId = schedulerHelper.submitJob(job);
log("Submitted job " + jobId);
log("Waiting for task1 to finish");
schedulerHelper.waitForEventTaskFinished(jobId, "task1");
schedulerHelper.waitForEventTaskRunning(jobId, "task2");
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
log("Killing job");
scheduler.killJob(jobId);
log("Wait when job finishes");
schedulerHelper.waitForEventJobFinished(jobId);
JobResult jobResult = scheduler.getJobResult(jobId);
printResult(jobResult);
assertEquals(1, jobResult.getAllResults().size());
assertEquals("OK", jobResult.getAllResults().get("task1").value().toString());
JobInfo jobInfo = jobResult.getJobInfo();
assertEquals(JobStatus.KILLED, jobInfo.getStatus());
assertEquals(1, jobInfo.getNumberOfFinishedTasks());
assertEquals(2, jobInfo.getTotalNumberOfTasks());
assertEquals(0, jobInfo.getNumberOfPendingTasks());
assertEquals(0, jobInfo.getNumberOfRunningTasks());
JobState state = scheduler.getJobState(jobId);
assertEquals(JobStatus.KILLED, state.getStatus());
assertEquals(1, state.getNumberOfFinishedTasks());
assertEquals(2, state.getTotalNumberOfTasks());
assertEquals(0, state.getNumberOfPendingTasks());
assertEquals(0, state.getNumberOfRunningTasks());
assertEquals(2, state.getTasks().size());
assertEquals(TaskStatus.FINISHED, findTask(state, "task1").getStatus());
assertEquals(TaskStatus.ABORTED, findTask(state, "task2").getStatus());
TaskState taskState0 = state.getTasks().get(0);
TaskState taskState1 = state.getTasks().get(1);
assertTrue(taskState0.getStartTime() > 0);
assertTrue(taskState0.getFinishedTime() > 0);
assertTrue(taskState0.getExecutionDuration() >= 0);
assertTrue(taskState0.getExecutionDuration() <= taskState0.getFinishedTime() - taskState0.getStartTime());
assertTrue(taskState1.getStartTime() > 0);
assertTrue(taskState1.getFinishedTime() > 0);
assertTrue(taskState1.getExecutionDuration() >= 0);
assertTrue(taskState1.getExecutionDuration() <= taskState1.getFinishedTime() - taskState1.getStartTime());
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class RunningTaskRecoveryWithDownNodeTest method checkTasks.
private void checkTasks(JobState jobState) {
int maximumNumberOfPendingTasks = jobState.getNumberOfPendingTasks();
for (int i = 0; i < maximumNumberOfPendingTasks; i++) {
TaskState taskState = jobState.getTasks().get(i);
TaskStatus taskStatus = taskState.getTaskInfo().getStatus();
assertThat(taskStatus.equals(TaskStatus.PENDING) || taskStatus.equals(TaskStatus.RUNNING)).isTrue();
}
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerDBManagerTest method testDatesTaskCentric.
@Test
public void testDatesTaskCentric() throws Throwable {
int nbJobs = 5;
int nbTasksPerJob = 10;
int totalNbTasks = nbJobs * nbTasksPerJob;
// These only should come up
actualInternalJobs = createTestJobs("Job-hier", "TAG-HIER", nbJobs, nbTasksPerJob);
for (InternalJob j : actualInternalJobs) {
service.submitJob(j);
}
// These should NOT come up
List<InternalJob> todayJobs = createTestJobs("Job-today", "TAG-TODAY", nbJobs, nbTasksPerJob);
for (InternalJob j : todayJobs) {
service.submitJob(j);
}
for (InternalJob j : actualInternalJobs) {
j.start();
j.setStartTime(100L);
for (InternalTask t : j.getITasks()) {
t.setStartTime(100L);
dbManager.jobTaskStarted(j, t, true);
}
}
for (int i = 0; i < todayJobs.size(); i++) {
terminateJob(i, 500L);
}
crit = TaskFilterCriteria.TFCBuilder.newInstance().from(100L).criterias();
actualPageState = getTaskStates(crit);
for (TaskState ts : actualPageState.getList()) {
String taskStr = "Results from criteria:" + ts.getName() + "," + ts.getTag() + "," + String.valueOf(ts.getStartTime()) + "," + String.valueOf(ts.getFinishedTime()) + "," + ts.getStatus();
System.out.println(taskStr);
}
assertEquals("Incorrect tasks list size due to coupled dates from/to", totalNbTasks, actualPageState.getList().size());
}
Aggregations