You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by gk...@apache.org on 2022/08/18 09:24:59 UTC
[turbine-core] branch trunk updated: Close the time gap between fetching the job in the housekeeping thread and actually running it by first peek (queue.first null safe check), that is if a job is in the queue. Fox to allow TurbineNonPersistentSchedulerServiceTest succeed job id lookup.
This is an automated email from the ASF dual-hosted git repository.
gk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/turbine-core.git
The following commit(s) were added to refs/heads/trunk by this push:
new 02de93eb Close the time gap between fetching the job in the housekeeping thread and actually running it by first peek (queue.first null safe check), that is if a job is in the queue. Fox to allow TurbineNonPersistentSchedulerServiceTest succeed job id lookup.
02de93eb is described below
commit 02de93eb3475b09f9e1f27e67bd3be1c74b80dbc
Author: Georg Kallidis <gk...@apache.org>
AuthorDate: Thu Aug 18 11:13:07 2022 +0200
Close the time gap between fetching the job in the housekeeping thread and actually running it by first peek (queue.first null safe check), that is if a job is in the queue. Fox to allow TurbineNonPersistentSchedulerServiceTest succeed job id lookup.
---
.../schedule/AbstractSchedulerService.java | 3 ++-
.../apache/turbine/services/schedule/JobQueue.java | 29 +++++++++++++++++-----
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/src/java/org/apache/turbine/services/schedule/AbstractSchedulerService.java b/src/java/org/apache/turbine/services/schedule/AbstractSchedulerService.java
index 4729a3d7..1f7a191b 100644
--- a/src/java/org/apache/turbine/services/schedule/AbstractSchedulerService.java
+++ b/src/java/org/apache/turbine/services/schedule/AbstractSchedulerService.java
@@ -288,7 +288,8 @@ public abstract class AbstractSchedulerService extends TurbineBaseService implem
while (!Thread.interrupted())
{
// Grab the next job off the queue.
- JobEntry je = scheduleQueue.getNext();
+ //JobEntry je = scheduleQueue.getNext();
+ JobEntry je = scheduleQueue.getFirst();
if (je == null)
{
diff --git a/src/java/org/apache/turbine/services/schedule/JobQueue.java b/src/java/org/apache/turbine/services/schedule/JobQueue.java
index dacd064a..47a5697d 100644
--- a/src/java/org/apache/turbine/services/schedule/JobQueue.java
+++ b/src/java/org/apache/turbine/services/schedule/JobQueue.java
@@ -58,24 +58,41 @@ public class JobQueue<J extends JobEntry>
{
return queue.pollFirst();
}
+
+ /**
+ * Return the next job of the top of the queue or <code>null</code> if
+ * there are no jobs in the queue.
+ *
+ * @return The next job in the queue.
+ */
+ public J getFirst()
+ {
+ return !queue.isEmpty()? queue.first(): null;
+ }
/**
* Return a specific job.
*
- * @param je The JobEntry we are looking for.
+ * @param je The JobEntry we are looking for. Falls back to check job id, if job was not found.
* @return A JobEntry.
*/
public J getJob(J je)
{
if (je != null)
{
- J job = queue.floor(je);
- if (je.equals(job))
+ J job = queue.floor(je);
+ if (je.equals(job))
+ {
+ return job;
+ }
+ for (J jobEntry : list())
{
- return job;
- }
+ if (jobEntry.getJobId() == je.getJobId())
+ {
+ return jobEntry;
+ }
+ }
}
-
return null;
}