Search in sources :

Example 41 with PermissionException

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

the class SchedulerUsageTest method fallbackToMyAccountUsage.

private void fallbackToMyAccountUsage(Scheduler scheduler) throws NotConnectedException, PermissionException {
    List<JobUsage> asAUser = scheduler.getMyAccountUsage(new Date(0), new Date(0));
    assertNotNull(asAUser);
    // fallback to my account usage
    List<JobUsage> forMyUser = scheduler.getAccountUsage(TestUsers.USER.username, new Date(0), new Date(0));
    assertNotNull(forMyUser);
    try {
        scheduler.getAccountUsage(TestUsers.DEMO.username, new Date(0), new Date(0));
        fail("Should throw permission exception");
    } catch (PermissionException e) {
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) JobUsage(org.ow2.proactive.scheduler.common.usage.JobUsage) Date(java.util.Date)

Example 42 with PermissionException

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

the class AbstractSmartProxy method syncAwaitedJob.

/**
 * This method will synchronize this proxy with a remote Scheduler for the
 * given job
 *
 * @param id job ID
 */
private void syncAwaitedJob(String id) {
    AwaitedJob awaitedJob = jobTracker.getAwaitedJob(id);
    try {
        JobState js = getJobState(id);
        for (TaskState ts : js.getTasks()) {
            String tname = ts.getName();
            AwaitedTask at = awaitedJob.getAwaitedTask(tname);
            if ((at != null) && (!at.isTransferring())) {
                TaskResult tres = null;
                try {
                    tres = getTaskResult(id, tname);
                    if (tres != null) {
                        log.debug("Synchonizing task " + tname + " of job " + id);
                        taskStateUpdatedEvent(new NotificationData<>(SchedulerEvent.TASK_RUNNING_TO_FINISHED, ts.getTaskInfo()));
                    }
                } catch (NotConnectedException e) {
                    e.printStackTrace();
                } catch (UnknownJobException e) {
                    log.error("Could not retrieve output data for job " + id + " because this job is not known by the Scheduler. \n ", e);
                } catch (UnknownTaskException e) {
                    log.error("Could not retrieve output data for task " + tname + " of job " + id + " because this task is not known by the Scheduler. \n ", e);
                } catch (Exception e) {
                    log.error("Unexpected error while getting the output data for task " + tname + " of job " + id, e);
                }
            }
        }
        if (js.isFinished()) {
            jobStateUpdatedEvent(new NotificationData<>(SchedulerEvent.JOB_RUNNING_TO_FINISHED, js.getJobInfo()));
        }
    } catch (NotConnectedException e) {
        log.error("A connection error occured while trying to download output data of Job " + id + ". This job will remain in the list of awaited jobs. Another attempt to dowload the output data will be made next time the application is initialized. ", e);
    } catch (UnknownJobException e) {
        log.error("Could not retrieve output data for job " + id + " because this job is not known by the Scheduler. \n ", e);
        log.warn("Job  " + id + " will be removed from the known job list. The system will not attempt again to retrieve data for this job. You could try to manually copy the data from the location  " + awaitedJob.getPullURL());
        jobTracker.removeAwaitedJob(id);
    } catch (PermissionException e) {
        log.error("Could not retrieve output data for job " + id + " because you don't have permmission to access this job. You need to use the same connection credentials you used for submitting the job.  \n Another attempt to dowload the output data for this job will be made next time the application is initialized. ", e);
    }
}
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) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) LoginException(javax.security.auth.login.LoginException) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) 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) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException)

Example 43 with PermissionException

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

the class SchedulerFrontend 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 {
    RestPageParameters params = new RestPageParameters(frontendState, "getTaskIds", from, to, mytasks, running, pending, finished, offset, limit, taskTag, SortSpecifierContainer.EMPTY_CONTAINER);
    Page<TaskInfo> pTaskInfo;
    pTaskInfo = dbManager.getTasks(params.getFrom(), params.getTo(), params.getTag(), params.getOffset(), params.getLimit(), params.getUserName(), params.isPending(), params.isRunning(), params.isFinished());
    List<TaskId> lTaskId = new ArrayList<TaskId>(pTaskInfo.getList().size());
    for (TaskInfo taskInfo : pTaskInfo.getList()) {
        lTaskId.add(taskInfo.getTaskId());
    }
    return new Page<TaskId>(lTaskId, pTaskInfo.getSize());
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ArrayList(java.util.ArrayList) Page(org.ow2.proactive.scheduler.common.Page)

Example 44 with PermissionException

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

the class SchedulerFrontend method restartAllInErrorTasks.

@Override
public boolean restartAllInErrorTasks(String jobId) throws NotConnectedException, UnknownJobException, PermissionException {
    final JobId jobIdObject = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("restartAllInErrorTasks", frontendState.getIdentifiedJob(jobIdObject), YOU_DO_NOT_HAVE_PERMISSION_TO_RESTART_IN_ERROR_TASKS_IN_THIS_JOB);
    return schedulingService.restartAllInErrorTasks(jobIdObject);
}
Also used : JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 45 with PermissionException

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

the class SchedulerFrontend method getTaskServerLogs.

@Override
@ImmediateService
public String getTaskServerLogs(String jobId, String taskName) throws UnknownJobException, UnknownTaskException, NotConnectedException, PermissionException {
    JobId id = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("getTaskServerLogs", frontendState.getIdentifiedJob(id), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_TASK_LOGS_OF_THIS_JOB);
    for (TaskId taskId : frontendState.getJobTasks(id)) {
        if (taskId.getReadableName().equals(taskName)) {
            return ServerJobAndTaskLogs.getTaskLog(taskId);
        }
    }
    throw new UnknownTaskException("Unknown task " + taskName + " in job " + jobId);
}
Also used : UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) JobId(org.ow2.proactive.scheduler.common.job.JobId) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Aggregations

PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)64 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)62 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)46 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)46 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)44 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)39 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)34 Path (javax.ws.rs.Path)32 Produces (javax.ws.rs.Produces)30 GET (javax.ws.rs.GET)26 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)25 JobState (org.ow2.proactive.scheduler.common.job.JobState)21 GZIP (org.jboss.resteasy.annotations.GZIP)17 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)17 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)16 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)16 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)16 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)16 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)15