Search in sources :

Example 1 with UnknownTaskException

use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.

the class SchedulerStateRest method retrieveTaskLogsUsingDatabase.

private String retrieveTaskLogsUsingDatabase(String sessionId, String jobId, String taskName) throws NotConnectedRestException, UnknownJobException, UnknownTaskException, NotConnectedException, PermissionException, PermissionRestException {
    Scheduler scheduler = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskName + "/result/log/all");
    TaskResult taskResult = scheduler.getTaskResult(jobId, taskName);
    if (taskResult != null && taskResult.getOutput() != null) {
        return taskResult.getOutput().getAllLogs(true);
    }
    return "";
}
Also used : Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult)

Example 2 with UnknownTaskException

use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.

the class SchedulerStateRest method taskLogout.

/**
 * Returns the standard output (stderr) generated by the task
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            the id of the job
 * @param taskname
 *            the name of the task
 * @return the stdout generated by the task or an empty string if the result
 *         is not yet available
 */
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/{taskname}/result/log/out")
@Produces("application/json")
public String taskLogout(@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/log/out");
        TaskResult tr = s.getTaskResult(jobId, taskname);
        if ((tr != null) && (tr.getOutput() != null)) {
            return tr.getOutput().getStdoutLogs(true);
        } else {
            return "";
        }
    } 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) UnknownTaskRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException) 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 3 with UnknownTaskException

use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.

the class NoVncSecuredTargetResolver method doResolve.

// package-protected for testing
InetSocketAddress doResolve(String sessionId, String jobId, String taskName) {
    if (sessionId == null || jobId == null || taskName == null) {
        LOGGER.warn("One of the web socket path parameter is missing (sessionId, jobId, taskName).");
        return null;
    }
    Session session = SharedSessionStore.getInstance().get(sessionId);
    if (session == null) {
        LOGGER.warn("Unknown sessionId.");
        return null;
    }
    SchedulerProxyUserInterface scheduler = session.getScheduler();
    try {
        TaskResult taskResult = scheduler.getTaskResult(jobId, taskName);
        List<String> paRemoteConnectionLines = retrievePaRemoteConnectionLines(session, jobId, taskResult);
        String taskId = retrieveTaskId(taskName, scheduler.getJobState(jobId));
        return resolveVncTargetFromLogs(paRemoteConnectionLines, jobId, taskId);
    } catch (NotConnectedException e) {
        LOGGER.warn("Failed to connect to scheduler", e);
    } catch (UnknownJobException e) {
        LOGGER.warn("Job does not exist", e);
    } catch (UnknownTaskException e) {
        LOGGER.warn("Task does not exist", e);
    } catch (PermissionException e) {
        LOGGER.warn("Not allowed to access task", e);
    }
    return null;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

Example 4 with UnknownTaskException

use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.

the class SchedulerClient method isTaskFinished.

@Override
public boolean isTaskFinished(String jobId, String taskName) throws UnknownJobException, NotConnectedException, PermissionException, UnknownTaskException {
    boolean finished = false;
    try {
        TaskStateData taskStateData = restApi().jobTask(sid, jobId, taskName);
        TaskState taskState = taskState(taskStateData);
        finished = !taskState.getStatus().isTaskAlive();
    } catch (Exception e) {
        throwUJEOrNCEOrPEOrUTE(e);
    }
    return finished;
}
Also used : TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) TimeoutException(java.util.concurrent.TimeoutException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)

Example 5 with UnknownTaskException

use of org.ow2.proactive.scheduler.common.exception.UnknownTaskException in project scheduling by ow2-proactive.

the class SchedulerClient method getTaskResultsByTag.

@Override
public List<TaskResult> getTaskResultsByTag(JobId jobId, String taskTag) throws NotConnectedException, UnknownJobException, PermissionException {
    List<TaskState> taskStates = getJobState(jobId).getTasksByTag(taskTag);
    ArrayList<TaskResult> results = new ArrayList<TaskResult>(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) ArrayList(java.util.ArrayList) DataUtility.toTaskResult(org.ow2.proactive.scheduler.rest.data.DataUtility.toTaskResult) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Aggregations

UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)28 Test (org.junit.Test)27 JobId (org.ow2.proactive.scheduler.common.job.JobId)25 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)25 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)21 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)21 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)21 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)18 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)18 ArrayList (java.util.ArrayList)16 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)16 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)14 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)14 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)10 HashMap (java.util.HashMap)8 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)8 SchedulerDBManager (org.ow2.proactive.scheduler.core.db.SchedulerDBManager)8 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)8 List (java.util.List)7 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)7