Search in sources :

Example 91 with PermissionException

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

the class TestDisabledListenJobLogs method test.

@Test
public void test() throws Throwable {
    log("Submitting job");
    JobId id = schedulerHelper.submitJob(new File(simpleJob.toURI()).getAbsolutePath());
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    try {
        scheduler.listenJobLogs(id, null);
        fail("listenJobLogs should throw an exception");
    } catch (PermissionException ex) {
        assertEquals(EXPECTED_MESSAGE, ex.getMessage());
    }
    try {
        scheduler.listenJobLogs(id.value(), null);
        fail("listenJobLogs should throw an exception");
    } catch (PermissionException ex) {
        assertEquals(EXPECTED_MESSAGE, ex.getMessage());
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 92 with PermissionException

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

the class SchedulerFrontend method getJobServerLogs.

@Override
@ImmediateService
public String getJobServerLogs(String jobId) throws UnknownJobException, NotConnectedException, PermissionException {
    JobId id = JobIdImpl.makeJobId(jobId);
    frontendState.checkPermissions("getJobServerLogs", frontendState.getIdentifiedJob(id), YOU_DO_NOT_HAVE_PERMISSIONS_TO_GET_THE_LOGS_OF_THIS_JOB);
    return ServerJobAndTaskLogs.getJobLog(JobIdImpl.makeJobId(jobId), frontendState.getJobTasks(id));
}
Also used : JobId(org.ow2.proactive.scheduler.common.job.JobId) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 93 with PermissionException

use of org.ow2.proactive.scheduler.common.exception.PermissionException 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<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) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 94 with PermissionException

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

the class SchedulerFrontend method getJobResult.

/**
 * {@inheritDoc}
 */
@Override
@ImmediateService
public JobResult getJobResult(final JobId jobId) throws NotConnectedException, PermissionException, UnknownJobException {
    // checking permissions
    IdentifiedJob ij = frontendState.getIdentifiedJob(jobId);
    frontendState.checkPermissions("getJobResult", ij, YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_RESULT_OF_THIS_JOB);
    if (!ij.isFinished()) {
        jlogger.info(jobId, "is not finished");
        jlogger.info(jobId, "Job state: " + frontendState.getJobState(jobId).getStatus());
        return null;
    }
    jlogger.info(jobId, "trying to get the job result");
    JobResult result = dbManager.loadJobResult(jobId);
    if (result == null) {
        throw new UnknownJobException(jobId);
    }
    if (!result.getJobInfo().isToBeRemoved() && SCHEDULER_REMOVED_JOB_DELAY > 0) {
        // remember that this job is to be removed
        dbManager.jobSetToBeRemoved(jobId);
        schedulingService.scheduleJobRemove(jobId, System.currentTimeMillis() + SCHEDULER_REMOVED_JOB_DELAY);
        jlogger.info(jobId, "will be removed in " + (SCHEDULER_REMOVED_JOB_DELAY / 1000) + "sec");
    }
    return result;
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) IdentifiedJob(org.ow2.proactive.scheduler.job.IdentifiedJob) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Example 95 with PermissionException

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

the class SchedulerFrontend method getTasksToSchedule.

@Override
public List<TaskDescriptor> getTasksToSchedule() throws NotConnectedException, PermissionException {
    Policy policy = null;
    List<TaskDescriptor> eligibleTasks = new ArrayList<>();
    Map<JobId, JobDescriptor> jobMap = null;
    try {
        jobMap = schedulingService.lockJobsToSchedule();
        policy = (Policy) Class.forName(getCurrentPolicy()).newInstance();
        // we wait for next scheduling loop
        if (jobMap.isEmpty()) {
            return eligibleTasks;
        }
        List<JobDescriptor> descriptors = new ArrayList<>(jobMap.values());
        LinkedList<EligibleTaskDescriptor> taskRetrievedFromPolicy = policy.getOrderedTasks(descriptors);
        // if there is no task to scheduled, return
        if (taskRetrievedFromPolicy.isEmpty()) {
            return eligibleTasks;
        }
        eligibleTasks = (List) taskRetrievedFromPolicy;
    } catch (Exception e) {
        logger.error("Error Loading Current Policy:", e);
    } finally {
        schedulingService.unlockJobsToSchedule(jobMap.values());
    }
    return eligibleTasks;
}
Also used : Policy(org.ow2.proactive.scheduler.policy.Policy) ClientsPolicy(org.ow2.proactive.policy.ClientsPolicy) TaskDescriptor(org.ow2.proactive.scheduler.common.TaskDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) JobDescriptor(org.ow2.proactive.scheduler.common.JobDescriptor) EligibleTaskDescriptor(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptor) ArrayList(java.util.ArrayList) JobId(org.ow2.proactive.scheduler.common.job.JobId) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) TaskCouldNotRestartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotRestartException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) AlreadyConnectedException(org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) TaskCouldNotStartException(org.ow2.proactive.scheduler.common.exception.TaskCouldNotStartException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) DatabaseManagerException(org.ow2.proactive.db.DatabaseManagerException) TaskSkippedException(org.ow2.proactive.scheduler.common.exception.TaskSkippedException)

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