Revision 608efcce Ganeti/HTools/Cluster.hs
b/Ganeti/HTools/Cluster.hs  

52  52 
type Score = Double 
53  53  
54  54 
  The description of an instance placement. 
55 
type Placement = (Int, Int, Int, Score)


55 
type Placement = (Idx, Ndx, Ndx, Score)


56  56  
57  57 
{  A cluster solution described as the solution delta and the list 
58  58 
of placements. 
...  ...  
72  72  
73  73 
  An instance move definition 
74  74 
data IMove = Failover  ^ Failover the instance (f) 
75 
 ReplacePrimary Int  ^ Replace primary (f, r:np, f)


76 
 ReplaceSecondary Int  ^ Replace secondary (r:ns)


77 
 ReplaceAndFailover Int  ^ Replace secondary, failover (r:np, f)


78 
 FailoverAndReplace Int  ^ Failover, replace secondary (f, r:ns)


75 
 ReplacePrimary Ndx  ^ Replace primary (f, r:np, f)


76 
 ReplaceSecondary Ndx  ^ Replace secondary (r:ns)


77 
 ReplaceAndFailover Ndx  ^ Replace secondary, failover (r:np, f)


78 
 FailoverAndReplace Ndx  ^ Failover, replace secondary (f, r:ns)


79  79 
deriving (Show) 
80  80  
81  81 
  The complete state for the balancing solution 
...  ...  
238  238 
 Second phase functions 
239  239  
240  240 
  Singlenode relocation cost 
241 
nodeDelta :: Int > Int > Int > Int


241 
nodeDelta :: Ndx > Ndx > Ndx > Int


242  242 
nodeDelta i p s = 
243  243 
if i == p  i == s then 
244  244 
0 
...  ...  
333  333  
334  334 
  Apply a move 
335  335 
applyMove :: Node.List > Instance.Instance 
336 
> IMove > (Maybe Node.List, Instance.Instance, Int, Int)


336 
> IMove > (Maybe Node.List, Instance.Instance, Ndx, Ndx)


337  337 
 Failover (f) 
338  338 
applyMove nl inst Failover = 
339  339 
let old_pdx = Instance.pnode inst 
...  ...  
451  451 
  Given the status of the current secondary as a valid new node 
452  452 
 and the current candidate target node, 
453  453 
 generate the possible moves for a instance. 
454 
possibleMoves :: Bool > Int > [IMove]


454 
possibleMoves :: Bool > Ndx > [IMove]


455  455 
possibleMoves True tdx = 
456  456 
[ReplaceSecondary tdx, 
457  457 
ReplaceAndFailover tdx, 
...  ...  
463  463 
ReplaceAndFailover tdx] 
464  464  
465  465 
  Compute the best move for a given instance. 
466 
checkInstanceMove :: [Int]  Allowed target node indices


466 
checkInstanceMove :: [Ndx]  Allowed target node indices


467  467 
> Table  Original table 
468  468 
> Instance.Instance  Instance to move 
469  469 
> Table  Best new table for this instance 
...  ...  
482  482 
foldl' (checkSingleStep ini_tbl target) aft_failover all_moves 
483  483  
484  484 
  Compute the best next move. 
485 
checkMove :: [Int]  ^ Allowed target node indices


485 
checkMove :: [Ndx]  ^ Allowed target node indices


486  486 
> Table  ^ The current solution 
487  487 
> [Instance.Instance]  ^ List of instances still to move 
488  488 
> Table  ^ The new solution 
Also available in: Unified diff