/** * Checks if the given notification satisfies this trigger. */ private boolean isSatisfied(ProgramSchedule schedule, Notification notification) { if (!notification.getNotificationType().equals(Notification.Type.TIME)) { return false; } String systemOverridesJson = notification.getProperties().get(ProgramOptionConstants.SYSTEM_OVERRIDES); if (systemOverridesJson == null) { return false; } Map<String, String> args = GSON.fromJson(systemOverridesJson, STRING_STRING_MAP); String cronExpr = args.get(ProgramOptionConstants.CRON_EXPRESSION); // See if the notification is from pre 4.3 system, which doesn't have the cron expression in the notification. // The checking is done by the fact that in pre 4.3 system, composite trigger is not supported, // hence if there is a time notification, it must be matching with this trigger. return getCronExpression().equals(cronExpr) || (cronExpr == null && schedule.getTrigger().getType() == Type.TIME); } }
/** * Checks if the given notification satisfies this trigger. */ private boolean isSatisfied(ProgramSchedule schedule, Notification notification) { if (!notification.getNotificationType().equals(Notification.Type.TIME)) { return false; } String systemOverridesJson = notification.getProperties().get(ProgramOptionConstants.SYSTEM_OVERRIDES); if (systemOverridesJson == null) { return false; } Map<String, String> args = GSON.fromJson(systemOverridesJson, STRING_STRING_MAP); String cronExpr = args.get(ProgramOptionConstants.CRON_EXPRESSION); // See if the notification is from pre 4.3 system, which doesn't have the cron expression in the notification. // The checking is done by the fact that in pre 4.3 system, composite trigger is not supported, // hence if there is a time notification, it must be matching with this trigger. return getCronExpression().equals(cronExpr) || (cronExpr == null && schedule.getTrigger().getType() == Type.TIME); } }
@Override public List<TriggerInfo> getTriggerInfos(TriggerInfoContext context) { for (Notification notification : context.getNotifications()) { if (!isSatisfied(context.getSchedule(), notification)) { continue; } Long logicalStartTime = getLogicalStartTime(notification); if (logicalStartTime == null) { LOG.warn("The notification '{}' in the job of schedule '{}' does not contain logical start time", notification, context.getSchedule()); continue; } TriggerInfo triggerInfo = new DefaultTimeTriggerInfo(getCronExpression(), logicalStartTime); return Collections.singletonList(triggerInfo); } return Collections.emptyList(); }
@Override public List<TriggerInfo> getTriggerInfos(TriggerInfoContext context) { for (Notification notification : context.getNotifications()) { if (!isSatisfied(context.getSchedule(), notification)) { continue; } Long logicalStartTime = getLogicalStartTime(notification); if (logicalStartTime == null) { LOG.warn("The notification '{}' in the job of schedule '{}' does not contain logical start time", notification, context.getSchedule()); continue; } TriggerInfo triggerInfo = new DefaultTimeTriggerInfo(getCronExpression(), logicalStartTime); return Collections.singletonList(triggerInfo); } return Collections.emptyList(); }
String cron = ((TimeTrigger) timeTrigger).getCronExpression(); String triggerName = AbstractTimeSchedulerService.getTriggerName(program, programType, schedule.getName(), cron); cronTriggerKeyMap.put(((TimeTrigger) schedule.getTrigger()).getCronExpression(), triggerKeyForName(triggerName)); return cronTriggerKeyMap;
String cron = ((TimeTrigger) timeTrigger).getCronExpression(); String triggerName = AbstractTimeSchedulerService.getTriggerName(program, programType, schedule.getName(), cron); cronTriggerKeyMap.put(((TimeTrigger) schedule.getTrigger()).getCronExpression(), triggerKeyForName(triggerName)); return cronTriggerKeyMap;
Assert.assertEquals("0 4 * * *", ((TimeTrigger) schedule.getTrigger()).getCronExpression()); Assert.assertEquals(new ProtoConstraint.ConcurrencyConstraint(5), schedule.getConstraints().get(0)); Assert.assertEquals("0/15 * * * * ?", ((TimeTrigger) schedule.getTrigger()).getCronExpression());