13

I have some questions about Quartz clustering, specifically about how triggers fire / jobs execute within the cluster.

  1. Does quartz give any preference to nodes when executing jobs? Such as always or never the node that executed the same job the last time, or is it simply whichever node that gets to the job first?

  2. Is it possible to specify the node which should execute the job?

oberlies
  • 11,503
  • 4
  • 63
  • 110
ButterflyCoder
  • 135
  • 1
  • 4

2 Answers2

12

The answer to this will be something of a "it depends".

For quartz 1.x, the answer is that the execution of the job is always (only) on a more-or-less random node. Where "randomness" is really based on whichever node gets to it first. For "busy" schedulers (where there are always a lot of jobs to run) this ends up giving a pretty balanced load across the cluster nodes. For non-busy scheduler (only an occasional job to fire) it may sometimes look like a single node is firing all the jobs (because the scheduler looks for the next job to fire whenever a job execution completes - so the node just finishing an execution tends to find the next job to execute).

With quartz 2.0 (which is in beta) the answer is the same as above, for standard quartz. But the Terracotta folks have built an Enterprise Edition of their TerracottaJobStore which offers more complex clustering control - as you schedule jobs you can specify which nodes of the cluster are valid for the execution of the job, or you can specify node characteristics/requisites, such as "a node with at least 100 MB RAM available". This also works along with ehcache, such that you can specify the job to run "on the node where the data keyed by X is local".

jhouse
  • 2,674
  • 1
  • 18
  • 17
0

I solved this question for my web application using Spring + AOP + memcached. My jobs do know from the data they traverse if the job has already been executed, so the only thing I need to avoid is two or more nodes running at the same time.

You can read it here:

http://blog.oio.de/2013/07/03/cluster-job-synchronization-with-spring-aop-and-memcached/