Search in sources :

Example 11 with TaskStatus

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

the class InternalTaskParentFinderTest method generateInternalTask.

private InternalTask generateInternalTask(long id, TaskStatus taskStatus) {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    InternalTask internalTask = new InternalScriptTask(job);
    internalTask.setId(TaskIdImpl.createTaskId(new JobIdImpl(666L, "JobName"), "readableName", id));
    internalTask.setStatus(taskStatus);
    return internalTask;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob)

Example 12 with TaskStatus

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

the class SchedulerDBManager method updateTaskData.

private int updateTaskData(final TaskState task, Session session) {
    Query taskUpdateQuery = session.getNamedQuery("updateTaskData");
    TaskInfo taskInfo = task.getTaskInfo();
    return taskUpdateQuery.setParameter("taskStatus", taskInfo.getStatus()).setParameter("numberOfExecutionLeft", taskInfo.getNumberOfExecutionLeft()).setParameter("numberOfExecutionOnFailureLeft", taskInfo.getNumberOfExecutionOnFailureLeft()).setParameter("inErrorTime", taskInfo.getInErrorTime()).setParameter("taskId", taskId(task.getId())).executeUpdate();
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) Query(org.hibernate.Query)

Example 13 with TaskStatus

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

the class TaskDBUtils method getTotalNumberOfTasks.

public static SessionWork<Integer> getTotalNumberOfTasks(final DBTaskDataParameters params) {
    return new SessionWork<Integer>() {

        @Override
        public Integer doInTransaction(Session session) {
            Set<TaskStatus> taskStatuses = params.getStatuses();
            if (taskStatuses.isEmpty()) {
                return 0;
            }
            boolean hasUser = params.hasUser();
            boolean hasTag = params.hasTag();
            boolean hasDateFrom = params.hasDateFrom();
            boolean hasDateTo = params.hasDateTo();
            String queryPrefix = "select count(*) from TaskData T where ";
            Query query = getQuery(session, params, taskStatuses, hasUser, hasTag, hasDateFrom, hasDateTo, SortSpecifierContainer.EMPTY_CONTAINER, queryPrefix);
            Long count = (Long) query.uniqueResult();
            return count.intValue();
        }
    };
}
Also used : SessionWork(org.ow2.proactive.db.SessionWork) Query(org.hibernate.Query) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) Session(org.hibernate.Session)

Example 14 with TaskStatus

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

the class InternalJob method start.

/**
 * Set all properties in order to start the job. After this method and for
 * better performances you may have to set the taskStatusModify to "null" :
 * setTaskStatusModify(null);
 */
public void start() {
    setStartTime(System.currentTimeMillis());
    setNumberOfPendingTasks(getTotalNumberOfTasks());
    setNumberOfRunningTasks(0);
    setStatus(JobStatus.RUNNING);
    List<InternalTask> internalTasks = getITasks();
    HashMap<TaskId, TaskStatus> taskStatus = new HashMap<>(internalTasks.size());
    for (InternalTask internalTask : internalTasks) {
        internalTask.setStatus(TaskStatus.PENDING);
        taskStatus.put(internalTask.getId(), TaskStatus.PENDING);
    }
}
Also used : 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) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus)

Example 15 with TaskStatus

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

the class RunningTaskRecoveryWithDownNodeTest method checkTasks.

private void checkTasks(JobState jobState) {
    int maximumNumberOfPendingTasks = jobState.getNumberOfPendingTasks();
    for (int i = 0; i < maximumNumberOfPendingTasks; i++) {
        TaskState taskState = jobState.getTasks().get(i);
        TaskStatus taskStatus = taskState.getTaskInfo().getStatus();
        assertThat(taskStatus.equals(TaskStatus.PENDING) || taskStatus.equals(TaskStatus.RUNNING)).isTrue();
    }
}
Also used : TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Aggregations

TaskStatus (org.ow2.proactive.scheduler.common.task.TaskStatus)16 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)8 Test (org.junit.Test)7 RecoveredSchedulerState (org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState)6 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)5 JobId (org.ow2.proactive.scheduler.common.job.JobId)4 Query (org.hibernate.Query)3 JobState (org.ow2.proactive.scheduler.common.job.JobState)3 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)3 TaskAbortedException (org.ow2.proactive.scheduler.common.exception.TaskAbortedException)2 TaskPreemptedException (org.ow2.proactive.scheduler.common.exception.TaskPreemptedException)2 TaskRestartedException (org.ow2.proactive.scheduler.common.exception.TaskRestartedException)2 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)2 JobStatus (org.ow2.proactive.scheduler.common.job.JobStatus)2 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)2 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)2 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Semaphore (java.util.concurrent.Semaphore)1 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)1