Search in sources :

Example 11 with JobState

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

the class DozerMappingTest method createJobState.

private JobState createJobState() {
    return new ClientJobState(new JobState() {

        @Override
        public void update(TaskInfo taskInfo) {
        }

        @Override
        public void update(JobInfo jobInfo) {
        }

        @Override
        public JobInfo getJobInfo() {
            return new JobInfoImpl();
        }

        @Override
        public ArrayList<TaskState> getTasks() {
            return new ArrayList<>(getHMTasks().values());
        }

        @Override
        public Map<TaskId, TaskState> getHMTasks() {
            TaskId taskId = TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1);
            TaskState value = new ClientTaskState(new TaskState() {

                @Override
                public void update(TaskInfo taskInfo) {
                }

                @Override
                public List<TaskState> getDependences() {
                    return null;
                }

                @Override
                public TaskInfo getTaskInfo() {
                    TaskInfoImpl taskInfo = new TaskInfoImpl();
                    taskInfo.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1));
                    return taskInfo;
                }

                @Override
                public int getMaxNumberOfExecutionOnFailure() {
                    return 0;
                }

                @Override
                public TaskState replicate() throws Exception {
                    return null;
                }

                @Override
                public int getIterationIndex() {
                    return 0;
                }

                @Override
                public int getReplicationIndex() {
                    return 0;
                }
            });
            return Collections.singletonMap(taskId, value);
        }

        @Override
        public String getOwner() {
            return null;
        }

        @Override
        public JobType getType() {
            return null;
        }
    });
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ArrayList(java.util.ArrayList) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) ClientTaskState(org.ow2.proactive.scheduler.task.ClientTaskState) TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) JobType(org.ow2.proactive.scheduler.common.job.JobType) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobState(org.ow2.proactive.scheduler.common.job.JobState) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) Map(java.util.Map) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) ClientTaskState(org.ow2.proactive.scheduler.task.ClientTaskState)

Example 12 with JobState

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

the class SchedulerStateRestJobLogsTest method job_full_logs_sorted.

@Test
public void job_full_logs_sorted() throws Exception {
    InternalTaskFlowJob jobState = new InternalTaskFlowJob();
    addTask(jobState, 1, 10);
    addTask(jobState, 10, 2);
    addTask(jobState, 3, 3);
    File logFolder = tempFolder.newFolder("123");
    File logFile = new File(logFolder, "TaskLogs-123-10.log");
    FileUtils.write(logFile, "10");
    logFile = new File(logFolder, "TaskLogs-123-2.log");
    FileUtils.write(logFile, "2");
    logFile = new File(logFolder, "TaskLogs-123-3.log");
    FileUtils.write(logFile, "3");
    when(mockScheduler.getJobState("123")).thenReturn(jobState);
    when(mockScheduler.getUserSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
    when(mockScheduler.getGlobalSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
    InputStream fullLogs = restScheduler.jobFullLogs(validSessionId, "123", validSessionId);
    assertEquals("1032", IOUtils.toString(fullLogs));
}
Also used : InputStream(java.io.InputStream) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) File(java.io.File) Test(org.junit.Test)

Example 13 with JobState

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

the class SchedulerStateRestJobLogsTest method job_full_logs_finished.

@Test
public void job_full_logs_finished() throws Exception {
    InternalTaskFlowJob jobState = new InternalTaskFlowJob();
    InternalScriptTask task = new InternalScriptTask(jobState);
    task.setPreciousLogs(true);
    jobState.addTask(task);
    File logFolder = tempFolder.newFolder("0");
    File logFile = new File(logFolder, "TaskLogs-0-0.log");
    FileUtils.write(logFile, "logs", Charset.defaultCharset());
    when(mockScheduler.getJobState("0")).thenReturn(jobState);
    when(mockScheduler.getUserSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
    when(mockScheduler.getGlobalSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
    InputStream fullLogs = restScheduler.jobFullLogs(validSessionId, "0", validSessionId);
    assertEquals("logs", IOUtils.toString(fullLogs, Charset.defaultCharset()));
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InputStream(java.io.InputStream) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) File(java.io.File) Test(org.junit.Test)

Example 14 with JobState

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

the class SchedulerStateRestJobLogsTest method addTask.

private static void addTask(InternalTaskFlowJob jobState, long finishedTime, long id) {
    InternalScriptTask task = new InternalScriptTask(jobState);
    task.setPreciousLogs(true);
    task.setFinishedTime(finishedTime);
    jobState.addTask(task);
    task.setId(TaskIdImpl.createTaskId(new JobIdImpl(123, "job"), "task", id));
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl)

Example 15 with JobState

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

the class SchedulerStateRestPaginationTest method testGetJobTasksIdsPaginated.

@Test
public void testGetJobTasksIdsPaginated() throws Throwable {
    JobState job = newMockedJob(jobIdStr, nbTasks);
    when(mockOfScheduler.getJobState(jobIdStr)).thenReturn(job);
    RestPage<String> page = restInterface.getTasksNamesPaginated(sessionId, jobIdStr, 0, nbTasks);
    assertTasks(nbTasks, jobIdStr, page);
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState) Test(org.junit.Test)

Aggregations

JobState (org.ow2.proactive.scheduler.common.job.JobState)67 Test (org.junit.Test)34 JobId (org.ow2.proactive.scheduler.common.job.JobId)28 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)25 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)23 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)19 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)17 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)17 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)15 ArrayList (java.util.ArrayList)14 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)14 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)14 GET (javax.ws.rs.GET)13 Path (javax.ws.rs.Path)13 Produces (javax.ws.rs.Produces)13 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)13 File (java.io.File)12 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)9 ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)9 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)8