Commit 9dc6023f authored by Iustin Pop's avatar Iustin Pop
Browse files

Simplify the checkInstanceMove function

This patch flattens the two folds into one, by simply building the whole
list of moves instead  of the double recursion (nodes and the each
node's moves). This has no functional change, but it's much cleaner.
parent 256810de
......@@ -397,20 +397,13 @@ checkInstanceMove nodes_idx ini_tbl target =
opdx = Instance.pnode target
osdx = Instance.snode target
nodes = filter (\idx -> idx /= opdx && idx /= osdx)
nodes = filter (\idx -> idx /= opdx && idx /= osdx) nodes_idx
aft_failover = checkSingleStep ini_tbl target ini_tbl Failover
all_moves = concatMap (\idx -> [ReplacePrimary idx,
ReplaceSecondary idx]) nodes
-- iterate over the possible nodes for this instance
(\ accu_p new_idx ->
pmoves = [ReplacePrimary new_idx,
ReplaceSecondary new_idx]
foldl' -- while doing both possible moves
(checkSingleStep ini_tbl target) accu_p pmoves
) aft_failover nodes
foldl' (checkSingleStep ini_tbl target) aft_failover all_moves
-- | Compute the best next move.
checkMove :: [Int] -- ^ Allowed target node indices
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