Commit c622fa7c authored by Iustin Pop's avatar Iustin Pop
Browse files

Rename the maxRes to r_mem

This is to keep in style with the other memory variables.
parent 04247752
......@@ -38,11 +38,11 @@ data Node = Node { t_mem :: Double -- ^ total memory (Mib)
, f_dsk :: Int -- ^ free disk space (MiB)
, plist :: [Int] -- ^ list of primary instance indices
, slist :: [Int] -- ^ list of secondary instance indices
, idx :: Int -- ^ internal index for book-keeping
, idx :: Int -- ^ internal index for book-keeping
, peers:: PeerMap.PeerMap -- ^ primary node to instance
-- mapping
, failN1:: Bool -- ^ whether the node has failed n1
, maxRes :: Int -- ^ maximum memory needed for
, r_mem :: Int -- ^ maximum memory needed for
-- failover by primaries of this node
, p_mem :: Double
, p_dsk :: Double
......@@ -73,7 +73,7 @@ create mem_t_init mem_f_init dsk_t_init dsk_f_init =
failN1 = True,
idx = -1,
peers = PeerMap.empty,
maxRes = 0,
r_mem = 0,
p_mem = (fromIntegral mem_f) / (fromIntegral mem_t),
p_dsk = (fromIntegral dsk_f) / (fromIntegral dsk_t),
p_rem = 0
......@@ -108,7 +108,7 @@ buildPeers t il num_nodes =
new_rmem = computeMaxRes pmap
new_failN1 = computeFailN1 new_rmem (f_mem t) (f_dsk t)
new_prem = (fromIntegral new_rmem) / (t_mem t)
in t {peers=pmap, failN1 = new_failN1, maxRes = new_rmem, p_rem = new_prem}
in t {peers=pmap, failN1 = new_failN1, r_mem = new_rmem, p_rem = new_prem}
-- | Removes a primary instance.
removePri :: Node -> Instance.Instance -> Node
......@@ -119,7 +119,7 @@ removePri t inst =
new_dsk = f_dsk t + Instance.dsk inst
new_mp = (fromIntegral new_mem) / (t_mem t)
new_dp = (fromIntegral new_dsk) / (t_dsk t)
new_failn1 = computeFailN1 (maxRes t) new_mem new_dsk
new_failn1 = computeFailN1 (r_mem t) new_mem new_dsk
in t {plist = new_plist, f_mem = new_mem, f_dsk = new_dsk,
failN1 = new_failn1, p_mem = new_mp, p_dsk = new_dp}
......@@ -134,7 +134,7 @@ removeSec t inst =
old_peem = PeerMap.find pnode old_peers
new_peem = old_peem - (Instance.mem inst)
new_peers = PeerMap.add pnode new_peem old_peers
old_rmem = maxRes t
old_rmem = r_mem t
new_rmem = if old_peem < old_rmem then
old_rmem
else
......@@ -143,7 +143,7 @@ removeSec t inst =
new_failn1 = computeFailN1 new_rmem (f_mem t) new_dsk
new_dp = (fromIntegral new_dsk) / (t_dsk t)
in t {slist = new_slist, f_dsk = new_dsk, peers = new_peers,
failN1 = new_failn1, maxRes = new_rmem, p_dsk = new_dp,
failN1 = new_failn1, r_mem = new_rmem, p_dsk = new_dp,
p_rem = new_prem}
-- | Adds a primary instance.
......@@ -152,7 +152,7 @@ addPri t inst =
let iname = Instance.idx inst
new_mem = f_mem t - Instance.mem inst
new_dsk = f_dsk t - Instance.dsk inst
new_failn1 = computeFailN1 (maxRes t) new_mem new_dsk in
new_failn1 = computeFailN1 (r_mem t) new_mem new_dsk in
if (failHealth new_mem new_dsk) || (new_failn1 && not (failN1 t)) then
Nothing
else
......@@ -172,7 +172,7 @@ addSec t inst pdx =
new_dsk = f_dsk t - Instance.dsk inst
new_peem = PeerMap.find pdx old_peers + Instance.mem inst
new_peers = PeerMap.add pdx new_peem old_peers
new_rmem = max (maxRes t) new_peem
new_rmem = max (r_mem t) new_peem
new_prem = (fromIntegral new_rmem) / (t_mem t)
new_failn1 = computeFailN1 new_rmem old_mem new_dsk in
if (failHealth old_mem new_dsk) || (new_failn1 && not (failN1 t)) then
......@@ -183,7 +183,7 @@ addSec t inst pdx =
in
Just t {slist = new_slist, f_dsk = new_dsk,
peers = new_peers, failN1 = new_failn1,
maxRes = new_rmem, p_dsk = new_dp,
r_mem = new_rmem, p_dsk = new_dp,
p_rem = new_prem}
-- | Add a primary instance to a node without other updates
......@@ -214,6 +214,6 @@ list mname n t =
in
printf " %c %-*s %5d %5d %5d %3d %3d %.5f %.5f"
(if fn then '*' else ' ')
mname n (f_mem t) (maxRes t) ((f_dsk t) `div` 1024)
mname n (f_mem t) (r_mem t) ((f_dsk t) `div` 1024)
(length pl) (length sl)
mp dp
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