Search in sources :

Example 21 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState 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 22 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState 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 23 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.

the class SchedulerClient method getJobState.

@Override
public JobState getJobState(String jobId) throws NotConnectedException, UnknownJobException, PermissionException {
    JobState jobState = null;
    try {
        JobStateData jobStateData = restApi().listJobs(sid, jobId);
        jobState = toJobState(jobStateData);
    } catch (Exception e) {
        throwUJEOrNCEOrPE(e);
    }
    return jobState;
}
Also used : JobState(org.ow2.proactive.scheduler.common.job.JobState) DataUtility.toJobState(org.ow2.proactive.scheduler.rest.data.DataUtility.toJobState) JobStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobStateData) 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 24 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.

the class SchedulerClientTest method testJobSubmissionEventListener.

@Test(timeout = MAX_WAIT_TIME * 2)
public void testJobSubmissionEventListener() throws Exception {
    ISchedulerClient client = clientInstance();
    SchedulerEventListenerImpl listener = new SchedulerEventListenerImpl();
    client.addEventListener(listener, true, SchedulerEvent.JOB_SUBMITTED, SchedulerEvent.USERS_UPDATE);
    Job job = defaultJob();
    JobId jobId = client.submit(job);
    JobState submittedJob = listener.getSubmittedJob();
    while (!submittedJob.getId().value().equals(jobId.value())) {
        submittedJob = listener.getSubmittedJob();
    }
    UserIdentification userIdentification = listener.getLastUserUpdate();
    assertTrue(userIdentification.getLastSubmitTime() != -1);
    client.removeEventListener();
    client.waitForJob(jobId, TimeUnit.SECONDS.toMillis(120));
}
Also used : ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleJob(functionaltests.jobs.SimpleJob) Job(org.ow2.proactive.scheduler.common.job.Job) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) UserIdentification(org.ow2.proactive.scheduler.common.job.UserIdentification) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 25 with JobState

use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.

the class SchedulerEventBroadcaster method jobUpdatedFullDataEvent.

@Override
public void jobUpdatedFullDataEvent(JobState jobState) {
    logEvent(jobState);
    broadcast(new EventNotification(EventNotification.Action.JOB_FULL_DATA_UPDATED, SchedulerEvent.JOB_UPDATED.name(), jobState));
}
Also used : EventNotification(org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification)

Aggregations

JobState (org.ow2.proactive.scheduler.common.job.JobState)67 Test (org.junit.Test)34 JobId (org.ow2.proactive.scheduler.common.job.JobId)28 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)25 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)23 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)19 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)17 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)17 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)15 ArrayList (java.util.ArrayList)14 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)14 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)14 GET (javax.ws.rs.GET)13 Path (javax.ws.rs.Path)13 Produces (javax.ws.rs.Produces)13 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)13 File (java.io.File)12 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)9 ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)9 TaskStatesPage (org.ow2.proactive.scheduler.common.task.TaskStatesPage)8