use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerStateRest method jobTask.
/**
* Return the task state of the task <code>taskname</code> of the job
* <code>jobId</code>
*
* @param sessionId
* a valid session id
* @param jobId
* the id of the job
* @param taskname
* the name of the task
* @return the task state of the task <code>taskname</code> of the job
* <code>jobId</code>
*/
@Override
@GET
@Path("jobs/{jobid}/tasks/{taskname}")
@Produces("application/json")
public TaskStateData jobTask(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("taskname") String taskname) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException, UnknownTaskRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskname);
JobState jobState = s.getJobState(jobId);
for (TaskState ts : jobState.getTasks()) {
if (ts.getId().getReadableName().equals(taskname)) {
return mapper.map(ts, TaskStateData.class);
}
}
throw new UnknownTaskRestException("task " + taskname + "not found");
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
}
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerStateRest method getJobTasksIdsByTag.
/**
* Returns a list of the name of the tasks belonging to job and filtered by
* a given tag. <code>jobId</code>
*
* @param sessionId
* a valid session id
* @param jobId
* jobid one wants to list the tasks' name
* @param taskTag
* the tag used to filter the tasks.
* @return the list of task ids with the total number of them
*/
@Override
@GET
@Path("jobs/{jobid}/tasks/tag/{tasktag}")
@Produces("application/json")
public RestPage<String> getJobTasksIdsByTag(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks");
JobState jobState = s.getJobState(jobId);
TaskStatesPage page = jobState.getTaskByTagPaginated(taskTag, 0, TASKS_PAGE_SIZE);
List<TaskState> tasks = page.getTaskStates();
List<String> tasksName = new ArrayList<>(tasks.size());
for (TaskState ts : tasks) {
tasksName.add(ts.getId().getReadableName());
}
return new RestPage<String>(tasksName, page.getSize());
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
}
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerStateRest method getJobTaskStatesPaginated.
/**
* Returns a list of taskState with pagination
*
* @param sessionId
* a valid session id
* @param jobId
* the job id
* @param offset
* the index of the first TaskState to return
* @param limit
* the index (non inclusive) of the last TaskState to return
* @return a list of task' states of the job <code>jobId</code>
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/taskstates/paginated")
@Produces("application/json")
public RestPage<TaskStateData> getJobTaskStatesPaginated(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("-1") int limit) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
if (limit == -1)
limit = TASKS_PAGE_SIZE;
try {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/taskstates/paginated");
JobState jobState = s.getJobState(jobId);
TaskStatesPage page = jobState.getTasksPaginated(offset, limit);
List<TaskStateData> tasks = map(page.getTaskStates(), TaskStateData.class);
return new RestPage<TaskStateData>(tasks, page.getSize());
} catch (PermissionException e) {
throw new PermissionRestException(e);
} catch (UnknownJobException e) {
throw new UnknownJobRestException(e);
} catch (NotConnectedException e) {
throw new NotConnectedRestException(e);
}
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class RestSchedulerPushPullFileTest method setUp.
@Before
public void setUp() throws Exception {
Scheduler scheduler = RestFuncTHelper.getScheduler();
SchedulerState state = scheduler.getState();
List<JobState> jobStates = new ArrayList<>();
jobStates.addAll(state.getPendingJobs());
jobStates.addAll(state.getRunningJobs());
jobStates.addAll(state.getFinishedJobs());
for (JobState jobState : jobStates) {
JobId jobId = jobState.getId();
scheduler.killJob(jobId);
scheduler.removeJob(jobId);
}
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class RestSchedulerTagTest method submitWorkflowWhichIsUSedByAllTestCasesOnce.
@Before
public void submitWorkflowWhichIsUSedByAllTestCasesOnce() throws Exception {
if (submittedJobId == null) {
System.out.println("Setup - no jobId found: Remove all jobs from scheduler");
scheduler = RestFuncTHelper.getScheduler();
SchedulerState state = scheduler.getState();
List<JobState> jobStates = new ArrayList<>();
jobStates.addAll(state.getPendingJobs());
jobStates.addAll(state.getRunningJobs());
jobStates.addAll(state.getFinishedJobs());
for (JobState jobState : jobStates) {
JobId jobId = jobState.getId();
scheduler.killJob(jobId);
scheduler.removeJob(jobId);
}
System.out.println("Scheduler was cleaned.");
System.out.println("Submit job for test cases.");
// submit a job with a loop and out and err outputs
System.out.println("submit a job with loop, out and err outputs");
submittedJobId = submitJob("flow_loop_out.xml");
}
System.out.println("Finished setup test case.");
}
Aggregations