use of org.quartz.TriggerKey in project OpenOLAT by OpenOLAT.
the class StatisticsAdminController method refreshUIState.
private void refreshUIState() {
log_.info("refreshUIState: schedulerFactoryBean found");
boolean enabled = false;
String cronExpression = "";
Trigger.TriggerState triggerState;
try {
TriggerKey triggerKey = new TriggerKey("updateStatisticsTrigger", null);
triggerState = scheduler.getTriggerState(triggerKey);
enabled = triggerState != Trigger.TriggerState.NONE && triggerState != Trigger.TriggerState.ERROR;
Trigger trigger = scheduler.getTrigger(triggerKey);
if (trigger == null) {
enabled &= false;
} else {
enabled &= trigger.getJobKey().getName().equals("org.olat.statistics.job.enabled");
if (trigger instanceof CronTrigger) {
log_.info("refreshUIState: org.olat.statistics.job.enabled check, enabled now: " + enabled);
cronExpression = ((CronTrigger) trigger).getCronExpression();
}
}
log_.info("refreshUIState: updateStatisticsTrigger state was " + triggerState + ", enabled now: " + enabled);
} catch (SchedulerException e) {
log_.warn("refreshUIState: Got a SchedulerException while asking for the updateStatisticsTrigger's state", e);
}
StatisticUpdateManager statisticUpdateManager = getStatisticUpdateManager();
if (statisticUpdateManager == null) {
log_.info("refreshUIState: statisticUpdateManager not configured");
enabled = false;
} else {
enabled &= statisticUpdateManager.isEnabled();
log_.info("refreshUIState: statisticUpdateManager configured, enabled now: " + enabled);
}
if (enabled) {
content.contextPut("status", getTranslator().translate("statistics.status.enabled", new String[] { cronExpression }));
} else {
content.contextPut("status", getTranslator().translate("statistics.status.disabled"));
}
content.contextPut("statisticEnabled", enabled);
recalcLastUpdated();
updateStatisticUpdateOngoingFlag();
}
use of org.quartz.TriggerKey in project xwiki-platform by xwiki.
the class SchedulerPlugin method getTrigger.
/**
* Get Trigger object of the given job
*
* @param object the unwrapped XObject to be retrieve the trigger for
* @param context the XWiki context
* @return the trigger object of the given job
*/
private Trigger getTrigger(BaseObject object, XWikiContext context) throws SchedulerPluginException {
String job = getObjectUniqueId(object, context);
Trigger trigger;
try {
trigger = getScheduler().getTrigger(new TriggerKey(job));
} catch (SchedulerException e) {
throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_JOB_XCLASS_NOT_FOUND, "Error while getting trigger for job " + job, e);
}
if (trigger == null) {
throw new SchedulerPluginException(SchedulerPluginException.ERROR_SCHEDULERPLUGIN_JOB_DOES_NOT_EXITS, "Job does not exists");
}
return trigger;
}
use of org.quartz.TriggerKey in project syncope by apache.
the class TaskDataBinderImpl method setExecTime.
private void setExecTime(final SchedTaskTO taskTO, final Task task) {
taskTO.setLastExec(taskTO.getStart());
String triggerName = JobNamer.getTriggerName(JobNamer.getJobKey(task).getName());
try {
Trigger trigger = scheduler.getScheduler().getTrigger(new TriggerKey(triggerName, Scheduler.DEFAULT_GROUP));
if (trigger != null) {
taskTO.setLastExec(trigger.getPreviousFireTime());
taskTO.setNextExec(trigger.getNextFireTime());
}
} catch (SchedulerException e) {
LOG.warn("While trying to get to " + triggerName, e);
}
}
use of org.quartz.TriggerKey in project spring-cloud-framework by zhuwj921.
the class JobAndTriggerImpl method getJobAndTriggerDetails.
public PageInfo<JobAndTrigger> getJobAndTriggerDetails(int pageNum, int pageSize) throws SchedulerException {
PageHelper.startPage(pageNum, pageSize);
List<JobAndTrigger> list = jobAndTriggerDAO.getJobAndTriggerDetails();
Iterator<JobAndTrigger> listIt = list.iterator();
while (listIt.hasNext()) {
JobAndTrigger jobAndTrigger = listIt.next();
Trigger.TriggerState triggerState = scheduler.getTriggerState(new TriggerKey(jobAndTrigger.getTriggerName(), jobAndTrigger.getTriggerGroup()));
if (triggerState == Trigger.TriggerState.NORMAL) {
jobAndTrigger.setRunning(true);
}
}
PageInfo<JobAndTrigger> page = new PageInfo<JobAndTrigger>(list);
return page;
}
use of org.quartz.TriggerKey in project dubidubi by lzzzz4.
the class Quartz method updateJobTime.
public static void updateJobTime(String jobName, String jobGroupName, String triggerName, String triggerGroupName, String cron) {
try {
Scheduler sched = schedulerFactory.getScheduler();
TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroupName);
CronTrigger trigger = (CronTrigger) sched.getTrigger(triggerKey);
if (trigger == null) {
return;
}
String oldTime = trigger.getCronExpression();
if (!oldTime.equalsIgnoreCase(cron)) {
/**
* 方式一 :调用 rescheduleJob 开始
*/
// 触发器
TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
// 触发器名,触发器组
triggerBuilder.withIdentity(triggerName, triggerGroupName);
triggerBuilder.startNow();
// 触发器时间设定
triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cron));
// 创建Trigger对象
trigger = (CronTrigger) triggerBuilder.build();
// 方式一 :修改一个任务的触发时间
sched.rescheduleJob(triggerKey, trigger);
/**
* 方式一 :调用 rescheduleJob 结束
*/
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations