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

Java RAMJobStore类代码示例

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

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



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

示例1: initSched

import org.quartz.simpl.RAMJobStore; //导入依赖的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


示例2: start

import org.quartz.simpl.RAMJobStore; //导入依赖的package包/类
@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");
    }
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:23,代码来源:QuartzScheduling.java


示例3: getProperties

import org.quartz.simpl.RAMJobStore; //导入依赖的package包/类
private Properties getProperties() {
    Properties props = new Properties();

    props.setProperty("org.quartz.jobStore.class", quartzConfig.getJobStore().getName());
    props.setProperty("org.quartz.threadPool.threadCount", String.valueOf(quartzConfig.getThreads()));

    if (!quartzConfig.getJobStore().equals(RAMJobStore.class)) {
        props.setProperty("org.quartz.jobStore.driverDelegateClass", quartzConfig.getDbDelegate().getName());
        props.setProperty("org.quartz.jobStore.dataSource", "main");
        props.setProperty("org.quartz.dataSource.main.driver", dbConfig.getDriverClass());
        props.setProperty("org.quartz.dataSource.main.URL", dbConfig.getUrl());
        props.setProperty("org.quartz.dataSource.main.user", dbConfig.getUser());
        props.setProperty("org.quartz.dataSource.main.password", dbConfig.getPassword());
    }

    return props;
}
 
开发者ID:Lugribossk,项目名称:dropwizard-experiment,代码行数:18,代码来源:Quartz.java


示例4: createVolatileScheduler

import org.quartz.simpl.RAMJobStore; //导入依赖的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


示例5: createQuartzScheduler

import org.quartz.simpl.RAMJobStore; //导入依赖的package包/类
public Scheduler createQuartzScheduler() throws SchedulerException {
    Properties properties = new Properties();
    properties.setProperty("org.quartz.scheduler.skipUpdateCheck", "true");
    properties.setProperty("org.quartz.threadPool.class", SimpleThreadPool.class.getName());
    properties.setProperty("org.quartz.threadPool.threadCount", "1");
    properties.setProperty("org.quartz.jobStore.class", RAMJobStore.class.getName());

    val schedulerFactory = new StdSchedulerFactory(properties);
    return schedulerFactory.getScheduler();
}
 
开发者ID:bingoohuang,项目名称:westcache,代码行数:11,代码来源:Quartz.java


示例6: quartzScheduler

import org.quartz.simpl.RAMJobStore; //导入依赖的package包/类
@Bean
public Scheduler quartzScheduler(ApplicationContext context) throws Exception {
    SchedulerFactoryBean factory = new SchedulerFactoryBean();

    factory.setApplicationContext(context);
    factory.setExposeSchedulerInRepository(true);
    factory.setApplicationContextSchedulerContextKey(APPLICATION_CONTEXT_KEY);
    factory.setJobFactory(glassJobFactory);

    Properties properties = new Properties();
    properties.setProperty("org.quartz.scheduler.skipUpdateCheck","true");
    properties.setProperty("org.quartz.threadPool.class", SimpleThreadPool.class.getName());
    properties.setProperty("org.quartz.threadPool.threadCount", "15");
    properties.setProperty("org.quartz.threadPool.threadPriority", "4");

    if (configuration().isInMemory()) {
        properties.setProperty("org.quartz.jobStore.class", RAMJobStore.class.getName());
    } else {
        factory.setDataSource(dataSource());

        properties.setProperty("org.quartz.jobStore.tablePrefix", configuration().getTablePrefix());
        properties.setProperty("org.quartz.jobStore.isClustered", "false");
        properties.setProperty("org.quartz.jobStore.driverDelegateClass", configuration().getDriverDelegateClass());
    }

    factory.setQuartzProperties(properties);

    factory.afterPropertiesSet();

    Scheduler scheduler = factory.getObject();

    scheduler.getListenerManager().addJobListener(glassJobListener);
    scheduler.getListenerManager().addSchedulerListener(glassSchedulerListener);

    scheduler.start();

    return scheduler;
}
 
开发者ID:bingoohuang,项目名称:quartz-glass,代码行数:39,代码来源:SpringConfig.java


示例7: createAndUpdateSchedule

import org.quartz.simpl.RAMJobStore; //导入依赖的package包/类
@Test
public void createAndUpdateSchedule() throws Exception {
	final ApplicationContext mockContext = Mockito.mock(ApplicationContext.class);
	final VmScheduleRepository vmScheduleRepository = Mockito.mock(VmScheduleRepository.class);
	final VmResource mockResource = Mockito.mock(VmResource.class);
	final Subscription entity = this.subscriptionRepository.findOneExpected(subscription);
	Mockito.when(mockContext.getBean(VmScheduleRepository.class)).thenReturn(vmScheduleRepository);
	Mockito.when(mockContext.getBean(SecurityHelper.class)).thenReturn(Mockito.mock(SecurityHelper.class));
	Mockito.when(mockContext.getBean(VmResource.class)).thenReturn(mockResource);

	final StdScheduler scheduler = (StdScheduler) vmSchedulerFactoryBean.getScheduler();
	final QuartzScheduler qscheduler = (QuartzScheduler) FieldUtils.getField(StdScheduler.class, "sched", true).get(scheduler);
	final QuartzSchedulerResources resources = (QuartzSchedulerResources) FieldUtils.getField(QuartzScheduler.class, "resources", true)
			.get(qscheduler);
	final JobDetail jobDetail = scheduler.getJobDetail(scheduler.getJobKeys(GroupMatcher.anyJobGroup()).iterator().next());

	// "ON" call would fail
	Mockito.doThrow(new RuntimeException()).when(mockResource).execute(entity, VmOperation.ON);

	try {
		// Mock the factory
		jobDetail.getJobDataMap().put("context", mockContext);
		((RAMJobStore) resources.getJobStore()).storeJob(jobDetail, true);

		Assert.assertEquals(1, this.vmScheduleRepository.findAll().size());

		// Schedule all operations within the next 2 seconds
		final String cron = "" + ((DateUtils.newCalendar().get(Calendar.SECOND) + 2) % 60) + " * * * * ?";
		final int id = mockSchedule(vmScheduleRepository, resource.createSchedule(newSchedule(cron, VmOperation.OFF)));
		mockSchedule(vmScheduleRepository, resource.createSchedule(newSchedule(cron + " *", VmOperation.ON)));
		Assert.assertEquals(3, this.vmScheduleRepository.findAll().size());

		// Yield for the schedules
		Thread.sleep(2500);

		// Check the executions
		Mockito.verify(mockResource).execute(entity, VmOperation.OFF);
		Mockito.verify(mockResource).execute(entity, VmOperation.ON); // Failed
		Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.REBOOT);
		Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.RESET);
		Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.SHUTDOWN);
		Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.SUSPEND);

		// Update the CRON and the operation
		final VmScheduleVo vo = newSchedule("" + ((DateUtils.newCalendar().get(Calendar.SECOND) + 2) % 60) + " * * * * ?",
				VmOperation.SHUTDOWN);
		vo.setId(id);
		vo.setSubscription(subscription);
		resource.updateSchedule(vo);
		Assert.assertEquals(3, this.vmScheduleRepository.findAll().size());

		// Yield for the schedules
		Thread.sleep(2500);
		Mockito.verify(mockResource).execute(entity, VmOperation.SHUTDOWN);
	} finally {
		// Restore the factory's context
		jobDetail.getJobDataMap().put("context", applicationContext);
		((RAMJobStore) resources.getJobStore()).storeJob(jobDetail, true);
	}
}
 
开发者ID:ligoj,项目名称:plugin-vm,代码行数:61,代码来源:VmResourceTest.java


示例8: createVolatileScheduler

import org.quartz.simpl.RAMJobStore; //导入依赖的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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java CameraScene类代码示例发布时间:2022-05-22
下一篇:
Java EntityStray类代码示例发布时间: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