{-
-Copyright (C) 2009 Google Inc.
+Copyright (C) 2009, 2010 Google Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-- * Creation
, IntMap.empty
, IntMap.singleton
- , fromAssocList
+ , IntMap.fromList
-- * Query
, IntMap.size
, IntMap.null
add :: Key -> a -> Container a -> Container a
add = IntMap.insert
--- | Create a map from an association list.
-fromAssocList :: [(Key, a)] -> Container a
-fromAssocList = IntMap.fromList
-
-- | Add or update two elements of the map.
addTwo :: Key -> a -> Key -> a -> Container a -> Container a
addTwo k1 v1 k2 v2 = add k1 v1 . add k2 v2
Types.AllocPreferred
defGroupList :: Group.List
-defGroupList = Container.fromAssocList [(Group.idx defGroup, defGroup)]
+defGroupList = Container.fromList [(Group.idx defGroup, defGroup)]
defGroupAssoc :: Data.Map.Map String Types.Gdx
defGroupAssoc = Data.Map.singleton (Group.uuid defGroup) (Group.idx defGroup)
nn { Node.name = name,
Node.alias = alias }))
$ zip names nodes
- nl' = Container.fromAssocList nodes'
+ nl' = Container.fromList nodes'
target = snd (nodes' !! fidx)
in Container.findByName nl' (Node.name target) == Just target &&
Container.findByName nl' (Node.alias target) == Just target &&
(Node.tDsk node > 0) && (Node.tMem node > 0)) ==>
let fn = Node.buildPeers node Container.empty
nlst = zip [1..] $ replicate count fn::[(Types.Ndx, Node.Node)]
- nl = Container.fromAssocList nlst
+ nl = Container.fromList nlst
score = Cluster.compCV nl
-- we can't say == 0 here as the floating point errors accumulate;
-- this should be much lower than the default score in CLI.hs
(Node.availDisk node > 0) && (Node.availMem node > 0)) ==>
let fn = Node.buildPeers node Container.empty
nlst = zip [1..] $ replicate count fn::[(Types.Ndx, Node.Node)]
- nl = Container.fromAssocList nlst
+ nl = Container.fromList nlst
cstats = Cluster.totalResources nl
in Cluster.csAdsk cstats >= 0 &&
Cluster.csAdsk cstats <= Cluster.csFdsk cstats
inst1 = Instance.setBoth inst (Node.idx node1) (Node.idx node2)
inst2 = Instance.setBoth inst (Node.idx node1) Node.noSecondary
inst3 = Instance.setBoth inst (Node.idx node1) (Node.idx node3)
- ccheck = Cluster.findSplitInstances nl' . Container.fromAssocList
+ ccheck = Cluster.findSplitInstances nl' . Container.fromList
in null (ccheck [(0, inst1)]) &&
null (ccheck [(0, inst2)]) &&
(not . null $ ccheck [(0, inst3)])
-- | Checks that the number of primary instances recorded on the nodes
-- is zero
prop_Loader_mergeData ns =
- let na = Container.fromAssocList $ map (\n -> (Node.idx n, n)) ns
+ let na = Container.fromList $ map (\n -> (Node.idx n, n)) ns
in case Loader.mergeData [] [] []
(Loader.emptyCluster {Loader.cdNodes = na}) of
Types.Bad _ -> False
let ktn = map (\(idx, n) -> (idx, Node.setIdx n idx))
$ zip [1..] nodes'
ktg = map (\g -> (Group.idx g, g)) groups
- return (ClusterData (Container.fromAssocList ktg)
- (Container.fromAssocList ktn) Container.empty [])
+ return (ClusterData (Container.fromList ktg)
+ (Container.fromList ktn) Container.empty [])
-- | Builds the cluster data from node\/instance files.
loadData :: [String] -- ^ Cluster description in text format