use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class TestTaskNotStarted method test.
@Test
public void test() throws Exception {
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
JobId jobId;
JobState jobState;
jobId = scheduler.submit(createJob1());
jobState = scheduler.getJobState(jobId);
assertEquals(1, jobState.getTasks().size());
assertEquals(TaskStatus.SUBMITTED, jobState.getTasks().get(0).getStatus());
scheduler.killJob(jobId);
jobState = scheduler.getJobState(jobId);
assertEquals(1, jobState.getTasks().size());
assertEquals(TaskStatus.NOT_STARTED, jobState.getTasks().get(0).getStatus());
jobId = scheduler.submit(createJob2());
schedulerHelper.waitForEventJobRunning(jobId);
jobState = scheduler.getJobState(jobId);
assertEquals(2, jobState.getTasks().size());
assertEquals(TaskStatus.PENDING, getTask(jobState, "task2").getStatus());
scheduler.killJob(jobId);
jobState = scheduler.getJobState(jobId);
assertEquals(2, jobState.getTasks().size());
assertEquals(TaskStatus.NOT_STARTED, getTask(jobState, "task2").getStatus());
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class TestTaskNotExecuted method testTaskNotExecuted.
private void testTaskNotExecuted(String jobDescriptorPath1, String jobDescriptorPath2, String jobDescriptorPath3) throws Exception {
log("Submitting job 1");
JobId id1 = schedulerHelper.submitJob(jobDescriptorPath1);
log("Wait for event job 1 submitted");
schedulerHelper.waitForEventJobSubmitted(id1);
log("Wait for event t1 running");
schedulerHelper.waitForEventTaskRunning(id1, "t0");
schedulerHelper.waitForEventTaskFinished(id1, "t0");
schedulerHelper.waitForEventJobFinished(id1);
TaskResult tr1 = schedulerHelper.getSchedulerInterface().getTaskResult(id1, "t1");
assertTrue(tr1.getException() instanceof TaskCouldNotStartException);
log("Submitting job 2");
JobId id2 = schedulerHelper.submitJob(jobDescriptorPath2);
log("Wait for event job 2 submitted");
schedulerHelper.waitForEventJobSubmitted(id2);
log("Wait for event t2 running");
schedulerHelper.waitForEventTaskRunning(id2, "t2");
log("Restarting task");
schedulerHelper.getSchedulerInterface().restartTask(id2, "t2", Integer.MAX_VALUE);
TaskInfo ti2 = schedulerHelper.waitForEventTaskWaitingForRestart(id2, "t2");
schedulerHelper.getSchedulerInterface().killJob(id2);
schedulerHelper.waitForEventJobFinished(id2);
JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(id2);
Assert.assertEquals(TaskStatus.NOT_RESTARTED, jobState.getTasks().get(0).getStatus());
TaskResult tr2 = schedulerHelper.getSchedulerInterface().getTaskResult(id2, "t2");
assertTrue(tr2.getException() instanceof TaskCouldNotRestartException);
log("Submitting job 3");
JobId id3 = schedulerHelper.submitJob(jobDescriptorPath3);
log("Wait for event job 3 submitted");
schedulerHelper.waitForEventJobSubmitted(id3);
log("Wait for event T T1 T2 finished");
schedulerHelper.waitForEventTaskFinished(id3, "T");
schedulerHelper.waitForEventTaskFinished(id3, "T1");
TaskResult tr3_1 = schedulerHelper.getSchedulerInterface().getTaskResult(id3, "T1");
TaskResult tr3_2 = schedulerHelper.getSchedulerInterface().getTaskResult(id3, "T2");
assertNull(tr3_1.getException());
assertTrue(tr3_2.getException() instanceof TaskSkippedException);
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class TestJobServerLogs method checkRemoval.
public void checkRemoval(JobId jobId) throws Exception {
JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobId);
List<TaskState> tasks = jobState.getTasks();
checkJobAndTaskLogFiles(jobId, tasks, true);
// Before it was only job removal but it was bug prone (for pendingJob only)
// because the following sequence of the events could happen:
// 1. SchedulerMethodImpl main loop retrieves info about this forever pending job
// 2. we call removeJob
// 3. SchedulerMethodImpl main loop asks for RM::getRMNodes.
//
// Third action would print "[SelectionManager.doSelectNodes] "scheduler"..." to the task log
// which would actually re-created removed log file which would cause an error
// in the last line of this method
// that is why kill the job and after wait 5s to make sure that
// iteration of SchedulerMethodImpl main loop is finished,
// and finally, we remove job with its log files.
schedulerHelper.killJob(jobId.value());
Thread.sleep(5000);
schedulerHelper.removeJob(jobId);
schedulerHelper.waitForEventJobRemoved(jobId);
System.out.println("Suppose to remove all logs at " + simpleDateFormat.format(new Date()));
checkNoLogsFromAPI(jobId, tasks);
checkJobAndTaskLogFiles(jobId, tasks, false);
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class TestMultipleHostsRequest method testMultipleHostsRequest.
@Test
public void testMultipleHostsRequest() throws Throwable {
String task1Name = "task1";
switch(OperatingSystem.getOperatingSystem()) {
case windows:
// set system Property for executable path
System.setProperty(executablePathPropertyName, new File(executablePathWindows.toURI()).getAbsolutePath());
break;
case unix:
SchedulerTHelper.setExecutable(new File(executablePath.toURI()).getAbsolutePath());
// set system Property for executable path
System.setProperty(executablePathPropertyName, new File(executablePath.toURI()).getAbsolutePath());
break;
default:
throw new IllegalStateException("Unsupported operating system");
}
// test submission and event reception
TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
JobId id = schedulerHelper.submitJob(job);
schedulerHelper.addExtraNodes(3);
log("Job submitted, id " + id.toString());
log("Waiting for jobSubmitted Event");
JobState receivedState = schedulerHelper.waitForEventJobSubmitted(id);
assertEquals(receivedState.getId(), id);
log("Waiting for job running");
JobInfo jInfo = schedulerHelper.waitForEventJobRunning(id);
assertEquals(jInfo.getJobId(), id);
assertEquals(JobStatus.RUNNING, jInfo.getStatus());
schedulerHelper.waitForEventTaskRunning(id, task1Name);
TaskInfo tInfo = schedulerHelper.waitForEventTaskFinished(id, task1Name);
log(schedulerHelper.getSchedulerInterface().getTaskResult(id, "task1").getOutput().getAllLogs(false));
assertEquals(TaskStatus.FINISHED, tInfo.getStatus());
schedulerHelper.waitForEventJobFinished(id);
JobResult res = schedulerHelper.getJobResult(id);
// check that there is one exception in results
assertTrue(res.getExceptionResults().isEmpty());
// remove job
schedulerHelper.removeJob(id);
schedulerHelper.waitForEventJobRemoved(id);
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerFrontendState method getJobState.
synchronized JobState getJobState(JobId jobId) throws NotConnectedException, UnknownJobException, PermissionException {
checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_JOB);
ClientJobState jobState = jobsMap.get(jobId);
ClientJobState jobStateCopy;
synchronized (jobState) {
try {
jobStateCopy = (ClientJobState) ProActiveMakeDeepCopy.WithProActiveObjectStream.makeDeepCopy(jobState);
} catch (Exception e) {
logger.error("Error when copying job state", e);
throw new IllegalStateException(e);
}
}
return jobStateCopy;
}
Aggregations