From cb0c77ffdea421df940f17626ca59af2b4327006 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 30 Dec 2010 11:18:30 +0100 Subject: [PATCH] Container: remove fromAssocList Container.fromAssocList is just a re-export of IntMap.fromList; it makes sense to remove it and simply export the original name, as it needs just a bit of renaming in the rest of the code. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Balazs Lecz <leczb@google.com> --- Ganeti/HTools/Cluster.hs | 2 +- Ganeti/HTools/Container.hs | 8 ++------ Ganeti/HTools/Loader.hs | 2 +- Ganeti/HTools/QC.hs | 12 ++++++------ Ganeti/HTools/Simu.hs | 4 ++-- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Ganeti/HTools/Cluster.hs b/Ganeti/HTools/Cluster.hs index 1e111f05c..c3a1a2640 100644 --- a/Ganeti/HTools/Cluster.hs +++ b/Ganeti/HTools/Cluster.hs @@ -999,4 +999,4 @@ splitCluster nl il = let nidxs = map Node.idx nodes nodes' = zip nidxs nodes instances = Container.filter ((`elem` nidxs) . Instance.pNode) il - in (guuid, (Container.fromAssocList nodes', instances))) ngroups + in (guuid, (Container.fromList nodes', instances))) ngroups diff --git a/Ganeti/HTools/Container.hs b/Ganeti/HTools/Container.hs index d24bb793b..12d19788f 100644 --- a/Ganeti/HTools/Container.hs +++ b/Ganeti/HTools/Container.hs @@ -7,7 +7,7 @@ give the best performance for our workload. {- -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 @@ -34,7 +34,7 @@ module Ganeti.HTools.Container -- * Creation , IntMap.empty , IntMap.singleton - , fromAssocList + , IntMap.fromList -- * Query , IntMap.size , IntMap.null @@ -69,10 +69,6 @@ find k = (IntMap.! k) 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 diff --git a/Ganeti/HTools/Loader.hs b/Ganeti/HTools/Loader.hs index f011629dd..c17aba1c7 100644 --- a/Ganeti/HTools/Loader.hs +++ b/Ganeti/HTools/Loader.hs @@ -119,7 +119,7 @@ assignIndices nodes = let (na, idx_node) = unzip . map (\ (idx, (k, v)) -> ((k, idx), (idx, setIdx v idx))) . zip [0..] $ nodes - in (M.fromList na, Container.fromAssocList idx_node) + in (M.fromList na, Container.fromList idx_node) -- | For each instance, add its index to its primary and secondary nodes. fixNodes :: Node.List diff --git a/Ganeti/HTools/QC.hs b/Ganeti/HTools/QC.hs index 1f55a6ea6..79600b83c 100644 --- a/Ganeti/HTools/QC.hs +++ b/Ganeti/HTools/QC.hs @@ -85,7 +85,7 @@ defGroup = flip Group.setIdx 0 $ 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) @@ -325,7 +325,7 @@ prop_Container_findByName node othername = 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 && @@ -655,7 +655,7 @@ prop_Score_Zero node count = (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 @@ -667,7 +667,7 @@ prop_CStats_sane node count = (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 @@ -770,7 +770,7 @@ prop_ClusterCheckConsistency node inst = 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)]) @@ -849,7 +849,7 @@ prop_Loader_assignIndices nodes = -- | 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 diff --git a/Ganeti/HTools/Simu.hs b/Ganeti/HTools/Simu.hs index f129a3670..1515bd0db 100644 --- a/Ganeti/HTools/Simu.hs +++ b/Ganeti/HTools/Simu.hs @@ -82,8 +82,8 @@ parseData ndata = do 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 -- GitLab