Search in sources :

Example 31 with JobInfo

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

the class ClientJobStateTest method createTaskInfo.

private TaskInfoImpl createTaskInfo(JobInfoImpl jobInfo) {
    TaskInfoImpl updatedTask = new TaskInfoImpl();
    updatedTask.setJobInfo(jobInfo);
    updatedTask.setTaskId(TaskIdImpl.createTaskId(jobInfo.getJobId(), "task", 1));
    return updatedTask;
}
Also used : TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl)

Example 32 with JobInfo

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

the class ClientJobStateTest method testNumberOfTasksInJobInfoUpdatedWhenUpdateTask.

@Test
public void testNumberOfTasksInJobInfoUpdatedWhenUpdateTask() throws Exception {
    JobInfoImpl jobInfo = createJobInfo();
    ClientJobState jobState = new ClientJobState(createJobState(jobInfo));
    jobInfo.setNumberOfFinishedTasks(3);
    jobInfo.setNumberOfPendingTasks(2);
    jobInfo.setNumberOfRunningTasks(1);
    TaskInfoImpl updatedTask = createTaskInfo(jobInfo);
    jobState.update(updatedTask);
    assertEquals(1, jobState.getJobInfo().getNumberOfRunningTasks());
    assertEquals(2, jobState.getJobInfo().getNumberOfPendingTasks());
    assertEquals(3, jobState.getJobInfo().getNumberOfFinishedTasks());
}
Also used : TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) Test(org.junit.Test)

Example 33 with JobInfo

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

the class SchedulerStateRest method jobInfo.

/**
 * {@inheritDoc}
 */
@Override
public JobInfoData jobInfo(String sessionId, String jobId) throws NotConnectedRestException, PermissionRestException, UnknownJobRestException {
    Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/info");
    JobInfoData job = null;
    try {
        job = mapper.map(s.getJobInfo(jobId), JobInfoData.class);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    }
    return job;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) JobInfoData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobInfoData) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)

Example 34 with JobInfo

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

the class SchedulerStateRest method jobs.

/**
 * Returns the ids of the current jobs under a list of string.
 *
 * @param sessionId
 *            a valid session id
 * @param index
 *            optional, if a sublist has to be returned the index of the
 *            sublist
 * @param limit
 *            optional, if a sublist has to be returned, the limit of the
 *            sublist
 * @return a list of jobs' ids under the form of a list of string
 */
@Override
@GET
@Path("jobs")
@Produces("application/json")
public RestPage<String> jobs(@HeaderParam("sessionid") String sessionId, @QueryParam("index") @DefaultValue("-1") int index, @QueryParam("limit") @DefaultValue("-1") int limit) throws NotConnectedRestException, PermissionRestException {
    try {
        Scheduler s = checkAccess(sessionId, "/scheduler/jobs");
        Page<JobInfo> page = s.getJobs(index, limit, new JobFilterCriteria(false, true, true, true), DEFAULT_JOB_SORT_PARAMS);
        List<String> ids = new ArrayList<String>(page.getList().size());
        for (JobInfo jobInfo : page.getList()) {
            ids.add(jobInfo.getJobId().value());
        }
        return new RestPage<String>(ids, page.getSize());
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    }
}
Also used : JobFilterCriteria(org.ow2.proactive.scheduler.common.JobFilterCriteria) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) ArrayList(java.util.ArrayList) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 35 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)31 JobId (org.ow2.proactive.scheduler.common.job.JobId)20 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)9 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)9 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)9 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)9 JobState (org.ow2.proactive.scheduler.common.job.JobState)8 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)8 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)8 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)8 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)7 File (java.io.File)6 HashMap (java.util.HashMap)5 JobFilterCriteria (org.ow2.proactive.scheduler.common.JobFilterCriteria)5 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)5 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)5 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)5 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)5 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)5