Browse Source

Merge pull request #186 in CORE/base-third from ~ZED/base-third:release/10.0 to release/10.0

* commit '362aa2e8e7d29c9a6549d86458bca09a0619e768':
  DEC-7376 定时调度任务表中存在脏数据的时候,不能影响整个scheduler
bugfix/10.0
zed 6 years ago
parent
commit
a86c1b0239
  1. 265
      fine-quartz/src/com/fr/third/v2/org/quartz/impl/jdbcjobstore/JobStoreSupport.java

265
fine-quartz/src/com/fr/third/v2/org/quartz/impl/jdbcjobstore/JobStoreSupport.java

@ -17,38 +17,21 @@
package com.fr.third.v2.org.quartz.impl.jdbcjobstore; package com.fr.third.v2.org.quartz.impl.jdbcjobstore;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.fr.third.v2.org.quartz.Calendar; import com.fr.third.v2.org.quartz.Calendar;
import com.fr.third.v2.org.quartz.Job; import com.fr.third.v2.org.quartz.Job;
import com.fr.third.v2.org.quartz.JobDataMap;
import com.fr.third.v2.org.quartz.JobDetail; import com.fr.third.v2.org.quartz.JobDetail;
import com.fr.third.v2.org.quartz.JobKey;
import com.fr.third.v2.org.quartz.JobPersistenceException;
import com.fr.third.v2.org.quartz.ObjectAlreadyExistsException; import com.fr.third.v2.org.quartz.ObjectAlreadyExistsException;
import com.fr.third.v2.org.quartz.Scheduler; import com.fr.third.v2.org.quartz.Scheduler;
import com.fr.third.v2.org.quartz.SchedulerConfigException; import com.fr.third.v2.org.quartz.SchedulerConfigException;
import com.fr.third.v2.org.quartz.TriggerKey;
import com.fr.third.v2.org.quartz.spi.OperableTrigger;
import com.fr.third.v2.org.quartz.spi.ThreadExecutor;
import com.fr.third.v2.org.quartz.spi.TriggerFiredResult;
import com.fr.third.v2.org.quartz.JobDataMap;
import com.fr.third.v2.org.quartz.JobKey;
import com.fr.third.v2.org.quartz.JobPersistenceException;
import com.fr.third.v2.org.quartz.SchedulerException; import com.fr.third.v2.org.quartz.SchedulerException;
import com.fr.third.v2.org.quartz.SimpleTrigger; import com.fr.third.v2.org.quartz.SimpleTrigger;
import com.fr.third.v2.org.quartz.Trigger; import com.fr.third.v2.org.quartz.Trigger;
import com.fr.third.v2.org.quartz.Trigger.CompletedExecutionInstruction; import com.fr.third.v2.org.quartz.Trigger.CompletedExecutionInstruction;
import com.fr.third.v2.org.quartz.Trigger.TriggerState; import com.fr.third.v2.org.quartz.Trigger.TriggerState;
import com.fr.third.v2.org.quartz.TriggerKey;
import com.fr.third.v2.org.quartz.impl.DefaultThreadExecutor; import com.fr.third.v2.org.quartz.impl.DefaultThreadExecutor;
import com.fr.third.v2.org.quartz.impl.matchers.GroupMatcher; import com.fr.third.v2.org.quartz.impl.matchers.GroupMatcher;
import com.fr.third.v2.org.quartz.impl.matchers.StringMatcher; import com.fr.third.v2.org.quartz.impl.matchers.StringMatcher;
@ -56,12 +39,29 @@ import com.fr.third.v2.org.quartz.impl.matchers.StringMatcher.StringOperatorName
import com.fr.third.v2.org.quartz.impl.triggers.SimpleTriggerImpl; import com.fr.third.v2.org.quartz.impl.triggers.SimpleTriggerImpl;
import com.fr.third.v2.org.quartz.spi.ClassLoadHelper; import com.fr.third.v2.org.quartz.spi.ClassLoadHelper;
import com.fr.third.v2.org.quartz.spi.JobStore; import com.fr.third.v2.org.quartz.spi.JobStore;
import com.fr.third.v2.org.quartz.spi.OperableTrigger;
import com.fr.third.v2.org.quartz.spi.SchedulerSignaler; import com.fr.third.v2.org.quartz.spi.SchedulerSignaler;
import com.fr.third.v2.org.quartz.spi.ThreadExecutor;
import com.fr.third.v2.org.quartz.spi.TriggerFiredBundle; import com.fr.third.v2.org.quartz.spi.TriggerFiredBundle;
import com.fr.third.v2.org.quartz.spi.TriggerFiredResult;
import com.fr.third.v2.org.quartz.utils.DBConnectionManager; import com.fr.third.v2.org.quartz.utils.DBConnectionManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/** /**
* <p> * <p>
@ -354,6 +354,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
public long getDbRetryInterval() { public long getDbRetryInterval() {
return dbRetryInterval; return dbRetryInterval;
} }
/** /**
* @param dbRetryInterval The dbRetryInterval to set. * @param dbRetryInterval The dbRetryInterval to set.
*/ */
@ -473,7 +474,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* should be performed after obtaining an explicit DB lock. This is the * should be performed after obtaining an explicit DB lock. This is the
* behavior prior to Quartz 1.6.3, but is considered unnecessary for most * behavior prior to Quartz 1.6.3, but is considered unnecessary for most
* databases, and therefore a superfluous performance hit. * databases, and therefore a superfluous performance hit.
* * <p>
* However, if batch acquisition is used, it is important for this behavior * However, if batch acquisition is used, it is important for this behavior
* to be used for all dbs. * to be used for all dbs.
*/ */
@ -488,13 +489,12 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* Set the JDBC driver delegate class. * Set the JDBC driver delegate class.
* </p> * </p>
* *
* @param delegateClassName * @param delegateClassName the delegate class name
* the delegate class name
*/ */
@SuppressWarnings("UnusedDeclaration") /* called reflectively */ @SuppressWarnings("UnusedDeclaration") /* called reflectively */
public void setDriverDelegateClass(String delegateClassName) public void setDriverDelegateClass(String delegateClassName)
throws InvalidConfigurationException { throws InvalidConfigurationException {
synchronized(this) { synchronized (this) {
this.delegateClassName = delegateClassName; this.delegateClassName = delegateClassName;
} }
} }
@ -515,8 +515,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* Set the JDBC driver delegate's initialization string. * Set the JDBC driver delegate's initialization string.
* </p> * </p>
* *
* @param delegateInitString * @param delegateInitString the delegate init string
* the delegate init string
*/ */
@SuppressWarnings("UnusedDeclaration") /* called reflectively */ @SuppressWarnings("UnusedDeclaration") /* called reflectively */
public void setDriverDelegateInitString(String delegateInitString) public void setDriverDelegateInitString(String delegateInitString)
@ -639,7 +638,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
} }
classLoadHelper = loadHelper; classLoadHelper = loadHelper;
if(isThreadsInheritInitializersClassLoadContext()) { if (isThreadsInheritInitializersClassLoadContext()) {
log.info("JDBCJobStore threads will inherit ContextClassLoader of thread: " + Thread.currentThread().getName()); log.info("JDBCJobStore threads will inherit ContextClassLoader of thread: " + Thread.currentThread().getName());
initializersLoader = Thread.currentThread().getContextClassLoader(); initializersLoader = Thread.currentThread().getContextClassLoader();
} }
@ -657,8 +656,8 @@ public abstract class JobStoreSupport implements JobStore, Constants {
} }
if (getUseDBLocks()) { if (getUseDBLocks()) {
if(getDriverDelegateClass() != null && getDriverDelegateClass().equals(MSSQLDelegate.class.getName())) { if (getDriverDelegateClass() != null && getDriverDelegateClass().equals(MSSQLDelegate.class.getName())) {
if(getSelectWithLockSQL() == null) { if (getSelectWithLockSQL() == null) {
String msSqlDflt = "SELECT * FROM {0}LOCKS WITH (UPDLOCK,ROWLOCK) WHERE " + COL_SCHEDULER_NAME + " = {1} AND LOCK_NAME = ?"; String msSqlDflt = "SELECT * FROM {0}LOCKS WITH (UPDLOCK,ROWLOCK) WHERE " + COL_SCHEDULER_NAME + " = {1} AND LOCK_NAME = ?";
getLog().info("Detected usage of MSSQLDelegate class - defaulting 'selectWithLockSQL' to '" + msSqlDflt + "'."); getLog().info("Detected usage of MSSQLDelegate class - defaulting 'selectWithLockSQL' to '" + msSqlDflt + "'.");
setSelectWithLockSQL(msSqlDflt); setSelectWithLockSQL(msSqlDflt);
@ -682,7 +681,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
if (isClustered()) { if (isClustered()) {
clusterManagementThread = new ClusterManager(); clusterManagementThread = new ClusterManager();
if(initializersLoader != null) if (initializersLoader != null)
clusterManagementThread.setContextClassLoader(initializersLoader); clusterManagementThread.setContextClassLoader(initializersLoader);
clusterManagementThread.initialize(); clusterManagementThread.initialize();
} else { } else {
@ -695,7 +694,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
} }
misfireHandler = new MisfireHandler(); misfireHandler = new MisfireHandler();
if(initializersLoader != null) if (initializersLoader != null)
misfireHandler.setContextClassLoader(initializersLoader); misfireHandler.setContextClassLoader(initializersLoader);
misfireHandler.initialize(); misfireHandler.initialize();
schedulerRunning = true; schedulerRunning = true;
@ -763,9 +762,9 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* (and potentially restored to a pool). * (and potentially restored to a pool).
*/ */
protected Connection getAttributeRestoringConnection(Connection conn) { protected Connection getAttributeRestoringConnection(Connection conn) {
return (Connection)Proxy.newProxyInstance( return (Connection) Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(), Thread.currentThread().getContextClassLoader(),
new Class[] { Connection.class }, new Class[]{Connection.class},
new AttributeRestoringConnectionInvocationHandler(conn)); new AttributeRestoringConnectionInvocationHandler(conn));
} }
@ -799,13 +798,16 @@ public abstract class JobStoreSupport implements JobStore, Constants {
conn.setAutoCommit(false); conn.setAutoCommit(false);
} }
if(isTxIsolationLevelSerializable()) { if (isTxIsolationLevelSerializable()) {
conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
} }
} catch (SQLException sqle) { } catch (SQLException sqle) {
getLog().warn("Failed to override connection auto commit/transaction isolation.", sqle); getLog().warn("Failed to override connection auto commit/transaction isolation.", sqle);
} catch (Throwable e) { } catch (Throwable e) {
try { conn.close(); } catch(Throwable ignored) {} try {
conn.close();
} catch (Throwable ignored) {
}
throw new JobPersistenceException( throw new JobPersistenceException(
"Failure setting up connection.", e); "Failure setting up connection.", e);
@ -846,8 +848,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* appropriate. * appropriate.
* </p> * </p>
* *
* @throws JobPersistenceException * @throws JobPersistenceException if jobs could not be recovered
* if jobs could not be recovered
*/ */
protected void recoverJobs(Connection conn) throws JobPersistenceException { protected void recoverJobs(Connection conn) throws JobPersistenceException {
try { try {
@ -874,18 +875,22 @@ public abstract class JobStoreSupport implements JobStore, Constants {
+ recoveringJobTriggers.size() + recoveringJobTriggers.size()
+ " jobs that were in-progress at the time of the last shut-down."); + " jobs that were in-progress at the time of the last shut-down.");
for (OperableTrigger recoveringJobTrigger: recoveringJobTriggers) { for (OperableTrigger recoveringJobTrigger : recoveringJobTriggers) {
try {
if (jobExists(conn, recoveringJobTrigger.getJobKey())) { if (jobExists(conn, recoveringJobTrigger.getJobKey())) {
recoveringJobTrigger.computeFirstFireTime(null); recoveringJobTrigger.computeFirstFireTime(null);
storeTrigger(conn, recoveringJobTrigger, null, false, storeTrigger(conn, recoveringJobTrigger, null, false,
STATE_WAITING, false, true); STATE_WAITING, false, true);
} }
} catch (JobPersistenceException e) {
getLog().error(e.getMessage());
}
} }
getLog().info("Recovery complete."); getLog().info("Recovery complete.");
// remove lingering 'complete' triggers... // remove lingering 'complete' triggers...
List<TriggerKey> cts = getDelegate().selectTriggersInState(conn, STATE_COMPLETE); List<TriggerKey> cts = getDelegate().selectTriggersInState(conn, STATE_COMPLETE);
for(TriggerKey ct: cts) { for (TriggerKey ct : cts) {
removeTrigger(conn, ct); removeTrigger(conn, ct);
} }
getLog().info( getLog().info(
@ -933,9 +938,11 @@ public abstract class JobStoreSupport implements JobStore, Constants {
public boolean hasMoreMisfiredTriggers() { public boolean hasMoreMisfiredTriggers() {
return _hasMoreMisfiredTriggers; return _hasMoreMisfiredTriggers;
} }
public int getProcessedMisfiredTriggerCount() { public int getProcessedMisfiredTriggerCount() {
return _processedMisfiredTriggerCount; return _processedMisfiredTriggerCount;
} }
public long getEarliestNewTime() { public long getEarliestNewTime() {
return _earliestNewTime; return _earliestNewTime;
} }
@ -974,7 +981,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
return RecoverMisfiredJobsResult.NO_OP; return RecoverMisfiredJobsResult.NO_OP;
} }
for (TriggerKey triggerKey: misfiredTriggers) { for (TriggerKey triggerKey : misfiredTriggers) {
OperableTrigger trig = OperableTrigger trig =
retrieveTrigger(conn, triggerKey); retrieveTrigger(conn, triggerKey);
@ -985,7 +992,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
doUpdateOfMisfiredTrigger(conn, trig, false, STATE_WAITING, recovering); doUpdateOfMisfiredTrigger(conn, trig, false, STATE_WAITING, recovering);
if(trig.getNextFireTime() != null && trig.getNextFireTime().getTime() < earliestNewTime) if (trig.getNextFireTime() != null && trig.getNextFireTime().getTime() < earliestNewTime)
earliestNewTime = trig.getNextFireTime().getTime(); earliestNewTime = trig.getNextFireTime().getTime();
} }
@ -1044,12 +1051,9 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* Store the given <code>{@link JobDetail}</code> and <code>{@link Trigger}</code>. * Store the given <code>{@link JobDetail}</code> and <code>{@link Trigger}</code>.
* </p> * </p>
* *
* @param newJob * @param newJob The <code>JobDetail</code> to be stored.
* The <code>JobDetail</code> to be stored. * @param newTrigger The <code>Trigger</code> to be stored.
* @param newTrigger * @throws ObjectAlreadyExistsException if a <code>Job</code> with the same name/group already
* The <code>Trigger</code> to be stored.
* @throws ObjectAlreadyExistsException
* if a <code>Job</code> with the same name/group already
* exists. * exists.
*/ */
public void storeJobAndTrigger(final JobDetail newJob, public void storeJobAndTrigger(final JobDetail newJob,
@ -1071,14 +1075,11 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* Store the given <code>{@link JobDetail}</code>. * Store the given <code>{@link JobDetail}</code>.
* </p> * </p>
* *
* @param newJob * @param newJob The <code>JobDetail</code> to be stored.
* The <code>JobDetail</code> to be stored. * @param replaceExisting If <code>true</code>, any <code>Job</code> existing in the
* @param replaceExisting
* If <code>true</code>, any <code>Job</code> existing in the
* <code>JobStore</code> with the same name & group should be * <code>JobStore</code> with the same name & group should be
* over-written. * over-written.
* @throws ObjectAlreadyExistsException * @throws ObjectAlreadyExistsException if a <code>Job</code> with the same name/group already
* if a <code>Job</code> with the same name/group already
* exists, and replaceExisting is set to false. * exists, and replaceExisting is set to false.
*/ */
public void storeJob(final JobDetail newJob, public void storeJob(final JobDetail newJob,
@ -1140,14 +1141,11 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* Store the given <code>{@link Trigger}</code>. * Store the given <code>{@link Trigger}</code>.
* </p> * </p>
* *
* @param newTrigger * @param newTrigger The <code>Trigger</code> to be stored.
* The <code>Trigger</code> to be stored. * @param replaceExisting If <code>true</code>, any <code>Trigger</code> existing in
* @param replaceExisting
* If <code>true</code>, any <code>Trigger</code> existing in
* the <code>JobStore</code> with the same name & group should * the <code>JobStore</code> with the same name & group should
* be over-written. * be over-written.
* @throws ObjectAlreadyExistsException * @throws ObjectAlreadyExistsException if a <code>Trigger</code> with the same name/group already
* if a <code>Trigger</code> with the same name/group already
* exists, and replaceExisting is set to false. * exists, and replaceExisting is set to false.
*/ */
public void storeTrigger(final OperableTrigger newTrigger, public void storeTrigger(final OperableTrigger newTrigger,
@ -1187,7 +1185,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
shouldBepaused = getDelegate().isTriggerGroupPaused( shouldBepaused = getDelegate().isTriggerGroupPaused(
conn, newTrigger.getKey().getGroup()); conn, newTrigger.getKey().getGroup());
if(!shouldBepaused) { if (!shouldBepaused) {
shouldBepaused = getDelegate().isTriggerGroupPaused(conn, shouldBepaused = getDelegate().isTriggerGroupPaused(conn,
ALL_GROUPS_PAUSED); ALL_GROUPS_PAUSED);
@ -1201,7 +1199,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
} }
} }
if(job == null) { if (job == null) {
job = retrieveJob(conn, newTrigger.getJobKey()); job = retrieveJob(conn, newTrigger.getJobKey());
} }
if (job == null) { if (job == null) {
@ -1271,7 +1269,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
try { try {
List<TriggerKey> jobTriggers = getDelegate().selectTriggerKeysForJob(conn, jobKey); List<TriggerKey> jobTriggers = getDelegate().selectTriggerKeysForJob(conn, jobKey);
for (TriggerKey jobTrigger: jobTriggers) { for (TriggerKey jobTrigger : jobTriggers) {
deleteTriggerAndChildren(conn, jobTrigger); deleteTriggerAndChildren(conn, jobTrigger);
} }
@ -1326,9 +1324,9 @@ public abstract class JobStoreSupport implements JobStore, Constants {
public void executeVoid(Connection conn) throws JobPersistenceException { public void executeVoid(Connection conn) throws JobPersistenceException {
// FUTURE_TODO: make this more efficient with a true bulk operation... // FUTURE_TODO: make this more efficient with a true bulk operation...
for(JobDetail job: triggersAndJobs.keySet()) { for (JobDetail job : triggersAndJobs.keySet()) {
storeJob(conn, job, replace); storeJob(conn, job, replace);
for(Trigger trigger: triggersAndJobs.get(job)) { for (Trigger trigger : triggersAndJobs.get(job)) {
storeTrigger(conn, (OperableTrigger) trigger, job, replace, storeTrigger(conn, (OperableTrigger) trigger, job, replace,
STATE_WAITING, false, false); STATE_WAITING, false, false);
} }
@ -1371,7 +1369,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* @return The desired <code>Job</code>, or null if there is no match. * @return The desired <code>Job</code>, or null if there is no match.
*/ */
public JobDetail retrieveJob(final JobKey jobKey) throws JobPersistenceException { public JobDetail retrieveJob(final JobKey jobKey) throws JobPersistenceException {
return (JobDetail)executeWithoutLock( // no locks necessary for read... return (JobDetail) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return retrieveJob(conn, jobKey); return retrieveJob(conn, jobKey);
@ -1516,7 +1514,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* match. * match.
*/ */
public OperableTrigger retrieveTrigger(final TriggerKey triggerKey) throws JobPersistenceException { public OperableTrigger retrieveTrigger(final TriggerKey triggerKey) throws JobPersistenceException {
return (OperableTrigger)executeWithoutLock( // no locks necessary for read... return (OperableTrigger) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return retrieveTrigger(conn, triggerKey); return retrieveTrigger(conn, triggerKey);
@ -1547,7 +1545,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* @see TriggerState#NONE * @see TriggerState#NONE
*/ */
public TriggerState getTriggerState(final TriggerKey triggerKey) throws JobPersistenceException { public TriggerState getTriggerState(final TriggerKey triggerKey) throws JobPersistenceException {
return (TriggerState)executeWithoutLock( // no locks necessary for read... return (TriggerState) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return getTriggerState(conn, triggerKey); return getTriggerState(conn, triggerKey);
@ -1601,16 +1599,12 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* Store the given <code>{@link Calendar}</code>. * Store the given <code>{@link Calendar}</code>.
* </p> * </p>
* *
* @param calName * @param calName The name of the calendar.
* The name of the calendar. * @param calendar The <code>Calendar</code> to be stored.
* @param calendar * @param replaceExisting If <code>true</code>, any <code>Calendar</code> existing
* The <code>Calendar</code> to be stored.
* @param replaceExisting
* If <code>true</code>, any <code>Calendar</code> existing
* in the <code>JobStore</code> with the same name & group * in the <code>JobStore</code> with the same name & group
* should be over-written. * should be over-written.
* @throws ObjectAlreadyExistsException * @throws ObjectAlreadyExistsException if a <code>Calendar</code> with the same name already
* if a <code>Calendar</code> with the same name already
* exists, and replaceExisting is set to false. * exists, and replaceExisting is set to false.
*/ */
public void storeCalendar(final String calName, public void storeCalendar(final String calName,
@ -1641,10 +1635,10 @@ public abstract class JobStoreSupport implements JobStore, Constants {
"Couldn't store calendar. Update failed."); "Couldn't store calendar. Update failed.");
} }
if(updateTriggers) { if (updateTriggers) {
List<OperableTrigger> trigs = getDelegate().selectTriggersForCalendar(conn, calName); List<OperableTrigger> trigs = getDelegate().selectTriggersForCalendar(conn, calName);
for(OperableTrigger trigger: trigs) { for (OperableTrigger trigger : trigs) {
trigger.updateWithNewCalendar(calendar, getMisfireThreshold()); trigger.updateWithNewCalendar(calendar, getMisfireThreshold());
storeTrigger(conn, trigger, null, true, STATE_WAITING, false, false); storeTrigger(conn, trigger, null, true, STATE_WAITING, false, false);
} }
@ -1667,7 +1661,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
throw new JobPersistenceException("Couldn't store calendar: " throw new JobPersistenceException("Couldn't store calendar: "
+ e.getMessage(), e); + e.getMessage(), e);
}catch (SQLException e) { } catch (SQLException e) {
throw new JobPersistenceException("Couldn't store calendar: " throw new JobPersistenceException("Couldn't store calendar: "
+ e.getMessage(), e); + e.getMessage(), e);
} }
@ -1695,6 +1689,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* <code>Trigger</code>s pointing to non-existent calendars, then a * <code>Trigger</code>s pointing to non-existent calendars, then a
* <code>JobPersistenceException</code> will be thrown.</p> * <code>JobPersistenceException</code> will be thrown.</p>
* * * *
*
* @param calName The name of the <code>Calendar</code> to be removed. * @param calName The name of the <code>Calendar</code> to be removed.
* @return <code>true</code> if a <code>Calendar</code> with the given name * @return <code>true</code> if a <code>Calendar</code> with the given name
* was found and removed from the store. * was found and removed from the store.
@ -1735,14 +1730,13 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* Retrieve the given <code>{@link Trigger}</code>. * Retrieve the given <code>{@link Trigger}</code>.
* </p> * </p>
* *
* @param calName * @param calName The name of the <code>Calendar</code> to be retrieved.
* The name of the <code>Calendar</code> to be retrieved.
* @return The desired <code>Calendar</code>, or null if there is no * @return The desired <code>Calendar</code>, or null if there is no
* match. * match.
*/ */
public Calendar retrieveCalendar(final String calName) public Calendar retrieveCalendar(final String calName)
throws JobPersistenceException { throws JobPersistenceException {
return (Calendar)executeWithoutLock( // no locks necessary for read... return (Calendar) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return retrieveCalendar(conn, calName); return retrieveCalendar(conn, calName);
@ -1871,7 +1865,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Set<JobKey> getJobKeys(final GroupMatcher<JobKey> matcher) public Set<JobKey> getJobKeys(final GroupMatcher<JobKey> matcher)
throws JobPersistenceException { throws JobPersistenceException {
return (Set<JobKey>)executeWithoutLock( // no locks necessary for read... return (Set<JobKey>) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return getJobNames(conn, matcher); return getJobNames(conn, matcher);
@ -1903,7 +1897,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* @throws JobPersistenceException * @throws JobPersistenceException
*/ */
public boolean checkExists(final JobKey jobKey) throws JobPersistenceException { public boolean checkExists(final JobKey jobKey) throws JobPersistenceException {
return (Boolean)executeWithoutLock( // no locks necessary for read... return (Boolean) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return checkExists(conn, jobKey); return checkExists(conn, jobKey);
@ -1929,7 +1923,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* @throws JobPersistenceException * @throws JobPersistenceException
*/ */
public boolean checkExists(final TriggerKey triggerKey) throws JobPersistenceException { public boolean checkExists(final TriggerKey triggerKey) throws JobPersistenceException {
return (Boolean)executeWithoutLock( // no locks necessary for read... return (Boolean) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return checkExists(conn, triggerKey); return checkExists(conn, triggerKey);
@ -1984,7 +1978,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Set<TriggerKey> getTriggerKeys(final GroupMatcher<TriggerKey> matcher) public Set<TriggerKey> getTriggerKeys(final GroupMatcher<TriggerKey> matcher)
throws JobPersistenceException { throws JobPersistenceException {
return (Set<TriggerKey>)executeWithoutLock( // no locks necessary for read... return (Set<TriggerKey>) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return getTriggerNames(conn, matcher); return getTriggerNames(conn, matcher);
@ -2022,7 +2016,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<String> getJobGroupNames() public List<String> getJobGroupNames()
throws JobPersistenceException { throws JobPersistenceException {
return (List<String>)executeWithoutLock( // no locks necessary for read... return (List<String>) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return getJobGroupNames(conn); return getJobGroupNames(conn);
@ -2059,7 +2053,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<String> getTriggerGroupNames() public List<String> getTriggerGroupNames()
throws JobPersistenceException { throws JobPersistenceException {
return (List<String>)executeWithoutLock( // no locks necessary for read... return (List<String>) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return getTriggerGroupNames(conn); return getTriggerGroupNames(conn);
@ -2095,7 +2089,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<String> getCalendarNames() public List<String> getCalendarNames()
throws JobPersistenceException { throws JobPersistenceException {
return (List<String>)executeWithoutLock( // no locks necessary for read... return (List<String>) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return getCalendarNames(conn); return getCalendarNames(conn);
@ -2124,7 +2118,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<OperableTrigger> getTriggersForJob(final JobKey jobKey) throws JobPersistenceException { public List<OperableTrigger> getTriggersForJob(final JobKey jobKey) throws JobPersistenceException {
return (List<OperableTrigger>)executeWithoutLock( // no locks necessary for read... return (List<OperableTrigger>) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return getTriggersForJob(conn, jobKey); return getTriggersForJob(conn, jobKey);
@ -2209,7 +2203,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
new VoidTransactionCallback() { new VoidTransactionCallback() {
public void executeVoid(Connection conn) throws JobPersistenceException { public void executeVoid(Connection conn) throws JobPersistenceException {
List<OperableTrigger> triggers = getTriggersForJob(conn, jobKey); List<OperableTrigger> triggers = getTriggersForJob(conn, jobKey);
for (OperableTrigger trigger: triggers) { for (OperableTrigger trigger : triggers) {
pauseTrigger(conn, trigger.getKey()); pauseTrigger(conn, trigger.getKey());
} }
} }
@ -2335,7 +2329,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
} }
boolean blocked = false; boolean blocked = false;
if(STATE_PAUSED_BLOCKED.equals(status.getStatus())) { if (STATE_PAUSED_BLOCKED.equals(status.getStatus())) {
blocked = true; blocked = true;
} }
@ -2348,8 +2342,8 @@ public abstract class JobStoreSupport implements JobStore, Constants {
newState, true); newState, true);
} }
if(!misfired) { if (!misfired) {
if(blocked) { if (blocked) {
getDelegate().updateTriggerStateFromOtherState(conn, getDelegate().updateTriggerStateFromOtherState(conn,
key, newState, STATE_PAUSED_BLOCKED); key, newState, STATE_PAUSED_BLOCKED);
} else { } else {
@ -2384,7 +2378,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
new VoidTransactionCallback() { new VoidTransactionCallback() {
public void executeVoid(Connection conn) throws JobPersistenceException { public void executeVoid(Connection conn) throws JobPersistenceException {
List<OperableTrigger> triggers = getTriggersForJob(conn, jobKey); List<OperableTrigger> triggers = getTriggersForJob(conn, jobKey);
for (OperableTrigger trigger: triggers) { for (OperableTrigger trigger : triggers) {
resumeTrigger(conn, trigger.getKey()); resumeTrigger(conn, trigger.getKey());
} }
} }
@ -2415,9 +2409,9 @@ public abstract class JobStoreSupport implements JobStore, Constants {
Set<JobKey> jobKeys = getJobNames(conn, matcher); Set<JobKey> jobKeys = getJobNames(conn, matcher);
Set<String> groupNames = new HashSet<String>(); Set<String> groupNames = new HashSet<String>();
for (JobKey jobKey: jobKeys) { for (JobKey jobKey : jobKeys) {
List<OperableTrigger> triggers = getTriggersForJob(conn, jobKey); List<OperableTrigger> triggers = getTriggersForJob(conn, jobKey);
for (OperableTrigger trigger: triggers) { for (OperableTrigger trigger : triggers) {
resumeTrigger(conn, trigger.getKey()); resumeTrigger(conn, trigger.getKey());
} }
groupNames.add(jobKey.getGroup()); groupNames.add(jobKey.getGroup());
@ -2492,7 +2486,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Set<String> getPausedTriggerGroups() public Set<String> getPausedTriggerGroups()
throws JobPersistenceException { throws JobPersistenceException {
return (Set<String>)executeWithoutLock( // no locks necessary for read... return (Set<String>) executeWithoutLock( // no locks necessary for read...
new TransactionCallback() { new TransactionCallback() {
public Object execute(Connection conn) throws JobPersistenceException { public Object execute(Connection conn) throws JobPersistenceException {
return getPausedTriggerGroups(conn); return getPausedTriggerGroups(conn);
@ -2569,7 +2563,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
Set<TriggerKey> keys = getDelegate().selectTriggersInGroup(conn, Set<TriggerKey> keys = getDelegate().selectTriggersInGroup(conn,
matcher); matcher);
for (TriggerKey key: keys) { for (TriggerKey key : keys) {
resumeTrigger(conn, key); resumeTrigger(conn, key);
groups.add(key.getGroup()); groups.add(key.getGroup());
} }
@ -2658,7 +2652,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
List<String> names = getTriggerGroupNames(conn); List<String> names = getTriggerGroupNames(conn);
for (String name: names) { for (String name : names) {
pauseTriggerGroup(conn, GroupMatcher.triggerGroupEquals(name)); pauseTriggerGroup(conn, GroupMatcher.triggerGroupEquals(name));
} }
@ -2717,7 +2711,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
List<String> names = getTriggerGroupNames(conn); List<String> names = getTriggerGroupNames(conn);
for (String name: names) { for (String name : names) {
resumeTriggerGroup(conn, GroupMatcher.triggerGroupEquals(name)); resumeTriggerGroup(conn, GroupMatcher.triggerGroupEquals(name));
} }
@ -2748,7 +2742,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
throws JobPersistenceException { throws JobPersistenceException {
String lockName; String lockName;
if(isAcquireTriggersWithinLock() || maxCount > 1) { if (isAcquireTriggersWithinLock() || maxCount > 1) {
lockName = LOCK_TRIGGER_ACCESS; lockName = LOCK_TRIGGER_ACCESS;
} else { } else {
lockName = null; lockName = null;
@ -2793,7 +2787,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
final int MAX_DO_LOOP_RETRY = 3; final int MAX_DO_LOOP_RETRY = 3;
int currentLoopCount = 0; int currentLoopCount = 0;
do { do {
currentLoopCount ++; currentLoopCount++;
try { try {
List<TriggerKey> keys = getDelegate().selectTriggerToAcquire(conn, noLaterThan + timeWindow, getMisfireTime(), maxCount); List<TriggerKey> keys = getDelegate().selectTriggerToAcquire(conn, noLaterThan + timeWindow, getMisfireTime(), maxCount);
@ -2803,10 +2797,10 @@ public abstract class JobStoreSupport implements JobStore, Constants {
long batchEnd = noLaterThan; long batchEnd = noLaterThan;
for(TriggerKey triggerKey: keys) { for (TriggerKey triggerKey : keys) {
// If our trigger is no longer available, try a new one. // If our trigger is no longer available, try a new one.
OperableTrigger nextTrigger = retrieveTrigger(conn, triggerKey); OperableTrigger nextTrigger = retrieveTrigger(conn, triggerKey);
if(nextTrigger == null) { if (nextTrigger == null) {
continue; // next trigger continue; // next trigger
} }
@ -2846,7 +2840,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
nextTrigger.setFireInstanceId(getFiredTriggerRecordId()); nextTrigger.setFireInstanceId(getFiredTriggerRecordId());
getDelegate().insertFiredTrigger(conn, nextTrigger, STATE_ACQUIRED, null); getDelegate().insertFiredTrigger(conn, nextTrigger, STATE_ACQUIRED, null);
if(acquiredTriggers.isEmpty()) { if (acquiredTriggers.isEmpty()) {
batchEnd = Math.max(nextTrigger.getNextFireTime().getTime(), System.currentTimeMillis()) + timeWindow; batchEnd = Math.max(nextTrigger.getNextFireTime().getTime(), System.currentTimeMillis()) + timeWindow;
} }
acquiredTriggers.add(nextTrigger); acquiredTriggers.add(nextTrigger);
@ -2854,7 +2848,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
// if we didn't end up with any trigger to fire from that first // if we didn't end up with any trigger to fire from that first
// batch, try again for another batch. We allow with a max retry count. // batch, try again for another batch. We allow with a max retry count.
if(acquiredTriggers.size() == 0 && currentLoopCount < MAX_DO_LOOP_RETRY) { if (acquiredTriggers.size() == 0 && currentLoopCount < MAX_DO_LOOP_RETRY) {
continue; continue;
} }
@ -2925,7 +2919,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
result = new TriggerFiredResult(bundle); result = new TriggerFiredResult(bundle);
} catch (JobPersistenceException jpe) { } catch (JobPersistenceException jpe) {
result = new TriggerFiredResult(jpe); result = new TriggerFiredResult(jpe);
} catch(RuntimeException re) { } catch (RuntimeException re) {
result = new TriggerFiredResult(re); result = new TriggerFiredResult(re);
} }
results.add(result); results.add(result);
@ -2978,7 +2972,9 @@ public abstract class JobStoreSupport implements JobStore, Constants {
try { try {
job = retrieveJob(conn, trigger.getJobKey()); job = retrieveJob(conn, trigger.getJobKey());
if (job == null) { return null; } if (job == null) {
return null;
}
} catch (JobPersistenceException jpe) { } catch (JobPersistenceException jpe) {
try { try {
getLog().error("Error retrieving job, setting trigger state to ERROR.", jpe); getLog().error("Error retrieving job, setting trigger state to ERROR.", jpe);
@ -2992,7 +2988,9 @@ public abstract class JobStoreSupport implements JobStore, Constants {
if (trigger.getCalendarName() != null) { if (trigger.getCalendarName() != null) {
cal = retrieveCalendar(conn, trigger.getCalendarName()); cal = retrieveCalendar(conn, trigger.getCalendarName());
if (cal == null) { return null; } if (cal == null) {
return null;
}
} }
try { try {
@ -3056,7 +3054,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
LOCK_TRIGGER_ACCESS, LOCK_TRIGGER_ACCESS,
new VoidTransactionCallback() { new VoidTransactionCallback() {
public void executeVoid(Connection conn) throws JobPersistenceException { public void executeVoid(Connection conn) throws JobPersistenceException {
triggeredJobComplete(conn, trigger, jobDetail,triggerInstCode); triggeredJobComplete(conn, trigger, jobDetail, triggerInstCode);
} }
}); });
} }
@ -3066,15 +3064,15 @@ public abstract class JobStoreSupport implements JobStore, Constants {
CompletedExecutionInstruction triggerInstCode) throws JobPersistenceException { CompletedExecutionInstruction triggerInstCode) throws JobPersistenceException {
try { try {
if (triggerInstCode == CompletedExecutionInstruction.DELETE_TRIGGER) { if (triggerInstCode == CompletedExecutionInstruction.DELETE_TRIGGER) {
if(trigger.getNextFireTime() == null) { if (trigger.getNextFireTime() == null) {
// double check for possible reschedule within job // double check for possible reschedule within job
// execution, which would cancel the need to delete... // execution, which would cancel the need to delete...
TriggerStatus stat = getDelegate().selectTriggerStatus( TriggerStatus stat = getDelegate().selectTriggerStatus(
conn, trigger.getKey()); conn, trigger.getKey());
if(stat != null && stat.getNextFireTime() == null) { if (stat != null && stat.getNextFireTime() == null) {
removeTrigger(conn, trigger.getKey()); removeTrigger(conn, trigger.getKey());
} }
} else{ } else {
removeTrigger(conn, trigger.getKey()); removeTrigger(conn, trigger.getKey());
signalSchedulingChangeOnTxCompletion(0L); signalSchedulingChangeOnTxCompletion(0L);
} }
@ -3142,10 +3140,10 @@ public abstract class JobStoreSupport implements JobStore, Constants {
* </p> * </p>
*/ */
protected DriverDelegate getDelegate() throws NoSuchDelegateException { protected DriverDelegate getDelegate() throws NoSuchDelegateException {
synchronized(this) { synchronized (this) {
if(null == delegate) { if (null == delegate) {
try { try {
if(delegateClassName != null) { if (delegateClassName != null) {
delegateClass = getClassLoadHelper().loadClass(delegateClassName, DriverDelegate.class); delegateClass = getClassLoadHelper().loadClass(delegateClassName, DriverDelegate.class);
} }
@ -3225,12 +3223,13 @@ public abstract class JobStoreSupport implements JobStore, Constants {
} }
protected ThreadLocal<Long> sigChangeForTxCompletion = new ThreadLocal<Long>(); protected ThreadLocal<Long> sigChangeForTxCompletion = new ThreadLocal<Long>();
protected void signalSchedulingChangeOnTxCompletion(long candidateNewNextFireTime) { protected void signalSchedulingChangeOnTxCompletion(long candidateNewNextFireTime) {
Long sigTime = sigChangeForTxCompletion.get(); Long sigTime = sigChangeForTxCompletion.get();
if(sigTime == null && candidateNewNextFireTime >= 0L) if (sigTime == null && candidateNewNextFireTime >= 0L)
sigChangeForTxCompletion.set(candidateNewNextFireTime); sigChangeForTxCompletion.set(candidateNewNextFireTime);
else { else {
if(sigTime == null || candidateNewNextFireTime < sigTime) if (sigTime == null || candidateNewNextFireTime < sigTime)
sigChangeForTxCompletion.set(candidateNewNextFireTime); sigChangeForTxCompletion.set(candidateNewNextFireTime);
} }
} }
@ -3322,7 +3321,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
List<SchedulerStateRecord> states = getDelegate().selectSchedulerStateRecords(conn, null); List<SchedulerStateRecord> states = getDelegate().selectSchedulerStateRecords(conn, null);
for(SchedulerStateRecord rec: states) { for (SchedulerStateRecord rec : states) {
// find own record... // find own record...
if (rec.getSchedulerInstanceId().equals(getInstanceId())) { if (rec.getSchedulerInstanceId().equals(getInstanceId())) {
@ -3376,12 +3375,12 @@ public abstract class JobStoreSupport implements JobStore, Constants {
Set<String> allFiredTriggerInstanceNames = getDelegate().selectFiredTriggerInstanceNames(conn); Set<String> allFiredTriggerInstanceNames = getDelegate().selectFiredTriggerInstanceNames(conn);
if (!allFiredTriggerInstanceNames.isEmpty()) { if (!allFiredTriggerInstanceNames.isEmpty()) {
for (SchedulerStateRecord rec: schedulerStateRecords) { for (SchedulerStateRecord rec : schedulerStateRecords) {
allFiredTriggerInstanceNames.remove(rec.getSchedulerInstanceId()); allFiredTriggerInstanceNames.remove(rec.getSchedulerInstanceId());
} }
for (String inst: allFiredTriggerInstanceNames) { for (String inst : allFiredTriggerInstanceNames) {
SchedulerStateRecord orphanedInstance = new SchedulerStateRecord(); SchedulerStateRecord orphanedInstance = new SchedulerStateRecord();
orphanedInstance.setSchedulerInstanceId(inst); orphanedInstance.setSchedulerInstanceId(inst);
@ -3413,7 +3412,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
// check in... // check in...
lastCheckin = System.currentTimeMillis(); lastCheckin = System.currentTimeMillis();
if(getDelegate().updateSchedulerState(conn, getInstanceId(), lastCheckin) == 0) { if (getDelegate().updateSchedulerState(conn, getInstanceId(), lastCheckin) == 0) {
getDelegate().insertSchedulerState(conn, getInstanceId(), getDelegate().insertSchedulerState(conn, getInstanceId(),
lastCheckin, getClusterCheckinInterval()); lastCheckin, getClusterCheckinInterval());
} }
@ -3605,13 +3604,13 @@ public abstract class JobStoreSupport implements JobStore, Constants {
protected void cleanupConnection(Connection conn) { protected void cleanupConnection(Connection conn) {
if (conn != null) { if (conn != null) {
if (conn instanceof Proxy) { if (conn instanceof Proxy) {
Proxy connProxy = (Proxy)conn; Proxy connProxy = (Proxy) conn;
InvocationHandler invocationHandler = InvocationHandler invocationHandler =
Proxy.getInvocationHandler(connProxy); Proxy.getInvocationHandler(connProxy);
if (invocationHandler instanceof AttributeRestoringConnectionInvocationHandler) { if (invocationHandler instanceof AttributeRestoringConnectionInvocationHandler) {
AttributeRestoringConnectionInvocationHandler connHandler = AttributeRestoringConnectionInvocationHandler connHandler =
(AttributeRestoringConnectionInvocationHandler)invocationHandler; (AttributeRestoringConnectionInvocationHandler) invocationHandler;
connHandler.restoreOriginalAtributes(); connHandler.restoreOriginalAtributes();
closeConnection(connHandler.getWrappedConnection()); closeConnection(connHandler.getWrappedConnection());
@ -3666,7 +3665,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
conn.rollback(); conn.rollback();
} catch (SQLException e) { } catch (SQLException e) {
getLog().error( getLog().error(
"Couldn't rollback jdbc connection. "+e.getMessage(), e); "Couldn't rollback jdbc connection. " + e.getMessage(), e);
} }
} }
} }
@ -3686,7 +3685,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
conn.commit(); conn.commit();
} catch (SQLException e) { } catch (SQLException e) {
throw new JobPersistenceException( throw new JobPersistenceException(
"Couldn't commit jdbc connection. "+e.getMessage(), e); "Couldn't commit jdbc connection. " + e.getMessage(), e);
} }
} }
} }
@ -3757,7 +3756,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
try { try {
return executeInNonManagedTXLock(lockName, txCallback, null); return executeInNonManagedTXLock(lockName, txCallback, null);
} catch (JobPersistenceException jpe) { } catch (JobPersistenceException jpe) {
if(retry % 4 == 0) { if (retry % 4 == 0) {
schedSignaler.notifySchedulerListenersError("An error occurred while " + txCallback, jpe); schedSignaler.notifySchedulerListenersError("An error occurred while " + txCallback, jpe);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
@ -3816,7 +3815,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
} }
Long sigTime = clearAndGetSignalSchedulingChangeOnTxCompletion(); Long sigTime = clearAndGetSignalSchedulingChangeOnTxCompletion();
if(sigTime != null && sigTime >= 0) { if (sigTime != null && sigTime >= 0) {
signalSchedulingChangeImmediately(sigTime); signalSchedulingChangeImmediately(sigTime);
} }
@ -3876,7 +3875,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
numFails = 0; numFails = 0;
getLog().debug("ClusterManager: Check-in complete."); getLog().debug("ClusterManager: Check-in complete.");
} catch (Exception e) { } catch (Exception e) {
if(numFails % 4 == 0) { if (numFails % 4 == 0) {
getLog().error( getLog().error(
"ClusterManager: Error managing cluster: " "ClusterManager: Error managing cluster: "
+ e.getMessage(), e); + e.getMessage(), e);
@ -3898,7 +3897,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
timeToSleep = 100L; timeToSleep = 100L;
} }
if(numFails > 0) { if (numFails > 0) {
timeToSleep = Math.max(getDbRetryInterval(), timeToSleep); timeToSleep = Math.max(getDbRetryInterval(), timeToSleep);
} }
@ -3952,7 +3951,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
numFails = 0; numFails = 0;
return res; return res;
} catch (Exception e) { } catch (Exception e) {
if(numFails % 4 == 0) { if (numFails % 4 == 0) {
getLog().error( getLog().error(
"MisfireHandler: Error handling misfires: " "MisfireHandler: Error handling misfires: "
+ e.getMessage(), e); + e.getMessage(), e);
@ -3983,7 +3982,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
timeToSleep = 50l; timeToSleep = 50l;
} }
if(numFails > 0) { if (numFails > 0) {
timeToSleep = Math.max(getDbRetryInterval(), timeToSleep); timeToSleep = Math.max(getDbRetryInterval(), timeToSleep);
} }
} }

Loading…
Cancel
Save