Search in sources :

Example 61 with JobInfo

use of org.ow2.proactive.scheduler.common.job.JobInfo 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 62 with JobInfo

use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.

the class SchedulingServiceTest method createMockedInternalJob.

private InternalJob createMockedInternalJob(JobId jobId) {
    JobInfo jobInfo = Mockito.mock(JobInfoImpl.class);
    InternalJob internalJob = Mockito.mock(InternalJob.class);
    Mockito.when(jobInfo.getJobId()).thenReturn(jobId);
    Mockito.when(internalJob.getJobInfo()).thenReturn(jobInfo);
    Mockito.when(internalJob.getOwner()).thenReturn("MOCKED OWNER");
    return internalJob;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo)

Example 63 with JobInfo

use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.

the class SchedulerStateRestJobTest method testJobsInfoList.

@Test
public void testJobsInfoList() throws Throwable {
    List<JobInfo> expectedJobs = new ArrayList<>();
    JobInfo jobData1 = RestTestUtils.newMockedJobInfo("2", null, 10);
    expectedJobs.add(jobData1);
    JobInfo jobData2 = RestTestUtils.newMockedJobInfo("4", null, 2);
    expectedJobs.add(jobData2);
    JobInfo jobData3 = RestTestUtils.newMockedJobInfo("10", null, 8);
    expectedJobs.add(jobData3);
    List<String> jobIds = new ArrayList<>();
    jobIds.add("2");
    jobIds.add("4");
    jobIds.add("10");
    when(mockOfScheduler.getJobsInfoList(jobIds)).thenReturn(expectedJobs);
    List<UserJobData> actualList = restInterface.jobsInfoList(sessionId, jobIds);
    for (int i = 0; i < expectedJobs.size() && i < actualList.size(); i++) {
        RestTestUtils.assertJobInfo(expectedJobs.get(i), actualList.get(i));
    }
}
Also used : UserJobData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.UserJobData) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 64 with JobInfo

use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.

the class SchedulerStateRestJobTaskResultTest method testValueOfJobResult.

@Test
public void testValueOfJobResult() throws Throwable {
    TaskResultImpl taskResult = new TaskResultImpl(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("42"), "mytask", 1), ObjectToByteConverter.ObjectStream.convert("hello"), null, null, false);
    JobResultImpl jobResultWithValue = new JobResultImpl();
    JobInfoImpl jobInfo = new JobInfoImpl();
    jobInfo.setJobId(new JobIdImpl(12, "myjob"));
    jobResultWithValue.setJobInfo(jobInfo);
    jobResultWithValue.addTaskResult("mytask", taskResult, false);
    when(mockOfScheduler.getJobResult("42")).thenReturn(jobResultWithValue);
    JobResultData jobResultData = restInterface.jobResult(sessionId, "42");
    TaskResultData taskResultData = jobResultData.getAllResults().get("mytask");
    assertNotNull(taskResultData);
    assertNotNull(taskResultData.getValue());
    assertEquals("hello", taskResultData.getValue());
    Map<String, String> jobResult = restInterface.jobResultValue(sessionId, "42");
    String result = jobResult.get("mytask");
    assertNotNull(result);
    assertEquals("hello", result);
}
Also used : JobResultImpl(org.ow2.proactive.scheduler.job.JobResultImpl) JobResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) Test(org.junit.Test)

Example 65 with JobInfo

use of org.ow2.proactive.scheduler.common.job.JobInfo in project scheduling by ow2-proactive.

the class RestTestUtils method newMockedJob.

protected static JobState newMockedJob(final String jobIdStr, final String tag, final int nbTasks) {
    JobState mockedJob = mock(JobState.class);
    JobId mockedJobId = mock(JobId.class);
    JobInfo mockedJobInfo = mock(JobInfo.class);
    List<TaskState> dumbList = new ArrayList<TaskState>(nbTasks);
    for (int i = 0; i < nbTasks; i++) {
        dumbList.add(newTaskState(jobIdStr, null, i, nbTasks));
    }
    when(mockedJobId.value()).thenReturn(jobIdStr);
    when(mockedJobInfo.getJobId()).thenReturn(mockedJobId);
    when(mockedJobInfo.getStatus()).thenReturn(JobStatus.PENDING);
    when(mockedJob.getId()).thenReturn(mockedJobId);
    when(mockedJob.getTasksPaginated(0, 50)).thenReturn(new TaskStatesPage(dumbList, nbTasks));
    when(mockedJob.getTaskByTagPaginated("", 0, 50)).thenReturn(new TaskStatesPage(dumbList, nbTasks));
    when(mockedJob.getJobInfo()).thenReturn(mockedJobInfo);
    return mockedJob;
}
Also used : JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ArrayList(java.util.ArrayList) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskStatesPage(org.ow2.proactive.scheduler.common.task.TaskStatesPage) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Aggregations

JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)47 JobId (org.ow2.proactive.scheduler.common.job.JobId)29 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)12 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)12 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)11 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)10 JobState (org.ow2.proactive.scheduler.common.job.JobState)10 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)10 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)9 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)9 Job (org.ow2.proactive.scheduler.common.job.Job)8 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)8 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)8 File (java.io.File)7 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)7 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)7 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)7 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)7 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)7