This function, when called, will do the same tasks that are done periodically in the job queue anyway: the status of all jobs considered running is verified and some jobs are scheduled, should this be possible.
This will allow to react quicker to events indicating that a burst of untracked jobs has finished. Signed-off-by: Klaus Aehlig <[email protected]> --- src/Ganeti/JQScheduler.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Ganeti/JQScheduler.hs b/src/Ganeti/JQScheduler.hs index 186225b..127bace 100644 --- a/src/Ganeti/JQScheduler.hs +++ b/src/Ganeti/JQScheduler.hs @@ -44,6 +44,7 @@ module Ganeti.JQScheduler , dequeueJob , setJobPriority , cleanupIfDead + , updateStatusAndScheduleSomeJobs , configChangeNeedsRescheduling ) where @@ -472,11 +473,9 @@ cleanupIfDead state jid = do let jobWS = find ((==) jid . qjId . jJob) $ qRunning jobs maybe (return True) (checkForDeath state) jobWS --- | Time-based watcher for updating the job queue. -onTimeWatcher :: JQStatus -> IO () -onTimeWatcher qstate = forever $ do - threadDelay watchInterval - logDebug "Job queue watcher timer fired" +-- | Force the queue to check the state of all jobs. +updateStatusAndScheduleSomeJobs :: JQStatus -> IO () +updateStatusAndScheduleSomeJobs qstate = do jobs <- readIORef (jqJobs qstate) mapM_ (checkForDeath qstate) $ qRunning jobs jobs' <- readIORef (jqJobs qstate) @@ -485,6 +484,13 @@ onTimeWatcher qstate = forever $ do jobs'' <- readIORef (jqJobs qstate) logInfo $ showQueue jobs'' scheduleSomeJobs qstate + +-- | Time-based watcher for updating the job queue. +onTimeWatcher :: JQStatus -> IO () +onTimeWatcher qstate = forever $ do + threadDelay watchInterval + logDebug "Job queue watcher timer fired" + updateStatusAndScheduleSomeJobs qstate logDebug "Job queue watcher cycle finished" -- | Read a single, non-archived, job, specified by its id, from disk. -- 2.2.0.rc0.207.ga3a616c
