Search in sources :

Example 1 with JobInfoImpl

use of org.ow2.proactive.scheduler.rest.data.JobInfoImpl in project scheduling by ow2-proactive.

the class JobData method toJobInfo.

JobInfo toJobInfo() {
    JobId jobIdInstance = new JobIdImpl(getId(), getJobName());
    JobInfoImpl jobInfo = createJobInfo(jobIdInstance);
    return jobInfo;
}
Also used : JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 2 with JobInfoImpl

use of org.ow2.proactive.scheduler.rest.data.JobInfoImpl in project scheduling by ow2-proactive.

the class JobData method createJobInfo.

JobInfoImpl createJobInfo(JobId jobId) {
    JobInfoImpl jobInfo = new JobInfoImpl();
    jobInfo.setJobId(jobId);
    jobInfo.setJobOwner(getOwner());
    jobInfo.setStatus(getStatus());
    jobInfo.setTotalNumberOfTasks(getTotalNumberOfTasks());
    jobInfo.setNumberOfPendingTasks(getNumberOfPendingTasks());
    jobInfo.setNumberOfRunningTasks(getNumberOfRunningTasks());
    jobInfo.setNumberOfFinishedTasks(getNumberOfFinishedTasks());
    jobInfo.setNumberOfFailedTasks(getNumberOfFailedTasks());
    jobInfo.setNumberOfFaultyTasks(getNumberOfFaultyTasks());
    jobInfo.setNumberOfInErrorTasks(getNumberOfInErrorTasks());
    jobInfo.setPriority(getPriority());
    jobInfo.setRemovedTime(getRemovedTime());
    jobInfo.setStartTime(getStartTime());
    jobInfo.setInErrorTime(getInErrorTime());
    jobInfo.setFinishedTime(getFinishedTime());
    jobInfo.setSubmittedTime(getSubmittedTime());
    jobInfo.setRemovedTime(getRemovedTime());
    jobInfo.setLastUpdatedTime(getLastUpdatedTime());
    if (isToBeRemoved()) {
        jobInfo.setToBeRemoved();
    }
    jobInfo.setGenericInformation(getGenericInformation());
    jobInfo.setVariables(createVariablesStringMap());
    return jobInfo;
}
Also used : JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl)

Example 3 with JobInfoImpl

use of org.ow2.proactive.scheduler.rest.data.JobInfoImpl in project scheduling by ow2-proactive.

the class JobData method toInternalJob.

InternalJob toInternalJob() {
    JobId jobIdInstance = new JobIdImpl(getId(), getJobName());
    JobInfoImpl jobInfo = createJobInfo(jobIdInstance);
    InternalJob internalJob = new InternalTaskFlowJob();
    internalJob.setCredentials(getCredentials());
    internalJob.setJobInfo(jobInfo);
    internalJob.setGenericInformation(getGenericInformation());
    internalJob.setVariables(variablesToJobVariables());
    internalJob.setProjectName(getProjectName());
    internalJob.setOwner(getOwner());
    internalJob.setDescription(getDescription());
    internalJob.setInputSpace(getInputSpace());
    internalJob.setOutputSpace(getOutputSpace());
    internalJob.setGlobalSpace(getGlobalSpace());
    internalJob.setUserSpace(getGlobalSpace());
    internalJob.setMaxNumberOfExecution(getMaxNumberOfExecution());
    internalJob.setOnTaskError(OnTaskError.getInstance(this.onTaskErrorString));
    internalJob.setScheduledTimeForRemoval(getScheduledTimeForRemoval());
    return internalJob;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 4 with JobInfoImpl

use of org.ow2.proactive.scheduler.rest.data.JobInfoImpl 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 5 with JobInfoImpl

use of org.ow2.proactive.scheduler.rest.data.JobInfoImpl 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)

Aggregations

JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)11 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)9 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)8 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)6 ArrayList (java.util.ArrayList)5 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)4 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)4 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)4 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)4 JobId (org.ow2.proactive.scheduler.common.job.JobId)3 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)2 JobState (org.ow2.proactive.scheduler.common.job.JobState)2 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)2 ChangedTasksInfo (org.ow2.proactive.scheduler.job.ChangedTasksInfo)2 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)2 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1