Search in sources :

Example 26 with TaskDescriptor

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

the class SchedulerFrontend method getTasksToSchedule.

@Override
public List<TaskDescriptor> getTasksToSchedule() throws NotConnectedException, PermissionException {
    Policy policy = null;
    List<TaskDescriptor> eligibleTasks = new ArrayList<>();
    Map<JobId, JobDescriptor> jobMap = null;
    try {
        jobMap = schedulingService.lockJobsToSchedule();
        policy = (Policy) Class.forName(getCurrentPolicy()).newInstance();
        // we wait for next scheduling loop
        if (jobMap.isEmpty()) {
            return eligibleTasks;
        }
        List<JobDescriptor> descriptors = new ArrayList<>(jobMap.values());
        LinkedList<EligibleTaskDescriptor> taskRetrievedFromPolicy = policy.getOrderedTasks(descriptors);
        // if there is no task to scheduled, return
        if (taskRetrievedFromPolicy.isEmpty()) {
            return eligibleTasks;
        }
        eligibleTasks = (List) taskRetrievedFromPolicy;
    } catch (Exception e) {
        logger.error("Error Loading Current Policy:", e);
    } finally {
        schedulingService.unlockJobsToSchedule(jobMap.values());
    }
    return eligibleTasks;
}
Also used : Policy(org.ow2.proactive.scheduler.policy.Policy) ClientsPolicy(org.ow2.proactive.policy.ClientsPolicy) TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) ArrayList(java.util.ArrayList) JobId(org.ow2.proactive.scheduler.common.job.JobId) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) TaskCouldNotRestartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotRestartException) 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) TaskCouldNotStartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotStartException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) DatabaseManagerException(org.ow2.proactive.db.DatabaseManagerException) TaskSkippedException(org.ow2.proactive.scheduler.common.exception.TaskSkippedException)

Aggregations

TaskDescriptor (org.ow2.proactive.scheduler.common.TaskDescriptor)21 EligibleTaskDescriptor (org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor)15 JobDescriptor (org.ow2.proactive.scheduler.common.JobDescriptor)12 JobId (org.ow2.proactive.scheduler.common.job.JobId)10 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)10 Test (org.junit.Test)8 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)7 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 HashMap (java.util.HashMap)3 EligibleTaskDescriptorImpl (org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl)3 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)3 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)3 IOException (java.io.IOException)2 Collection (java.util.Collection)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)2 TopologyDisabledException (org.ow2.proactive.resourcemanager.frontend.topology.TopologyDisabledException)2 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)2 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)2