use of org.candlepin.model.JobCurator in project candlepin by candlepin.
the class PinsetterKernel method scheduleJob.
private JobStatus scheduleJob(JobDetail detail, String grpName, Trigger trigger) throws PinsetterException {
JobDetailImpl detailImpl = (JobDetailImpl) detail;
detailImpl.setGroup(grpName);
try {
JobStatus status = (JobStatus) (detail.getJobClass().getMethod("scheduleJob", JobCurator.class, Scheduler.class, JobDetail.class, Trigger.class).invoke(null, jobCurator, scheduler, detail, trigger));
if (log.isDebugEnabled()) {
log.debug("Scheduled " + detailImpl.getFullName());
}
return status;
} catch (Exception e) {
log.error("There was a problem scheduling " + detail.getKey().getName(), e);
throw new PinsetterException("There was a problem scheduling " + detail.getKey().getName(), e);
}
}
use of org.candlepin.model.JobCurator in project candlepin by candlepin.
the class HypervisorUpdateJobTest method monogamousJobTest.
/*
* Make sure only one test is running at a time.
*/
@Test
public void monogamousJobTest() throws JobExecutionException, SchedulerException {
JobDetail detail = HypervisorUpdateJob.forOwner(owner, hypervisorJson, true, principal, null);
JobStatus newJob = new JobStatus(detail);
JobCurator jobCurator = mock(JobCurator.class);
when(jobCurator.findNumRunningByClassAndTarget(owner.getKey(), HypervisorUpdateJob.class)).thenReturn(1L);
assertFalse(HypervisorUpdateJob.isSchedulable(jobCurator, newJob));
}
use of org.candlepin.model.JobCurator in project candlepin by candlepin.
the class HypervisorUpdateJobTest method dontSkipIfExistsTest.
/*
* Schedule the job to be executed later even if a similar job exists.
*/
@Test
public void dontSkipIfExistsTest() throws JobExecutionException, SchedulerException {
JobDetail detail = HypervisorUpdateJob.forOwner(owner, hypervisorJson, true, principal, null);
JobStatus preExistingJobStatus = new JobStatus();
preExistingJobStatus.setState(JobState.WAITING);
HypervisorUpdateJob job = new HypervisorUpdateJob(ownerCurator, consumerCurator, consumerTypeCurator, consumerResource, i18n, subAdapter, complianceRules);
JobStatus newlyScheduledJobStatus = new JobStatus();
JobCurator jobCurator = mock(JobCurator.class);
Scheduler scheduler = mock(Scheduler.class);
ListenerManager lm = mock(ListenerManager.class);
when(jobCurator.getByClassAndTarget(anyString(), any(Class.class))).thenReturn(preExistingJobStatus);
when(scheduler.getListenerManager()).thenReturn(lm);
when(jobCurator.create(any(JobStatus.class))).thenReturn(newlyScheduledJobStatus);
JobStatus resultStatus = job.scheduleJob(jobCurator, scheduler, detail, null);
assertEquals(newlyScheduledJobStatus, resultStatus);
}
use of org.candlepin.model.JobCurator in project candlepin by candlepin.
the class JobCleanerTest method execute.
@Test
public void execute() throws Exception {
JobCurator curator = mock(JobCurator.class);
JobCleaner cleaner = new JobCleaner(curator);
injector.injectMembers(cleaner);
cleaner.execute(null);
verify(curator).cleanUpOldCompletedJobs(any(Date.class));
verify(curator).cleanupAllOldJobs(any(Date.class));
}
Aggregations