Search in sources :

Example 66 with UnknownJobException

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

the class SchedulerFrontend method restartInErrorTask.

/**
 * {@inheritDoc}
 */
@Override
@ImmediateService
public boolean restartInErrorTask(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    // checking permissions
    final JobId jobIdObject = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("restartTaskOnError", frontendState.getIdentifiedJob(jobIdObject), YOU_DO_NOT_HAVE_PERMISSION_TO_RESTART_THIS_TASK);
    return schedulingService.restartInErrorTask(jobIdObject, taskName);
}
Also used : JobId(org.ow2.proactive.scheduler.common.job.JobId) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 67 with UnknownJobException

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

the class SchedulerFrontend method finishInErrorTask.

/**
 * {@inheritDoc}
 */
@Override
@ImmediateService
public boolean finishInErrorTask(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    // checking permissions
    final JobId jobIdObject = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("finishTaskInError", frontendState.getIdentifiedJob(jobIdObject), YOU_DO_NOT_HAVE_PERMISSION_TO_FINISH_THIS_TASK);
    return schedulingService.finishInErrorTask(jobIdObject, taskName);
}
Also used : JobId(org.ow2.proactive.scheduler.common.job.JobId) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 68 with UnknownJobException

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

the class SchedulerFrontend method getTaskServerLogsByTag.

@Override
@ImmediateService
public String getTaskServerLogsByTag(String jobId, String taskTag) throws UnknownJobException, NotConnectedException, PermissionException {
    JobId id = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("getTaskServerLogsByTag", frontendState.getIdentifiedJob(id), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_LOGS_OF_THIS_JOB);
    List<TaskState> lTaskState = frontendState.getJobState(id).getTasksByTag(taskTag);
    Set<TaskId> tasksIds = new HashSet<>(lTaskState.size());
    for (TaskState taskState : lTaskState) {
        tasksIds.add(taskState.getId());
    }
    return ServerJobAndTaskLogs.getJobLog(id, tasksIds);
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId) HashSet(java.util.HashSet) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 69 with UnknownJobException

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

the class SchedulerFrontendState method checkChangeJobPriority.

synchronized void checkChangeJobPriority(JobId jobId, JobPriority priority) throws NotConnectedException, UnknownJobException, PermissionException, JobAlreadyFinishedException {
    checkPermissions("changeJobPriority", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_CHANGE_THE_PRIORITY_OF_THIS_JOB);
    UserIdentificationImpl ui = identifications.get(PAActiveObject.getContext().getCurrentRequest().getSourceBodyID()).getUser();
    try {
        ui.checkPermission(new ChangePriorityPermission(priority.getPriority()), ui.getUsername() + " does not have permissions to set job priority to " + priority);
    } catch (PermissionException ex) {
        logger.info(ex.getMessage());
        throw ex;
    }
    if (jobs.get(jobId).isFinished()) {
        String msg = " is already finished";
        jlogger.info(jobId, msg);
        throw new JobAlreadyFinishedException("Job " + jobId + msg);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl) ChangePriorityPermission(org.ow2.proactive.scheduler.permissions.ChangePriorityPermission) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)

Example 70 with UnknownJobException

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

the class SchedulerFrontendState method getTaskState.

synchronized TaskState getTaskState(JobId jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_TASK);
    if (jobsMap.get(jobId) == null) {
        throw new UnknownJobException(jobId);
    }
    TaskId taskId = null;
    for (TaskId t : getJobTasks(jobId)) {
        if (t.getReadableName().equals(taskName)) {
            taskId = t;
        }
    }
    if (taskId == null) {
        throw new UnknownTaskException(taskName, jobId);
    }
    JobState jobState = jobsMap.get(jobId);
    synchronized (jobState) {
        TaskState ts = jobState.getHMTasks().get(taskId);
        if (ts == null) {
            throw new UnknownTaskException(taskId, jobId);
        }
        return ts;
    }
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobState(org.ow2.proactive.scheduler.common.job.JobState) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState)

Aggregations

UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)46 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)34 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)33 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)29 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)29 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)29 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)28 Path (javax.ws.rs.Path)24 GET (javax.ws.rs.GET)22 Produces (javax.ws.rs.Produces)22 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)21 JobState (org.ow2.proactive.scheduler.common.job.JobState)21 JobId (org.ow2.proactive.scheduler.common.job.JobId)19 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)17 ArrayList (java.util.ArrayList)16 GZIP (org.jboss.resteasy.annotations.GZIP)16 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)15 Test (org.junit.Test)12 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)12 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)9