Commit 22f3fc92 authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Add a function to obtain all active locks



Add a function that extracts from a LockAllocation the list
of all locks that are in use (directly or indirectly).
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent aa4a4b76
......@@ -29,6 +29,7 @@ module Ganeti.Locking.Allocation
, OwnerState(..)
, lockOwners
, listLocks
, listAllLocks
, holdsLock
, LockRequest(..)
, requestExclusive
......@@ -126,6 +127,10 @@ lockOwners = M.keys . laOwned
listLocks :: Ord b => b -> LockAllocation a b -> M.Map a OwnerState
listLocks owner = fromMaybe M.empty . M.lookup owner . laOwned
-- | List all locks currently (directly or indirectly) owned by someone.
listAllLocks :: Ord b => LockAllocation a b -> [a]
listAllLocks = M.keys . laLocks
-- | Returns 'True' if the given owner holds the given lock at the given
-- ownership level or higher. This means that querying for a shared lock
-- returns 'True' of the owner holds the lock in shared or exlusive mode.
......
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