Commit 966ea086 authored by Klaus Aehlig's avatar Klaus Aehlig

Add function to compute the absolute id of a dependency

SubmitManyJobs also accepts jobs with dependencies given as
relative ids. Together with the absolute id of the job, once
assigned, the dependency can be resolved. Add a function doing
this computation.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 4b49a72b
......@@ -110,6 +110,7 @@ module Ganeti.Types
, RelativeJobId
, JobIdDep(..)
, JobDependency(..)
, absoluteJobDependency
, OpSubmitPriority(..)
, opSubmitPriorityToRaw
, parseSubmitPriority
......@@ -675,6 +676,12 @@ instance JSON.JSON JobIdDep where
JSON.Ok r -> return $ JobDepRelative r
JSON.Error _ -> liftM JobDepAbsolute (parseJobId v)
-- | From job ID dependency and job ID, compute the absolute dependency.
absoluteJobIdDep :: (Monad m) => JobIdDep -> JobId -> m JobIdDep
absoluteJobIdDep (JobDepAbsolute jid) _ = return $ JobDepAbsolute jid
absoluteJobIdDep (JobDepRelative rjid) jid =
liftM JobDepAbsolute . makeJobId $ fromJobId jid + fromNegative rjid
-- | Job Dependency type.
data JobDependency = JobDependency JobIdDep [FinalizedJobStatus]
deriving (Show, Eq)
......@@ -683,6 +690,11 @@ instance JSON JobDependency where
showJSON (JobDependency dep status) = showJSON (dep, status)
readJSON = liftM (uncurry JobDependency) . readJSON
-- | From job dependency and job id compute an absolute job dependency.
absoluteJobDependency :: (Monad m) => JobDependency -> JobId -> m JobDependency
absoluteJobDependency (JobDependency jdep fstats) jid =
liftM (flip JobDependency fstats) $ absoluteJobIdDep jdep jid
-- | Valid opcode priorities for submit.
$(THH.declareIADT "OpSubmitPriority"
[ ("OpPrioLow", 'ConstantUtils.priorityLow)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment