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;
}
Aggregations