Search in sources :

Example 1 with DefaultTriggerInfo

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

the class TriggerInfoImplTest method setUp.

@Before
public void setUp() throws Exception {
    today = new Date();
    trigger = new DefaultTriggerInfo(Mockito.mock(JobIdentifier.class), Mockito.mock(TriggerIdentifier.class));
    trigger.setJobIdentifier(Mockito.mock(JobIdentifier.class));
    trigger.setState(TriggerInfo.TriggerState.BLOCKED);
    trigger.setTriggerClass(Object.class);
    trigger.setTriggerIdentifier(Mockito.mock(TriggerIdentifier.class));
}
Also used : DefaultTriggerInfo(com.thinkbiganalytics.scheduler.model.DefaultTriggerInfo) Date(java.util.Date) Before(org.junit.Before)

Example 2 with DefaultTriggerInfo

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

the class QuartzScheduler method buildTriggerInfo.

private TriggerInfo buildTriggerInfo(JobIdentifier jobIdentifier, Trigger trigger) {
    TriggerInfo triggerInfo = new DefaultTriggerInfo(jobIdentifier, triggerIdentifierForTriggerKey(trigger.getKey()));
    triggerInfo.setDescription(trigger.getDescription());
    triggerInfo.setTriggerClass(trigger.getClass());
    String cronExpression = null;
    triggerInfo.setCronExpressionSummary("");
    if (trigger instanceof CronTrigger) {
        CronTrigger ct = (CronTrigger) trigger;
        cronExpression = ct.getCronExpression();
        triggerInfo.setCronExpressionSummary(ct.getExpressionSummary());
    }
    boolean isSimpleTrigger = (!CronTrigger.class.isAssignableFrom(trigger.getClass()) && SimpleTrigger.class.isAssignableFrom(trigger.getClass()));
    triggerInfo.setSimpleTrigger(isSimpleTrigger);
    boolean isScheduled = CronTrigger.class.isAssignableFrom(triggerInfo.getTriggerClass());
    triggerInfo.setScheduled(isScheduled);
    triggerInfo.setCronExpression(cronExpression);
    triggerInfo.setNextFireTime(trigger.getNextFireTime());
    triggerInfo.setStartTime(trigger.getStartTime());
    triggerInfo.setEndTime(trigger.getEndTime());
    // triggerInfo.setFinalFireTime(trigger.getFinalFireTime());
    triggerInfo.setPreviousFireTime(trigger.getPreviousFireTime());
    return triggerInfo;
}
Also used : DefaultTriggerInfo(com.thinkbiganalytics.scheduler.model.DefaultTriggerInfo) CronTrigger(org.quartz.CronTrigger) DefaultTriggerInfo(com.thinkbiganalytics.scheduler.model.DefaultTriggerInfo)

Example 3 with DefaultTriggerInfo

use of com.thinkbiganalytics.scheduler.model.DefaultTriggerInfo 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

DefaultTriggerInfo (com.thinkbiganalytics.scheduler.model.DefaultTriggerInfo)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DefaultJobIdentifier (com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier)1 DefaultTriggerIdentifier (com.thinkbiganalytics.scheduler.model.DefaultTriggerIdentifier)1 IOException (java.io.IOException)1 Date (java.util.Date)1 Before (org.junit.Before)1 Test (org.junit.Test)1 CronTrigger (org.quartz.CronTrigger)1