Search in sources :

Example 1 with PinsetterException

use of org.candlepin.pinsetter.core.PinsetterException in project candlepin by candlepin.

the class PinsetterAsyncFilterTest method schedulingError.

@Test(expected = ServiceUnavailableException.class)
public void schedulingError() throws PinsetterException {
    JobDetail detail = newJob(RefreshPoolsJob.class).build();
    when(response.getEntity()).thenReturn(detail);
    when(this.pinsetterKernel.scheduleSingleJob(detail)).thenThrow(new PinsetterException("Error scheduling job!"));
    this.interceptor.postProcess(response);
}
Also used : RefreshPoolsJob(org.candlepin.pinsetter.tasks.RefreshPoolsJob) JobDetail(org.quartz.JobDetail) PinsetterException(org.candlepin.pinsetter.core.PinsetterException) Test(org.junit.Test)

Example 2 with PinsetterException

use of org.candlepin.pinsetter.core.PinsetterException in project candlepin by candlepin.

the class CancelJobJob method toExecute.

@Override
public void toExecute(JobExecutionContext ctx) throws JobExecutionException {
    try {
        Set<JobKey> keys = pinsetterKernel.getSingleJobKeys();
        Set<String> statusIds = new HashSet<>();
        for (JobKey key : keys) {
            statusIds.add(key.getName());
        }
        try {
            Set<JobStatus> jobs = this.jobCurator.findCanceledJobs(statusIds);
            if (jobs.size() > 0) {
                pinsetterKernel.cancelJobs(jobs);
            }
        } catch (PinsetterException e) {
            log.error("Exception canceling jobs", e);
        }
    } catch (SchedulerException e) {
        log.error("Unable to cancel jobs", e);
    }
}
Also used : JobStatus(org.candlepin.pinsetter.core.model.JobStatus) JobKey(org.quartz.JobKey) SchedulerException(org.quartz.SchedulerException) PinsetterException(org.candlepin.pinsetter.core.PinsetterException) HashSet(java.util.HashSet)

Aggregations

PinsetterException (org.candlepin.pinsetter.core.PinsetterException)2 HashSet (java.util.HashSet)1 JobStatus (org.candlepin.pinsetter.core.model.JobStatus)1 RefreshPoolsJob (org.candlepin.pinsetter.tasks.RefreshPoolsJob)1 Test (org.junit.Test)1 JobDetail (org.quartz.JobDetail)1 JobKey (org.quartz.JobKey)1 SchedulerException (org.quartz.SchedulerException)1