grails - 如何限制 Quartz 作业总数和集群中单个节点上运行的数量

标签 grails cluster-computing quartz-scheduler

如果我有一个 3 节点集群。我需要运行一个特定的 Quartz 作业,如下所示:

  • 在给定时间,需要运行许多(例如 30 个)此类作业。
  • 限制同时在所有集群上运行的 Quartz 作业的数量(由于系统资源的原因,最多为 10 个)
  • 限制单个服务器上同时运行的 Quartz 作业数量(由于 CPU 负载,最多为 5 个)

如何将同时作业实例的总数限制为 10 个,并将任何一台主机上运行的数量限制为 5 个?这可能吗?

请注意,我无法限制线程数,因为我还有其他作业需要同时在同一服务器上运行,而这些作业也需要线程。

谢谢。

最佳答案

虽然不能严格限制连续作业计数,但您可以使用线程池配置限制最大线程计数。请参阅Quartz Configuration Reference .

Grails Quartz 插件附带了一个用于安装配置文件的方便脚本:
grails install-quartz-config

org.quartz.threadPool.threadCount

Can be any positive integer, although you should realize that only numbers between 1 and 100 are very practical. This is the number of threads that are available for concurrent execution of jobs. If you only have a few jobs that fire a few times a day, then 1 thread is plenty! If you have tens of thousands of jobs, with many firing every minute, then you probably want a thread count more like 50 or 100 (this highly depends on the nature of the work that your jobs perform, and your systems resources!).

关于grails - 如何限制 Quartz 作业总数和集群中单个节点上运行的数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20977694/

相关文章:

grails - 欧芹验证文件是否已上传?

grails - Grails 2.4.4覆盖springSecurityService

LISP - 没有 setq/setf 等的最接近函数

hadoop - Hadoop集群配置资源管理

c++ - Wordcount C++ Hadoop 管道不起作用

java - Quartz JobDetail 缺少方法

oracle - 在 GORM 中使用不同的数据库用户

spring - 提前释放 Grails 数据库连接

java - 在quartz中可以在一台服务器上配置作业并在另一台服务器上运行该作业吗?

java - 如何将 QUARTZ JOB 设置为仅在另一个 JOB 完成、停止时启动?