Search in sources :

Example 26 with UnknownJobException

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

the class RestSchedulerJobTaskTest method cleanScheduler.

private static void cleanScheduler() throws NotConnectedException, PermissionException, UnknownJobException {
    Scheduler scheduler = RestFuncTHelper.getScheduler();
    SchedulerState state = scheduler.getState();
    Iterable<JobState> jobs = Iterables.concat(state.getPendingJobs(), state.getRunningJobs(), state.getFinishedJobs());
    for (JobState jobState : jobs) {
        JobId jobId = jobState.getId();
        scheduler.killJob(jobId);
        scheduler.removeJob(jobId);
    }
}
Also used : SchedulerState(org.ow2.proactive.scheduler.common.SchedulerState) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 27 with UnknownJobException

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

the class SchedulerStateRestLiveLogsTest method verifyListenAndGetAppender.

private Appender verifyListenAndGetAppender(String jobId) throws NotConnectedException, UnknownJobException, PermissionException, LogForwardingException {
    ArgumentCaptor<AppenderProvider> appenderProviderArgumentCaptor = ArgumentCaptor.forClass(AppenderProvider.class);
    verify(scheduler).listenJobLogs(eq(jobId), appenderProviderArgumentCaptor.capture());
    AppenderProvider appenderProvider = appenderProviderArgumentCaptor.getValue();
    return appenderProvider.getAppender();
}
Also used : AppenderProvider(org.ow2.proactive.scheduler.common.util.logforwarder.AppenderProvider)

Example 28 with UnknownJobException

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

the class NoVncSecuredTargetResolverTest method mockSchedulerState.

@Before
public void mockSchedulerState() throws NotConnectedException, UnknownJobException, PermissionException {
    JobState jobState = mock(JobState.class);
    when(schedulerMock.getJobState("42")).thenReturn(jobState);
    TaskState taskState = mock(TaskState.class);
    when(taskState.getName()).thenReturn("remoteVisuTask");
    TaskId taskId = mock(TaskId.class);
    when(taskId.value()).thenReturn("1");
    when(taskState.getId()).thenReturn(taskId);
    when(jobState.getHMTasks()).thenReturn(Collections.singletonMap(taskId, taskState));
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Before(org.junit.Before)

Example 29 with UnknownJobException

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

the class AbstractFunctCmdTest method cleanScheduler.

protected void cleanScheduler() throws NotConnectedException, PermissionException, UnknownJobException {
    scheduler = RestFuncTHelper.getScheduler();
    SchedulerState state = scheduler.getState();
    System.out.println("Cleaning scheduler.");
    List<JobState> aliveJobsStates = new ArrayList<>(state.getPendingJobs().size() + state.getRunningJobs().size());
    aliveJobsStates.addAll(state.getPendingJobs());
    aliveJobsStates.addAll(state.getRunningJobs());
    List<JobState> finishedJobsStates = new ArrayList<>(state.getFinishedJobs().size());
    finishedJobsStates.addAll(state.getFinishedJobs());
    for (JobState jobState : aliveJobsStates) {
        JobId jobId = jobState.getId();
        try {
            System.out.println("Killing job " + jobId);
            scheduler.killJob(jobId);
        } catch (Exception ignored) {
        }
        System.out.println("Removing killed job " + jobId);
        scheduler.removeJob(jobId);
    }
    for (JobState jobState : finishedJobsStates) {
        JobId jobId = jobState.getId();
        System.out.println("Removing finished job " + jobId);
        scheduler.removeJob(jobId);
    }
}
Also used : SchedulerState(org.ow2.proactive.scheduler.common.SchedulerState) ArrayList(java.util.ArrayList) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException)

Example 30 with UnknownJobException

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

the class SchedulerClient method getJobInfo.

@Override
public JobInfo getJobInfo(String jobId) throws UnknownJobException, NotConnectedException, PermissionException {
    JobInfoData jobInfoData = null;
    try {
        jobInfoData = restApi().jobInfo(sid, jobId);
    } catch (NotConnectedRestException e) {
        throw new NotConnectedException(e);
    } catch (PermissionRestException e) {
        throw new PermissionException(e);
    } catch (UnknownJobRestException e) {
        throw new UnknownJobException(e);
    }
    JobInfoImpl jobInfoImpl = new JobInfoImpl();
    JobId newJobId = JobIdImpl.makeJobId(jobId);
    jobInfoImpl.setJobId(newJobId);
    jobInfoImpl.setJobOwner(jobInfoData.getJobOwner());
    jobInfoImpl.setFinishedTime(jobInfoData.getFinishedTime());
    jobInfoImpl.setRemovedTime(jobInfoData.getRemovedTime());
    jobInfoImpl.setStartTime(jobInfoData.getStartTime());
    jobInfoImpl.setInErrorTime(jobInfoData.getInErrorTime());
    jobInfoImpl.setSubmittedTime(jobInfoData.getSubmittedTime());
    jobInfoImpl.setNumberOfFinishedTasks(jobInfoData.getNumberOfFinishedTasks());
    jobInfoImpl.setNumberOfPendingTasks(jobInfoData.getNumberOfPendingTasks());
    jobInfoImpl.setNumberOfRunningTasks(jobInfoData.getNumberOfRunningTasks());
    jobInfoImpl.setNumberOfInErrorTasks(jobInfoData.getNumberOfInErrorTasks());
    jobInfoImpl.setNumberOfFaultyTasks(jobInfoData.getNumberOfFaultyTasks());
    jobInfoImpl.setTotalNumberOfTasks(jobInfoData.getTotalNumberOfTasks());
    jobInfoImpl.setJobPriority(JobPriority.findPriority(jobInfoData.getPriority().toString()));
    jobInfoImpl.setJobStatus(JobStatus.findPriority(jobInfoData.getStatus().toString()));
    if (jobInfoData.isToBeRemoved())
        jobInfoImpl.setToBeRemoved();
    jobInfoImpl.setGenericInformation(jobInfoData.getGenericInformation());
    jobInfoImpl.setVariables(jobInfoData.getVariables());
    return jobInfoImpl;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) JobInfoData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobInfoData) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) JobInfoImpl(org.ow2.proactive.scheduler.rest.data.JobInfoImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId)

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