use of org.ow2.proactive.scheduler.common.job.JobStatus 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.JobStatus in project scheduling by ow2-proactive.
the class AbstractRestFuncTestCase method waitJobState.
public void waitJobState(String jobId, JobStatus expected, long timeout) throws Exception {
long stopTime = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < stopTime) {
JobStatus currentStatus = getScheduler().getJobState(jobId).getStatus();
if (currentStatus.equals(expected)) {
return;
} else if (!currentStatus.isJobAlive()) {
break;
} else {
Thread.sleep(300);
}
}
Assert.fail("Failed to wait when " + jobId + " is " + expected + ", current status is " + getScheduler().getJobState(jobId).getStatus());
}
use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.
the class RestSmartProxyTest method testInErrorEventsReception.
@Test(timeout = TEN_MINUTES)
public void testInErrorEventsReception() throws Exception {
System.out.println("Begin testInErrorEventsReception ");
TaskFlowJob job = createInErrorJob();
final Semaphore semaphore = new Semaphore(0);
printJobXmlRepresentation(job);
final MutableBoolean taskHasBeenInError = new MutableBoolean(false);
final MutableBoolean taskMarkedAsFinished = new MutableBoolean(false);
SchedulerEventListenerExtended listener = new SchedulerEventListenerExtended() {
@Override
public void schedulerStateUpdatedEvent(SchedulerEvent eventType) {
System.out.println("RestSmartProxyTest.schedulerStateUpdatedEvent " + eventType);
}
@Override
public void jobSubmittedEvent(JobState job) {
System.out.println("RestSmartProxyTest.jobSubmittedEvent");
}
@Override
public void jobStateUpdatedEvent(NotificationData<JobInfo> notification) {
JobStatus status = notification.getData().getStatus();
System.out.println("RestSmartProxyTest.jobStateUpdatedEvent, eventType=" + notification.getEventType() + ", jobStatus=" + status);
if (status == JobStatus.IN_ERROR) {
semaphore.release();
}
}
@Override
public void taskStateUpdatedEvent(NotificationData<TaskInfo> notification) {
TaskStatus status = notification.getData().getStatus();
System.out.println("RestSmartProxyTest.taskStateUpdatedEvent, taskStatus=" + status);
if (status == TaskStatus.WAITING_ON_ERROR || status == TaskStatus.IN_ERROR) {
// IN_ERROR previously
taskHasBeenInError.setTrue();
}
if (status == TaskStatus.FINISHED && taskHasBeenInError.isTrue()) {
taskMarkedAsFinished.setTrue();
}
}
@Override
public void usersUpdatedEvent(NotificationData<UserIdentification> notification) {
System.out.println("RestSmartProxyTest.usersUpdatedEvent " + notification.getData());
}
@Override
public void pullDataFinished(String jobId, String taskName, String localFolderPath) {
System.out.println("RestSmartProxyTest.pullDataFinished");
}
@Override
public void pullDataFailed(String jobId, String taskName, String remoteFolder_URL, Throwable t) {
System.out.println("RestSmartProxyTest.pullDataFailed");
}
@Override
public void jobUpdatedFullDataEvent(JobState job) {
System.out.println("RestSmartProxyTest.jobUpdatedFullDataEvent");
}
};
restSmartProxy.addEventListener(listener);
JobId jobId = restSmartProxy.submit(job, inputLocalFolder.getAbsolutePath(), pushUrl, outputLocalFolder.getAbsolutePath(), pullUrl, false, false);
// the next line blocks until jobStateUpdatedEvent is called on the
// listener
// with job status set to IN_ERROR
semaphore.acquire();
String jobIdAsString = jobId.value();
System.out.println("Finish in-error task");
restSmartProxy.finishInErrorTask(jobIdAsString, inerrorTaskName);
waitForJobFinishState(jobIdAsString);
assertThat(taskHasBeenInError.booleanValue()).isTrue();
assertThat(taskMarkedAsFinished.booleanValue()).isTrue();
System.out.println("End testInErrorEventsReception");
}
use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.
the class SchedulerClientTest method testJobResult.
@Test(timeout = MAX_WAIT_TIME)
public void testJobResult() throws Throwable {
ISchedulerClient client = clientInstance();
Job job = createJobManyTasks("JobResult", SimpleJob.class, ErrorTask.class, LogTask.class, VariableTask.class, MetadataTask.class, RawTask.class);
JobId jobId = submitJob(job, client);
JobResult result = client.waitForJob(jobId, TimeUnit.MINUTES.toMillis(3));
// job result
Assert.assertNotNull(result.getJobId());
Assert.assertNotNull(result.getJobInfo());
Assert.assertEquals(JobStatus.FINISHED, result.getJobInfo().getStatus());
// the following check cannot work because of the way the job id is created on the client side.
// Assert.assertEquals(job.getName(), result.getName());
Assert.assertTrue(result.hadException());
Assert.assertEquals(1, result.getExceptionResults().size());
// job info
checkJobInfo(result.getJobInfo());
checkJobInfo(client.getJobInfo(jobId.value()));
JobState jobState = client.getJobState(jobId.value());
JobStatus status = jobState.getStatus();
Assert.assertFalse(status.isJobAlive());
Assert.assertEquals(JobStatus.FINISHED, status);
checkJobInfo(jobState.getJobInfo());
TaskState errorTaskState = findTask(getTaskNameForClass(ErrorTask.class), jobState.getHMTasks());
Assert.assertNotNull(errorTaskState);
TaskState simpleTaskState = findTask(getTaskNameForClass(SimpleJob.class), jobState.getHMTasks());
Assert.assertNotNull(simpleTaskState);
Assert.assertEquals(TaskStatus.FAULTY, errorTaskState.getStatus());
Assert.assertEquals(TaskStatus.FINISHED, simpleTaskState.getStatus());
// task result simple
TaskResult tResSimple = result.getResult(getTaskNameForClass(SimpleJob.class));
Assert.assertNotNull(tResSimple.value());
Assert.assertNotNull(tResSimple.getSerializedValue());
Assert.assertEquals(new StringWrapper(TEST_JOB), tResSimple.value());
Assert.assertEquals(new StringWrapper(TEST_JOB), ObjectByteConverter.byteArrayToObject(tResSimple.getSerializedValue()));
// task result with error
TaskResult tResError = result.getResult(getTaskNameForClass(ErrorTask.class));
Assert.assertNotNull(tResError);
Assert.assertTrue(tResError.hadException());
Assert.assertNotNull(tResError.getException());
Assert.assertTrue(tResError.getException() instanceof TaskException);
// task result with logs
TaskResult tResLog = result.getResult(getTaskNameForClass(LogTask.class));
Assert.assertNotNull(tResLog);
Assert.assertNotNull(tResLog.getOutput());
System.err.println(tResLog.getOutput().getStdoutLogs(false));
Assert.assertTrue(tResLog.getOutput().getStdoutLogs(false).contains(LogTask.HELLO_WORLD));
// task result with variables
TaskResult tResVar = result.getResult(getTaskNameForClass(VariableTask.class));
Assert.assertNotNull(tResVar.getPropagatedVariables());
Map<String, Serializable> vars = tResVar.getVariables();
System.out.println(vars);
Assert.assertTrue(tResVar.getPropagatedVariables().containsKey(VariableTask.MYVAR));
Assert.assertEquals("myvalue", vars.get(VariableTask.MYVAR));
// task result with metadata
TaskResult tMetaVar = result.getResult(getTaskNameForClass(MetadataTask.class));
Assert.assertNotNull(tMetaVar.getMetadata());
Assert.assertTrue(tMetaVar.getMetadata().containsKey(MetadataTask.MYVAR));
// task result with raw result
TaskResult tResRaw = result.getResult(getTaskNameForClass(RawTask.class));
Assert.assertNotNull(tResRaw.value());
Assert.assertNotNull(tResRaw.getSerializedValue());
Assert.assertArrayEquals(TEST_JOB.getBytes(), (byte[]) tResRaw.value());
Assert.assertArrayEquals(TEST_JOB.getBytes(), tResRaw.getSerializedValue());
}
use of org.ow2.proactive.scheduler.common.job.JobStatus in project scheduling by ow2-proactive.
the class TestRMReconnectionWhileRunning method assertJobFinished.
private void assertJobFinished(JobId jobId) throws Exception {
final JobResult result0 = schedulerHelper.getJobResult(jobId);
assertNotNull(result0);
final JobInfo jobInfo0 = result0.getJobInfo();
final JobStatus status0 = jobInfo0.getStatus();
assertFalse(status0.isJobAlive());
}
Aggregations