use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.
the class DefaultPolicyTest method single_job.
@Test
public void single_job() throws Exception {
JobDescriptorImpl job = createSingleTaskJob();
List<JobDescriptor> jobs = submitJobs(job);
LinkedList<EligibleTaskDescriptor> orderedTasks = new DefaultPolicy().getOrderedTasks(jobs);
assertEquals(1, orderedTasks.size());
}
use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.
the class ExtendedSchedulerPolicyTest method createJobDescWithTwoTasks.
private JobDescriptor createJobDescWithTwoTasks(String jobStartAt, String oneTaskStartAt, String otherTaskStartAt) {
InternalTaskFlowJob taskFlowJob = new InternalTaskFlowJob("test", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "");
taskFlowJob.setId(JobIdImpl.makeJobId(Integer.toString(jobId++)));
ArrayList<InternalTask> tasks = new ArrayList<>();
tasks.add(createTask(oneTaskStartAt));
tasks.add(createTask(otherTaskStartAt));
taskFlowJob.addTasks(tasks);
if (jobStartAt != null) {
taskFlowJob.addGenericInformation("START_AT", jobStartAt);
}
return new JobDescriptorImpl(taskFlowJob);
}
use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.
the class SchedulingServiceTest8 method testTaskPreempt.
@Test
public void testTaskPreempt() throws Exception {
service.submitJob(createJob(createTestJob()));
listener.assertEvents(SchedulerEvent.JOB_SUBMITTED);
JobDescriptor jobDesc = startTask();
try {
service.preemptTask(jobDesc.getJobId(), "invalid task name", 100);
Assert.fail();
} catch (UnknownTaskException e) {
}
try {
service.preemptTask(JobIdImpl.makeJobId("1234567"), "javaTask", 100);
Assert.fail();
} catch (UnknownJobException e) {
}
service.preemptTask(jobDesc.getJobId(), "javaTask", 100);
listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_WAITING_FOR_RESTART);
infrastructure.assertRequests(1);
startTask();
service.preemptTask(jobDesc.getJobId(), "javaTask", 100);
listener.assertEvents(SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_WAITING_FOR_RESTART);
infrastructure.assertRequests(1);
startTask();
TaskId taskId = ((JobDescriptorImpl) jobDesc).getInternal().getTask("javaTask").getId();
service.taskTerminatedWithResult(taskId, new TaskResultImpl(taskId, "OK", null, 0));
listener.assertEvents(SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
infrastructure.assertRequests(1);
service.removeJob(jobDesc.getJobId());
try {
service.preemptTask(jobDesc.getJobId(), "javaTask", 100);
Assert.fail();
} catch (UnknownJobException e) {
}
}
use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.
the class TaskResultCreatorTest method getMockedJobDescriptorWithPausedTask.
private JobDescriptorImpl getMockedJobDescriptorWithPausedTask() {
JobDescriptorImpl mockedJobDescriptor = this.getMockedJobDescriptor();
Map fakeMap = this.mockedPausedOrRunningTaskMap();
when(mockedJobDescriptor.getPausedTasks()).thenReturn(fakeMap);
return mockedJobDescriptor;
}
use of org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl in project scheduling by ow2-proactive.
the class TaskResultCreatorTest method testRunningTasksAreCheckedForATaskId.
@Test
public void testRunningTasksAreCheckedForATaskId() throws UnknownTaskException {
TaskResultCreator taskResultCreator = new TaskResultCreator();
TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.class);
Map<TaskId, TaskResult> loadTaskResultsValue = new HashMap<>();
loadTaskResultsValue.put(this.createTaskID(), mockedTaskResultImpl);
SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenReturn(loadTaskResultsValue);
JobDescriptorImpl mockedJobDescriptorHasRunningTask = this.getMockedJobDescriptorWithRunningTask();
taskResultCreator.getTaskResult(mockedschedulerDbManager, this.getMockedInternalJob(mockedJobDescriptorHasRunningTask), this.getMockedInternalTask());
verify(mockedJobDescriptorHasRunningTask, atLeastOnce()).getRunningTasks();
}
Aggregations