Revision 72747d91 src/Ganeti/HTools/Program/Hspace.hs
b/src/Ganeti/HTools/Program/Hspace.hs | ||
---|---|---|
4 | 4 |
|
5 | 5 |
{- |
6 | 6 |
|
7 |
Copyright (C) 2009, 2010, 2011, 2012 Google Inc. |
|
7 |
Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc.
|
|
8 | 8 |
|
9 | 9 |
This program is free software; you can redistribute it and/or modify |
10 | 10 |
it under the terms of the GNU General Public License as published by |
... | ... | |
105 | 105 |
specDescription SpecNormal = "Standard (fixed-size)" |
106 | 106 |
specDescription SpecTiered = "Tiered (initial size)" |
107 | 107 |
|
108 |
-- | The \"name\" of a 'SpecType'. |
|
109 |
specName :: SpecType -> String |
|
110 |
specName SpecNormal = "Standard" |
|
111 |
specName SpecTiered = "Tiered" |
|
112 |
|
|
108 | 113 |
-- | Efficiency generic function. |
109 | 114 |
effFn :: (Cluster.CStats -> Integer) |
110 | 115 |
-> (Cluster.CStats -> Double) |
... | ... | |
191 | 196 |
\ != counted (%d)\n" (num_instances + allocs) |
192 | 197 |
(Cluster.csNinst fin_stats) |
193 | 198 |
|
199 |
main_reason <- exitIfEmpty "Internal error, no failure reasons?!" sreason |
|
200 |
|
|
194 | 201 |
printKeysHTS $ printStats PFinal fin_stats |
195 | 202 |
printKeysHTS [ ("ALLOC_USAGE", printf "%.8f" |
196 | 203 |
((fromIntegral num_instances::Double) / |
197 | 204 |
fromIntegral fin_instances)) |
198 | 205 |
, ("ALLOC_INSTANCES", printf "%d" allocs) |
199 |
, ("ALLOC_FAIL_REASON", map toUpper . show . fst $ head sreason)
|
|
206 |
, ("ALLOC_FAIL_REASON", map toUpper . show . fst $ main_reason)
|
|
200 | 207 |
] |
201 | 208 |
printKeysHTS $ map (\(x, y) -> (printf "ALLOC_%s_CNT" (show x), |
202 | 209 |
printf "%d" y)) sreason |
... | ... | |
210 | 217 |
printFinalHTS :: Bool -> IO () |
211 | 218 |
printFinalHTS = printFinal htsPrefix |
212 | 219 |
|
220 |
{-# ANN tieredSpecMap "HLint: ignore Use alternative" #-} |
|
213 | 221 |
-- | Compute the tiered spec counts from a list of allocated |
214 | 222 |
-- instances. |
215 | 223 |
tieredSpecMap :: [Instance.Instance] |
... | ... | |
217 | 225 |
tieredSpecMap trl_ixes = |
218 | 226 |
let fin_trl_ixes = reverse trl_ixes |
219 | 227 |
ix_byspec = groupBy ((==) `on` Instance.specOf) fin_trl_ixes |
228 |
-- head is "safe" here, as groupBy returns list of non-empty lists |
|
220 | 229 |
spec_map = map (\ixs -> (Instance.specOf $ head ixs, length ixs)) |
221 | 230 |
ix_byspec |
222 | 231 |
in spec_map |
... | ... | |
365 | 374 |
Just result_noalloc -> return result_noalloc |
366 | 375 |
Nothing -> exitIfBad "failure during allocation" actual_result |
367 | 376 |
|
368 |
let name = head . words . specDescription $ mode
|
|
377 |
let name = specName mode
|
|
369 | 378 |
descr = name ++ " allocation" |
370 | 379 |
ldescr = "after " ++ map toLower descr |
371 | 380 |
|
Also available in: Unified diff