start implementing k-choices rebalancing, considering 1 VS each run
only loop implemented, rebalancing not implemented
This commit is contained in:
parent
b111515178
commit
0cb4b6815c
|
@ -322,6 +322,34 @@ kChoicesDepartureCost remainingOwnLoad ownCap thisSegmentLoad segment =
|
||||||
+ abs (remainingOwnLoad + thisSegmentLoad) / ownCap
|
+ abs (remainingOwnLoad + thisSegmentLoad) / ownCap
|
||||||
- abs (segmentOwnerRemainingLoadTarget segment) / segmentOwnerCapacity segment
|
- abs (segmentOwnerRemainingLoadTarget segment) / segmentOwnerCapacity segment
|
||||||
|
|
||||||
|
|
||||||
|
kChoicesRebalanceThread :: (Service s (RealNodeSTM s)) => RealNodeSTM s -> IO ()
|
||||||
|
kChoicesRebalanceThread nodeSTM = (confKChoicesRebalanceInterval . nodeConfig <$> readTVarIO nodeSTM) >>= rebalanceVS 0
|
||||||
|
where
|
||||||
|
rebalanceVS :: NodeID -> Int -> IO ()
|
||||||
|
rebalanceVS startAt interval = do
|
||||||
|
threadDelay interval
|
||||||
|
(vsToRebalance', serv) <- atomically $ do
|
||||||
|
node <- readTVar nodeSTM
|
||||||
|
pure (rMapLookupPred 0 (vservers node), nodeService node)
|
||||||
|
maybe
|
||||||
|
-- wait and retry if no active VS available
|
||||||
|
(rebalanceVS startAt interval)
|
||||||
|
(\(vsNid, vsSTM) -> do
|
||||||
|
vs <- readTVarIO vsSTM
|
||||||
|
-- query neighbour node(s) load
|
||||||
|
-- query own load
|
||||||
|
-- calculate departure cost
|
||||||
|
-- if deciding to re-balance, first leave and then join
|
||||||
|
-- loop
|
||||||
|
rebalanceVS vsNid interval
|
||||||
|
)
|
||||||
|
vsToRebalance'
|
||||||
|
|
||||||
|
|
||||||
|
-- placeholder
|
||||||
|
pure ()
|
||||||
|
|
||||||
-- | Join a new node into the DHT, using a provided bootstrap node as initial cache seed
|
-- | Join a new node into the DHT, using a provided bootstrap node as initial cache seed
|
||||||
-- for resolving the new node's position.
|
-- for resolving the new node's position.
|
||||||
fediChordBootstrapJoin :: Service s (RealNodeSTM s)
|
fediChordBootstrapJoin :: Service s (RealNodeSTM s)
|
||||||
|
|
Loading…
Reference in a new issue