/** * Extracts a {@link DeadlineMessage} from provided {@code jobDataMap}. * * <b>Note</b> that this function is able to retrieve two different formats of DeadlineMessage. The first being * a now deprecated solution which used to serialized the entire {@link DeadlineMessage} into the * {@link JobDataMap}. This is only kept for backwards compatibility. The second is the new solution which * stores all the required deadline fields separately, only de-/serializing the payload and metadata of a * DeadlineMessage instead of the entire message. * * @param serializer the {@link Serializer} used to deserialize the contents of the given {@code} jobDataMap} * into a {@link DeadlineMessage} * @param jobDataMap the {@link JobDataMap} which should contain a {@link DeadlineMessage} * @return the {@link DeadlineMessage} pulled from the {@code jobDataMap} */ public static DeadlineMessage deadlineMessage(Serializer serializer, JobDataMap jobDataMap) { if (jobDataMap.containsKey(SERIALIZED_DEADLINE_MESSAGE)) { SimpleSerializedObject<byte[]> serializedDeadlineMessage = new SimpleSerializedObject<>( (byte[]) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE), byte[].class, (String) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE_CLASS_NAME), null ); return serializer.deserialize(serializedDeadlineMessage); } return new GenericDeadlineMessage<>((String) jobDataMap.get(DEADLINE_NAME), (String) jobDataMap.get(MESSAGE_ID), deserializeDeadlinePayload(serializer, jobDataMap), deserializeDeadlineMetaData(serializer, jobDataMap), retrieveDeadlineTimestamp(jobDataMap)); }
public void execute(JobExecutionContext context) throws JobExecutionException { JobDataMap data = context.getMergedJobDataMap(); String command = data.getString(PROP_COMMAND); String parameters = data.getString(PROP_PARAMETERS); if (parameters == null) { parameters = ""; } boolean wait = true; if(data.containsKey(PROP_WAIT_FOR_PROCESS)) { wait = data.getBooleanValue(PROP_WAIT_FOR_PROCESS); } boolean consumeStreams = false; if(data.containsKey(PROP_CONSUME_STREAMS)) { consumeStreams = data.getBooleanValue(PROP_CONSUME_STREAMS); } Integer exitCode = this.runNativeCommand(command, parameters, wait, consumeStreams); context.setResult(exitCode); }
if(mergedJobDataMap.containsKey(LAST_MODIFIED_TIME)) { lastDate = mergedJobDataMap.getLong(LAST_MODIFIED_TIME); if(mergedJobDataMap.containsKey(MINIMUM_UPDATE_AGE)) { minAge = mergedJobDataMap.getLong(MINIMUM_UPDATE_AGE);
/** * <b>Note</b> that this function is able to retrieve an Event Message in two formats. The first is the * original, deprecated approach, which uses the Quartz serializer (read Java serialization) to serialize an * entire event message at once. The second approach uses the configurable {@link Serializer} in this class to * serialized the payload and metadata of an event message. All fields which required to instantiate a * {@link GenericEventMessage} are currently stored in the {@code jobDataMap} when calling the * {@link DirectEventJobDataBinder#toJobData(Object)} function. * Approach one only exists for backwards compatibility and should be removed in subsequent major releases. * <p> * {@inheritDoc} */ @Override public Object fromJobData(JobDataMap jobDataMap) { if (jobDataMap.containsKey(SERIALIZED_MESSAGE_PAYLOAD)) { return new GenericEventMessage<>((String) jobDataMap.get(MESSAGE_ID), deserializePayload(jobDataMap), deserializeMetaData(jobDataMap), retrieveDeadlineTimestamp(jobDataMap)); } return fromJobDataMap(jobDataMap); }
if(mergedJobDataMap.containsKey(LAST_MODIFIED_TIME)) { lastDate = mergedJobDataMap.getLong(LAST_MODIFIED_TIME); if(mergedJobDataMap.containsKey(MINIMUM_UPDATE_AGE)) { minAge = mergedJobDataMap.getLong(MINIMUM_UPDATE_AGE);
protected boolean isEagerCallback(Trigger trigger) { return trigger.getJobDataMap().containsKey(EAGER_CALLBACK_COUNT); }
final int retries = jobDataMap.containsKey(COUNT_MAP_KEY) ? jobDataMap.getIntValue(COUNT_MAP_KEY) : 0;
AuditService auditService = (AuditService) map.get("AuditService"); if (map.containsKey(LOCK_TYPE)) { lockType = (LockType) map.get(LOCK_TYPE); if (map.containsKey(CRON_JOB)) { job = (CronJob) map.get(CRON_JOB);
AuditService auditService = (AuditService) map.get("AuditService"); if (map.containsKey(LOCK_TYPE)) { lockType = (LockType) map.get(LOCK_TYPE); if (map.containsKey(CRON_JOB)) { job = (CronJob) map.get(CRON_JOB);
/** * Extracts a {@link DeadlineMessage} from provided {@code jobDataMap}. * * <b>Note</b> that this function is able to retrieve two different formats of DeadlineMessage. The first being * a now deprecated solution which used to serialized the entire {@link DeadlineMessage} into the * {@link JobDataMap}. This is only kept for backwards compatibility. The second is the new solution which * stores all the required deadline fields separately, only de-/serializing the payload and metadata of a * DeadlineMessage instead of the entire message. * * @param serializer the {@link Serializer} used to deserialize the contents of the given {@code} jobDataMap} * into a {@link DeadlineMessage} * @param jobDataMap the {@link JobDataMap} which should contain a {@link DeadlineMessage} * @return the {@link DeadlineMessage} pulled from the {@code jobDataMap} */ public static DeadlineMessage deadlineMessage(Serializer serializer, JobDataMap jobDataMap) { if (jobDataMap.containsKey(SERIALIZED_DEADLINE_MESSAGE)) { SimpleSerializedObject<byte[]> serializedDeadlineMessage = new SimpleSerializedObject<>( (byte[]) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE), byte[].class, (String) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE_CLASS_NAME), null ); return serializer.deserialize(serializedDeadlineMessage); } return new GenericDeadlineMessage<>((String) jobDataMap.get(DEADLINE_NAME), (String) jobDataMap.get(MESSAGE_ID), deserializeDeadlinePayload(serializer, jobDataMap), deserializeDeadlineMetaData(serializer, jobDataMap), retrieveDeadlineTimestamp(jobDataMap)); }
/** * Extracts a {@link DeadlineMessage} from provided {@code jobDataMap}. * * <b>Note</b> that this function is able to retrieve two different formats of DeadlineMessage. The first being * a now deprecated solution which used to serialized the entire {@link DeadlineMessage} into the * {@link JobDataMap}. This is only kept for backwards compatibility. The second is the new solution which * stores all the required deadline fields separately, only de-/serializing the payload and metadata of a * DeadlineMessage instead of the entire message. * * @param serializer the {@link Serializer} used to deserialize the contents of the given {@code} jobDataMap} * into a {@link DeadlineMessage} * @param jobDataMap the {@link JobDataMap} which should contain a {@link DeadlineMessage} * @return the {@link DeadlineMessage} pulled from the {@code jobDataMap} */ public static DeadlineMessage deadlineMessage(Serializer serializer, JobDataMap jobDataMap) { if (jobDataMap.containsKey(SERIALIZED_DEADLINE_MESSAGE)) { SimpleSerializedObject<byte[]> serializedDeadlineMessage = new SimpleSerializedObject<>( (byte[]) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE), byte[].class, (String) jobDataMap.get(SERIALIZED_DEADLINE_MESSAGE_CLASS_NAME), null ); return serializer.deserialize(serializedDeadlineMessage); } return new GenericDeadlineMessage<>((String) jobDataMap.get(DEADLINE_NAME), (String) jobDataMap.get(MESSAGE_ID), deserializeDeadlinePayload(serializer, jobDataMap), deserializeDeadlineMetaData(serializer, jobDataMap), retrieveDeadlineTimestamp(jobDataMap)); }
if (jobDataMap.containsKey("endpointRef"))
public void execute(JobExecutionContext context) throws JobExecutionException { JobDataMap data = context.getMergedJobDataMap(); String command = data.getString(PROP_COMMAND); String parameters = data.getString(PROP_PARAMETERS); if (parameters == null) { parameters = ""; } boolean wait = true; if(data.containsKey(PROP_WAIT_FOR_PROCESS)) { wait = data.getBooleanValue(PROP_WAIT_FOR_PROCESS); } boolean consumeStreams = false; if(data.containsKey(PROP_CONSUME_STREAMS)) { consumeStreams = data.getBooleanValue(PROP_CONSUME_STREAMS); } Integer exitCode = this.runNativeCommand(command, parameters, wait, consumeStreams); context.setResult(exitCode); }
public void execute(JobExecutionContext context) throws JobExecutionException { JobDataMap data = context.getMergedJobDataMap(); String command = data.getString(PROP_COMMAND); String parameters = data.getString(PROP_PARAMETERS); if (parameters == null) { parameters = ""; } boolean wait = true; if(data.containsKey(PROP_WAIT_FOR_PROCESS)) { wait = data.getBooleanValue(PROP_WAIT_FOR_PROCESS); } boolean consumeStreams = false; if(data.containsKey(PROP_CONSUME_STREAMS)) { consumeStreams = data.getBooleanValue(PROP_CONSUME_STREAMS); } Integer exitCode = this.runNativeCommand(command, parameters, wait, consumeStreams); context.setResult(exitCode); }
protected void notify(JobExecutionContext jobExecutionContext, String jobStatus) { try { StringBuffer mailMessageSubject = new StringBuffer(configurationService.getPropertyString(KFSConstants.ENVIRONMENT_KEY)).append(": ").append(jobExecutionContext.getJobDetail().getGroup()).append(": ").append(jobExecutionContext.getJobDetail().getName()); MailMessage mailMessage = new MailMessage(); mailMessage.setFromAddress(mailService.getBatchMailingList()); if (jobExecutionContext.getMergedJobDataMap().containsKey(REQUESTOR_EMAIL_ADDRESS_KEY) && !StringUtils.isBlank(jobExecutionContext.getMergedJobDataMap().getString(REQUESTOR_EMAIL_ADDRESS_KEY))) { mailMessage.addToAddress(jobExecutionContext.getMergedJobDataMap().getString(REQUESTOR_EMAIL_ADDRESS_KEY)); } if (SchedulerService.FAILED_JOB_STATUS_CODE.equals(jobStatus) || SchedulerService.CANCELLED_JOB_STATUS_CODE.equals(jobStatus)) { mailMessage.addToAddress(mailService.getBatchMailingList()); } mailMessageSubject.append(": ").append(jobStatus); String messageText = MessageFormat.format(configurationService.getPropertyString(KFSKeyConstants.MESSAGE_BATCH_FILE_LOG_EMAIL_BODY), getLogFileName(NDC.peek())); mailMessage.setMessage(messageText); if (mailMessage.getToAddresses().size() > 0) { mailMessage.setSubject(mailMessageSubject.toString()); mailService.sendMessage(mailMessage); } } catch (InvalidAddressException iae) { LOG.error("Caught exception while trying to send job completion notification e-mail for " + jobExecutionContext.getJobDetail().getName(), iae); } }
/** * <b>Note</b> that this function is able to retrieve an Event Message in two formats. The first is the * original, deprecated approach, which uses the Quartz serializer (read Java serialization) to serialize an * entire event message at once. The second approach uses the configurable {@link Serializer} in this class to * serialized the payload and metadata of an event message. All fields which required to instantiate a * {@link GenericEventMessage} are currently stored in the {@code jobDataMap} when calling the * {@link DirectEventJobDataBinder#toJobData(Object)} function. * Approach one only exists for backwards compatibility and should be removed in subsequent major releases. * <p> * {@inheritDoc} */ @Override public Object fromJobData(JobDataMap jobDataMap) { if (jobDataMap.containsKey(SERIALIZED_MESSAGE_PAYLOAD)) { return new GenericEventMessage<>((String) jobDataMap.get(MESSAGE_ID), deserializePayload(jobDataMap), deserializeMetaData(jobDataMap), retrieveDeadlineTimestamp(jobDataMap)); } return fromJobDataMap(jobDataMap); }
/** * <b>Note</b> that this function is able to retrieve an Event Message in two formats. The first is the * original, deprecated approach, which uses the Quartz serializer (read Java serialization) to serialize an * entire event message at once. The second approach uses the configurable {@link Serializer} in this class to * serialized the payload and metadata of an event message. All fields which required to instantiate a * {@link GenericEventMessage} are currently stored in the {@code jobDataMap} when calling the * {@link DirectEventJobDataBinder#toJobData(Object)} function. * Approach one only exists for backwards compatibility and should be removed in subsequent major releases. * <p> * {@inheritDoc} */ @Override public Object fromJobData(JobDataMap jobDataMap) { if (jobDataMap.containsKey(SERIALIZED_MESSAGE_PAYLOAD)) { return new GenericEventMessage<>((String) jobDataMap.get(MESSAGE_ID), deserializePayload(jobDataMap), deserializeMetaData(jobDataMap), retrieveDeadlineTimestamp(jobDataMap)); } return fromJobDataMap(jobDataMap); }
@Override public Job newJob(TriggerFiredBundle arg0, Scheduler arg1) throws SchedulerException { JobDataMap data = arg0.getJobDetail().getJobDataMap(); ExecutionRunnable task; Execution execution; if(data.containsKey(Executor.EXECUTION_ID)) { String executionID = data.getString(Executor.EXECUTION_ID); execution = context.getExecutionAccessor().get(executionID); } else { String executionTaskID = data.getString(Executor.EXECUTION_TASK_ID); ExecutionParameters executionParams = (ExecutionParameters) data.get(Executor.EXECUTION_PARAMETERS); ControllerSetting schedulerUsernameSetting = controllerSettingAccessor.getSettingByKey("scheduler_execution_username"); if(schedulerUsernameSetting != null) { String schedulerUsername = schedulerUsernameSetting.getValue(); if(schedulerUsername != null && schedulerUsername.trim().length()>0) { executionParams.setUserID(schedulerUsername); } } execution = executionRunnableFactory.createExecution(executionParams, executionTaskID); } task = executionRunnableFactory.newExecutionRunnable(execution); ExecutionJob job = new ExecutionJob(task); return job; } }
private void deleteRedirectTriggers(@NotNull String oid) throws SchedulerException { LOGGER.trace("Going to remove obsolete redirect triggers"); Scheduler scheduler = taskManager.getExecutionManager().getQuartzScheduler(); List<? extends Trigger> existingTriggers = scheduler.getTriggersOfJob(TaskQuartzImplUtil.createJobKeyForTaskOid(oid)); for (Trigger trigger : existingTriggers) { if (trigger.getJobDataMap().containsKey(REDIRECT_FLAG)) { LOGGER.trace("Removing obsolete redirect trigger {}", trigger); scheduler.unscheduleJob(trigger.getKey()); } } } }
@Override public void execute(JobExecutionContext context) throws JobExecutionException { try { LOG.info("Received Trigger at {}", context.getScheduledFireTime().toString()); JobDataMap triggerMap = context.getTrigger().getJobDataMap(); JobDataMap map = context.getMergedJobDataMap(); String[] keys = map.getKeys(); TriggerKey triggerKey = context.getTrigger().getKey(); if (triggerKey.getName().equalsIgnoreCase("g2")) { Preconditions.checkArgument(triggerMap.getString(KEY).equals(VALUE)); } else { Preconditions.checkArgument(!triggerMap.containsKey(KEY)); } Preconditions.checkArgument(keys != null); Preconditions.checkArgument(keys.length > 0); LOG.info("Number of parameters {}", keys.length); for (String key : keys) { LOG.info("Parameter key: {}, value: {}", key, map.get(key)); } } catch (Throwable e) { throw Throwables.propagate(e); } throw new JobExecutionException("exception"); } }