Search in sources :

Example 16 with NotificationData

use of org.ow2.proactive.scheduler.common.NotificationData 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();
            }
        }
    }
}
Also used : JobId(org.ow2.proactive.scheduler.common.job.JobId) SchedulerEvent(org.ow2.proactive.scheduler.common.SchedulerEvent)

Example 17 with NotificationData

use of org.ow2.proactive.scheduler.common.NotificationData 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);
}
Also used : SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 18 with NotificationData

use of org.ow2.proactive.scheduler.common.NotificationData in project scheduling by ow2-proactive.

the class TerminateIfTaskHandler method terminateIfTask.

public boolean terminateIfTask(FlowAction action, InternalTask initiator, ChangedTasksInfo changesInfo, SchedulerStateUpdate frontend, InternalTask descriptor, TaskId taskId) {
    InternalTask[] targets = searchIfElseJoinTasks(action, initiator);
    // the targetIf from action getTarget is the selected branch
    // the IF condition has already been evaluated prior to being put in a
    // FlowAction
    // the targetElse from action getTargetElse is the branch that was NOT
    // selected
    InternalTask targetIf = targets[0];
    InternalTask targetElse = targets[1];
    InternalTask targetJoin = targets[2];
    LOGGER.info("Control Flow Action IF: " + targetIf.getId() + " join: " + ((targetJoin == null) ? "null" : targetJoin.getId()));
    // these 2 tasks delimit the Task Block formed by the IF branch
    InternalTask branchStart = targetIf;
    InternalTask branchEnd = null;
    String match = targetIf.getMatchingBlock();
    if (match != null) {
        for (InternalTask t : internalJob.getIHMTasks().values()) {
            if (match.equals(t.getName()) && !(t.getStatus().equals(TaskStatus.FINISHED) || t.getStatus().equals(TaskStatus.SKIPPED))) {
                branchEnd = t;
            }
        }
    }
    // no matching block: there is no block, the branch is a single task
    if (branchEnd == null) {
        branchEnd = targetIf;
    }
    // plug the branch
    branchStart.addDependence(initiator);
    changesInfo.taskUpdated(branchStart);
    if (targetJoin != null) {
        targetJoin.addDependence(branchEnd);
        changesInfo.taskUpdated(targetJoin);
    }
    // the other branch will not be executed
    // first, find the concerned tasks
    List<InternalTask> elseTasks = new ArrayList<>();
    // elseTasks.add(targetElse);
    for (InternalTask t : internalJob.getIHMTasks().values()) {
        if (t.dependsOn(targetElse)) {
            elseTasks.add(t);
        }
    }
    // even though the targetElse is not going to be executed, a
    // dependency on initiator still makes sense and would help
    // reconstruct the job graph on the client
    targetElse.addDependence(initiator);
    changesInfo.taskUpdated(targetElse);
    for (InternalTask it : elseTasks) {
        it.setFinishedTime(descriptor.getFinishedTime() + 1);
        it.setStatus(TaskStatus.SKIPPED);
        it.setExecutionDuration(0);
        changesInfo.taskSkipped(it);
        internalJob.setNumberOfPendingTasks(internalJob.getNumberOfPendingTasks() - 1);
        internalJob.setNumberOfFinishedTasks(internalJob.getNumberOfFinishedTasks() + 1);
        LOGGER.info("Task " + it.getId() + " will not be executed");
    }
    // plug the branch in the descriptor
    TaskId joinId = null;
    if (targetJoin != null) {
        joinId = targetJoin.getId();
    }
    internalJob.getJobDescriptor().doIf(initiator.getId(), branchStart.getId(), branchEnd.getId(), joinId, targetElse.getId(), elseTasks);
    ((JobInfoImpl) internalJob.getJobInfo()).setTasksChanges(changesInfo, internalJob);
    // notify frontend that tasks were modified
    if (frontend != null) {
        frontend.jobStateUpdated(internalJob.getOwner(), new NotificationData<>(SchedulerEvent.TASK_SKIPPED, internalJob.getJobInfo()));
        frontend.jobUpdatedFullData(internalJob);
    }
    ((JobInfoImpl) internalJob.getJobInfo()).clearTasksChanges();
    // no jump is performed ; now that the tasks have been plugged
    // the flow can continue its normal operation
    internalJob.getJobDescriptor().terminate(taskId);
    return true;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl)

Example 19 with NotificationData

use of org.ow2.proactive.scheduler.common.NotificationData in project scheduling by ow2-proactive.

the class SchedulingService method getProgressAndPingTaskNode.

void getProgressAndPingTaskNode(RunningTaskData taskData) {
    if (!jobs.canPingTask(taskData) || taskData.getPingAttempts() > PASchedulerProperties.SCHEDULER_NODE_PING_ATTEMPTS.getValueAsInt()) {
        return;
    }
    InternalTask task = taskData.getTask();
    try {
        // (2)
        int progress = taskData.getLauncher().getProgress();
        // get previous inside td
        if (progress != task.getProgress()) {
            // (1)
            task.setProgress(progress);
            // if progress != previously set progress (0 by default) -> update
            listener.taskStateUpdated(taskData.getUser(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_PROGRESS, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
        }
    } catch (Throwable t) {
        tlogger.debug(task.getId(), "TaskLauncher is not accessible, checking if the node can be reached.", t);
        pingTaskNodeAndInitiateRestart(task);
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl)

Example 20 with NotificationData

use of org.ow2.proactive.scheduler.common.NotificationData in project scheduling by ow2-proactive.

the class SchedulerFrontendState method jobStateUpdated.

@Override
public synchronized void jobStateUpdated(String owner, NotificationData<JobInfo> notification) {
    ClientJobState js = jobsMap.get(notification.getData().getJobId());
    synchronized (js) {
        js.update(notification.getData());
        switch(notification.getEventType()) {
            case JOB_PENDING_TO_RUNNING:
                sState.pendingToRunning(js);
                break;
            case JOB_PAUSED:
            case JOB_IN_ERROR:
            case JOB_RESUMED:
            case JOB_RESTARTED_FROM_ERROR:
            case JOB_CHANGE_PRIORITY:
            case TASK_REPLICATED:
            case TASK_SKIPPED:
                break;
            case JOB_PENDING_TO_FINISHED:
                sState.pendingToFinished(js);
                // set this job finished, user can get its result
                jobs.get(notification.getData().getJobId()).setFinished(true);
                break;
            case JOB_RUNNING_TO_FINISHED:
                sState.runningToFinished(js);
                // set this job finished, user can get its result
                jobs.get(notification.getData().getJobId()).setFinished(true);
                break;
            case JOB_REMOVE_FINISHED:
                // removing jobs from the global list : this job is no more managed
                sState.removeFinished(js);
                jobsMap.remove(js.getId());
                jobs.remove(notification.getData().getJobId());
                logger.debug("HOUSEKEEPING removed the finished job " + js.getId() + " from the SchedulerFrontEndState");
                break;
            default:
                logger.warn("**WARNING** - Unconsistent update type received from Scheduler Core : " + notification.getEventType());
                return;
        }
        dispatchJobStateUpdated(owner, notification);
        new JobEmailNotification(js, notification).checkAndSend();
    }
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState)

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