Revision ed6cf449 src/Ganeti/JQScheduler.hs

b/src/Ganeti/JQScheduler.hs
36 36
import Control.Monad
37 37
import Data.List
38 38
import Data.IORef
39
import System.INotify
39 40

  
40 41
import Ganeti.BasicTypes
41 42
import Ganeti.Constants as C
......
45 46
import Ganeti.Types
46 47
import Ganeti.Utils
47 48

  
48
data JobWithStat = JobWithStat { jStat :: FStat, jJob :: QueuedJob }
49
data JobWithStat = JobWithStat { jINotify :: Maybe INotify
50
                               , jStat :: FStat
51
                               , jJob :: QueuedJob
52
                               }
49 53
data Queue = Queue { qEnqueued :: [JobWithStat], qRunning :: [JobWithStat] }
50 54

  
51 55
{-| Representation of the job queue
......
78 82

  
79 83
-- | Obtain a JobWithStat from a QueuedJob.
80 84
unreadJob :: QueuedJob -> JobWithStat
81
unreadJob job = JobWithStat {jJob=job, jStat=nullFStat}
85
unreadJob job = JobWithStat {jJob=job, jStat=nullFStat, jINotify=Nothing}
82 86

  
83 87
-- | Reload interval for polling the running jobs for updates in microseconds.
84 88
watchInterval :: Int
......
94 98

  
95 99
-- | Reread a job from disk, if the file has changed.
96 100
readJobStatus :: JobWithStat -> IO (Maybe JobWithStat)
97
readJobStatus (JobWithStat {jStat=fstat, jJob=job})  = do
101
readJobStatus jWS@(JobWithStat {jStat=fstat, jJob=job})  = do
98 102
  let jid = qjId job
99 103
  qdir <- queueDir
100 104
  let fpath = liveJobFile qdir jid
......
117 121
        Ok (job', _) -> do
118 122
          logDebug
119 123
            $ "Read job " ++ jids ++ ", staus is " ++ show (calcJobStatus job')
120
          return . Just $ JobWithStat {jStat=fstat', jJob=job'}
124
          return . Just $ jWS {jStat=fstat', jJob=job'}
125
                          -- jINotify unchanged
121 126

  
122 127
-- | Update a job in the job queue, if it is still there. This is the
123 128
-- pure function for inserting a previously read change into the queue.
......
212 217
  tryFstat <- try $ getFStat fpath :: IO (Either IOError FStat)
213 218
  let fstat = either (const nullFStat) id tryFstat
214 219
  loadResult <- JQ.loadJobFromDisk qdir False jid
215
  return $ liftM (JobWithStat fstat . fst) loadResult
220
  return $ liftM (JobWithStat Nothing fstat . fst) loadResult
216 221

  
217 222
-- | Read all non-finalized jobs from disk.
218 223
readJobsFromDisk :: IO [JobWithStat]

Also available in: Unified diff