Skip to content

Commit

Permalink
SAK-44261 Use the stateful quartz wrapper for the SiteStats aggregati…
Browse files Browse the repository at this point in the history
…on job (sakaiproject#8545)

* SAK-44261 Use the stateful quartz wrapper for the SiteStats aggregation job

This commit also removes the CR line-endings from components.xml, so view without
whitespace changes to see the actual update.

* SAK-44261 Update comment on use of stateful job
  • Loading branch information
smarquard authored Sep 11, 2020
1 parent fbd5556 commit 668ed80
Show file tree
Hide file tree
Showing 2 changed files with 455 additions and 455 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
import org.quartz.StatefulJob;
import org.sakaiproject.component.app.scheduler.jobs.SpringJobBeanWrapper;
import org.sakaiproject.component.app.scheduler.jobs.SpringStatefulJobBeanWrapper;
import org.sakaiproject.db.api.SqlService;
import org.sakaiproject.event.api.Event;
import org.sakaiproject.sitestats.api.JobRun;
Expand Down Expand Up @@ -135,11 +135,11 @@ public void execute(JobExecutionContext context) throws JobExecutionException {
String jobName = context.getJobDetail().getKey().getName();

// ABORT if job is currently running in this cluster node.
// -> Required as StatefullJob is only correctly supported in trunk!
// WARNING: I cannot currently check if this is running in OTHER cluster nodes!!!
// This should never happen, as the job is stateful so quartz should not execute
// more than one instance concurrently.
try{
while(isJobCurrentlyRunning(context)) {
String beanId = context.getJobDetail().getJobDataMap().getString(SpringJobBeanWrapper.SPRING_BEAN_NAME);
String beanId = context.getJobDetail().getJobDataMap().getString(SpringStatefulJobBeanWrapper.SPRING_BEAN_NAME);
log.warn("Another instance of "+beanId+" is currently running - Execution aborted.");
return;
}
Expand Down Expand Up @@ -197,12 +197,12 @@ public void execute(JobExecutionContext context) throws JobExecutionException {
}

private boolean isJobCurrentlyRunning(JobExecutionContext context) throws SchedulerException {
String beanId = context.getJobDetail().getJobDataMap().getString(SpringJobBeanWrapper.SPRING_BEAN_NAME);
String beanId = context.getJobDetail().getJobDataMap().getString(SpringStatefulJobBeanWrapper.SPRING_BEAN_NAME);
List<JobExecutionContext> jobsRunning = context.getScheduler().getCurrentlyExecutingJobs();

int jobsCount = 0;
for(JobExecutionContext j : jobsRunning)
if(beanId.equals(j.getJobDetail().getJobDataMap().getString(SpringJobBeanWrapper.SPRING_BEAN_NAME))) {
if(beanId.equals(j.getJobDetail().getJobDataMap().getString(SpringStatefulJobBeanWrapper.SPRING_BEAN_NAME))) {
jobsCount++;
}
if(jobsCount > 1)
Expand Down
Loading

0 comments on commit 668ed80

Please sign in to comment.