简体   繁体   English

在特定主机上运行特定的石英作业

[英]Running particular quartz job on specific host

I've few quartz jobs that I'm running in clustered mode. 我有几个在群集模式下运行的石英作业。 Some are IO intensive and some are CPU intensive jobs. 有些是IO密集型工作,有些是CPU密集型工作。 What I want to do is run CPU bound jobs on a particular host and run IO bound job on another set of hosts. 我要做的是在特定主机上运行CPU绑定的作业,在另一组主机上运行IO绑定的作业。 Is there any configuration where I can whitelist a set of jobs that can run on a particular machine? 是否有任何配置可以将可以在特定计算机上运行的一组作业列入白名单? I don't want to create another set of quartz table do this kind of thing. 我不想创建另一套石英表来做这种事情。

Tech: Spring boot, Oracle, Quartz 2.X 技术:春季启动,Oracle,Quartz 2.X

Thanks a lot! 非常感谢!

I suggest in the Jobstore, just use pauseJob or pauseJobGroup for each jobs for those particular machines. 我建议在Jobstore中,仅对那些特定计算机的每个作业使用pauseJob或pauseJobGroup。

Or you can also use pause thru SQL 或者您也可以通过SQL使用暂停

Or thru environment settings, you have a switch there to what jobs you want to get disabled. 或通过环境设置,您可以在那里切换到要禁用的作业。

The way I did this is to create a different scheduler instance depending on the property passed in JVM startup parameter. 我这样做的方法是根据JVM启动参数中传递的属性创建一个不同的调度程序实例。 I used Spring quartz integration and here is the sample code for that. 我使用了Spring Crystal集成,这是该示例代码。 Most important part is setting of auto startup to false for the scheduler that should not run. 最重要的部分是将不应运行的调度程序的自动启动设置为false。 This way I was able to create different scheduler but only started the ones that were configured in properties. 这样,我可以创建不同的调度程序,但是只能启动在属性中配置的调度程序。

 @Bean
public SchedulerFactoryBean schedulerFactory(DataSource dataSource, JobFactory jobFactory)
        throws IOException {
    SchedulerFactoryBean factory = new SchedulerFactoryBean();
    factory.setBeanName("myscheduler");
    factory.setDataSource(dataSource);
    factory.setJobFactory(jobFactory);
    factory.setQuartzProperties(getQuartzProperties());
    if (!System.getProperty(SCHEDULER_NAME).contains("myscheduler")) {
        factory.setAutoStartup(false);
    }
    return factory;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM