Commits

Anonymous committed 23822f7

QUARTZ-691: improper calculation of whether newly added trigger is earlier than the currently acquired trigger.

git-svn-id: http://svn.opensymphony.com/svn/quartz/trunk@83869f7d36a-ea1c-0410-88ea-9fd03e4c9665

  • Participants
  • Parent commits 719158a

Comments (0)

Files changed (4)

File src/java/org/quartz/core/JobRunShell.java

                 break;
             } while (true);
     
-            qs.notifySchedulerThread(0L);
         } finally {
             jobRunShellFactory.returnJobRunShell(this);
         }

File src/java/org/quartz/core/QuartzSchedulerThread.java

 		// implementation to tell us the amount of time in which it "thinks"
 		// it can abandon the acquired trigger and acquire a new one.  However
 		// we have no current facility for having it tell us that, so we make
-		// and somewhat educated but arbitrary guess ;-).
+		// a somewhat educated but arbitrary guess ;-).
 
     	synchronized(sigLock) {
 			
 			
 			if(earlier) {
 				// so the new time is considered earlier, but is it enough earlier?
-				long diff = System.currentTimeMillis() - oldTime;
-				if(diff < (qsRsrcs.getJobStore().supportsPersistence() ? 90L : 7L))
+				// le
+				long diff = oldTime - System.currentTimeMillis();
+				if(diff < (qsRsrcs.getJobStore().supportsPersistence() ? 80L : 7L))
 					earlier = false;
 			}
 			

File src/java/org/quartz/impl/jdbcjobstore/JobStoreSupport.java

                     }
                 } else{
                     removeTrigger(conn, ctxt, trigger.getName(), trigger.getGroup());
+                    signaler.signalSchedulingChange(0L);
                 }
             } else if (triggerInstCode == Trigger.INSTRUCTION_SET_TRIGGER_COMPLETE) {
                 getDelegate().updateTriggerState(conn, trigger.getName(),
                         trigger.getGroup(), STATE_COMPLETE);
+                signaler.signalSchedulingChange(0L);
             } else if (triggerInstCode == Trigger.INSTRUCTION_SET_TRIGGER_ERROR) {
                 getLog().info("Trigger " + trigger.getFullName() + " set to ERROR state.");
                 getDelegate().updateTriggerState(conn, trigger.getName(),
                         trigger.getGroup(), STATE_ERROR);
+                signaler.signalSchedulingChange(0L);
             } else if (triggerInstCode == Trigger.INSTRUCTION_SET_ALL_JOB_TRIGGERS_COMPLETE) {
                 getDelegate().updateTriggerStatesForJob(conn,
                         trigger.getJobName(), trigger.getJobGroup(),
                         STATE_COMPLETE);
+                signaler.signalSchedulingChange(0L);
             } else if (triggerInstCode == Trigger.INSTRUCTION_SET_ALL_JOB_TRIGGERS_ERROR) {
                 getLog().info("All triggers of Job " + 
                         trigger.getFullJobName() + " set to ERROR state.");
                 getDelegate().updateTriggerStatesForJob(conn,
                         trigger.getJobName(), trigger.getJobGroup(),
                         STATE_ERROR);
+                signaler.signalSchedulingChange(0L);
             }
 
             if (jobDetail.isStateful()) {
                         jobDetail.getName(), jobDetail.getGroup(),
                         STATE_PAUSED, STATE_PAUSED_BLOCKED);
 
+                signaler.signalSchedulingChange(0L);
+
                 try {
                     if (jobDetail.getJobDataMap().isDirty()) {
                         getDelegate().updateJobData(conn, jobDetail);

File src/java/org/quartz/simpl/RAMJobStore.java

                             ttw.state = TriggerWrapper.STATE_PAUSED;
                         }
                     }
+                    signaler.signalSchedulingChange(0L);
                 }
             } else { // even if it was deleted, there may be cleanup to do
                 blockedJobs.remove(JobWrapper.getJobNameKey(jobDetail));
                         }
                     } else {
                         removeTrigger(ctxt, trigger.getName(), trigger.getGroup());
+                        signaler.signalSchedulingChange(0L);
                     }
                 } else if (triggerInstCode == Trigger.INSTRUCTION_SET_TRIGGER_COMPLETE) {
                     tw.state = TriggerWrapper.STATE_COMPLETE;
                     timeTriggers.remove(tw);
+                    signaler.signalSchedulingChange(0L);
                 } else if(triggerInstCode == Trigger.INSTRUCTION_SET_TRIGGER_ERROR) {
                     getLog().info("Trigger " + trigger.getFullName() + " set to ERROR state.");
                     tw.state = TriggerWrapper.STATE_ERROR;
+                    signaler.signalSchedulingChange(0L);
                 } else if (triggerInstCode == Trigger.INSTRUCTION_SET_ALL_JOB_TRIGGERS_ERROR) {
                     getLog().info("All triggers of Job " 
                             + trigger.getFullJobName() + " set to ERROR state.");
                             trigger.getJobName(), 
                             trigger.getJobGroup(),
                             TriggerWrapper.STATE_ERROR);
+                    signaler.signalSchedulingChange(0L);
                 } else if (triggerInstCode == Trigger.INSTRUCTION_SET_ALL_JOB_TRIGGERS_COMPLETE) {
                     setAllTriggersOfJobToState(
                             trigger.getJobName(), 
                             trigger.getJobGroup(),
                             TriggerWrapper.STATE_COMPLETE);
+                    signaler.signalSchedulingChange(0L);
                 }
             }
         }