Safe HaskellSafe-Infered



Implementation of a reader for the job queue.



data JQStatus Source

Representation of the job queue

We keep two lists of jobs (together with information about the last fstat result observed): the jobs that are enqueued, but not yet handed over for execution, and the jobs already handed over for execution. They are kept together in a single IORef, so that we can atomically update both, in particular when scheduling jobs to be handed over for execution.




jqJobs :: IORef Queue
jqConfig :: IORef (Result ConfigData)
jqLivelock :: Livelock
jqForkLock :: Lock

getConfigValue :: (Cluster -> a) -> a -> JQStatus -> IO aSource

getRQL :: JQStatus -> IO IntSource

modifyJobs :: JQStatus -> (Queue -> Queue) -> IO ()Source

moveJob :: Lens' Queue [JobWithStat] -> Lens' Queue [JobWithStat] -> JobId -> Queue -> (Queue, Maybe JobWithStat)Source

manipulateRunningJob :: JQStatus -> JobId -> IO a -> IO (Maybe a)Source

jobWatcher :: JQStatus -> JobWithStat -> Event -> IO ()Source



:: Int

How many jobs are allowed to run at the same time.

-> Set FilterRule

Filter rules to respect for scheduling

-> Queue 
-> (Queue, [JobWithStat]) 

Decide on which jobs to schedule next for execution. This is the pure function doing the scheduling.

scheduleSomeJobs :: JQStatus -> IO ()Source

Schedule jobs to be run. This is the IO wrapper around the pure selectJobsToRun.

showQueue :: Queue -> StringSource

cleanupIfDead :: JQStatus -> JobId -> IO BoolSource

Trigger job detection for the job with the given job id. Return True, if the job is dead.

updateStatusAndScheduleSomeJobs :: JQStatus -> IO ()Source

Force the queue to check the state of all jobs.

initJQScheduler :: JQStatus -> IO ()Source

Set up the job scheduler. This will also start the monitoring of changes to the running jobs.

enqueueNewJobs :: JQStatus -> [QueuedJob] -> IO ()Source

Enqueue new jobs. This will guarantee that the jobs will be executed eventually.

dequeueJob :: JQStatus -> JobId -> IO (Result Bool)Source

Try to remove a queued job from the job queue. Return True, if the job could be removed from the queue before being handed over to execution, False if the job already started, and a Bad result if the job is unknown.

setJobPriority :: JQStatus -> JobId -> Int -> IO (Result (Maybe QueuedJob))Source

Change the priority of a queued job (once the job is handed over to execution, the job itself needs to be informed). To avoid the job being started unmodified, it is temporarily unqueued during the change. Return the modified job, if the job's priority was sucessfully modified, Nothing, if the job already started, and a Bad value, if the job is unkown.

configChangeNeedsRescheduling :: ConfigData -> ConfigData -> BoolSource

Given old and new configs, determines if the changes between them should trigger the scheduler to run.