Search in sources :

Example 11 with NotificationData

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;
            }
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 12 with NotificationData

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;
            }
    }
}
Also used : JobStatus(org.ow2.proactive.scheduler.common.job.JobStatus) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 13 with NotificationData

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);
    }
}
Also used : IdentifiedJob(org.ow2.proactive.scheduler.job.IdentifiedJob) UserIdentification(org.ow2.proactive.scheduler.common.job.UserIdentification) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) AlreadyConnectedException(org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException)

Example 14 with NotificationData

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");
}
Also used : JobStatus(org.ow2.proactive.scheduler.common.job.JobStatus) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) JobState(org.ow2.proactive.scheduler.common.job.JobState) SchedulerEventListenerExtended(org.ow2.proactive.scheduler.smartproxy.common.SchedulerEventListenerExtended) Semaphore(java.util.concurrent.Semaphore) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) JobId(org.ow2.proactive.scheduler.common.job.JobId) SchedulerEvent(org.ow2.proactive.scheduler.common.SchedulerEvent) NotificationData(org.ow2.proactive.scheduler.common.NotificationData) Test(org.junit.Test)

Example 15 with NotificationData

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()));
}
Also used : EventNotification(org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification)

Aggregations

TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)8 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)7 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)7 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)7 JobId (org.ow2.proactive.scheduler.common.job.JobId)6 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)5 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)5 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)5 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)5 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)4 ArrayList (java.util.ArrayList)3 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)3 EventNotification (org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification)3 HashMap (java.util.HashMap)2 SchedulerEvent (org.ow2.proactive.scheduler.common.SchedulerEvent)2 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)2 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)2 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)2 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)2 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)2