本文整理汇总了Java中org.quartz.JobDataMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java JobDataMap.put方法的具体用法?Java JobDataMap.put怎么用?Java JobDataMap.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.JobDataMap
的用法示例。
在下文中一共展示了JobDataMap.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateMethodInovkeJob
import org.quartz.JobDataMap; //导入方法依赖的package包/类
public JobDetail updateMethodInovkeJob(String schedulerName, String jobName, String jobGroup, String jobClass,
Object[] constructorArguments, String jobClassMethodName,
Object[] jobClassMethodArgs, String description) throws SchedulerException {
Assert.notNull(jobClass, "jobClass can not be null");
Assert.notEmpty(schedulerName, "schedulerName can not be empty");
Assert.notEmpty(jobName, "jobName can not be empty");
Assert.notEmpty(jobGroup, "jobGroup can not be empty");
Assert.notEmpty(jobClassMethodName, "jobClassMethodName can not be empty");
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("jobClass", jobClass);
jobDataMap.put("constructorArguments", constructorArguments);
jobDataMap.put("jobClassMethodName", jobClassMethodName);
jobDataMap.put("jobClassMethodArgs", jobClassMethodArgs);
JobDetail jobDetail = JobBuilder.newJob(MethodInvokeJob.class).withIdentity(jobName, jobGroup)
.withDescription(description).setJobData(jobDataMap).storeDurably().build();
updateJob(schedulerName, jobDetail);
return jobDetail;
}
示例2: processUserMessage
import org.quartz.JobDataMap; //导入方法依赖的package包/类
private void processUserMessage(String messageContent, SlackUser messageSender, SlackSession session, SlackChannel channel) {
// TODO change it to be processed asynchronously
// Parse the message content
String parsedMessage = parseMessage(messageContent);
if (parsedMessage != null) {
logger.info("=> Received message from amigo bot:" + parsedMessage);
try {
// Some unique job name
String jobName = "SLACK-MESG-JOB-" + UUID.randomUUID().toString();
String groupName = JOB_GRP_SLACKBOT;
JobDataMap params = new JobDataMap();
params.put(JOB_PARAM_MESSAGE, parsedMessage);
params.put(JOB_PARAM_MSG_SENDER, messageSender);
params.put(JOB_PARAM_SLACK_SESSION, session);
params.put(JOB_PARAM_SLACK_CHANNEL, channel);
params.put(JOB_PARAM_BOT_TOK, System.getenv("SLACK_BOT_TOKEN"));
logger.info("Processing message async with params: " + params);
JobManager.getInstance().scheduleJob(SlackMessageProcessorJob.class, jobName, groupName, params);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error in processing message", e);
}
}
}
示例3: processMessageAsync
import org.quartz.JobDataMap; //导入方法依赖的package包/类
private void processMessageAsync(String value) {
if (value != null && !value.trim().isEmpty()) {
try {
// Some unique job name
String jobName = "CP-MESG-JOB-" + UUID.randomUUID().toString();
String groupName = JOB_GRP_CP;
JobDataMap params = new JobDataMap();
params.put(JOB_PARAM_MESSAGE, value);
params.put(JOB_PARAM_DBCLIENT, dbClient);
JobManager.getInstance().scheduleJob(MessageProcessorJob.class, jobName, groupName, params);
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例4: createJob
import org.quartz.JobDataMap; //导入方法依赖的package包/类
/**
* Create Quartz Job.
*
* @param jobClass Class whose executeInternal() method needs to be called.
* @param isDurable Job needs to be persisted even after completion. if true, job will be persisted, not otherwise.
* @param context Spring application context.
* @param jobName Job name.
* @param jobGroup Job group.
*
* @return JobDetail object
*/
protected static JobDetail createJob(Class<? extends QuartzJobBean> jobClass, boolean isDurable,
ApplicationContext context, String jobName, String jobGroup){
JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
factoryBean.setJobClass(jobClass);
factoryBean.setDurability(isDurable);
factoryBean.setApplicationContext(context);
factoryBean.setName(jobName);
factoryBean.setGroup(jobGroup);
// set job data map
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("myKey", "myValue");
factoryBean.setJobDataMap(jobDataMap);
factoryBean.afterPropertiesSet();
return factoryBean.getObject();
}
示例5: convert
import org.quartz.JobDataMap; //导入方法依赖的package包/类
@Override
public Trigger convert(After trigger) {
OnDemandScheduleBuilder onDemandScheduleBuilder = OnDemandScheduleBuilder.onDemandSchedule();
JobDataMap dataMap = new JobDataMap(trigger.getTriggerData());
dataMap.put(Constants.CRONYX_TYPE, After.class);
return newTrigger()
.withIdentity(trigger.getTriggerKey().getName(), trigger.getTriggerKey().getGroup())
.forJob(trigger.getJobKey().getName(), trigger.getJobKey().getGroup())
.withDescription(trigger.getDescription())
.withSchedule(onDemandScheduleBuilder)
.usingJobData(dataMap)
.build();
}
示例6: newJobDataMap
import org.quartz.JobDataMap; //导入方法依赖的package包/类
public static JobDataMap newJobDataMap(Map<String, Object> map) {
JobDataMap jobDataMap = new JobDataMap();
if(map != null) {
for (final Iterator<String> pos = map.keySet().iterator(); pos.hasNext();) {
String key = pos.next();
jobDataMap.put(key, map.get(key));
}
}
return jobDataMap;
}
示例7: startScheduler
import org.quartz.JobDataMap; //导入方法依赖的package包/类
private void startScheduler() throws SchedulerException {
log.warn("Starting scheduler (pid:" + ServerUtil.getCurrentPid() + ")");
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.start();
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put(ApiFactoryService.class.getName(), this.apiFactoryService);
jobDataMap.put(DistributedApplianceConformJobFactory.class.getName(), this.daConformJobFactory);
jobDataMap.put(DeploymentSpecConformJobFactory.class.getName(), this.dsConformJobFactory);
jobDataMap.put(SecurityGroupConformJobFactory.class.getName(), this.sgConformJobFactory);
jobDataMap.put(ManagerConnectorConformJobFactory.class.getName(), this.mcConformJobFactory);
JobDetail syncDaJob = JobBuilder.newJob(SyncDistributedApplianceJob.class).usingJobData(jobDataMap).build();
JobDetail syncSgJob = JobBuilder.newJob(SyncSecurityGroupJob.class).usingJobData(jobDataMap).build();
// TODO: Remove the delay, once plugin state listener is implemented.
// Related issue: https://github.com/opensecuritycontroller/osc-core/issues/545
Trigger syncDaJobTrigger = TriggerBuilder.newTrigger()
.startAt(Date.from(Instant.now().plusSeconds(SERVER_SYNC_DELAY))).withSchedule(SimpleScheduleBuilder
.simpleSchedule().withIntervalInMinutes(this.scheduledSyncInterval).repeatForever()).build();
Trigger syncSgJobTrigger = TriggerBuilder.newTrigger()
.startAt(Date.from(Instant.now().plusSeconds(SERVER_SYNC_DELAY))).withSchedule(SimpleScheduleBuilder
.simpleSchedule().withIntervalInMinutes(this.scheduledSyncInterval).repeatForever()).build();
scheduler.scheduleJob(syncDaJob, syncDaJobTrigger);
scheduler.scheduleJob(syncSgJob, syncSgJobTrigger);
this.archiveService.maybeScheduleArchiveJob();
}
示例8: buildTrigger
import org.quartz.JobDataMap; //导入方法依赖的package包/类
/**
* Convenience method for building a Trigger
*
* @return the Trigger associated with this descriptor
*/
public Trigger buildTrigger() {
// @formatter:off
if (!isEmpty(cron)) {
if (!isValidExpression(cron))
throw new IllegalArgumentException("Provided expression " + cron + " is not a valid cron expression");
return newTrigger()
.withIdentity(buildName(), group)
.withSchedule(cronSchedule(cron)
.withMisfireHandlingInstructionFireAndProceed()
.inTimeZone(TimeZone.getTimeZone(systemDefault())))
.usingJobData("cron", cron)
.build();
} else if (!isEmpty(fireTime)) {
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("fireTime", fireTime);
return newTrigger()
.withIdentity(buildName(), group)
.withSchedule(simpleSchedule()
.withMisfireHandlingInstructionNextWithExistingCount())
.startAt(Date.from(fireTime.atZone(systemDefault()).toInstant()))
.usingJobData(jobDataMap)
.build();
}
// @formatter:on
throw new IllegalStateException("unsupported trigger descriptor " + this);
}
示例9: createJobDetail
import org.quartz.JobDataMap; //导入方法依赖的package包/类
static JobDetailImpl createJobDetail(RollupTask task, KairosDatastore dataStore, String hostName)
{
JobDetailImpl jobDetail = new JobDetailImpl();
jobDetail.setJobClass(RollUpJob.class);
jobDetail.setKey(getJobKey(task));
JobDataMap map = new JobDataMap();
map.put("task", task);
map.put("datastore", dataStore);
map.put("hostName", hostName);
jobDetail.setJobDataMap(map);
return jobDetail;
}
示例10: scheduleRecoveryIfNeeded
import org.quartz.JobDataMap; //导入方法依赖的package包/类
private void scheduleRecoveryIfNeeded(TriggerWrapper tw, FiredTrigger recovering) {
JobWrapper jobWrapper = jobFacade.get(tw.getJobKey());
if (jobWrapper == null) {
getLog().error("No job found for orphaned trigger: " + tw);
return;
}
if (jobWrapper.requestsRecovery()) {
OperableTrigger recoveryTrigger = createRecoveryTrigger(tw, jobWrapper, "recover_" + terracottaClientId + "_"
+ ftrCtr++, recovering);
JobDataMap jd = tw.getTriggerClone().getJobDataMap();
jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_NAME, tw.getKey().getName());
jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_GROUP, tw.getKey().getGroup());
jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_FIRETIME_IN_MILLISECONDS, String.valueOf(recovering.getFireTime()));
jd.put(Scheduler.FAILED_JOB_ORIGINAL_TRIGGER_SCHEDULED_FIRETIME_IN_MILLISECONDS, String.valueOf(recovering.getScheduledFireTime()));
recoveryTrigger.setJobDataMap(jd);
recoveryTrigger.computeFirstFireTime(null);
try {
storeTrigger(recoveryTrigger, false);
if (!tw.mayFireAgain()) {
removeTrigger(tw.getKey());
}
getLog().info("Recovered job " + jobWrapper + " for trigger " + tw);
} catch (JobPersistenceException e) {
getLog().error("Can't recover job " + jobWrapper + " for trigger " + tw, e);
}
}
}
示例11: addQuartzJob
import org.quartz.JobDataMap; //导入方法依赖的package包/类
/**
* 添加继承自 org.quartz.Job的类的方法
* @param schedulerName
* @param jobName
* @param jobGroup
* @param jobClass
* @param jobDataMap
* @param description
* @return
*/
private JSONResult addQuartzJob(String schedulerName, String jobName, String jobGroup, String jobClass,
Map<String, Object> jobDataMap, String description) {
try {
Assert.notEmpty(schedulerName, "schedulerName can not be empty");
Assert.notEmpty(jobName, "jobName can not be empty");
Assert.notEmpty(jobGroup, "jobGroup can not be empty");
if (!QuartzWebManager.checkClass(jobClass)) {
throw new IllegalArgumentException("jobClass no class found [" + jobClass + "] exception");
}
Class beanClass = QuartzWebManager.getClass(jobClass);
if (org.quartz.Job.class.isAssignableFrom(beanClass)) {
// 开始添加job
JobDataMap jobMap = new JobDataMap();
if (jobDataMap != null) {
for (Map.Entry<String, Object> entry : jobDataMap.entrySet()) {
if (!StringUtils.isEmpty(entry.getKey())) {
jobMap.put(entry.getKey(), entry.getValue());
}
}
}
JobDetail jobDetail = JobBuilder.newJob(beanClass).withIdentity(jobName, jobGroup)
.withDescription(description).setJobData(jobMap).storeDurably().build();
if (!QuartzWebManager.checkJobExist(schedulerName, jobName, jobGroup)) {
QuartzWebManager.addJob(schedulerName, jobDetail);
} else {
QuartzWebManager.updateJob(schedulerName, jobDetail);
}
return JSONResult.build(JSONResult.RESULT_CODE_SUCCESS, "ok");
} else {
throw new UnsupportedClassException(jobClass + " must extends org.quartz.Job ");
}
} catch (Exception e) {
e.printStackTrace();
return JSONResult.build(JSONResult.RESULT_CODE_ERROR, e.getMessage());
}
}
示例12: setupTimer
import org.quartz.JobDataMap; //导入方法依赖的package包/类
protected void setupTimer()
{
try
{
final String jobName = "SolrWatcher";
final String jobGroup = "Solr";
// If a Quartz job already exists with this name and group then we want to replace it.
// It is not expected that this will occur during production, but it is possible during automated testing
// where application contexts could be rebuilt between test cases, leading to multiple creations of
// equivalent Quartz jobs. Quartz disallows the scheduling of multiple jobs with the same name and group.
JobDetail existingJob = scheduler.getJobDetail(jobName, jobGroup);
if (existingJob != null)
{
scheduler.deleteJob(jobName, jobGroup);
}
JobDetail job = new JobDetail(jobName, jobGroup, SOLRWatcherJob.class);
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("SOLR_TRACKER", this);
job.setJobDataMap(jobDataMap);
trigger = new CronTrigger("SolrWatcherTrigger", jobGroup, solrPingCronExpression);
scheduler.scheduleJob(job, trigger);
}
catch(Exception e)
{
throw new AlfrescoRuntimeException("Unable to set up SOLRTracker timer", e);
}
}
示例13: newJobDataMap
import org.quartz.JobDataMap; //导入方法依赖的package包/类
public static JobDataMap newJobDataMap(TabularData tabularData) {
JobDataMap jobDataMap = new JobDataMap();
for (final Iterator pos = tabularData.values().iterator(); pos
.hasNext();) {
CompositeData cData = (CompositeData) pos.next();
jobDataMap.put((String) cData.get("key"), (String) cData
.get("value"));
}
return jobDataMap;
}
示例14: testJobLocking
import org.quartz.JobDataMap; //导入方法依赖的package包/类
@Test
public void testJobLocking() throws Exception
{
HBBaseDataCollector simpleCollector = mock(HBBaseDataCollector.class);
when(simpleCollector.getCollectorId()).thenReturn("c1");
when(simpleCollector.getCronExpression()).thenReturn("0 0 0 ? * *");
// mock the job context
JobExecutionContext mockJobExecutionContext = mock(JobExecutionContext.class);
JobDetail jobDetail = new JobDetail();
when(mockJobExecutionContext.getJobDetail()).thenReturn(jobDetail);
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("collector", simpleCollector);
jobDataMap.put("hbDataSenderService", mockDataSenderService);
jobDataMap.put("jobLockService", mockJobLockService);
jobDetail.setJobDataMap(jobDataMap);
// Simulate job lock service
String lockToken = "token";
when(mockJobLockService.getLock(isA(QName.class), anyLong()))
.thenReturn(lockToken) // first job gets the lock
.thenThrow(new LockAcquisitionException("", "")); // second job doesn't get the lock
// Run two heart beat jobs
new HeartBeatJob().execute(mockJobExecutionContext);
new HeartBeatJob().execute(mockJobExecutionContext);
// Verify that the collector only collects data once, since only one job got the lock
verify(simpleCollector, Mockito.times(1)).collectData();
// Verify that data was passed to data sender
verify(mockDataSenderService, Mockito.times(1)).sendData(any(List.class));
verify(mockDataSenderService, Mockito.times(0)).sendData(any(HBData.class));
// Verify that both jobs tried to get the lock
verify(mockJobLockService, Mockito.times(2)).getLock(any(QName.class), anyLong());
// Verify that a callback was registered once
verify(mockJobLockService, Mockito.times(1)).refreshLock(eq(lockToken), any(QName.class),
anyLong(),
any(JobLockService.JobLockRefreshCallback.class));
}
示例15: maybeScheduleArchiveJob
import org.quartz.JobDataMap; //导入方法依赖的package包/类
/**
* Schedule the archiving job based on the interval defined in the DB.
*
* If archiving is disabled, deletes the archiving job.
*/
@Override
public void maybeScheduleArchiveJob() {
try {
BaseDtoResponse<JobsArchiveDto> reponse = this.jobsArchiveService.dispatch(new Request() {
});
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
boolean doesJobExists = scheduler.checkExists(new JobKey(ARCHIVE_JOB_NAME,
ARCHIVE_GROUP_NAME));
if (reponse.getDto().getAutoSchedule() && !doesJobExists) {
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put(GetJobsArchiveServiceApi.class.getName(), this.jobsArchiveService);
jobDataMap.put(ArchiveServiceApi.class.getName(), this);
JobDetail archiveJob = JobBuilder.newJob(ArchiveScheduledJob.class)
.usingJobData(jobDataMap)
.withIdentity(ARCHIVE_JOB_NAME, ARCHIVE_GROUP_NAME).build();
Trigger archiveTrigger = TriggerBuilder
.newTrigger()
.startAt(DateUtils.addMinutes(new Date(), ARCHIVE_STARTUP_DELAY_IN_MIN))
.withSchedule(
SimpleScheduleBuilder.simpleSchedule().withIntervalInHours(24).repeatForever()
.withMisfireHandlingInstructionFireNow()).build();
scheduler.scheduleJob(archiveJob, archiveTrigger);
log.info("Archiving job check is scheduled to run every 24 hours. Starting at: "
+ archiveTrigger.getStartTime());
} else if (!reponse.getDto().getAutoSchedule()) {
// If archiving is disabled, delete the job if it exists
if (scheduler.deleteJob(new JobKey(ArchiveScheduledJob.ARCHIVE_JOB_NAME, ARCHIVE_GROUP_NAME))) {
log.info("Archiving job Deleted");
}
}
} catch (Exception e) {
log.error("Scheduler fail to start/stop Archiving job", e);
this.alertGenerator.processSystemFailureEvent(SystemFailureType.ARCHIVE_FAILURE,
new LockObjectReference(1L, "Archive Settings", ObjectType.ARCHIVE),
"Failure during archive schedule configuration " + e.getMessage());
}
}