use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class LiveJobs method restartAllInErrorTasks.
public Boolean restartAllInErrorTasks(JobId jobId) {
JobData jobData = lockJob(jobId);
if (jobData == null) {
return false;
}
try {
InternalJob job = jobData.job;
for (TaskState taskState : job.getTasks()) {
try {
restartInErrorTask(jobId, taskState.getName());
} catch (UnknownTaskException e) {
logger.error("", e);
jlogger.error(jobId, "", e);
tlogger.error(taskState.getId(), "", e);
}
}
setJobStatusToInErrorIfNotPaused(job);
dbManager.updateJobAndTasksState(job);
updateJobInSchedulerState(job, SchedulerEvent.JOB_RESTARTED_FROM_ERROR);
return Boolean.TRUE;
} finally {
jobData.unlock();
}
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerFrontendState method getTaskState.
synchronized TaskState getTaskState(JobId jobId, TaskId taskId) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_TASK);
if (jobsMap.get(jobId) == null) {
throw new UnknownJobException(jobId);
}
JobState jobState = jobsMap.get(jobId);
synchronized (jobState) {
TaskState ts = jobState.getHMTasks().get(taskId);
if (ts == null) {
throw new UnknownTaskException(taskId, jobId);
}
return ts;
}
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class TaskData method toTaskState.
public TaskState toTaskState() {
TaskInfo taskInfo = toTaskInfo();
TaskStateImpl taskState = new TaskStateImpl();
taskState.update(taskInfo);
taskState.setName(getTaskName());
taskState.setDescription(getDescription());
taskState.setTag(getTag());
taskState.setIterationIndex(getIteration());
taskState.setReplicationIndex(getReplication());
taskState.setMaxNumberOfExecution(getMaxNumberOfExecution());
taskState.setParallelEnvironment(getParallelEnvironment());
taskState.setGenericInformation(getGenericInformation());
taskState.setVariables(variablesToTaskVariables());
return taskState;
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class TestLicensePolicy method testLicensePolicy.
/**
* Tests that two independent tasks do not run at the same time, due to license limitation.
*
* @throws Exception
*/
@Test
public void testLicensePolicy() throws Throwable {
JobId jobId = schedulerHelper.submitJob(new File(jobDescriptor.toURI()).getAbsolutePath());
log("Waiting for job finished");
schedulerHelper.waitForEventJobFinished(jobId);
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
TaskState taskState0 = scheduler.getJobState(jobId).getTasks().get(0);
TaskState taskState1 = scheduler.getJobState(jobId).getTasks().get(1);
boolean tasksExecutedOneByOne = (taskState0.getFinishedTime() < taskState1.getStartTime()) || (taskState1.getFinishedTime() < taskState0.getStartTime());
Assert.assertTrue(tasksExecutedOneByOne);
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class RunningTaskRecoveryWhenNodesAreReservedInBatchTest method action.
@Test
public void action() throws Throwable {
nodes = schedulerHelper.createRMNodeStarterNodes(RunningTaskRecoveryWhenNodesAreReservedInBatchTest.class.getSimpleName(), NB_NODES);
for (int i = 0; i < NB_NODES; i++) {
schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
}
JobId jobid = schedulerHelper.submitJob(new File(JOB_DESCRIPTOR.toURI()).getAbsolutePath());
schedulerHelper.waitForEventJobRunning(jobid);
schedulerHelper.waitForEventTaskFinished(jobid, "Groovy_Task");
JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobid);
SchedulerTHelper.log("Total number of tasks: " + jobState.getTotalNumberOfTasks());
List<TaskState> tasks = jobState.getTasks();
TaskState fifthTask = tasks.get(5);
SchedulerTHelper.log("Wait for the fifth task running");
// we wait for the fifth task to be running so that when we kill the
// scheduler we have a mix of pending/submitted/running tasks
schedulerHelper.waitForEventTaskRunning(fifthTask.getJobId(), fifthTask.getName());
SchedulerTHelper.log("Fifth task is running");
// restart scheduler
printRmStateAndReturnNotFreeNodeNumber();
printJobStateAndReturnNumberOfRunningTasks(jobid);
TestScheduler.kill();
schedulerHelper = new SchedulerTHelper(false, new File(SCHEDULER_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), new File(RM_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), null, false);
SchedulerTHelper.log("Wait for job to finish");
JobInfo jobInfo = schedulerHelper.waitForEventJobFinished(jobid);
assertThat(jobInfo.getNumberOfFailedTasks()).isEqualTo(0);
assertThat(jobInfo.getNumberOfInErrorTasks()).isEqualTo(0);
// wait for all nodes released
while (printRmStateAndReturnNotFreeNodeNumber() != 0) {
schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
}
// all nodes should be free now
int notFreeNodeNumber = printRmStateAndReturnNotFreeNodeNumber();
assertThat(notFreeNodeNumber).isEqualTo(0);
}
Aggregations