use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class TestJobWithInvalidSelectionScript method testJobWithInvalidSelectionScript.
@Test
public void testJobWithInvalidSelectionScript() throws Throwable {
String task1Name = "task1";
String task2Name = "task2";
String task3Name = "task3";
// cannot use SchedulerTHelper.testJobsubmission because
// task 3 is never executed so no event can received
// regarding this task.
JobId id = schedulerHelper.submitJob(new File(jobDescriptor.toURI()).getAbsolutePath());
// check events reception
log("Job submitted, id " + id.toString());
log("Waiting for jobSubmitted");
schedulerHelper.waitForEventJobSubmitted(id);
log("Waiting for job running");
schedulerHelper.waitForEventJobRunning(id);
log("Waiting for task running : " + task1Name);
schedulerHelper.waitForEventTaskRunning(id, task1Name);
log("Waiting for task finished : " + task1Name);
schedulerHelper.waitForEventTaskFinished(id, task1Name);
// second task will not even start
try {
log("Waiting for task *running : " + task2Name);
schedulerHelper.waitForEventTaskRunning(id, task2Name, 2000);
log("Waiting for task *finished : " + task2Name);
schedulerHelper.waitForEventTaskFinished(id, task2Name, 2000);
// should always go in the catch
fail();
} catch (ProActiveTimeoutException expected) {
}
// task 3 should not be started
boolean task3Started = false;
try {
schedulerHelper.waitForEventTaskRunning(id, task3Name, 1000);
// should always go in the catch
fail();
} catch (ProActiveTimeoutException e) {
}
schedulerHelper.killJob(id.toString());
JobInfo jobInfo = schedulerHelper.waitForEventJobFinished(id);
JobResult res = schedulerHelper.getJobResult(id);
Map<String, TaskResult> results = res.getAllResults();
// check that all tasks results are defined
assertNotNull(results.get("task1").value());
assertNull(results.get("task2"));
assertNull(results.get("task3"));
assertEquals(JobStatus.KILLED, jobInfo.getStatus());
assertEquals(1, jobInfo.getNumberOfFinishedTasks());
assertEquals(0, jobInfo.getNumberOfRunningTasks());
assertEquals(0, jobInfo.getNumberOfPendingTasks());
}
use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class JobResultSchedulerListener method jobRunningToFinishedEvent.
private void jobRunningToFinishedEvent(NotificationData<JobInfo> jobNotification) {
JobId jobId = jobNotification.getData().getJobId();
logger.trace("Trying to get the job result for job " + jobId);
try {
logger.info("The result for job with ID " + jobId + " is " + this.daddy.getJobResult(jobId));
} catch (SchedulerException e) {
logger.error("Cannot get the job result for job with id " + jobId + " from the scheduler", e);
}
}
use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class AbstractSmartProxy method updateJob.
// ********* Awaited Jobs methods ******************************* //
/**
* @return a new HashSet with the awaited jobs. Modifying the result of this
* method will not affect the source HashSet (the awaited jobs)
*/
/**
* Check if the job concerned by this notification is awaited. Retrieve
* corresponding data if needed
*
* @param notification
*/
protected void updateJob(NotificationData<?> notification) {
// am I interested in this job?
JobId id = ((NotificationData<JobInfo>) notification).getData().getJobId();
AwaitedJob aj = jobTracker.getAwaitedJob(id.toString());
if (aj == null)
return;
JobStatus status = ((NotificationData<JobInfo>) notification).getData().getStatus();
switch(status) {
case KILLED:
{
log.debug("The job " + id + "has been killed.");
jobTracker.removeAwaitedJob(id.toString());
break;
}
case FINISHED:
{
log.debug("The job " + id + " is finished.");
// removeAwaitedJob(id.toString());
break;
}
case CANCELED:
{
log.debug("The job " + id + " is canceled.");
jobTracker.removeAwaitedJob(id.toString());
break;
}
case FAILED:
{
log.debug("The job " + id + " is failed.");
// removeAwaitedJob(id.toString());
break;
}
}
}
use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class TestJobNativeSubmission method testJobNativeSubmission.
@Test
public void testJobNativeSubmission() throws Throwable {
// test submission and event reception
TaskFlowJob job = new TaskFlowJob();
NativeTask successfulTask = new NativeTask();
successfulTask.setName("successfulTask");
if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
successfulTask.setCommandLine("cmd", "/C", "ping 127.0.0.1 -n 10", ">", "NUL");
} else {
successfulTask.setCommandLine("ping", "-c", "5", "127.0.0.1");
}
job.addTask(successfulTask);
NativeTask invalidCommandTask = new NativeTask();
invalidCommandTask.setName("invalidCommandTask");
invalidCommandTask.addDependence(successfulTask);
invalidCommandTask.setCommandLine("invalid_command");
job.addTask(invalidCommandTask);
// SCHEDULING-1987
NativeTask taskReadingInput = new NativeTask();
taskReadingInput.setName("taskReadingInput");
if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
// wait for y/n
taskReadingInput.setCommandLine("choice");
} else {
// cat hangs for user's input
taskReadingInput.setCommandLine("cat");
}
job.addTask(taskReadingInput);
JobId id = schedulerHelper.submitJob(job);
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, successfulTask.getName());
TaskInfo tInfo = schedulerHelper.waitForEventTaskFinished(id, successfulTask.getName());
assertEquals(TaskStatus.FINISHED, tInfo.getStatus());
schedulerHelper.waitForEventTaskRunning(id, invalidCommandTask.getName());
tInfo = schedulerHelper.waitForEventTaskFinished(id, invalidCommandTask.getName());
assertEquals(TaskStatus.FAULTY, tInfo.getStatus());
TaskInfo taskReadingInputInfo = schedulerHelper.waitForEventTaskFinished(id, taskReadingInput.getName());
if (OperatingSystem.getOperatingSystem() == OperatingSystem.windows) {
// choice fails when input is closed
assertEquals(TaskStatus.FAULTY, taskReadingInputInfo.getStatus());
} else {
assertEquals(TaskStatus.FINISHED, taskReadingInputInfo.getStatus());
}
schedulerHelper.waitForEventJobFinished(id);
// remove job
schedulerHelper.removeJob(id);
schedulerHelper.waitForEventJobRemoved(id);
}
use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class JobRemoveHandlerTest method init.
@Before
public void init() throws Exception {
jobId = new JobIdImpl(id, jobName);
MockitoAnnotations.initMocks(this);
Mockito.when(infrastructure.getDBManager()).thenReturn(dbManager);
Mockito.when(infrastructure.getRMProxiesManager()).thenReturn(rmProxiesManager);
Mockito.when(rmProxiesManager.getRmUrl()).thenReturn(null);
Mockito.when(dbManager.loadJobWithTasksIfNotRemoved(jobId)).thenReturn(Collections.singletonList(job));
Mockito.when(job.getJobInfo()).thenReturn(jobInfo);
service = new SchedulingService(infrastructure, listener, null, policyClassName, schedulingMethod);
jobRemoveHandler = new JobRemoveHandler(service, jobId);
}
Aggregations