use of org.ow2.proactive.scheduler.common.NotificationData in project scheduling by ow2-proactive.
the class AbstractSmartProxy method updateTask.
/**
* Check if the task concerned by this notification is awaited. Retrieve
* corresponding data if needed
*
* @param notification
*/
protected void updateTask(NotificationData<TaskInfo> notification) {
// am I interested in this task?
TaskInfo taskInfoData = notification.getData();
JobId id = taskInfoData.getJobId();
TaskId tid = taskInfoData.getTaskId();
String tname = tid.getReadableName();
TaskStatus status = taskInfoData.getStatus();
AwaitedJob aj = jobTracker.getAwaitedJob(id.toString());
if (aj == null)
return;
AwaitedTask at = aj.getAwaitedTask(tname);
if (at == null)
return;
at.setTaskId(tid.toString());
jobTracker.putAwaitedJob(id.toString(), aj);
switch(status) {
case ABORTED:
case NOT_RESTARTED:
case NOT_STARTED:
case SKIPPED:
{
log.debug("The task " + tname + " from job " + id + " couldn't start. No data will be transfered");
jobTracker.removeAwaitedTask(id.toString(), tname);
break;
}
case FINISHED:
{
log.debug("The task " + tname + " from job " + id + " is finished.");
if (aj.isAutomaticTransfer()) {
log.debug("Transferring data for finished task " + tname + " from job " + id);
try {
downloadTaskOutputFiles(aj, id.toString(), tname, aj.getLocalOutputFolder());
} catch (Throwable t) {
log.error("Error while handling data for finished task " + tname + " for job " + id + ", task will be removed");
jobTracker.removeAwaitedTask(id.toString(), tname);
}
}
break;
}
case FAILED:
case FAULTY:
{
log.debug("The task " + tname + " from job " + id + " is faulty.");
jobTracker.removeAwaitedTask(id.toString(), tname);
break;
}
}
}
use of org.ow2.proactive.scheduler.common.NotificationData 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.NotificationData in project scheduling by ow2-proactive.
the class SchedulerFrontendState method jobSubmitted.
synchronized void jobSubmitted(InternalJob job, UserIdentificationImpl ident) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
// put the job inside the frontend management list
jobs.put(job.getId(), new IdentifiedJob(job.getId(), ident, job.getGenericInformation()));
// increase number of submit for this user
ident.addSubmit();
// send update user event
usersUpdated(new NotificationData<UserIdentification>(SchedulerEvent.USERS_UPDATE, ident));
jlogger.info(job.getId(), "submitted: name '" + job.getName() + "', tasks '" + job.getTotalNumberOfTasks() + "', owner '" + job.getOwner() + "'");
try {
jlogger.info(job.getId(), job.display());
} catch (Exception e) {
jlogger.error(job.getId(), "Error while displaying the job :", e);
}
}
use of org.ow2.proactive.scheduler.common.NotificationData 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.NotificationData in project scheduling by ow2-proactive.
the class SchedulerEventBroadcaster method usersUpdatedEvent.
@Override
public void usersUpdatedEvent(NotificationData<UserIdentification> notification) {
logEvent(notification);
broadcast(new EventNotification(EventNotification.Action.USERS_UPDATED, eventTypeName(notification), notification.getData()));
}
Aggregations