Search in sources :

Example 1 with JobSchedulerException

use of com.thinkbiganalytics.scheduler.JobSchedulerException in project kylo by Teradata.

the class DefaultServiceLevelAgreementScheduler method enableServiceLevelAgreement.

/**
 * Used to enable the schedule of the SLA, so that once again executes after a being disabled
 *
 * @param sla The SLA to enable
 */
public void enableServiceLevelAgreement(ServiceLevelAgreement sla) {
    ServiceLevelAgreement.ID slaId = sla.getId();
    JobIdentifier scheduledJobId = null;
    if (scheduledJobNames.containsKey(slaId)) {
        scheduledJobId = jobIdentifierForName(scheduledJobNames.get(slaId));
    } else {
        scheduledJobId = jobIdentifierForName(sla.getName());
    }
    QuartzScheduler scheduler = (QuartzScheduler) jobScheduler;
    if (scheduledJobId != null && scheduler.jobExists(scheduledJobId)) {
        try {
            jobScheduler.resumeTriggersOnJob(scheduledJobId);
        } catch (JobSchedulerException e) {
            log.error("Unable to resume the schedule for the SLA {} ", sla.getName());
        }
    } else {
        log.info("Unable to resume the SLA job {} .  The Job does not exist", sla.getName());
    }
}
Also used : JobSchedulerException(com.thinkbiganalytics.scheduler.JobSchedulerException) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) QuartzScheduler(com.thinkbiganalytics.scheduler.QuartzScheduler) JobIdentifier(com.thinkbiganalytics.scheduler.JobIdentifier) DefaultJobIdentifier(com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier)

Example 2 with JobSchedulerException

use of com.thinkbiganalytics.scheduler.JobSchedulerException in project kylo by Teradata.

the class DefaultServiceLevelAgreementScheduler method unscheduleServiceLevelAgreement.

/**
 * removes the SLA, identified by slaId, from the scheduler, so that it is no longer executed.
 *
 * @param slaId The ServiceLevelAgreement id
 * @return true if we were able to remove the SLA from the scheduler
 */
public boolean unscheduleServiceLevelAgreement(ServiceLevelAgreement.ID slaId) {
    boolean unscheduled = false;
    JobIdentifier scheduledJobId = null;
    try {
        if (scheduledJobNames.containsKey(slaId)) {
            scheduledJobId = jobIdentifierForName(scheduledJobNames.get(slaId));
        }
        QuartzScheduler scheduler = (QuartzScheduler) jobScheduler;
        if (scheduledJobId != null && scheduler.jobExists(scheduledJobId)) {
            log.info("Unscheduling sla job " + scheduledJobId.getName());
            jobScheduler.deleteJob(scheduledJobId);
            scheduledJobNames.remove(slaId);
            unscheduled = true;
            if (clusterService.isClustered()) {
                clusterService.sendMessageToOthers(QTZ_JOB_UNSCHEDULED_MESSAGE_TYPE, new ScheduledServiceLevelAgreementClusterMessage(slaId, scheduledJobId));
            }
        } else {
            log.info("Unable to unschedule/delete the SLA job.  Referencing SLA Id: {}.  It doesn't exist. Scheduled Jobs are: {}  ", slaId, scheduledJobNames);
        }
    } catch (JobSchedulerException e) {
        log.error("Unable to delete the SLA Job " + scheduledJobId);
    }
    return unscheduled;
}
Also used : JobSchedulerException(com.thinkbiganalytics.scheduler.JobSchedulerException) QuartzScheduler(com.thinkbiganalytics.scheduler.QuartzScheduler) JobIdentifier(com.thinkbiganalytics.scheduler.JobIdentifier) DefaultJobIdentifier(com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier)

Example 3 with JobSchedulerException

use of com.thinkbiganalytics.scheduler.JobSchedulerException in project kylo by Teradata.

the class DefaultServiceLevelAgreementScheduler method disableServiceLevelAgreement.

/**
 * Used to disable the schedule of the SLA, so that it no longer executes until subsequently re-enabled
 *
 * @param sla The SLA to disable
 */
public void disableServiceLevelAgreement(ServiceLevelAgreement sla) {
    ServiceLevelAgreement.ID slaId = sla.getId();
    JobIdentifier scheduledJobId = null;
    if (scheduledJobNames.containsKey(slaId)) {
        scheduledJobId = jobIdentifierForName(scheduledJobNames.get(slaId));
    } else {
        scheduledJobId = jobIdentifierForName(sla.getName());
    }
    QuartzScheduler scheduler = (QuartzScheduler) jobScheduler;
    if (scheduledJobId != null && scheduler.jobExists(scheduledJobId)) {
        try {
            jobScheduler.pauseTriggersOnJob(scheduledJobId);
        } catch (JobSchedulerException e) {
            log.error("Unable to pause the schedule for the disabled SLA {} ", sla.getName());
        }
    } else {
        log.info("Unable to pause the SLA job {} .  The Job does not exist", sla.getName());
    }
}
Also used : JobSchedulerException(com.thinkbiganalytics.scheduler.JobSchedulerException) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) QuartzScheduler(com.thinkbiganalytics.scheduler.QuartzScheduler) JobIdentifier(com.thinkbiganalytics.scheduler.JobIdentifier) DefaultJobIdentifier(com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier)

Example 4 with JobSchedulerException

use of com.thinkbiganalytics.scheduler.JobSchedulerException in project kylo by Teradata.

the class SimpleSchedulerQuartzJobBeanSetupTest method test.

@Test
public void test() throws Exception {
    SimpleSchedulerQuartzJobBeanSetup setup = new SimpleSchedulerQuartzJobBeanSetup();
    setup.setQuartzScheduler(scheduler);
    setup.setCronExpresson("cronExpression");
    setup.setDataMap(new HashMap<String, Object>());
    setup.setFireImmediately(false);
    setup.setGroupName("groupName");
    setup.setJobName("jobName");
    setup.setQuartzJobBean(MockJob.class.getCanonicalName());
    setup.scheduleMetadataJob();
    setup.setQuartzJobBean("ignore.error.TestMissingClass");
    setup.scheduleMetadataJob();
    Mockito.mock(QuartzScheduler.class, new Answer() {

        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            throw new JobSchedulerException();
        }
    });
}
Also used : SimpleSchedulerQuartzJobBeanSetup(com.thinkbiganalytics.scheduler.SimpleSchedulerQuartzJobBeanSetup) Answer(org.mockito.stubbing.Answer) JobSchedulerException(com.thinkbiganalytics.scheduler.JobSchedulerException) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Test(org.junit.Test)

Aggregations

JobSchedulerException (com.thinkbiganalytics.scheduler.JobSchedulerException)4 JobIdentifier (com.thinkbiganalytics.scheduler.JobIdentifier)3 QuartzScheduler (com.thinkbiganalytics.scheduler.QuartzScheduler)3 DefaultJobIdentifier (com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier)3 JcrServiceLevelAgreement (com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement)2 ServiceLevelAgreement (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)2 SimpleSchedulerQuartzJobBeanSetup (com.thinkbiganalytics.scheduler.SimpleSchedulerQuartzJobBeanSetup)1 Test (org.junit.Test)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1