System.setProperty("org.terracotta.quartz.skipUpdateCheck", Boolean.TRUE.toString());
final ThreadPoolManager tpm = this.threadPoolManager;
// sanity null check
if ( tpm == null ) {
throw new SchedulerException("Thread pool manager missing");
}
// create the pool
this.threadPool = tpm.get(poolName);
final QuartzThreadPool quartzPool = new QuartzThreadPool(this.threadPool);
final DirectSchedulerFactory factory = DirectSchedulerFactory.getInstance();
// unique run id
final String runID = new Date().toString().replace(' ', '_');
factory.createScheduler(QUARTZ_SCHEDULER_NAME, runID, quartzPool, new RAMJobStore());
// quartz does not provide a way to get the scheduler by name AND runID, so we have to iterate!
final Iterator<org.quartz.Scheduler> allSchedulersIter = factory.getAllSchedulers().iterator();
org.quartz.Scheduler s = null;
while ( s == null && allSchedulersIter.hasNext() ) {
final org.quartz.Scheduler current = allSchedulersIter.next();
if ( QUARTZ_SCHEDULER_NAME.equals(current.getSchedulerName())
&& runID.equals(current.getSchedulerInstanceId()) ) {
s = current;
}
}
if ( s == null ) {
throw new SchedulerException("Unable to find new scheduler with name " + QUARTZ_SCHEDULER_NAME + " and run ID " + runID);
}
s.start();
if ( this.logger.isDebugEnabled() ) {
this.logger.debug(PREFIX + "started.");