Revision 7711f32b
b/src/Ganeti/Query/Server.hs | ||
---|---|---|
33 | 33 |
import Control.Concurrent |
34 | 34 |
import Control.Exception |
35 | 35 |
import Control.Monad (forever, when, zipWithM, liftM) |
36 |
import Control.Monad.IO.Class |
|
36 | 37 |
import Data.Bits (bitSize) |
37 | 38 |
import qualified Data.Set as Set (toList) |
38 | 39 |
import Data.IORef |
... | ... | |
57 | 58 |
import Ganeti.Luxi |
58 | 59 |
import qualified Ganeti.Query.Language as Qlang |
59 | 60 |
import qualified Ganeti.Query.Cluster as QCluster |
60 |
import Ganeti.Path (queueDir, jobQueueLockFile, jobQueueDrainFile) |
|
61 |
import Ganeti.Path ( queueDir, jobQueueLockFile, jobQueueDrainFile |
|
62 |
, defaultMasterSocket) |
|
61 | 63 |
import Ganeti.Rpc |
62 | 64 |
import Ganeti.Query.Query |
63 | 65 |
import Ganeti.Query.Filter (makeSimpleFilter) |
... | ... | |
303 | 305 |
_ <- executeRpcCall mcs $ RpcCallSetDrainFlag value |
304 | 306 |
return . Ok . showJSON $ True |
305 | 307 |
|
308 |
handleCall _ qstat cfg (ChangeJobPriority jid prio) = do |
|
309 |
maybeJob <- setJobPriority qstat jid prio |
|
310 |
case maybeJob of |
|
311 |
Bad s -> return . Ok $ showJSON (False, s) |
|
312 |
Ok (Just job) -> runResultT $ do |
|
313 |
let mcs = Config.getMasterCandidates cfg |
|
314 |
qDir <- liftIO queueDir |
|
315 |
liftIO $ replicateManyJobs qDir mcs [job] |
|
316 |
return $ showJSON (True, "Priorities of pending opcodes for job " |
|
317 |
++ show (fromJobId jid) ++ " have been changed" |
|
318 |
++ " to " ++ show prio) |
|
319 |
Ok Nothing -> runResultT $ do |
|
320 |
-- Job has already started; so we have to forward the request |
|
321 |
-- to the job, currently handled by masterd. |
|
322 |
socketpath <- liftIO defaultMasterSocket |
|
323 |
cl <- liftIO $ getLuxiClient socketpath |
|
324 |
ResultT $ callMethod (ChangeJobPriority jid prio) cl |
|
325 |
|
|
306 | 326 |
handleCall _ qstat cfg (CancelJob jid) = do |
307 | 327 |
let jName = (++) "job " . show $ fromJobId jid |
308 | 328 |
dequeueResult <- dequeueJob qstat jid |
Also available in: Unified diff