Search in sources :

Example 1 with YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB

use of org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB in project scheduling by ow2-proactive.

the class SchedulerFrontend method getPreciousTaskResults.

@Override
@ImmediateService
public List<TaskResult> getPreciousTaskResults(String jobId) throws NotConnectedException, PermissionException, UnknownJobException {
    frontendState.checkPermissions("getJobResult", frontendState.getIdentifiedJob(JobIdImpl.makeJobId(jobId)), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB);
    List<TaskState> taskStates = getJobState(jobId).getTasks().stream().filter(Task::isPreciousResult).collect(Collectors.toList());
    List<TaskResult> results = new ArrayList<>();
    for (TaskState currentState : taskStates) {
        String taskName = currentState.getTaskInfo().getName();
        try {
            TaskResult currentResult = getTaskResult(jobId, taskName);
            if (currentResult != null) {
                results.add(currentResult);
            }
        } catch (UnknownTaskException ex) {
            // never occurs because tasks are filtered by tag so they cannot
            // be unknown.
            logger.warn("Unknown task.", ex);
        }
    }
    return results;
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 2 with YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB

use of org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB in project scheduling by ow2-proactive.

the class SchedulerFrontend method getTaskResultFromIncarnation.

/**
 * {@inheritDoc}
 */
@Override
@ImmediateService
public TaskResult getTaskResultFromIncarnation(JobId jobId, String taskName, int inc) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    // checking permissions
    frontendState.checkPermissions("getTaskResultFromIncarnation", frontendState.getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB);
    if (inc < 0) {
        throw new IllegalArgumentException("Incarnation must be 0 or greater.");
    }
    logger.debug("Job " + jobId + ", trying to get the task result, incarnation " + inc);
    try {
        TaskResult result = dbManager.loadTaskResult(jobId, taskName, inc);
        // handling special statuses
        TaskState ts = frontendState.getTaskState(jobId, taskName);
        switch(ts.getStatus()) {
            case NOT_STARTED:
                if (result == null) {
                    return new TaskResultImpl(frontendState.getTaskId(jobId, taskName), new TaskCouldNotStartException(), new SimpleTaskLogs("", "The task could not start due to dependency failure"), 0);
                } else {
                    Throwable newException = new TaskCouldNotStartException("The task could not start due to dependency failure", result.getException());
                    ((TaskResultImpl) result).setException(newException);
                }
                break;
            case NOT_RESTARTED:
                if (result == null) {
                    return new TaskResultImpl(frontendState.getTaskId(jobId, taskName), new TaskCouldNotRestartException(), new SimpleTaskLogs("", "The task could not be restarted after an error during the previous execution"), 0);
                } else {
                    Throwable newException = new TaskCouldNotRestartException("The task could not be restarted after an error during the previous execution", result.getException());
                    ((TaskResultImpl) result).setException(newException);
                }
                break;
            case SKIPPED:
                // result should always be null
                return new TaskResultImpl(frontendState.getTaskId(jobId, taskName), new TaskSkippedException(), new SimpleTaskLogs("", "The task was skipped in the workflow"), 0);
            default:
                if (result == null) {
                    // otherwise the task is not finished
                    logger.info("Task " + taskName + " of job " + jobId + " is not finished");
                }
                break;
        }
        return result;
    } catch (DatabaseManagerException e) {
        throw new UnknownTaskException("Unknown task " + taskName + ", job: " + jobId);
    }
}
Also used : SimpleTaskLogs(org.ow2.proactive.scheduler.common.task.SimpleTaskLogs) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskCouldNotStartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotStartException) TaskCouldNotRestartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotRestartException) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskSkippedException(org.ow2.proactive.scheduler.common.exception.TaskSkippedException) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) DatabaseManagerException(org.ow2.proactive.db.DatabaseManagerException) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 3 with YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB

use of org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB in project scheduling by ow2-proactive.

the class SchedulerFrontend method getTaskResultAllIncarnations.

/**
 * {@inheritDoc}
 */
@Override
@ImmediateService
public List<TaskResult> getTaskResultAllIncarnations(JobId jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    // checking permissions
    frontendState.checkPermissions("getTaskResultFromIncarnation", frontendState.getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB);
    logger.debug("Job " + jobId + ", trying to get all task results associated with task " + taskName + " from job " + jobId);
    try {
        return dbManager.loadTaskResultAllAttempts(jobId, taskName);
    } catch (DatabaseManagerException e) {
        throw new UnknownTaskException("Unknown task " + taskName + ", job: " + jobId);
    }
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) DatabaseManagerException(org.ow2.proactive.db.DatabaseManagerException) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 4 with YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB

use of org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB in project scheduling by ow2-proactive.

the class SchedulerFrontend method getTaskResultsByTag.

@Override
@ImmediateService
public List<TaskResult> getTaskResultsByTag(JobId jobId, String taskTag) throws NotConnectedException, UnknownJobException, PermissionException {
    frontendState.checkPermission("getTaskResultByTag", YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_RESULT_OF_THIS_JOB);
    List<TaskState> taskStates = getJobState(jobId).getTasksByTag(taskTag);
    ArrayList<TaskResult> results = new ArrayList<>(taskStates.size());
    for (TaskState currentState : taskStates) {
        String taskName = currentState.getTaskInfo().getName();
        try {
            TaskResult currentResult = getTaskResult(jobId, taskName);
            results.add(currentResult);
        } catch (UnknownTaskException ex) {
            // never occurs because tasks are filtered by tag so they cannot
            // be unknown.
            logger.warn("Unknown task.", ex);
        }
    }
    return results;
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Aggregations

ImmediateService (org.objectweb.proactive.annotation.ImmediateService)4 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)4 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)3 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)3 DatabaseManagerException (org.ow2.proactive.db.DatabaseManagerException)2 TaskCouldNotRestartException (org.ow2.proactive.scheduler.common.exception.TaskCouldNotRestartException)1 TaskCouldNotStartException (org.ow2.proactive.scheduler.common.exception.TaskCouldNotStartException)1 TaskSkippedException (org.ow2.proactive.scheduler.common.exception.TaskSkippedException)1 SimpleTaskLogs (org.ow2.proactive.scheduler.common.task.SimpleTaskLogs)1 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)1