On Thu, Nov 7, 2013 at 1:20 PM, Klaus Aehlig <[email protected]> wrote:
> Handle this request by writing the jobs to the
> queue and inform masterd; masterd will then also
> distribute the jobs to all master candidates.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  src/Ganeti/Query/Server.hs | 34 +++++++++++++++++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/src/Ganeti/Query/Server.hs b/src/Ganeti/Query/Server.hs
> index f4c5ce7..ae8ba06 100644
> --- a/src/Ganeti/Query/Server.hs
> +++ b/src/Ganeti/Query/Server.hs
> @@ -34,7 +34,7 @@ module Ganeti.Query.Server
>  import Control.Applicative
>  import Control.Concurrent
>  import Control.Exception
> -import Control.Monad (forever, when)
> +import Control.Monad (forever, when, zipWithM)
>  import Data.Bits (bitSize)
>  import qualified Data.Set as Set (toList)
>  import Data.IORef
> @@ -220,6 +220,38 @@ handleCall qlock cfg (SubmitJob ops) =
>         then return . Bad . GenericError $ "Queue drained"
>         else handleCall qlock cfg (SubmitJobToDrainedQueue ops)
>
> +handleCall qlock cfg (SubmitManyJobs lops) =
> +  do
> +    open <- isQueueOpen
> +    if not open
> +       then return . Bad . GenericError $ "Queue drained"
> +       else do

"then" and "else" are indented 3 spaces. It should be 2.

> +         result_jobids <- allocateJobIds (Config.getMasterCandidates cfg)
> +                            qlock (length lops)
> +         case result_jobids of
> +           Bad s -> return . Bad . GenericError $ s
> +           Ok jids -> do
> +             jobs <- zipWithM queuedJobFromOpCodes jids lops
> +             qDir <- queueDir
> +             write_results <- mapM (writeJobToDisk qDir) jobs
> +             let annotated_results = zip write_results jids
> +                 succeeded = map snd $ filter (isOk . fst) annotated_results
> +             when (any isBad write_results) . logWarning
> +               $ "Writing some jobs failed " ++ show annotated_results
> +             socketpath <- defaultLuxiSocket
> +             client <- getClient socketpath
> +             pickupResults <- mapM (flip callMethod client . PickupJob)
> +                                succeeded
> +             when (any isBad pickupResults)
> +               . logWarning . (++)  "Failed to notify maserd: " . show
> +               $ zip succeeded pickupResults
> +             return . Ok . JSArray
> +               . map (\(res, jid) ->
> +                       if isOk res
> +                         then showJSON (True, fromJobId jid)
> +                         else showJSON (False, genericResult id (const "") 
> res))
> +               $ annotated_results

Shouldn't the client be closed before exiting this function?

> +
>  handleCall _ _ op =
>    return . Bad $
>      GenericError ("Luxi call '" ++ strOfOp op ++ "' not implemented")
> --
> 1.8.4.1
>

Thanks,
Michele

-- 
Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to