Search in sources :

Example 1 with DefaultTriggerIdentifier

use of com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier in project kylo by Teradata.

the class NifiStatsJmsReceiver method scheduleStatsCompaction.

/**
 * Schedule the compaction job in Quartz if the properties have this enabled with a Cron Expression
 */
private void scheduleStatsCompaction() {
    if (compactStatsEnabled && StringUtils.isNotBlank(compactStatsCronSchedule)) {
        QuartzScheduler scheduler = (QuartzScheduler) jobScheduler;
        JobIdentifier jobIdentifier = new DefaultJobIdentifier("Compact NiFi Processor Stats", "KYLO");
        TriggerIdentifier triggerIdentifier = new DefaultTriggerIdentifier(jobIdentifier.getName(), jobIdentifier.getGroup());
        try {
            scheduler.scheduleJob(jobIdentifier, triggerIdentifier, NiFiStatsCompactionQuartzJobBean.class, compactStatsCronSchedule, null);
        } catch (ObjectAlreadyExistsException e) {
            log.info("Unable to schedule the job to compact the NiFi processor stats.  It already exists.  Most likely another Kylo node has already schceduled this job. ");
        } catch (SchedulerException e) {
            throw new RuntimeException("Error scheduling job: Compact NiFi Processor Stats", e);
        }
    }
}
Also used : SchedulerException(org.quartz.SchedulerException) DefaultTriggerIdentifier(com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier) QuartzScheduler(com.thinkbiganalytics.scheduler.QuartzScheduler) DefaultJobIdentifier(com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier) JobIdentifier(com.thinkbiganalytics.scheduler.JobIdentifier) DefaultTriggerIdentifier(com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier) TriggerIdentifier(com.thinkbiganalytics.scheduler.TriggerIdentifier) ObjectAlreadyExistsException(org.quartz.ObjectAlreadyExistsException) DefaultJobIdentifier(com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier)

Example 2 with DefaultTriggerIdentifier

use of com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier in project kylo by Teradata.

the class QuartzSchedulerTest method updateTriggerTest.

@Test
public void updateTriggerTest() throws Exception {
    toTest.updateTrigger(new DefaultTriggerIdentifier("trigger-key-name", "trigger-key-name"), "0 0 12 * * ?");
    verify(scheduler).rescheduleJob(eq(new TriggerKey("trigger-key-name", "trigger-key-name")), (Trigger) any());
    doThrow(new SchedulerException()).when(scheduler).rescheduleJob((TriggerKey) any(), (Trigger) any());
    try {
        toTest.updateTrigger(new DefaultTriggerIdentifier("trigger-key-name", "trigger-key-name"), "0 0 12 * * ?");
    } catch (final JobSchedulerException e) {
        return;
    }
    fail();
}
Also used : TriggerKey(org.quartz.TriggerKey) SchedulerException(org.quartz.SchedulerException) DefaultTriggerIdentifier(com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier) Test(org.junit.Test)

Example 3 with DefaultTriggerIdentifier

use of com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier in project kylo by Teradata.

the class QuartzSchedulerTest method existsTests.

@Test
public void existsTests() throws Exception {
    Set<JobKey> set = new HashSet<>();
    set.add(new JobKey("name", "group"));
    Mockito.when(scheduler.getJobKeys((GroupMatcher) anyObject())).thenReturn(set);
    toTest.jobExists(jobIdentifier);
    TriggerIdentifier triggerIdentifer = new DefaultTriggerIdentifier("trigger-key-name", "trigger-key-name");
    toTest.triggerExists(triggerIdentifer);
    toTest.resumeAll();
    toTest.getMetaData();
}
Also used : JobKey(org.quartz.JobKey) DefaultTriggerIdentifier(com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier) DefaultTriggerIdentifier(com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with DefaultTriggerIdentifier

use of com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier in project kylo by Teradata.

the class SchedulerObjectSerializatoinTest method testTriggerInfoSerialization.

@Test
public void testTriggerInfoSerialization() {
    try {
        TriggerInfo info = new DefaultTriggerInfo(new DefaultJobIdentifier(), new DefaultTriggerIdentifier());
        ObjectMapper objectMapper = new ObjectMapper();
        String json = null;
        json = objectMapper.writeValueAsString(info);
        System.out.println(json);
        TriggerInfo info2 = objectMapper.readValue(json, TriggerInfo.class);
        System.out.println(info2);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : DefaultTriggerInfo(com.thinkbiganalytics.scheduler.model.DefaultTriggerInfo) DefaultTriggerIdentifier(com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier) DefaultTriggerInfo(com.thinkbiganalytics.scheduler.model.DefaultTriggerInfo) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultJobIdentifier(com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier) Test(org.junit.Test)

Aggregations

DefaultTriggerIdentifier (com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier)4 Test (org.junit.Test)3 DefaultJobIdentifier (com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier)2 SchedulerException (org.quartz.SchedulerException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JobIdentifier (com.thinkbiganalytics.scheduler.JobIdentifier)1 QuartzScheduler (com.thinkbiganalytics.scheduler.QuartzScheduler)1 TriggerIdentifier (com.thinkbiganalytics.scheduler.TriggerIdentifier)1 DefaultTriggerInfo (com.thinkbiganalytics.scheduler.model.DefaultTriggerInfo)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 JobKey (org.quartz.JobKey)1 ObjectAlreadyExistsException (org.quartz.ObjectAlreadyExistsException)1 TriggerKey (org.quartz.TriggerKey)1