use of org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor in project scheduling by ow2-proactive.
the class BaseServiceTest method taskStarted.
void taskStarted(JobDescriptor jobDesc, EligibleTaskDescriptor taskDesc) throws Exception {
InternalTask task = ((EligibleTaskDescriptorImpl) taskDesc).getInternal();
TaskLauncher launcher = Mockito.mock(TaskLauncher.class);
task.setExecuterInformation(new ExecuterInformation(launcher, NodeFactory.getDefaultNode()));
service.taskStarted(((JobDescriptorImpl) jobDesc).getInternal(), task, launcher);
}
use of org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor in project scheduling by ow2-proactive.
the class SchedulingServiceTest1 method testSimpleJob.
@Test
public void testSimpleJob() throws Exception {
service.submitJob(createJob(createTestJob()));
listener.assertEvents(SchedulerEvent.JOB_SUBMITTED);
Map<JobId, JobDescriptor> jobsMap;
JobDescriptor jobDesc;
jobsMap = service.lockJobsToSchedule();
assertEquals(1, jobsMap.size());
jobDesc = jobsMap.values().iterator().next();
Assert.assertEquals(1, jobDesc.getEligibleTasks().size());
taskStarted(jobDesc, (EligibleTaskDescriptor) jobDesc.getEligibleTasks().iterator().next());
service.unlockJobsToSchedule(jobsMap.values());
jobsMap = service.lockJobsToSchedule();
assertEquals(1, jobsMap.size());
jobDesc = jobsMap.values().iterator().next();
Assert.assertEquals(0, jobDesc.getEligibleTasks().size());
service.unlockJobsToSchedule(jobsMap.values());
TaskId taskId = ((JobDescriptorImpl) jobDesc).getInternal().getTask("task1").getId();
service.taskTerminatedWithResult(taskId, new TaskResultImpl(taskId, "Result", null, 0));
jobsMap = service.lockJobsToSchedule();
// when a job finishes, it isn't removed from the hibernate context unless
// the housekeeping mechanism is enabled
assertEquals(1, jobsMap.size());
listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
infrastructure.assertRequests(1);
}
use of org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor 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;
}
use of org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor in project scheduling by ow2-proactive.
the class LiveJobs method simulateJobStart.
TerminationData simulateJobStart(List<EligibleTaskDescriptor> tasksToSchedule, String errorMsg) {
TerminationData terminationData = TerminationData.newTerminationData();
for (EligibleTaskDescriptor eltd : tasksToSchedule) {
JobId jobId = eltd.getJobId();
if (!terminationData.jobTerminated(jobId)) {
JobData jobData = lockJob(jobId);
if (jobData != null) {
try {
if (jobData.job.getStartTime() < 0) {
jobData.job.start();
updateJobInSchedulerState(jobData.job, SchedulerEvent.JOB_PENDING_TO_RUNNING);
jlogger.info(jobId, "started");
}
endJob(jobData, terminationData, ((EligibleTaskDescriptorImpl) eltd).getInternal(), null, errorMsg, JobStatus.CANCELED);
} finally {
jobData.unlock();
}
}
}
}
return terminationData;
}
Aggregations