This patch changes Cluster.totalResources to compute more details about
the cluster status, and enhances hspace to display more of these.
(bad_nodes, bad_instances)
-- | Compute the total free disk and memory in the cluster.
(bad_nodes, bad_instances)
-- | Compute the total free disk and memory in the cluster.
-totalResources :: Node.List -> (Int, Int)
+totalResources :: Node.List -> (Int, Int, Int, Int, Int)
totalResources nl =
foldl'
totalResources nl =
foldl'
- (\ (mem, dsk) node -> (mem + (Node.f_mem node),
- dsk + (Node.f_dsk node)))
- (0, 0) (Container.elems nl)
+ (\ (mem, dsk, amem, mmem, mdsk) node ->
+ let inc_amem = (Node.f_mem node) - (Node.r_mem node)
+ in (mem + (Node.f_mem node),
+ dsk + (Node.f_dsk node),
+ amem + (if inc_amem > 0 then inc_amem else 0),
+ max mmem inc_amem,
+ max mdsk (Node.f_dsk node)
+ )
+ ) (0, 0, 0, 0, 0) (Container.elems nl)
-- | Compute the mem and disk covariance.
compDetailedCV :: Node.List -> (Double, Double, Double, Double, Double, Double)
-- | Compute the mem and disk covariance.
compDetailedCV :: Node.List -> (Double, Double, Double, Double, Double, Double)
when (optShowNodes opts) $
do
when (optShowNodes opts) $
do
- let (orig_mem, orig_disk) = Cluster.totalResources nl
- (final_mem, final_disk) = Cluster.totalResources fin_nl
+ let (orig_mem, orig_disk, _, _, _) = Cluster.totalResources nl
+ (final_mem, final_disk, _, _, _) = Cluster.totalResources fin_nl
putStrLn ""
putStrLn "Final cluster status:"
putStrLn $ Cluster.printNodes fin_nl
putStrLn ""
putStrLn "Final cluster status:"
putStrLn $ Cluster.printNodes fin_nl
when (optShowNodes opts) $
do
when (optShowNodes opts) $
do
- let (orig_mem, orig_disk) = Cluster.totalResources nl
- (final_mem, final_disk) = Cluster.totalResources ns
+ let (orig_mem, orig_disk, _, _, _) = Cluster.totalResources nl
+ (final_mem, final_disk, _, _, _) = Cluster.totalResources ns
putStrLn ""
putStrLn "Final cluster status:"
putStrLn $ Cluster.printNodes ns
putStrLn ""
putStrLn "Final cluster status:"
putStrLn $ Cluster.printNodes ns
putStrLn $ Cluster.printNodes nl
let ini_cv = Cluster.compCV nl
putStrLn $ Cluster.printNodes nl
let ini_cv = Cluster.compCV nl
- (orig_mem, orig_disk) = Cluster.totalResources nl
+ (ini_mem, ini_disk, ini_amem, ini_mmem, ini_mdsk) =
+ Cluster.totalResources nl
(if verbose > 2 then
printf "Initial coefficients: overall %.8f, %s\n"
(if verbose > 2 then
printf "Initial coefficients: overall %.8f, %s\n"
else
printf "Initial score: %.8f\n" ini_cv)
printf "Initial instances: %d\n" num_instances
else
printf "Initial score: %.8f\n" ini_cv)
printf "Initial instances: %d\n" num_instances
- printf "Initial free RAM: %d\n" orig_mem
- printf "Initial free disk: %d\n" orig_disk
+ printf "Initial free RAM: %d\n" ini_mem
+ printf "Initial allocatable RAM: %d\n" ini_amem
+ printf "Initial free disk: %d\n" ini_disk
let nmlen = Container.maxNameLen nl
newinst = Instance.create "new" (optIMem opts) (optIDsk opts)
let nmlen = Container.maxNameLen nl
newinst = Instance.create "new" (optIMem opts) (optIDsk opts)
fin_instances = num_instances + allocs
fin_ixes = reverse ixes
ix_namelen = maximum . map (length . Instance.name) $ fin_ixes
fin_instances = num_instances + allocs
fin_ixes = reverse ixes
ix_namelen = maximum . map (length . Instance.name) $ fin_ixes
- (final_mem, final_disk) = Cluster.totalResources fin_nl
+ (fin_mem, fin_disk, fin_amem, fin_mmem, fin_mdsk) =
+ Cluster.totalResources fin_nl
printf "Final score: %.8f\n" (Cluster.compCV fin_nl)
printf "Final instances: %d\n" (num_instances + allocs)
printf "Final score: %.8f\n" (Cluster.compCV fin_nl)
printf "Final instances: %d\n" (num_instances + allocs)
- printf "Final free RAM: %d\n" final_mem
- printf "Final free disk: %d\n" final_disk
+ printf "Final free RAM: %d\n" fin_mem
+ printf "Final allocatable RAM: %d\n" fin_amem
+ printf "Final free disk: %d\n" fin_disk
printf "Usage: %.5f\n" (((fromIntegral num_instances)::Double) /
(fromIntegral fin_instances))
printf "Allocations: %d\n" allocs
printf "Usage: %.5f\n" (((fromIntegral num_instances)::Double) /
(fromIntegral fin_instances))
printf "Allocations: %d\n" allocs
when (optShowNodes opts) $
do
when (optShowNodes opts) $
do
- let (orig_mem, orig_disk) = Cluster.totalResources nl
- (final_mem, final_disk) = Cluster.totalResources fin_nl
putStrLn ""
putStrLn "Final cluster status:"
putStrLn $ Cluster.printNodes fin_nl
putStrLn ""
putStrLn "Final cluster status:"
putStrLn $ Cluster.printNodes fin_nl
- when (verbose > 3) $
- do
- printf "Original: mem=%d disk=%d\n" orig_mem orig_disk
- printf "Final: mem=%d disk=%d\n" final_mem final_disk