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);
}
}
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);
}
}
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);
}
}
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);
}
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;
}
Aggregations