From 2ec46c0d2aba07be19ffaef92f44751f7ea1954b Mon Sep 17 00:00:00 2001 From: charile_Lu Date: Fri, 14 Aug 2020 16:49:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?DEC-14382=20=E4=BF=AE=E6=94=B9=E7=9B=B8?= =?UTF-8?q?=E5=85=B3sql=E4=BB=A5=E5=8F=8A=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96BI=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E5=BB=B6?= =?UTF-8?q?=E8=BF=9F=E7=8E=B0=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/jdbcjobstore/DriverDelegate.java | 2 +- .../impl/jdbcjobstore/JobStoreSupport.java | 28 ++++++++----------- .../impl/jdbcjobstore/StdJDBCConstants.java | 4 +-- .../impl/jdbcjobstore/StdJDBCDelegate.java | 2 +- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/DriverDelegate.java b/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/DriverDelegate.java index d449b2428..0bd04c457 100644 --- a/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/DriverDelegate.java +++ b/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/DriverDelegate.java @@ -972,7 +972,7 @@ public interface DriverDelegate { public List selectTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount) throws SQLException; - List selectAppointTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount, String appointId); + List selectAppointOrNonTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount, String appointId); /** *

diff --git a/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/JobStoreSupport.java b/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/JobStoreSupport.java index a6e451966..a140dfe4f 100644 --- a/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/JobStoreSupport.java +++ b/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/JobStoreSupport.java @@ -673,11 +673,11 @@ public abstract class JobStoreSupport implements JobStore, Constants { this.schedSignaler = signaler; - // If the user hasn't specified an explicit lock handler, then + // If the user hasn't specified an explicit lock handler, then // choose one based on CMT/Clustered/UseDBLocks. if (getLockHandler() == null) { - // If the user hasn't specified an explicit lock handler, + // If the user hasn't specified an explicit lock handler, // then we *must* use DB locks with clustering if (isClustered()) { setUseDBLocks(true); @@ -987,8 +987,8 @@ public abstract class JobStoreSupport implements JobStore, Constants { List misfiredTriggers = new LinkedList(); long earliestNewTime = Long.MAX_VALUE; - // We must still look for the MISFIRED state in case triggers were left - // in this state when upgrading to this version that does not support it. + // We must still look for the MISFIRED state in case triggers were left + // in this state when upgrading to this version that does not support it. boolean hasMoreMisfiredTriggers = getDelegate().hasMisfiredTriggersInState( conn, STATE_WAITING, getMisfireTime(), @@ -2835,12 +2835,10 @@ public abstract class JobStoreSupport implements JobStore, Constants { currentLoopCount++; try { long misfireTime = getMisfireTime(); - List waitingKeys = getDelegate().selectTriggerToAcquire(conn, noLaterThan + timeWindow, misfireTime, maxCount); - List appointKeys = getDelegate().selectAppointTriggerToAcquire(conn, noLaterThan + timeWindow, misfireTime, maxCount, this.currentId); + List appointKeys = getDelegate().selectAppointOrNonTriggerToAcquire(conn, noLaterThan + timeWindow, misfireTime, maxCount, this.currentId); List allKeys = new ArrayList(); Set keyIds = new HashSet(); - mergeKeys(allKeys, keyIds, waitingKeys); mergeKeys(allKeys, keyIds, appointKeys); // No trigger is ready to fire yet. @@ -3117,7 +3115,7 @@ public abstract class JobStoreSupport implements JobStore, Constants { try { if (triggerInstCode == CompletedExecutionInstruction.DELETE_TRIGGER) { 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... TriggerStatus stat = getDelegate().selectTriggerStatus( conn, trigger.getKey()); @@ -3236,7 +3234,7 @@ public abstract class JobStoreSupport implements JobStore, Constants { try { RecoverMisfiredJobsResult result = RecoverMisfiredJobsResult.NO_OP; - // Before we make the potentially expensive call to acquire the + // Before we make the potentially expensive call to acquire the // trigger lock, peek ahead to see if it is likely we would find // misfired triggers requiring recovery. int misfireCount = (getDoubleCheckLockMisfireHandler()) ? @@ -3311,8 +3309,8 @@ public abstract class JobStoreSupport implements JobStore, Constants { Connection conn = getNonManagedTXConnection(); try { - // Other than the first time, always checkin first to make sure there is - // work to be done before we acquire the lock (since that is expensive, + // Other than the first time, always checkin first to make sure there is + // work to be done before we acquire the lock (since that is expensive, // and is almost never necessary). This must be done in a separate // transaction to prevent a deadlock under recovery conditions. List failedRecords = null; @@ -3325,7 +3323,7 @@ public abstract class JobStoreSupport implements JobStore, Constants { getLockHandler().obtainLock(conn, LOCK_STATE_ACCESS); transStateOwner = true; - // Now that we own the lock, make sure we still have work to do. + // Now that we own the lock, make sure we still have work to do. // The first time through, we also need to make sure we update/create our state record failedRecords = (firstCheckIn) ? clusterCheckIn(conn) : findFailedInstances(conn); @@ -3838,7 +3836,7 @@ public abstract class JobStoreSupport implements JobStore, Constants { Connection conn = null; try { if (lockName != null) { - // If we aren't using db locks, then delay getting DB connection + // If we aren't using db locks, then delay getting DB connection // until after acquiring the lock since it isn't needed. if (getLockHandler().requiresConnection()) { conn = getNonManagedTXConnection(); @@ -4047,6 +4045,4 @@ public abstract class JobStoreSupport implements JobStore, Constants { } } } -} - -// EOF +} \ No newline at end of file diff --git a/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCConstants.java b/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCConstants.java index 56c85c477..b95eba9fb 100644 --- a/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCConstants.java +++ b/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCConstants.java @@ -541,12 +541,12 @@ public interface StdJDBCConstants extends Constants { + "AND (" + COL_MISFIRE_INSTRUCTION + " = -1 OR (" + COL_MISFIRE_INSTRUCTION + " != -1 AND " + COL_NEXT_FIRE_TIME + " >= ?)) " + "ORDER BY " + COL_NEXT_FIRE_TIME + " ASC, " + COL_PRIORITY + " DESC"; - String SELECT_NEXT_APPOINT_TRIGGER_TO_ACQUIRE = "SELECT " + String SELECT_NEXT_APPOINT_OR_NON_TRIGGER_TO_ACQUIRE = "SELECT " + COL_TRIGGER_NAME + ", " + COL_TRIGGER_GROUP + ", " + COL_NEXT_FIRE_TIME + ", " + COL_PRIORITY + " FROM " + TABLE_PREFIX_SUBST + TABLE_TRIGGERS + " WHERE " + COL_SCHEDULER_NAME + " = " + SCHED_NAME_SUBST - + " AND " + COL_APPOINT_ID + " = ?" + + " AND (" + COL_APPOINT_ID + " = ? OR "+ COL_APPOINT_ID + " IS NULL)" + " AND " + COL_TRIGGER_STATE + " = ? AND " + COL_NEXT_FIRE_TIME + " <= ? " + "AND (" + COL_MISFIRE_INSTRUCTION + " = -1 OR (" + COL_MISFIRE_INSTRUCTION + " != -1 AND " + COL_NEXT_FIRE_TIME + " >= ?)) " + "ORDER BY " + COL_NEXT_FIRE_TIME + " ASC, " + COL_PRIORITY + " DESC"; diff --git a/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCDelegate.java b/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCDelegate.java index 73fc912ad..f01f2539f 100644 --- a/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCDelegate.java +++ b/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCDelegate.java @@ -2661,7 +2661,7 @@ public class StdJDBCDelegate implements DriverDelegate, StdJDBCConstants { ResultSet rs = null; List nextTriggers = new LinkedList(); try { - ps = conn.prepareStatement(rtp(SELECT_NEXT_APPOINT_TRIGGER_TO_ACQUIRE)); + ps = conn.prepareStatement(rtp(SELECT_NEXT_APPOINT_OR_NON_TRIGGER_TO_ACQUIRE)); if (maxCount < 1) maxCount = 1; From 1f5a857bec5762d0bb42c947f7d9e9256871ca04 Mon Sep 17 00:00:00 2001 From: charile_Lu Date: Fri, 14 Aug 2020 17:09:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?DEC-14382=20=E4=BF=AE=E6=94=B9=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third/v2/org/quartz/impl/jdbcjobstore/StdJDBCDelegate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCDelegate.java b/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCDelegate.java index f01f2539f..95d5f203e 100644 --- a/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCDelegate.java +++ b/fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCDelegate.java @@ -2656,7 +2656,7 @@ public class StdJDBCDelegate implements DriverDelegate, StdJDBCConstants { } } - public List selectAppointTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount, String appointId) { + public List selectAppointOrNonTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount, String appointId) { PreparedStatement ps = null; ResultSet rs = null; List nextTriggers = new LinkedList();