use of org.quartz.impl.StdSchedulerFactory in project dq-easy-cloud by dq-open-cloud.
the class LoadExample method run.
public void run() throws Exception {
Logger log = LoggerFactory.getLogger(LoadExample.class);
// First we must get a reference to a scheduler
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sched = sf.getScheduler();
log.info("------- Initialization Complete -----------");
// schedule 500 jobs to run
for (int count = 1; count <= _numberOfJobs; count++) {
JobDetail job = // ask scheduler
newJob(SimpleJob.class).withIdentity("job" + count, "group_1").requestRecovery().build();
// tell the job to delay some small amount... to simulate work...
long timeDelay = (long) (Math.random() * 2500);
job.getJobDataMap().put(SimpleJob.DELAY_TIME, timeDelay);
Trigger trigger = newTrigger().withIdentity("trigger_" + count, "group_1").startAt(// space fire times a small bit
futureDate((10000 + (count * 100)), IntervalUnit.MILLISECOND)).build();
sched.scheduleJob(job, trigger);
if (count % 25 == 0) {
log.info("...scheduled " + count + " jobs");
}
}
log.info("------- Starting Scheduler ----------------");
// start the schedule
sched.start();
log.info("------- Started Scheduler -----------------");
log.info("------- Waiting five minutes... -----------");
// wait five minutes to give our jobs a chance to run
try {
Thread.sleep(300L * 1000L);
} catch (Exception e) {
//
}
// shut down the scheduler
log.info("------- Shutting Down ---------------------");
sched.shutdown(true);
log.info("------- Shutdown Complete -----------------");
SchedulerMetaData metaData = sched.getMetaData();
log.info("Executed " + metaData.getNumberOfJobsExecuted() + " jobs.");
}
use of org.quartz.impl.StdSchedulerFactory in project incubator-gobblin by apache.
the class SchedulerService method startUp.
@Override
protected void startUp() throws SchedulerException {
StdSchedulerFactory schedulerFactory = new StdSchedulerFactory();
if (this.quartzProps.isPresent() && this.quartzProps.get().size() > 0) {
schedulerFactory.initialize(this.quartzProps.get());
}
this.scheduler = schedulerFactory.getScheduler();
this.scheduler.start();
}
use of org.quartz.impl.StdSchedulerFactory in project elastic-job by dangdangdotcom.
the class DaemonTaskScheduler method initializeScheduler.
private Scheduler initializeScheduler() throws SchedulerException {
StdSchedulerFactory factory = new StdSchedulerFactory();
factory.initialize(getBaseQuartzProperties());
return factory.getScheduler();
}
use of org.quartz.impl.StdSchedulerFactory 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.impl.StdSchedulerFactory in project druid by alibaba.
the class QuartzTest method setUp.
@Override
protected void setUp() throws Exception {
Properties props = new Properties();
props.load(getClass().getClassLoader().getResourceAsStream("bvt/quartz/quartz.properties"));
factory = new StdSchedulerFactory(props);
scheduler = factory.getScheduler();
}
Aggregations