use of org.quartz.SchedulerException in project elastic-job by dangdangdotcom.
the class JobScheduler method createScheduler.
private Scheduler createScheduler(final boolean isMisfire) {
Scheduler result;
try {
StdSchedulerFactory factory = new StdSchedulerFactory();
factory.initialize(getBaseQuartzProperties(isMisfire));
result = factory.getScheduler();
result.getListenerManager().addTriggerListener(jobExecutor.getSchedulerFacade().newJobTriggerListener());
} catch (final SchedulerException ex) {
throw new JobSystemException(ex);
}
return result;
}
use of org.quartz.SchedulerException in project elastic-job by dangdangdotcom.
the class TransientProducerScheduler method register.
// TODO 并发优化
synchronized void register(final CloudJobConfiguration jobConfig) {
String cron = jobConfig.getTypeConfig().getCoreConfig().getCron();
JobKey jobKey = buildJobKey(cron);
repository.put(jobKey, jobConfig.getJobName());
try {
if (!scheduler.checkExists(jobKey)) {
scheduler.scheduleJob(buildJobDetail(jobKey), buildTrigger(jobKey.getName()));
}
} catch (final SchedulerException ex) {
throw new JobSystemException(ex);
}
}
use of org.quartz.SchedulerException in project elastic-job by dangdangdotcom.
the class JobScheduleController method getNextFireTime.
/**
* 获取下次作业触发时间.
*
* @return 下次作业触发时间
*/
public Date getNextFireTime() {
List<? extends Trigger> triggers;
try {
triggers = scheduler.getTriggersOfJob(jobDetail.getKey());
} catch (final SchedulerException ex) {
return null;
}
Date result = null;
for (Trigger each : triggers) {
Date nextFireTime = each.getNextFireTime();
if (null == nextFireTime) {
continue;
}
if (null == result) {
result = nextFireTime;
} else if (nextFireTime.getTime() < result.getTime()) {
result = nextFireTime;
}
}
return result;
}
use of org.quartz.SchedulerException in project openhab1-addons by openhab.
the class GCalEventDownloader method createJobInfo.
/**
* Creates a detailed description of a <code>job</code> for logging purpose.
*
* @param job the job to create a detailed description for
* @return a detailed description of the new <code>job</code>
*/
private String createJobInfo(Event event, JobDetail job) {
if (job == null) {
return "SchedulerJob [null]";
}
StringBuffer sb = new StringBuffer();
sb.append("SchedulerJob [jobKey=").append(job.getKey().getName());
sb.append(", jobGroup=").append(job.getKey().getGroup());
try {
List<? extends Trigger> triggers = scheduler.getTriggersOfJob(job.getKey());
sb.append(", ").append(triggers.size()).append(" triggers=[");
int maxTriggerLogs = 24;
for (int triggerIndex = 0; triggerIndex < triggers.size() && triggerIndex < maxTriggerLogs; triggerIndex++) {
Trigger trigger = triggers.get(triggerIndex);
sb.append(trigger.getStartTime());
if (triggerIndex < triggers.size() - 1 && triggerIndex < maxTriggerLogs - 1) {
sb.append(", ");
}
}
if (triggers.size() >= maxTriggerLogs) {
sb.append(" and ").append(triggers.size() - maxTriggerLogs).append(" more ...");
}
if (triggers.size() == 0) {
sb.append("there are no triggers - probably the event lies in the past");
}
} catch (SchedulerException e) {
}
sb.append("], content=").append(event.getDescription());
return sb.toString();
}
use of org.quartz.SchedulerException in project openhab1-addons by openhab.
the class GCalEventDownloader method execute.
/**
* @{inheritDoc}
*/
@Override
protected void execute() {
Events myFeed = downloadEventFeed();
if (myFeed != null) {
List<Event> entries = myFeed.getItems();
if (entries.size() > 0) {
logger.debug("found {} calendar events to process", entries.size());
try {
if (scheduler.isShutdown()) {
logger.warn("Scheduler has been shut down - probably due to exceptions?");
}
cleanJobs();
processEntries(entries);
} catch (SchedulerException se) {
logger.error("scheduling jobs throws exception", se);
}
} else {
logger.debug("gcal feed contains no events ...");
}
}
}
Aggregations