Search in sources :

Example 1 with TaskIdData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData in project scheduling by ow2-proactive.

the class SchedulerClient method getTaskIds.

@Override
public Page<TaskId> getTaskIds(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit) throws NotConnectedException, PermissionException {
    RestPage<TaskStateData> page = null;
    try {
        page = restApi().getTaskStates(sid, from, to, mytasks, running, pending, finished, offset, limit, null);
    } catch (NotConnectedRestException e) {
        throw new NotConnectedException(e);
    } catch (PermissionRestException e) {
        throw new PermissionException(e);
    }
    List<TaskId> lTaskIds = new ArrayList<TaskId>(page.getList().size());
    for (TaskStateData taskStateData : page.getList()) {
        TaskInfoData taskInfo = taskStateData.getTaskInfo();
        TaskIdData taskIdData = taskInfo.getTaskId();
        JobId jobId = new JobIdImpl(taskInfo.getJobId().getId(), taskInfo.getJobId().getReadableName());
        TaskId taskId = TaskIdImpl.createTaskId(jobId, taskIdData.getReadableName(), taskIdData.getId());
        lTaskIds.add(taskId);
    }
    return new Page<TaskId>(lTaskIds, page.getSize());
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) TaskInfoData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData) ArrayList(java.util.ArrayList) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) Page(org.ow2.proactive.scheduler.common.Page) RestPage(org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) TaskIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 2 with TaskIdData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData in project scheduling by ow2-proactive.

the class JobStateImpl method getHMTasks.

@Override
public Map<TaskId, TaskState> getHMTasks() {
    Map<String, TaskStateData> taskStateDataMap = jobStateData.getTasks();
    Map<TaskId, TaskState> taskStateMap = new HashMap<>();
    for (TaskStateData taskStateData : taskStateDataMap.values()) {
        TaskIdData taskIdData = taskStateData.getTaskInfo().getTaskId();
        taskStateMap.put(DataUtility.taskId(DataUtility.jobId(jobStateData.getJobInfo().getJobId()), taskIdData), DataUtility.taskState(taskStateData));
    }
    return taskStateMap;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) HashMap(java.util.HashMap) TaskIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Example 3 with TaskIdData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData in project scheduling by ow2-proactive.

the class SchedulerStateRest method taskResult.

/**
 * Returns the task result 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 result of the task <code>taskName</code>
 */
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/{taskname}/result")
@Produces("application/json")
public TaskResultData taskResult(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("taskname") String taskname) throws NotConnectedRestException, UnknownJobRestException, UnknownTaskRestException, PermissionRestException {
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskname + "/result");
        TaskResult taskResult = s.getTaskResult(jobId, taskname);
        if (taskResult == null) {
            TaskIdData taskIdData = new TaskIdData();
            taskIdData.setReadableName(taskname);
            TaskResultData taskResultData = new TaskResultData();
            taskResultData.setId(taskIdData);
            return taskResultData;
        }
        return buildTaskResultData(taskResult);
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (UnknownTaskException e) {
        throw new UnknownTaskRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TaskIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData) UnknownTaskRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) 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) GZIP(org.jboss.resteasy.annotations.GZIP)

Example 4 with TaskIdData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData in project scheduling by ow2-proactive.

the class RestTestUtils method newMockedTaskStateData.

protected static TaskStateData newMockedTaskStateData(String jobIdStr, String tag, long cnt, int nbTasks) {
    TaskStateData mockedTaskStateData = mock(TaskStateData.class);
    TaskInfoData mockedTaskInfoData = mock(TaskInfoData.class);
    TaskIdData mockedTaskIdData = mock(TaskIdData.class);
    when(mockedTaskIdData.getReadableName()).thenReturn(generateReadableName(jobIdStr, cnt, nbTasks));
    when(mockedTaskIdData.getId()).thenReturn(cnt);
    when(mockedTaskInfoData.getTaskId()).thenReturn(mockedTaskIdData);
    when(mockedTaskStateData.getTaskInfo()).thenReturn(mockedTaskInfoData);
    when(mockedTaskStateData.getTag()).thenReturn(tag);
    return mockedTaskStateData;
}
Also used : TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskInfoData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData) TaskIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData)

Example 5 with TaskIdData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData in project scheduling by ow2-proactive.

the class StringUtility method taskStatesAsString.

public static String taskStatesAsString(Collection<TaskStateData> tasks, boolean displayTags) {
    // create formatter
    ObjectArrayFormatter formatter = new ObjectArrayFormatter();
    formatter.setMaxColumnLength(80);
    // space between column
    formatter.setSpace(4);
    // title line
    List<String> list = new ArrayList<>();
    list.add("ID");
    list.add("NAME");
    if (displayTags) {
        list.add("TAG");
    }
    list.add("ITER");
    list.add("DUP");
    list.add("STATUS");
    list.add("HOSTNAME");
    list.add("EXEC DURATION");
    list.add("TOT DURATION");
    list.add("#NODES USED");
    list.add("#EXECUTIONS");
    list.add("#NODES KILLED");
    formatter.setTitle(list);
    formatter.addEmptyLine();
    for (TaskStateData taskState : tasks) {
        list = new ArrayList<>();
        TaskInfoData taskInfo = taskState.getTaskInfo();
        TaskIdData taskId = taskInfo.getTaskId();
        list.add(String.valueOf(taskId.getId()));
        list.add(taskId.getReadableName());
        if (displayTags) {
            list.add(toStringNullable(taskState.getTag()));
        }
        list.add((taskState.getIterationIndex() > 0) ? "" + taskState.getIterationIndex() : "");
        list.add((taskState.getReplicationIndex() > 0) ? "" + taskState.getReplicationIndex() : "");
        list.add(taskInfo.getTaskStatus().toString());
        list.add(toStringNullable(taskInfo.getExecutionHostName(), "unknown"));
        if (taskInfo.getTaskStatus() == TaskStatusData.IN_ERROR) {
            list.add(Tools.getFormattedDuration(taskInfo.getInErrorTime(), taskInfo.getStartTime()));
        } else {
            list.add(Tools.getFormattedDuration(0, taskInfo.getExecutionDuration()));
        }
        list.add(Tools.getFormattedDuration(taskInfo.getFinishedTime(), taskInfo.getStartTime()));
        list.add("" + taskState.getNumberOfNodesNeeded());
        list.add((taskState.getMaxNumberOfExecution() - taskInfo.getNumberOfExecutionLeft()) + "/" + taskState.getMaxNumberOfExecution());
        list.add((taskState.getMaxNumberOfExecutionOnFailure() - taskInfo.getNumberOfExecutionOnFailureLeft()) + "/" + taskState.getMaxNumberOfExecutionOnFailure());
        formatter.addLine(list);
    }
    return Tools.getStringAsArray(formatter);
}
Also used : TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskInfoData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData) TaskIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData) ArrayList(java.util.ArrayList) ObjectArrayFormatter(org.ow2.proactive.utils.ObjectArrayFormatter)

Aggregations

TaskIdData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData)5 TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)4 TaskInfoData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData)3 ArrayList (java.util.ArrayList)2 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)2 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)2 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)2 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)2 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)2 HashMap (java.util.HashMap)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 GZIP (org.jboss.resteasy.annotations.GZIP)1 Page (org.ow2.proactive.scheduler.common.Page)1 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)1 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)1 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)1 JobId (org.ow2.proactive.scheduler.common.job.JobId)1 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)1