data Table = Table Node.List Instance.List Score [Placement]
deriving (Show)
-data CStats = CStats { cs_fmem :: Int -- ^ Cluster free mem
- , cs_fdsk :: Int -- ^ Cluster free disk
- , cs_amem :: Int -- ^ Cluster allocatable mem
- , cs_adsk :: Int -- ^ Cluster allocatable disk
- , cs_acpu :: Int -- ^ Cluster allocatable cpus
- , cs_mmem :: Int -- ^ Max node allocatable mem
- , cs_mdsk :: Int -- ^ Max node allocatable disk
- , cs_mcpu :: Int -- ^ Max node allocatable cpu
+data CStats = CStats { cs_fmem :: Int -- ^ Cluster free mem
+ , cs_fdsk :: Int -- ^ Cluster free disk
+ , cs_amem :: Int -- ^ Cluster allocatable mem
+ , cs_adsk :: Int -- ^ Cluster allocatable disk
+ , cs_acpu :: Int -- ^ Cluster allocatable cpus
+ , cs_mmem :: Int -- ^ Max node allocatable mem
+ , cs_mdsk :: Int -- ^ Max node allocatable disk
+ , cs_mcpu :: Int -- ^ Max node allocatable cpu
+ , cs_imem :: Int -- ^ Instance used mem
+ , cs_idsk :: Int -- ^ Instance used disk
+ , cs_icpu :: Int -- ^ Instance used cpu
+ , cs_tmem :: Double -- ^ Cluster total mem
+ , cs_tdsk :: Double -- ^ Cluster total disk
+ , cs_tcpu :: Double -- ^ Cluster total cpus
+ , cs_xmem :: Int -- ^ Unnacounted for mem
+ , cs_nmem :: Int -- ^ Node own memory
}
-- * Utility functions
, cs_mmem = 0
, cs_mdsk = 0
, cs_mcpu = 0
+ , cs_imem = 0
+ , cs_idsk = 0
+ , cs_icpu = 0
+ , cs_tmem = 0
+ , cs_tdsk = 0
+ , cs_tcpu = 0
+ , cs_xmem = 0
+ , cs_nmem = 0
}
updateCStats :: CStats -> Node.Node -> CStats
updateCStats cs node =
let CStats { cs_fmem = x_fmem, cs_fdsk = x_fdsk,
cs_amem = x_amem, cs_acpu = x_acpu, cs_adsk = x_adsk,
- cs_mmem = x_mmem, cs_mdsk = x_mdsk, cs_mcpu = x_mcpu }
+ cs_mmem = x_mmem, cs_mdsk = x_mdsk, cs_mcpu = x_mcpu,
+ cs_imem = x_imem, cs_idsk = x_idsk, cs_icpu = x_icpu,
+ cs_tmem = x_tmem, cs_tdsk = x_tdsk, cs_tcpu = x_tcpu,
+ cs_xmem = x_xmem, cs_nmem = x_nmem
+ }
= cs
inc_amem = Node.f_mem node - Node.r_mem node
inc_amem' = if inc_amem > 0 then inc_amem else 0
inc_adsk = Node.availDisk node
+ inc_imem = truncate (Node.t_mem node) - Node.n_mem node
+ - Node.x_mem node - Node.f_mem node
+ inc_icpu = Node.u_cpu node
+ inc_idsk = truncate (Node.t_dsk node) - Node.f_dsk node
+
in CStats { cs_fmem = x_fmem + Node.f_mem node
, cs_fdsk = x_fdsk + Node.f_dsk node
, cs_amem = x_amem + inc_amem'
, cs_mmem = max x_mmem inc_amem'
, cs_mdsk = max x_mdsk inc_adsk
, cs_mcpu = x_mcpu
+ , cs_imem = x_imem + inc_imem
+ , cs_idsk = x_idsk + inc_idsk
+ , cs_icpu = x_icpu + inc_icpu
+ , cs_tmem = x_tmem + Node.t_mem node
+ , cs_tdsk = x_tdsk + Node.t_dsk node
+ , cs_tcpu = x_tcpu + Node.t_cpu node
+ , cs_xmem = x_xmem + Node.x_mem node
+ , cs_nmem = x_nmem + Node.n_mem node
}
-- | Compute the total free disk and memory in the cluster.
printf "%s allocatable RAM: %d\n" kind (Cluster.cs_amem cs)
printf "%s reserved RAM: %d\n" kind (Cluster.cs_fmem cs -
Cluster.cs_amem cs)
+ printf "%s instance RAM: %d\n" kind (Cluster.cs_imem cs)
+ printf "%s overhead RAM: %d\n" kind (Cluster.cs_xmem cs + Cluster.cs_nmem cs)
+ printf "%s RAM usage efficiency: %.8f\n"
+ kind (fromIntegral (Cluster.cs_imem cs) / Cluster.cs_tmem cs)
printf "%s free disk: %d\n" kind (Cluster.cs_fdsk cs)
printf "%s allocatable disk: %d\n" kind (Cluster.cs_adsk cs)
printf "%s reserved disk: %d\n" kind (Cluster.cs_fdsk cs -
Cluster.cs_adsk cs)
+ printf "%s instance disk: %d\n" kind (Cluster.cs_idsk cs)
+ printf "%s disk usage efficiency: %.8f\n"
+ kind (fromIntegral (Cluster.cs_idsk cs) / Cluster.cs_tdsk cs)
+ printf "%s instance cpus: %d\n" kind (Cluster.cs_icpu cs)
+ printf "%s cpu usage efficiency: %.8f\n"
+ kind (fromIntegral (Cluster.cs_icpu cs) / Cluster.cs_tcpu cs)
printf "%s max node allocatable RAM: %d\n" kind (Cluster.cs_mmem cs)
printf "%s max node allocatable disk: %d\n" kind (Cluster.cs_mdsk cs)
ini_cv (Cluster.printStats nl)
else
printf "Initial score: %.8f\n" ini_cv)
+ printf "Cluster RAM: %.0f\n" (Cluster.cs_tmem ini_stats)
+ printf "Cluster disk: %.0f\n" (Cluster.cs_tdsk ini_stats)
+ printf "Cluster cpus: %.0f\n" (Cluster.cs_tcpu ini_stats)
printf "Initial instances: %d\n" num_instances
printStats "Initial" ini_stats