Commit 557f5dad authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Generate a separate return type for the job queue update RPC



The instantiation of RPC requires a bidirectional functional dependency
between call type and return type. Hence we cannot use Unit everywhere.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 36399e2a
......@@ -58,14 +58,16 @@ module Ganeti.JQueue
, startJobs
) where
import Control.Arrow (second)
import Control.Concurrent.MVar
import Control.Exception
import Control.Monad
import Data.Functor ((<$))
import Data.List
import Data.Maybe
import Data.Ord (comparing)
-- workaround what seems to be a bug in ghc 7.4's TH shadowing code
import Prelude hiding (log, id)
import Prelude hiding (id, log)
import System.Directory
import System.FilePath
import System.IO.Error (isDoesNotExistError)
......@@ -381,8 +383,9 @@ replicateJob :: FilePath -> [Node] -> QueuedJob -> IO [(Node, ERpcError ())]
replicateJob rootdir mastercandidates job = do
let filename = liveJobFile rootdir . qjId $ job
content = Text.JSON.encode . Text.JSON.showJSON $ job
result <- executeRpcCall mastercandidates
$ RpcCallJobqueueUpdate filename content
callresult <- executeRpcCall mastercandidates
$ RpcCallJobqueueUpdate filename content
let result = map (second (() <$)) callresult
logRpcErrors result
return result
......
......@@ -567,6 +567,8 @@ $(buildObject "RpcCallJobqueueUpdate" "rpcCallJobqueueUpdate"
, simpleField "content" [t| String |]
])
$(buildObject "RpcResultJobQueueUpdate" "rpcResultJobQueueUpdate" [])
instance RpcCall RpcCallJobqueueUpdate where
rpcCallName _ = "jobqueue_update"
rpcCallTimeout _ = rpcTimeoutToRaw Fast
......@@ -579,10 +581,10 @@ instance RpcCall RpcCallJobqueueUpdate where
)
)
instance Rpc RpcCallJobqueueUpdate () where
instance Rpc RpcCallJobqueueUpdate RpcResultJobQueueUpdate where
rpcResultFill _ res =
case res of
J.JSNull -> Right ()
J.JSNull -> Right RpcResultJobQueueUpdate
_ -> Left $ JsonDecodeError
("Expected JSNull, got " ++ show (pp_value res))
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