Search in sources :

Example 1 with TaskInfoData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData 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 TaskInfoData

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

the class SchedulerEventBroadcaster method taskStateUpdatedEvent.

@Override
public void taskStateUpdatedEvent(NotificationData<TaskInfo> notification) {
    logEvent(notification);
    TaskInfoData taskInfoData = dozerMapper.map(notification.getData(), TaskInfoData.class);
    broadcast(new EventNotification(EventNotification.Action.TASK_STATE_UPDATED, eventTypeName(notification), taskInfoData));
}
Also used : EventNotification(org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification) TaskInfoData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData)

Example 3 with TaskInfoData

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

the class AbstractSmartProxy method updateTask.

/**
 * Check if the task concerned by this notification is awaited. Retrieve
 * corresponding data if needed
 *
 * @param notification
 */
protected void updateTask(NotificationData<TaskInfo> notification) {
    // am I interested in this task?
    TaskInfo taskInfoData = notification.getData();
    JobId id = taskInfoData.getJobId();
    TaskId tid = taskInfoData.getTaskId();
    String tname = tid.getReadableName();
    TaskStatus status = taskInfoData.getStatus();
    AwaitedJob aj = jobTracker.getAwaitedJob(id.toString());
    if (aj == null)
        return;
    AwaitedTask at = aj.getAwaitedTask(tname);
    if (at == null)
        return;
    at.setTaskId(tid.toString());
    jobTracker.putAwaitedJob(id.toString(), aj);
    switch(status) {
        case ABORTED:
        case NOT_RESTARTED:
        case NOT_STARTED:
        case SKIPPED:
            {
                log.debug("The task " + tname + " from job " + id + " couldn't start. No data will be transfered");
                jobTracker.removeAwaitedTask(id.toString(), tname);
                break;
            }
        case FINISHED:
            {
                log.debug("The task " + tname + " from job " + id + " is finished.");
                if (aj.isAutomaticTransfer()) {
                    log.debug("Transferring data for finished task " + tname + " from job " + id);
                    try {
                        downloadTaskOutputFiles(aj, id.toString(), tname, aj.getLocalOutputFolder());
                    } catch (Throwable t) {
                        log.error("Error while handling data for finished task " + tname + " for job " + id + ", task will be removed");
                        jobTracker.removeAwaitedTask(id.toString(), tname);
                    }
                }
                break;
            }
        case FAILED:
        case FAULTY:
            {
                log.debug("The task " + tname + " from job " + id + " is faulty.");
                jobTracker.removeAwaitedTask(id.toString(), tname);
                break;
            }
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 4 with TaskInfoData

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData 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 TaskInfoData

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

the class DataUtility method taskInfo.

public static TaskInfo taskInfo(TaskInfoData d) {
    TaskInfoImpl impl = new TaskInfoImpl();
    JobIdData jobIdData = d.getJobId();
    if (jobIdData != null) {
        JobId jobId = jobId(jobIdData);
        impl.setJobId(jobId);
        TaskId taskId = taskId(jobId, d.getTaskId());
        impl.setTaskId(taskId);
    }
    impl.setExecutionDuration(d.getExecutionDuration());
    impl.setExecutionHostName(d.getExecutionHostName());
    impl.setInErrorTime(d.getInErrorTime());
    impl.setFinishedTime(d.getFinishedTime());
    impl.setNumberOfExecutionLeft(d.getNumberOfExecutionLeft());
    impl.setNumberOfExecutionOnFailureLeft(d.getNumberOfExecutionOnFailureLeft());
    impl.setStartTime(d.getStartTime());
    impl.setStatus(TaskStatus.valueOf(d.getTaskStatus().name()));
    impl.setName(d.getTaskId().getReadableName());
    impl.setProgress(d.getProgress());
    return impl;
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskIdImpl.createTaskId(org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId)

Aggregations

TaskInfoData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData)4 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)3 TaskIdData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskIdData)3 TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)3 ArrayList (java.util.ArrayList)2 JobId (org.ow2.proactive.scheduler.common.job.JobId)2 Page (org.ow2.proactive.scheduler.common.Page)1 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)1 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)1 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)1 TaskStatus (org.ow2.proactive.scheduler.common.task.TaskStatus)1 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)1 TaskIdImpl.createTaskId (org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId)1 ObjectArrayFormatter (org.ow2.proactive.utils.ObjectArrayFormatter)1 RestPage (org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)1 EventNotification (org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification)1 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)1 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)1