Search in sources :

Example 11 with JobInfo

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

the class InternalJob method replicateForNextLoopIteration.

public boolean replicateForNextLoopIteration(InternalTask initiator, InternalTask target, ChangedTasksInfo changesInfo, SchedulerStateUpdate frontend, FlowAction action) {
    LOGGER.info("LOOP (init:" + initiator.getId() + "; target:" + target.getId() + ")");
    // accumulates the tasks between the initiator and the target
    Map<TaskId, InternalTask> dup = new HashMap<>();
    // replicate the tasks between the initiator and the target
    try {
        initiator.replicateTree(dup, target.getId(), true, initiator.getReplicationIndex(), initiator.getIterationIndex());
    } catch (ExecutableCreationException e) {
        LOGGER.error("", e);
        return false;
    }
    ((JobInfoImpl) this.getJobInfo()).setNumberOfPendingTasks(this.getJobInfo().getNumberOfPendingTasks() + dup.size());
    // time-consuming but safe
    for (InternalTask nt : dup.values()) {
        boolean ok;
        do {
            ok = true;
            for (InternalTask task : tasks.values()) {
                if (nt.getName().equals(task.getName())) {
                    nt.setIterationIndex(nt.getIterationIndex() + 1);
                    ok = false;
                }
            }
        } while (!ok);
    }
    // configure the new tasks
    InternalTask newTarget = null;
    InternalTask newInit = null;
    for (Entry<TaskId, InternalTask> it : dup.entrySet()) {
        InternalTask nt = it.getValue();
        if (target.getId().equals(it.getKey())) {
            newTarget = nt;
        }
        if (initiator.getId().equals(it.getKey())) {
            newInit = nt;
        }
        nt.setJobInfo(getJobInfo());
        this.addTask(nt);
        assignReplicationTag(nt, initiator, true, action);
    }
    changesInfo.newTasksAdded(dup.values());
    // connect replicated tree
    newTarget.addDependence(initiator);
    changesInfo.taskUpdated(newTarget);
    // connect mergers
    List<InternalTask> mergers = new ArrayList<>();
    for (InternalTask t : this.tasks.values()) {
        if (t.getIDependences() != null) {
            for (InternalTask p : t.getIDependences()) {
                if (p.getId().equals(initiator.getId())) {
                    if (!t.equals(newTarget)) {
                        mergers.add(t);
                    }
                }
            }
        }
    }
    for (InternalTask t : mergers) {
        t.getIDependences().remove(initiator);
        t.addDependence(newInit);
        changesInfo.taskUpdated(t);
    }
    // propagate the changes in the job descriptor
    getJobDescriptor().doLoop(initiator.getId(), dup, newTarget, newInit);
    this.jobInfo.setTasksChanges(changesInfo, this);
    // notify frontend that tasks were added and modified
    frontend.jobStateUpdated(this.getOwner(), new NotificationData<JobInfo>(SchedulerEvent.TASK_REPLICATED, new JobInfoImpl(jobInfo)));
    frontend.jobUpdatedFullData(this);
    this.jobInfo.clearTasksChanges();
    return true;
}
Also used : ExecutableCreationException(org.ow2.proactive.scheduler.common.exception.ExecutableCreationException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ArrayList(java.util.ArrayList)

Example 12 with JobInfo

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

the class InternalJob method update.

@Override
public synchronized void update(JobInfo info) {
    if (!getId().equals(info.getJobId())) {
        throw new IllegalArgumentException("This job info is not applicable for this job. (expected id is '" + getId() + "' but was '" + info.getJobId() + "'");
    }
    // update job info
    this.jobInfo = (JobInfoImpl) info;
    // update skipped tasks
    if (this.jobInfo.getTasksSkipped() != null) {
        for (TaskId id : tasks.keySet()) {
            if (this.jobInfo.getTasksSkipped().contains(id)) {
                TaskInfoImpl taskInfo = (TaskInfoImpl) tasks.get(id).getTaskInfo();
                taskInfo.setStatus(TaskStatus.SKIPPED);
            }
        }
    }
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl)

Example 13 with JobInfo

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

the class SubmitJob method jobStateUpdatedEvent.

// get the running to finished event of my job
public void jobStateUpdatedEvent(NotificationData<JobInfo> notification) {
    if (myJobId.equals(notification.getData().getJobId())) {
        // test if it is my job
        System.out.print("Job " + myJobId + " terminated in ");
        // get the job result
        try {
            // 1. get the job result
            JobResult result = user.getJobResult(myJobId);
            System.out.println(result.getJobInfo().getFinishedTime() - result.getJobInfo().getStartTime() + "ms");
            // notify the test that it is terminated
            user.removeJob(notification.getData().getJobId());
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult)

Example 14 with JobInfo

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

the class TestLoadJobs method checkJobs.

private void checkJobs(List<JobInfo> jobs, JobId... expectedIds) {
    Set<JobId> jobIds = new HashSet<>(jobs.size());
    for (JobInfo job : jobs) {
        jobIds.add(job.getJobId());
        logger.info("Job " + job.getJobId() + " has status '" + job.getStatus() + "'");
    }
    for (JobId expectedId : expectedIds) {
        final boolean expectedJobIdContained = jobIds.contains(expectedId);
        logger.info("Checking if " + jobs + " contains " + expectedId + "? " + expectedJobIdContained);
        assertTrue(expectedJobIdContained);
    }
}
Also used : JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) JobId(org.ow2.proactive.scheduler.common.job.JobId) HashSet(java.util.HashSet)

Example 15 with JobInfo

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

the class TestLoadJobs method setUp.

@Before
public void setUp() throws Exception {
    logger.setLevel(Level.INFO);
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    List<JobInfo> jobs = scheduler.getJobs(0, 1000, criteria(true, true, true, true), SORT_BY_ID_ASC).getList();
    for (JobInfo job : jobs) {
        scheduler.removeJob(job.getJobId());
    }
}
Also used : JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) Before(org.junit.Before)

Aggregations

JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)31 JobId (org.ow2.proactive.scheduler.common.job.JobId)20 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)9 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)9 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)9 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)9 JobState (org.ow2.proactive.scheduler.common.job.JobState)8 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)8 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)8 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)8 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)7 File (java.io.File)6 HashMap (java.util.HashMap)5 JobFilterCriteria (org.ow2.proactive.scheduler.common.JobFilterCriteria)5 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)5 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)5 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)5 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)5 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)5