Revision 9131274c src/Ganeti/Query/Server.hs
b/src/Ganeti/Query/Server.hs | ||
---|---|---|
82 | 82 |
return $ showJSON <$> (qr >>= queryCompat) |
83 | 83 |
|
84 | 84 |
-- | Minimal wrapper to handle the missing config case. |
85 |
handleCallWrapper :: MVar () -> JQStatus -> Result ConfigData
|
|
85 |
handleCallWrapper :: MVar () -> JQStatus -> Result ConfigData |
|
86 | 86 |
-> LuxiOp -> IO (ErrorResult JSValue) |
87 | 87 |
handleCallWrapper _ _ (Bad msg) _ = |
88 | 88 |
return . Bad . ConfigurationError $ |
... | ... | |
91 | 91 |
handleCallWrapper qlock qstat (Ok config) op = handleCall qlock qstat config op |
92 | 92 |
|
93 | 93 |
-- | Actual luxi operation handler. |
94 |
handleCall :: MVar () -> JQStatus
|
|
94 |
handleCall :: MVar () -> JQStatus |
|
95 | 95 |
-> ConfigData -> LuxiOp -> IO (ErrorResult JSValue) |
96 | 96 |
handleCall _ _ cdata QueryClusterInfo = |
97 | 97 |
let cluster = configCluster cdata |
... | ... | |
274 | 274 |
$ annotated_results |
275 | 275 |
|
276 | 276 |
handleCall _ _ cfg (WaitForJobChange jid fields prev_job prev_log tmout) = do |
277 |
let compute_fn = computeJobUpdate cfg jid fields prev_log
|
|
277 |
let compute_fn = computeJobUpdate cfg jid fields prev_log |
|
278 | 278 |
qDir <- queueDir |
279 | 279 |
-- verify if the job is finalized, and return immediately in this case |
280 | 280 |
jobresult <- loadJobFromDisk qDir False jid |
... | ... | |
311 | 311 |
|
312 | 312 |
-- | Query the status of a job and return the requested fields |
313 | 313 |
-- and the logs newer than the given log number. |
314 |
computeJobUpdate :: ConfigData -> JobId -> [String] -> JSValue
|
|
314 |
computeJobUpdate :: ConfigData -> JobId -> [String] -> JSValue |
|
315 | 315 |
-> IO (JSValue, JSValue) |
316 | 316 |
computeJobUpdate cfg jid fields prev_log = do |
317 | 317 |
let sjid = show $ fromJobId jid |
... | ... | |
350 | 350 |
, U.hExec = luxiExec cfg |
351 | 351 |
} |
352 | 352 |
|
353 |
|
|
354 | 353 |
-- | Type alias for prepMain results |
355 | 354 |
type PrepResult = (Server, IORef (Result ConfigData), JQStatus) |
356 | 355 |
|
... | ... | |
366 | 365 |
s <- describeError "binding to the Luxi socket" |
367 | 366 |
Nothing (Just socket_path) $ getLuxiServer True socket_path |
368 | 367 |
cref <- newIORef (Bad "Configuration not yet loaded") |
369 |
jq <- emptyJQStatus
|
|
368 |
jq <- emptyJQStatus |
|
370 | 369 |
return (s, cref, jq) |
371 | 370 |
|
372 | 371 |
-- | Main function. |
... | ... | |
375 | 374 |
initConfigReader id cref |
376 | 375 |
let creader = readIORef cref |
377 | 376 |
initJQScheduler jq |
378 |
|
|
377 |
|
|
379 | 378 |
qlockFile <- jobQueueLockFile |
380 | 379 |
lockFile qlockFile >>= exitIfBad "Failed to obtain the job-queue lock" |
381 | 380 |
qlock <- newMVar () |
Also available in: Unified diff