Java 类org.quartz.impl.DirectSchedulerFactory 实例源码

项目:timeschedule    文件:QuartzScheduleWrapper.java   
public static void initSched(int threadCount) {

        try {
            SimpleThreadPool threadPool = new SimpleThreadPool(threadCount,
                    Thread.NORM_PRIORITY);
            threadPool.initialize();
            // create the job store
            JobStore jobStore = new RAMJobStore();
            DirectSchedulerFactory.getInstance().createScheduler(threadPool,
                    jobStore);

            sched = DirectSchedulerFactory.getInstance().getScheduler();


            //init heart sched
            SimpleThreadPool threadPoolHeart = new SimpleThreadPool(1,
                    Thread.NORM_PRIORITY);
            threadPoolHeart.initialize();
            JobStore jobStoreHeart = new RAMJobStore();
            DirectSchedulerFactory.getInstance().createScheduler("HeartScheduler", "SIMPLE_NON_CLUSTERED", threadPoolHeart,
                    jobStoreHeart);

            heartSched = DirectSchedulerFactory.getInstance().getScheduler("HeartScheduler");
        } catch (Exception e) {
            log.error("error init sched", e);
        }
    }
项目:wunderboss    文件:QuartzScheduling.java   
@Override
public void start() throws Exception {
    if (!started) {
        System.setProperty("org.terracotta.quartz.skipUpdateCheck", "true");
        DirectSchedulerFactory factory = DirectSchedulerFactory.getInstance();

        SimpleThreadPool threadPool = new SimpleThreadPool(this.numThreads,
                                                           Thread.NORM_PRIORITY);
        threadPool.setThreadNamePrefix("scheduling-worker");
        threadPool.initialize();
        final String schedulerName = DEFAULT_SCHEDULER_NAME + ":" + this.name;
        factory.createScheduler(schedulerName,
                                DEFAULT_INSTANCE_ID + ":" + this.name,
                                threadPool, new RAMJobStore());

        this.scheduler = factory.getScheduler(schedulerName);
        this.scheduler.getListenerManager().addTriggerListener(new TriggerListener());
        this.scheduler.start();
        started = true;
        log.info("Quartz started");
    }
}
项目:opensearchserver    文件:TaskManager.java   
public void start() throws SearchLibException {
    if (ClientFactory.INSTANCE.properties.isDisableScheduler())
        Logging.warn("The scheduler is disabled ");
    rwl.w.lock();
    try {
        if (scheduler == null) {
            if (schedulerFactory == null)
                schedulerFactory = DirectSchedulerFactory.getInstance();
            threadPoolSize = ClientFactory.INSTANCE.getSchedulerThreadPoolSize().getValue();
            schedulerFactory.createVolatileScheduler(threadPoolSize);
            scheduler = schedulerFactory.getScheduler();
        }
        scheduler.start();
    } catch (SchedulerException e) {
        throw new SearchLibException(e);
    } finally {
        rwl.w.unlock();
    }
}
项目:nexus-public    文件:QuartzSchedulerSPI.java   
/**
 * Create a new {@link Scheduler} and set to stand-by mode.
 */
private Scheduler createScheduler() throws SchedulerException {
  // ensure executed threads have TCCL set
  ThreadExecutor threadExecutor = new DefaultThreadExecutor()
  {
    @Override
    public void execute(final Thread thread) {
      thread.setContextClassLoader(QuartzSchedulerSPI.class.getClassLoader());
      super.execute(thread);
    }
  };

  // create Scheduler (implicitly registers it with repository)
  DirectSchedulerFactory.getInstance().createScheduler(
      SCHEDULER_NAME,
      nodeAccess.getId(), // instance-id
      new QuartzThreadPool(threadPoolSize),
      threadExecutor,
      jobStoreProvider.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 scheduler = DirectSchedulerFactory.getInstance().getScheduler(SCHEDULER_NAME);
  scheduler.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{}", scheduler.getMetaData().getVersion());

  scheduler.standby();

  return scheduler;
}
项目:sakai    文件:ScheduledInvocationTest.java   
@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);
}
项目:sakai    文件:ScheduledInvocationTest.java   
@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);
}