Java源码示例:org.quartz.impl.DirectSchedulerFactory

示例1
@Before
public void before() throws Exception {
  try (ODatabaseDocumentTx db = database.getInstance().acquire()) {
    OrientQuartzSchema.register(db);
    dbUrl = db.getURL();
  }
  SimpleThreadPool threadPool = new SimpleThreadPool(3, Thread.NORM_PRIORITY);
  threadPool.initialize();
  OrientConnectionProvider connProvider = new OrientConnectionProvider();
  connProvider.setConnectionString(dbUrl);
  connProvider.setUser("admin");
  connProvider.setPassword("admin");
  connProvider.setUsePool(true);
  connProvider.setPoolMin(3);
  connProvider.setPoolMax(3);
  connProvider.initialize();
  DBConnectionManager.getInstance().addConnectionProvider("orientDS", connProvider);
  DBConnectionManager.getInstance().getConnection("orientDS");
  JobStoreTX jobStore = new JobStoreTX();
  jobStore.setDataSource("orientDS");
  jobStore.setDriverDelegateClass(OrientDelegate.class.getName());
  DirectSchedulerFactory.getInstance().createScheduler("nexus", "1", threadPool, jobStore);
  scheduler = DirectSchedulerFactory.getInstance().getScheduler("nexus");
  scheduler.clear();

  scheduler.start();
}
 
示例2
@Before
public void setUp() throws SchedulerException {
    DirectSchedulerFactory schedulerFactory = DirectSchedulerFactory.getInstance();
    schedulerFactory.createVolatileScheduler(1);
    scheduler = schedulerFactory.getScheduler();
    scheduler.start();
    Assert.assertNotNull(scheduler);


    manager = new ScheduledInvocationManagerImpl();
    manager.setIdManager(() -> UUID.randomUUID().toString());
    manager.setSchedulerFactory(schedulerFactory);
    manager.setDao(dao);
}
 
示例3
@Before
public void setUp() throws SchedulerException {
    DirectSchedulerFactory schedulerFactory = DirectSchedulerFactory.getInstance();
    schedulerFactory.createVolatileScheduler(1);
    scheduler = schedulerFactory.getScheduler();
    scheduler.start();
    Assert.assertNotNull(scheduler);


    manager = new ScheduledInvocationManagerImpl();
    manager.setIdManager(() -> UUID.randomUUID().toString());
    manager.setSchedulerFactory(schedulerFactory);
    manager.setDao(dao);
}
 
示例4
private Scheduler createScheduler() {
  try {
    // ensure executed threads have TCCL set
    ThreadExecutor threadExecutor = new DefaultThreadExecutor()
    {
      @Override
      public void execute(final Thread thread) {
        thread.setContextClassLoader(QuartzSchedulerProvider.class.getClassLoader());
        super.execute(thread);
      }
    };

    // create Scheduler (implicitly registers it with repository)
    DirectSchedulerFactory.getInstance().createScheduler(
        SCHEDULER_NAME,
        nodeAccess.getId(), // instance-id
        new QuartzThreadPool(threadPoolSize, threadPriority),
        threadExecutor,
        jobStore.get(),
        null, // scheduler plugin-map
        null, // rmi-registry host
        0,    // rmi-registry port
        -1,   // idle-wait time
        -1,   // db-failure retry-interval
        true, // jmx-export
        null, // custom jmx object-name, lets use the default
        1,    // max batch-size
        0L    // batch time-window
    );
    Scheduler s = DirectSchedulerFactory.getInstance().getScheduler(SCHEDULER_NAME);
    s.setJobFactory(jobFactory);

    // re-logging with version, as by default we limit quartz logging to WARN, hiding its default version logging
    log.info("Quartz Scheduler v{}", s.getMetaData().getVersion());

    s.standby();

    return s;
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }
}