Get a list of all currently running jobs in a cluster with Quartz

The Scheduler.getCurrentlyExecutingJobs () method in quartz does not seem to be a cluster. What method do people use to get a list of all the tasks they complete?

+6
java-ee quartz-scheduler
source share
2 answers

It seems that the restructuring of the planning mechanism does not occur in the near future.

So, here is how I check the table directly - add group support if you want to:

class QuartzClusterJobStatusService { def quartzScheduler boolean isJobRunning(String job) { return isJobRunningHere(job) || isJobRunningElsewhere(job) } boolean isJobRunningHere(String job) { for (JobExecutionContext j : quartzScheduler.getCurrentlyExecutingJobs()) { if (new JobKey(job,"GRAILS_JOBS").equals(j.jobDetail.key)) { return true } } return false } boolean isJobRunningElsewhere(String job) { JobStoreSupport js = quartzScheduler.sched.resources.jobStore if (!js.isClustered()) { return false } Connection conn = DBConnectionManager.getInstance().getConnection(js.getDataSource()); PreparedStatement stmt = null try { stmt = conn.prepareStatement("SELECT 1 FROM " + js.getTablePrefix() + "FIRED_TRIGGERS where JOB_NAME = ?") stmt.setString(1, job) ResultSet rs = stmt.executeQuery() return rs.next() } finally { if (stmt != null) stmt.close() } } } 
+3
source share

I would suggest that one way is to access the database directly, although its a bit risky, since the API does it all.

There is a problem in their Jir for this purpose. Their conclusion is that you need to review the planning mechanism if they want to know the cluster.

You can refer to http://jira.opensymphony.com/browse/QUARTZ-372

0
source share

All Articles