use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerDBManagerTest method testUpdateJobAndTasksState.
@Test
public void testUpdateJobAndTasksState() throws Exception {
InternalJob job = createTestJob("test", "tag", 1);
service.submitJob(job);
job.setStatus(JobStatus.KILLED);
job.setNumberOfFailedTasks(2);
job.setNumberOfFaultyTasks(3);
job.setNumberOfInErrorTasks(5);
job.setInErrorTime(7);
InternalTask internalTask = job.getITasks().get(0);
internalTask.setStatus(TaskStatus.IN_ERROR);
internalTask.setInErrorTime(11);
dbManager.updateJobAndTasksState(job);
Page<JobInfo> jobs = dbManager.getJobs(0, 10, null, true, true, true, null);
assertThat(jobs.getSize()).isEqualTo(1);
JobInfo jobInfo = jobs.getList().get(0);
assertThat(jobInfo.getStatus()).isEqualTo(JobStatus.KILLED);
assertThat(jobInfo.getNumberOfFailedTasks()).isEqualTo(2);
assertThat(jobInfo.getNumberOfFaultyTasks()).isEqualTo(3);
assertThat(jobInfo.getNumberOfInErrorTasks()).isEqualTo(5);
assertThat(jobInfo.getInErrorTime()).isEqualTo(7);
Page<TaskState> tasks = dbManager.getTaskStates(0, 10, null, 0, 10, null, true, true, true, new SortSpecifierContainer());
assertThat(tasks.getSize()).isEqualTo(1);
TaskState taskState = tasks.getList().get(0);
assertThat(taskState.getStatus()).isEqualTo(TaskStatus.IN_ERROR);
assertThat(taskState.getTaskInfo().getInErrorTime()).isEqualTo(11);
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerDBManagerTest method assertTaskStatePage.
private void assertTaskStatePage(Page<TaskState> page, TaskFilterCriteria criterias) {
int nbTaskStates = page.getList().size();
for (TaskState taskState : page.getList()) {
String tag = criterias.getTag();
if (tag != null)
assertEquals("Tag is incorrect", tag, taskState.getTag());
// from
long from = criterias.getFrom();
if (from != 0)
assertEquals("startTime is incorrect", from, taskState.getStartTime());
// to
long to = criterias.getTo();
if (to != 0)
assertEquals("finishedTime is incorrect", to, taskState.getFinishedTime());
// pagination
int pageSize = criterias.getLimit() - criterias.getOffset();
if (pageSize > 0) {
assertTrue("Page size is incorrect", pageSize >= nbTaskStates);
}
// user
String expectedUser = criterias.getUser();
String actualUser = taskState.getTaskInfo().getJobInfo().getJobOwner();
if (expectedUser != null && "".compareTo(expectedUser) != 0) {
assertEquals("user is incorrect", expectedUser, actualUser);
}
// the corresponding criteria should be true
switch(taskState.getStatus()) {
case SUBMITTED:
case PENDING:
case NOT_STARTED:
assertTrue("Task status is incorrect", criterias.isPending());
break;
case PAUSED:
case RUNNING:
case WAITING_ON_ERROR:
case WAITING_ON_FAILURE:
assertTrue("Task status is incorrect", criterias.isRunning());
break;
case FAILED:
case NOT_RESTARTED:
case ABORTED:
case FAULTY:
case FINISHED:
case SKIPPED:
assertTrue("Task status is incorrect", criterias.isFinished());
break;
default:
fail("Incoherent task status");
}
}
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class TestLoadSchedulerClientState method checkTaskData.
private void checkTaskData(JavaTask expected, TaskState taskState, String... dependences) {
Assert.assertEquals(expected.getName(), taskState.getName());
Assert.assertEquals(expected.getDescription(), taskState.getDescription());
Assert.assertEquals(expected.getName(), taskState.getTaskInfo().getTaskId().getReadableName());
Assert.assertEquals(expected.getOnTaskErrorProperty().getValue(), taskState.getOnTaskErrorProperty().getValue());
Assert.assertEquals(expected.getMaxNumberOfExecution(), taskState.getMaxNumberOfExecution());
Assert.assertEquals(expected.isPreciousLogs(), taskState.isPreciousLogs());
Assert.assertEquals(expected.isPreciousResult(), taskState.isPreciousResult());
Assert.assertEquals(expected.isRunAsMe(), taskState.isRunAsMe());
Assert.assertEquals(expected.getWallTime(), taskState.getWallTime());
Assert.assertEquals("Unexpected number of dependencies", dependences.length, taskState.getDependences().size());
Set<String> dependenciesSet = new HashSet<>();
for (String dependecy : dependences) {
dependenciesSet.add(dependecy);
}
Set<String> actualDependenciesSet = new HashSet<>();
for (TaskState task : taskState.getDependences()) {
actualDependenciesSet.add(task.getName());
}
Assert.assertEquals("Unexpected dependencies", dependenciesSet, actualDependenciesSet);
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerFrontend method getTaskResultsByTag.
@Override
@ImmediateService
public List<TaskResult> getTaskResultsByTag(JobId jobId, String taskTag) throws NotConnectedException, UnknownJobException, PermissionException {
frontendState.checkPermission("getTaskResultByTag", YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB);
List<TaskState> taskStates = getJobState(jobId).getTasksByTag(taskTag);
ArrayList<TaskResult> results = new ArrayList<TaskResult>(taskStates.size());
for (TaskState currentState : taskStates) {
String taskName = currentState.getTaskInfo().getName();
try {
TaskResult currentResult = getTaskResult(jobId, taskName);
results.add(currentResult);
} catch (UnknownTaskException ex) {
// never occurs because tasks are filtered by tag so they cannot
// be unknown.
logger.warn("Unknown task.", ex);
}
}
return results;
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerFrontend method getTaskServerLogsByTag.
@Override
@ImmediateService
public String getTaskServerLogsByTag(String jobId, String taskTag) throws UnknownJobException, NotConnectedException, PermissionException {
JobId id = JobIdImpl.makeJobId(jobId);
frontendState.checkPermissions("getTaskServerLogsByTag", frontendState.getIdentifiedJob(id), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_LOGS_OF_THIS_JOB);
List<TaskState> lTaskState = frontendState.getJobState(id).getTasksByTag(taskTag);
Set<TaskId> tasksIds = new HashSet<>(lTaskState.size());
for (TaskState taskState : lTaskState) {
tasksIds.add(taskState.getId());
}
return ServerJobAndTaskLogs.getJobLog(id, tasksIds);
}
Aggregations