Search in sources :

Example 31 with InternalTaskFlowJob

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());
}
Also used : SchedulerJMXHelper(org.ow2.proactive.scheduler.core.jmx.SchedulerJMXHelper) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) RuntimeDataMBeanImpl(org.ow2.proactive.scheduler.core.jmx.mbean.RuntimeDataMBeanImpl) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) Vector(java.util.Vector) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) Test(org.junit.Test)

Example 32 with InternalTaskFlowJob

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();
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) Test(org.junit.Test)

Example 33 with InternalTaskFlowJob

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));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 34 with InternalTaskFlowJob

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));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) NodeSet(org.ow2.proactive.utils.NodeSet) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) SynchronizationInternal(org.ow2.proactive.scheduler.synchronization.SynchronizationInternal) HashMap(java.util.HashMap) Synchronization(org.ow2.proactive.scheduler.synchronization.Synchronization) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) SignalApi(org.ow2.proactive.scheduler.signal.SignalApi) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Credentials(org.ow2.proactive.authentication.crypto.Credentials) Test(org.junit.Test)

Example 35 with InternalTaskFlowJob

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();
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Aggregations

InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)39 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)33 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)33 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)30 Test (org.junit.Test)27 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)27 JobId (org.ow2.proactive.scheduler.common.job.JobId)22 ArrayList (java.util.ArrayList)20 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)14 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)10 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)5 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)5 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)5 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)5 InputStream (java.io.InputStream)3 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)3 File (java.io.File)2 LinkedHashMap (java.util.LinkedHashMap)2 Node (org.objectweb.proactive.core.node.Node)2 SchedulerDBManager (org.ow2.proactive.scheduler.core.db.SchedulerDBManager)2