use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class SchedulerStateRestJobTaskResultTest method testValueOfJobResult.
@Test
public void testValueOfJobResult() throws Throwable {
TaskResultImpl taskResult = new TaskResultImpl(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("42"), "mytask", 1), ObjectToByteConverter.ObjectStream.convert("hello"), null, null, false);
JobResultImpl jobResultWithValue = new JobResultImpl();
JobInfoImpl jobInfo = new JobInfoImpl();
jobInfo.setJobId(new JobIdImpl(12, "myjob"));
jobResultWithValue.setJobInfo(jobInfo);
jobResultWithValue.addTaskResult("mytask", taskResult, false);
when(mockOfScheduler.getJobResult("42")).thenReturn(jobResultWithValue);
JobResultData jobResultData = restInterface.jobResult(sessionId, "42");
TaskResultData taskResultData = jobResultData.getAllResults().get("mytask");
assertNotNull(taskResultData);
assertNotNull(taskResultData.getValue());
assertEquals("hello", taskResultData.getValue());
Map<String, String> jobResult = restInterface.jobResultValue(sessionId, "42");
String result = jobResult.get("mytask");
assertNotNull(result);
assertEquals("hello", result);
}
use of org.ow2.proactive.scheduler.common.job.JobInfo 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.JobInfo in project scheduling by ow2-proactive.
the class MyEventListener method jobStateUpdatedEvent.
@Override
public void jobStateUpdatedEvent(NotificationData<JobInfo> notification) {
System.out.println("MyEventListener.jobStateUpdatedEvent() " + notification);
JobId id = notification.getData().getJobId();
if (!id.equals(jobId))
return;
SchedulerEvent event = notification.getEventType();
if (event == SchedulerEvent.JOB_RUNNING_TO_FINISHED) {
jobFinished = true;
if (synchronous) {
synchronized (monitor) {
System.out.println("[MyEventListener] job finished event occured for " + jobId);
monitor.setEventOccured();
monitor.notifyAll();
}
}
}
}
use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class SchedulingServiceTest method createMockedInternalJob.
private InternalJob createMockedInternalJob(JobId jobId) {
JobInfo jobInfo = Mockito.mock(JobInfoImpl.class);
InternalJob internalJob = Mockito.mock(InternalJob.class);
Mockito.when(jobInfo.getJobId()).thenReturn(jobId);
Mockito.when(internalJob.getJobInfo()).thenReturn(jobInfo);
Mockito.when(internalJob.getOwner()).thenReturn("MOCKED OWNER");
return internalJob;
}
use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.
the class JobResultDecorator method jobRunningToFinishedEvent.
@Override
protected void jobRunningToFinishedEvent(NotificationData<JobInfo> event) {
super.jobRunningToFinishedEvent(event);
JobId jobId = event.getData().getJobId();
if (!this.mapOfJobs.containsKey(jobId)) {
logger.trace("We are not waiting for the result of job ID " + jobId);
return;
}
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);
}
// we have the result => stop monitoring this job
this.stopMonitoring(jobId);
}
Aggregations