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;
}
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());
}
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;
}
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);
}
}
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;
}
Aggregations