• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JobStore类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.quartz.spi.JobStore的典型用法代码示例。如果您正苦于以下问题:Java JobStore类的具体用法?Java JobStore怎么用?Java JobStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JobStore类属于org.quartz.spi包,在下文中一共展示了JobStore类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: QuartzSchedulerSPI

import org.quartz.spi.JobStore; //导入依赖的package包/类
@Inject
public QuartzSchedulerSPI(final EventManager eventManager,
                          final NodeAccess nodeAccess,
                          final Provider<JobStore> jobStoreProvider,
                          final JobFactory jobFactory,
                          @Named("${nexus.quartz.poolSize:-20}") final int threadPoolSize)
    throws Exception
{
  this.eventManager = checkNotNull(eventManager);
  this.nodeAccess = checkNotNull(nodeAccess);
  this.jobStoreProvider = checkNotNull(jobStoreProvider);
  this.jobFactory = checkNotNull(jobFactory);

  checkArgument(threadPoolSize > 0, "Invalid thread-pool size: %s", threadPoolSize);
  this.threadPoolSize = threadPoolSize;
  log.info("Thread-pool size: {}", threadPoolSize);

  this.scheduleFactory = new QuartzScheduleFactory();
  this.triggerConverter = new QuartzTriggerConverter(this.scheduleFactory);

  // FIXME: sort out with refinement to lifecycle below
  this.active = true;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:24,代码来源:QuartzSchedulerSPI.java


示例2: testStoreAndRetrieveJobs

import org.quartz.spi.JobStore; //导入依赖的package包/类
@Test
public void testStoreAndRetrieveJobs()
  throws Exception {

  final int nJobs = 10;

  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testStoreAndRetrieveJobs");
  store.initialize(loadHelper, schedSignaler);

  // Store jobs.
  for (int i = 0; i < nJobs; i++) {
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i).build();
    store.storeJob(job, false);
  }

  // Retrieve jobs.
  for (int i = 0; i < nJobs; i++) {
    JobKey jobKey = JobKey.jobKey("job" + i);
    JobDetail storedJob = store.retrieveJob(jobKey);
    Assert.assertEquals(storedJob.getKey(), jobKey);
  }
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:27,代码来源:HazelcastJobStoreTest.java


示例3: initSched

import org.quartz.spi.JobStore; //导入依赖的package包/类
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);
		}
	}
 
开发者ID:xiangtao,项目名称:timeschedule,代码行数:28,代码来源:QuartzScheduleWrapper.java


示例4: testStoreAndRetrieveJobs

import org.quartz.spi.JobStore; //导入依赖的package包/类
@Test()
public void testStoreAndRetrieveJobs() throws Exception {
  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testStoreAndRetrieveJobs");
  store.initialize(loadHelper, schedSignaler);

  // Store jobs.
  for (int i = 0; i < 10; i++) {
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i)
        .build();
    store.storeJob(job, false);
  }
  // Retrieve jobs.
  for (int i = 0; i < 10; i++) {
    JobKey jobKey = JobKey.jobKey("job" + i);
    JobDetail storedJob = store.retrieveJob(jobKey);
    Assert.assertEquals(jobKey, storedJob.getKey());
  }
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:23,代码来源:TestHazelcastJobStore.java


示例5: instantiate

import org.quartz.spi.JobStore; //导入依赖的package包/类
@Override
protected Scheduler instantiate(QuartzSchedulerResources rsrcs, QuartzScheduler qs)
{
    Scheduler scheduler = super.instantiate(rsrcs, qs);
    JobStore jobStore = rsrcs.getJobStore();
    if (jobStore instanceof SchedulerAware)
    {
        ((SchedulerAware) jobStore).setScheduler(scheduler);
    }
    return scheduler;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:12,代码来源:AlfrescoSchedulerFactory.java


示例6: createVolatileScheduler

import org.quartz.spi.JobStore; //导入依赖的package包/类
/**
 * Creates an in memory job store (<code>{@link RAMJobStore}</code>)
 * The thread priority is set to Thread.NORM_PRIORITY
 *
 * @param maxThreads
 *          The number of threads in the thread pool
 * @throws SchedulerException
 *           if initialization failed.
 */
public void createVolatileScheduler(int maxThreads)
    throws SchedulerException {
    SimpleThreadPool threadPool = new SimpleThreadPool(maxThreads,
            Thread.NORM_PRIORITY);
    threadPool.initialize();
    JobStore jobStore = new RAMJobStore();
    this.createScheduler(threadPool, jobStore);

}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:19,代码来源:DirectSchedulerFactory.java


示例7: testStoreAndRetriveTriggers

import org.quartz.spi.JobStore; //导入依赖的package包/类
@Test
public void testStoreAndRetriveTriggers()
  throws Exception {

  final int nJobs = 10;

  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testStoreAndRetriveTriggers");
  store.initialize(loadHelper, schedSignaler);

  // Store jobs and triggers.
  for (int i = 0; i < nJobs; i++) {
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i).build();
    store.storeJob(job, true);

    OperableTrigger trigger = buildTrigger("job" + i, DEFAULT_GROUP, job);
    store.storeTrigger((OperableTrigger) trigger, true);
  }
  // Retrieve jobs and triggers.
  for (int i = 0; i < nJobs; i++) {
    JobKey jobKey = JobKey.jobKey("job" + i);
    JobDetail storedJob = store.retrieveJob(jobKey);
    Assert.assertEquals(storedJob.getKey(), jobKey);

    TriggerKey triggerKey = TriggerKey.triggerKey("job" + i);
    OperableTrigger storedTrigger = store.retrieveTrigger(triggerKey);
    Assert.assertEquals(storedTrigger.getKey(), triggerKey);
  }
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:33,代码来源:HazelcastJobStoreTest.java


示例8: testStoreAndRetriveTriggers

import org.quartz.spi.JobStore; //导入依赖的package包/类
@Test()
public void testStoreAndRetriveTriggers() throws Exception {
  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testStoreAndRetriveTriggers");
  store.initialize(loadHelper, schedSignaler);

  // Store jobs and triggers.
  for (int i = 0; i < 10; i++) {
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i)
        .build();
    store.storeJob(job, true);
    SimpleScheduleBuilder schedule = SimpleScheduleBuilder.simpleSchedule();
    Trigger trigger = TriggerBuilder.newTrigger().withIdentity("job" + i)
        .withSchedule(schedule).forJob(job).build();
    store.storeTrigger((OperableTrigger) trigger, true);
  }
  // Retrieve job and trigger.
  for (int i = 0; i < 10; i++) {
    JobKey jobKey = JobKey.jobKey("job" + i);
    JobDetail storedJob = store.retrieveJob(jobKey);
    Assert.assertEquals(jobKey, storedJob.getKey());

    TriggerKey triggerKey = TriggerKey.triggerKey("job" + i);
    Trigger storedTrigger = store.retrieveTrigger(triggerKey);
    Assert.assertEquals(triggerKey, storedTrigger.getKey());
  }
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:31,代码来源:TestHazelcastJobStore.java


示例9: testAcquireTriggers

import org.quartz.spi.JobStore; //导入依赖的package包/类
@Test
public void testAcquireTriggers()
  throws Exception {

  final int nJobs = 10;

  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testAcquireTriggers");
  store.initialize(loadHelper, schedSignaler);

  // Setup: Store jobs and triggers.
  long MIN = 60 * 1000L;
  Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from
  // now.
  for (int i = 0; i < nJobs; i++) {
    Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i).build();
    SimpleScheduleBuilder schedule = SimpleScheduleBuilder.repeatMinutelyForever(2);
    OperableTrigger trigger = (OperableTrigger) newTrigger()
        .withIdentity("job" + i)
        .withSchedule(schedule).forJob(job)
        .startAt(startTime)
        .build();

    // Manually trigger the first fire time computation that scheduler would
    // do. Otherwise
    // the store.acquireNextTriggers() will not work properly.
    Date fireTime = trigger.computeFirstFireTime(null);
    Assert.assertNotNull(fireTime);

    store.storeJobAndTrigger(job, trigger);
  }

  // Test acquire one trigger at a time
  for (int i = 0; i < nJobs; i++) {
    long noLaterThan = (startTime0.getTime() + i * MIN);
    int maxCount = 1;
    long timeWindow = 0;
    List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan, maxCount, timeWindow);
    Assert.assertEquals(triggers.size(), 1);
    Assert.assertEquals(triggers.get(0).getKey().getName(), "job" + i);

    // Let's remove the trigger now.
    store.removeJob(triggers.get(0).getJobKey());
  }
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:50,代码来源:HazelcastJobStoreTest.java


示例10: testAcquireTriggersInBatch

import org.quartz.spi.JobStore; //导入依赖的package包/类
@Test
public void testAcquireTriggersInBatch()
  throws Exception {

  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testAcquireTriggersInBatch");
  store.initialize(loadHelper, schedSignaler);

  // Setup: Store jobs and triggers.
  long MIN = 60 * 1000L;
  Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from
  // now.
  for (int i = 0; i < 10; i++) {
    Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i).build();
    SimpleScheduleBuilder schedule = SimpleScheduleBuilder.repeatMinutelyForever(2);
    OperableTrigger trigger = (OperableTrigger) newTrigger()
        .withIdentity("job" + i)
        .withSchedule(schedule)
        .forJob(job)
        .startAt(startTime)
        .build();

    // Manually trigger the first fire time computation that scheduler would
    // do. Otherwise
    // the store.acquireNextTriggers() will not work properly.
    Date fireTime = trigger.computeFirstFireTime(null);
    Assert.assertNotNull(fireTime);

    store.storeJobAndTrigger(job, trigger);
  }

  // Test acquire batch of triggers at a time
  long noLaterThan = startTime0.getTime() + 10 * MIN;
  int maxCount = 7;
  // time window needs to be big to be able to pick up multiple triggers when
  // they are a minute apart
  long timeWindow = 8 * MIN;
  List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan, maxCount, timeWindow);
  Assert.assertEquals(triggers.size(), 7);
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:45,代码来源:HazelcastJobStoreTest.java


示例11: testAcquireTriggers

import org.quartz.spi.JobStore; //导入依赖的package包/类
@Test()
public void testAcquireTriggers() throws Exception {
  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testAcquireTriggers");
  store.initialize(loadHelper, schedSignaler);

  // Setup: Store jobs and triggers.
  long MIN = 60 * 1000L;
  Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from
                                                                // now.
  for (int i = 0; i < 10; i++) {
    Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i)
        .build();
    SimpleScheduleBuilder schedule = SimpleScheduleBuilder
        .repeatMinutelyForever(2);
    OperableTrigger trigger = (OperableTrigger) TriggerBuilder.newTrigger()
        .withIdentity("job" + i).withSchedule(schedule).forJob(job)
        .startAt(startTime).build();

    // Manually trigger the first fire time computation that scheduler would
    // do. Otherwise
    // the store.acquireNextTriggers() will not work properly.
    Date fireTime = trigger.computeFirstFireTime(null);
    Assert.assertEquals(true, fireTime != null);

    store.storeJobAndTrigger(job, trigger);
  }

  // Test acquire one trigger at a time
  for (int i = 0; i < 10; i++) {
    long noLaterThan = (startTime0.getTime() + i * MIN);
    int maxCount = 1;
    long timeWindow = 0;
    List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan,
        maxCount, timeWindow);
    Assert.assertEquals(1, triggers.size());
    Assert.assertEquals("job" + i, triggers.get(0).getKey().getName());

    // Let's remove the trigger now.
    store.removeJob(triggers.get(0).getJobKey());
  }
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:47,代码来源:TestHazelcastJobStore.java


示例12: testAcquireTriggersInBatch

import org.quartz.spi.JobStore; //导入依赖的package包/类
@Test()
public void testAcquireTriggersInBatch() throws Exception {
  SchedulerSignaler schedSignaler = new SampleSignaler();
  ClassLoadHelper loadHelper = new CascadingClassLoadHelper();
  loadHelper.initialize();

  JobStore store = createJobStore("testAcquireTriggersInBatch");
  store.initialize(loadHelper, schedSignaler);

  // Setup: Store jobs and triggers.
  long MIN = 60 * 1000L;
  Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from
                                                                // now.
  for (int i = 0; i < 10; i++) {
    Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart
    JobDetail job = JobBuilder.newJob(NoOpJob.class).withIdentity("job" + i)
        .build();
    SimpleScheduleBuilder schedule = SimpleScheduleBuilder
        .repeatMinutelyForever(2);
    OperableTrigger trigger = (OperableTrigger) TriggerBuilder.newTrigger()
        .withIdentity("job" + i).withSchedule(schedule).forJob(job)
        .startAt(startTime).build();

    // Manually trigger the first fire time computation that scheduler would
    // do. Otherwise
    // the store.acquireNextTriggers() will not work properly.
    Date fireTime = trigger.computeFirstFireTime(null);
    Assert.assertEquals(true, fireTime != null);

    store.storeJobAndTrigger(job, trigger);
  }

  // Test acquire batch of triggers at a time
  long noLaterThan = startTime0.getTime() + 10 * MIN;
  int maxCount = 7;
  // time window needs to be big to be able to pick up multiple triggers when
  // they are a minute apart
  long timeWindow = 8 * MIN;
  List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan,
      maxCount, timeWindow);
  Assert.assertEquals(7, triggers.size());
}
 
开发者ID:Ameausoone,项目名称:quartz-hazelcast-jobstore,代码行数:43,代码来源:TestHazelcastJobStore.java


示例13: createVolatileScheduler

import org.quartz.spi.JobStore; //导入依赖的package包/类
/**
 * Creates an in memory job store (<code>{@link RAMJobStore}</code>)
 * The thread priority is set to Thread.NORM_PRIORITY
 *
 * @param maxThreads
 *          The number of threads in the thread pool
 * @throws SchedulerException
 *           if initialization failed.
 */
public void createVolatileScheduler(int maxThreads)
    throws SchedulerException {
    SimpleThreadPool threadPool = new SimpleThreadPool(maxThreads,
            Thread.NORM_PRIORITY);
    threadPool.initialize();
    JobStore jobStore = new RAMJobStore();
    this.createScheduler(threadPool, jobStore);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:DirectSchedulerFactory.java


示例14: createScheduler

import org.quartz.spi.JobStore; //导入依赖的package包/类
/**
 * Same as
 * {@link DirectSchedulerFactory#createScheduler(ThreadPool threadPool, JobStore jobStore)},
 * with the addition of specifying the scheduler name and instance ID. This
 * scheduler can only be retrieved via
 * {@link DirectSchedulerFactory#getScheduler(String)}
 *
 * @param schedulerName
 *          The name for the scheduler.
 * @param schedulerInstanceId
 *          The instance ID for the scheduler.
 * @param threadPool
 *          The thread pool for executing jobs
 * @param jobStore
 *          The type of job store
 * @throws SchedulerException
 *           if initialization failed
 */
public void createScheduler(String schedulerName,
        String schedulerInstanceId, ThreadPool threadPool, JobStore jobStore)
    throws SchedulerException {
    createScheduler(schedulerName, schedulerInstanceId, threadPool,
            jobStore, null, 0, -1, -1);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:DirectSchedulerFactory.java


示例15: setJobStore

import org.quartz.spi.JobStore; //导入依赖的package包/类
/**
 * <p>
 * Set the <code>{@link JobStore}</code> for the <code>{@link QuartzScheduler}</code>
 * to use.
 * </p>
 * 
 * @exception IllegalArgumentException
 *              if jobStore is null.
 */
public void setJobStore(JobStore jobStore) {
    if (jobStore == null) {
        throw new IllegalArgumentException("JobStore cannot be null.");
    }

    this.jobStore = jobStore;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:QuartzSchedulerResources.java


示例16: createScheduler

import org.quartz.spi.JobStore; //导入依赖的package包/类
/**
 * Creates a scheduler using the specified thread pool and job store. This
 * scheduler can be retrieved via
 * {@link DirectSchedulerFactory#getScheduler()}
 *
 * @param threadPool
 *          The thread pool for executing jobs
 * @param jobStore
 *          The type of job store
 * @throws SchedulerException
 *           if initialization failed
 */
public void createScheduler(ThreadPool threadPool, JobStore jobStore)
    throws SchedulerException {
    createScheduler(DEFAULT_SCHEDULER_NAME, DEFAULT_INSTANCE_ID,
            threadPool, jobStore);
    initialized = true;
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:19,代码来源:DirectSchedulerFactory.java


示例17: getJobStore

import org.quartz.spi.JobStore; //导入依赖的package包/类
/**
 * <p>
 * Get the <code>{@link JobStore}</code> for the <code>{@link QuartzScheduler}</code>
 * to use.
 * </p>
 */
public JobStore getJobStore() {
    return jobStore;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:QuartzSchedulerResources.java



注:本文中的org.quartz.spi.JobStore类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EvaluationResult类代码示例发布时间:2022-05-22
下一篇:
Java BlockOpResponseProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap