use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class SchedulerFrontendStateTest method testLRUCache.
@Test
public void testLRUCache() throws Exception {
SchedulerJMXHelper mockJMX = mock(SchedulerJMXHelper.class);
when(mockJMX.getSchedulerRuntimeMBean()).thenReturn(new RuntimeDataMBeanImpl(null));
SchedulerStateImpl<ClientJobState> schedulerStateImpl = new SchedulerStateImpl<>();
final ClientJobState clientJobState0 = createClientJobState(10l);
final ClientJobState clientJobState01 = createClientJobState(11l);
final ClientJobState clientJobState1 = createClientJobState(1l);
final ClientJobState clientJobState2 = createClientJobState(2l);
schedulerStateImpl.setFinishedJobs(new Vector());
schedulerStateImpl.setRunningJobs(new Vector(Lists.newArrayList(clientJobState1)));
schedulerStateImpl.setPendingJobs(new Vector(Lists.newArrayList(clientJobState2)));
SCHEDULER_FINISHED_JOBS_LRU_CACHE_SIZE.updateProperty("1");
SchedulerDBManager dbManager = mock(SchedulerDBManager.class);
SchedulerFrontendState schedulerFrontendState = new SchedulerFrontendState(schedulerStateImpl, mockJMX, dbManager);
InternalJob internalJob = spy(new InternalTaskFlowJob());
JobInfoImpl jobInfo = mock(JobInfoImpl.class);
doReturn(jobInfo).when(internalJob).getJobInfo();
doReturn(clientJobState0.getId()).when(jobInfo).getJobId();
doReturn(clientJobState0.getId()).when(internalJob).getId();
doReturn(Collections.singletonList(internalJob)).when(dbManager).loadInternalJob(10l);
InternalJob internalJob1 = spy(new InternalTaskFlowJob());
JobInfoImpl jobInfo1 = mock(JobInfoImpl.class);
doReturn(jobInfo1).when(internalJob1).getJobInfo();
doReturn(clientJobState01.getId()).when(jobInfo1).getJobId();
doReturn(clientJobState01.getId()).when(internalJob1).getId();
doReturn(Collections.singletonList(internalJob1)).when(dbManager).loadInternalJob(11l);
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState01.getId()).getJobId(), clientJobState01.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState01.getId()).getJobId(), clientJobState01.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState01.getId()).getJobId(), clientJobState01.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
assertEquals(schedulerFrontendState.getIdentifiedJob(clientJobState0.getId()).getJobId(), clientJobState0.getId());
verify(dbManager, times(3)).loadInternalJob(anyLong());
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class SchedulingServiceTest method testCannotRestartTaskOnNodeFailure.
@Test
public void testCannotRestartTaskOnNodeFailure() {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
schedulingService.status = schedulingService.status.KILLED;
InternalTask task = new InternalScriptTask(job);
schedulingService.restartTaskOnNodeFailure(task);
Mockito.verify(infrastructure, Mockito.times(0)).getInternalOperationsThreadPool();
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class TerminationDataTest method testAddTaskData.
@Test
public void testAddTaskData() {
assertThat(terminationData.isEmpty(), is(true));
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId jobId = new JobIdImpl(666, "readableName");
InternalTask internalTask = new InternalScriptTask(job);
TaskId taskId = TaskIdImpl.createTaskId(jobId, "task-name", 777L);
internalTask.setId(taskId);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
RunningTaskData taskData = new RunningTaskData(internalTask, "user", null, null);
terminationData.addTaskData(null, taskData, TerminationData.TerminationStatus.NORMAL, null);
assertThat(terminationData.isEmpty(), is(false));
assertThat(terminationData.taskTerminated(jobId, "task-name"), is(true));
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class TerminationDataTest method testHandleTerminationForTaskNormalTermination.
@Test
public void testHandleTerminationForTaskNormalTermination() throws RMProxyCreationException, IOException, ClassNotFoundException {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId jobId = new JobIdImpl(666, "readableName");
InternalTask internalTask = new InternalScriptTask(job);
TaskId taskId = TaskIdImpl.createTaskId(jobId, "task-name", 777L);
internalTask.setId(taskId);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
job.setSynchronizationAPI(Mockito.mock(SynchronizationInternal.class));
RunningTaskData taskData = new RunningTaskData(internalTask, "user", null, launcher);
terminationData.addTaskData(job, taskData, TerminationData.TerminationStatus.NORMAL, null);
terminationData.handleTermination(service);
Mockito.verify(proxiesManager, Mockito.times(1)).getUserRMProxy("user", null);
Mockito.verify(rmProxy, Mockito.times(1)).releaseNodes(org.mockito.Matchers.any(NodeSet.class), org.mockito.Matchers.any(org.ow2.proactive.scripting.Script.class), Mockito.any(VariablesMap.class), Mockito.any(HashMap.class), Mockito.any(TaskId.class), Mockito.any(Credentials.class), Mockito.any(Synchronization.class), Mockito.any(SignalApi.class));
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class TerminationDataTest method testHandleTerminationForTaskAbortedTermination.
@Test
public void testHandleTerminationForTaskAbortedTermination() throws IOException, ClassNotFoundException {
InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
JobId jobId = new JobIdImpl(666, "readableName");
InternalTask internalTask = new InternalScriptTask(job);
TaskId taskId = TaskIdImpl.createTaskId(jobId, "task-name", 777L);
internalTask.setId(taskId);
internalTask.setName("task-name");
internalTask.setStatus(TaskStatus.RUNNING);
internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
RunningTaskData taskData = new RunningTaskData(internalTask, "user", null, launcher);
terminationData.addTaskData(null, taskData, TerminationData.TerminationStatus.ABORTED, null);
terminationData.handleTermination(service);
Mockito.verify(launcher, Mockito.times(1)).kill();
}
Aggregations