Search in sources :

Example 1 with SchedulerState

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

the class RestSchedulerJobPaginationTest method setUp.

@Before
public void setUp() throws Exception {
    Scheduler scheduler = RestFuncTHelper.getScheduler();
    SchedulerState state = scheduler.getState();
    List<JobState> jobStates = new ArrayList<>();
    jobStates.addAll(state.getPendingJobs());
    jobStates.addAll(state.getRunningJobs());
    jobStates.addAll(state.getFinishedJobs());
    for (JobState jobState : jobStates) {
        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) ArrayList(java.util.ArrayList) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId) Before(org.junit.Before)

Example 2 with SchedulerState

use of org.ow2.proactive.scheduler.common.SchedulerState 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 3 with SchedulerState

use of org.ow2.proactive.scheduler.common.SchedulerState 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 4 with SchedulerState

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

the class RecoveredSchedulerStateTest method testConstructor.

@Test
public void testConstructor() throws Exception {
    int nbJobs = 2;
    Vector<InternalJob> pendingJobs = createJobs(JobStatus.PENDING, nbJobs);
    Vector<InternalJob> runningJobs = createJobs(JobStatus.RUNNING, nbJobs);
    Vector<InternalJob> finishedJobs = createJobs(JobStatus.FINISHED, nbJobs);
    RecoveredSchedulerState recoveredState = new RecoveredSchedulerState(pendingJobs, runningJobs, finishedJobs);
    assertThat(recoveredState.getPendingJobs()).containsExactlyElementsIn(pendingJobs);
    assertThat(recoveredState.getRunningJobs()).containsExactlyElementsIn(runningJobs);
    assertThat(recoveredState.getFinishedJobs()).containsExactlyElementsIn(finishedJobs);
    SchedulerStateImpl schedulerState = recoveredState.getSchedulerState();
    assertThat(schedulerState).isNotNull();
    assertThat(schedulerState.getPendingJobs()).hasSize(nbJobs);
    assertThat(schedulerState.getRunningJobs()).hasSize(nbJobs);
    assertThat(schedulerState.getFinishedJobs()).hasSize(nbJobs);
    assertThat(schedulerState.getPendingJobs().get(0)).isInstanceOf(ClientJobState.class);
    assertThat(schedulerState.getRunningJobs().get(0)).isInstanceOf(ClientJobState.class);
    assertThat(schedulerState.getFinishedJobs().get(0)).isInstanceOf(ClientJobState.class);
}
Also used : RecoveredSchedulerState(org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) SchedulerStateImpl(org.ow2.proactive.scheduler.core.SchedulerStateImpl) Test(org.junit.Test)

Example 5 with SchedulerState

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

the class SchedulerFrontendState method addEventListener.

synchronized SchedulerState addEventListener(SchedulerEventListener sel, boolean myEventsOnly, boolean getCurrentState, SchedulerEvent... events) throws NotConnectedException, PermissionException {
    // checking permissions
    ListeningUser uIdent = checkPermissionReturningListeningUser("addEventListener", YOU_DO_NOT_HAVE_PERMISSION_TO_ADD_A_LISTENER);
    // check if listener is not null
    if (sel == null) {
        String msg = "Scheduler listener must be not null";
        logger.info(msg);
        throw new IllegalArgumentException(msg);
    }
    // check if the listener is a reified remote object
    if (!MOP.isReifiedObject(sel)) {
        String msg = "Scheduler listener must be a remote object";
        logger.info(msg);
        throw new IllegalArgumentException(msg);
    }
    // get the scheduler State
    SchedulerState currentState = null;
    if (getCurrentState) {
        // check get state permission is checked in getState method
        currentState = getState(myEventsOnly);
    } else {
        // check get state permission
        handleOnlyMyJobsPermission(myEventsOnly, uIdent.getUser(), YOU_DO_NOT_HAVE_PERMISSION_TO_ADD_A_LISTENER);
    }
    // prepare user for receiving events
    uIdent.getUser().setUserEvents(events);
    // set if the user wants to get its events only or every events
    uIdent.getUser().setMyEventsOnly(myEventsOnly);
    // add the listener to the list of listener for this user.
    UniqueID id = PAActiveObject.getContext().getCurrentRequest().getSourceBodyID();
    uIdent.setListener(new ClientRequestHandler(this, id, sel));
    // cancel timer for this user : session is now managed by events
    uIdent.getUser().getSession().cancel();
    // return to the user
    return currentState;
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID) SchedulerState(org.ow2.proactive.scheduler.common.SchedulerState)

Aggregations

SchedulerState (org.ow2.proactive.scheduler.common.SchedulerState)11 JobId (org.ow2.proactive.scheduler.common.job.JobId)6 JobState (org.ow2.proactive.scheduler.common.job.JobState)6 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)5 ArrayList (java.util.ArrayList)4 Before (org.junit.Before)3 Test (org.junit.Test)3 MonitorEventReceiver (functionaltests.monitor.MonitorEventReceiver)2 SchedulerMonitorsHandler (functionaltests.monitor.SchedulerMonitorsHandler)2 CredData (org.ow2.proactive.authentication.crypto.CredData)2 RecoveredSchedulerState (org.ow2.proactive.scheduler.core.db.RecoveredSchedulerState)2 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)2 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 PAActiveObject (org.objectweb.proactive.api.PAActiveObject)1 UniqueID (org.objectweb.proactive.core.UniqueID)1 Credentials (org.ow2.proactive.authentication.crypto.Credentials)1 SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)1 SchedulerEventListener (org.ow2.proactive.scheduler.common.SchedulerEventListener)1 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)1