On Wed, Sep 28, 2011 at 01:17:33PM +0200, Agata Murawska wrote:
> On Mon, Sep 26, 2011 at 12:08 PM, Iustin Pop <[email protected]> wrote:
> > Currently, the node pairs used for allocation are a simple [(primary,
> > secondary)] list of tuples, as this is how they were used before the
> > previous patch. However, for that patch, we use them separately per
> > primary node, and we have to unpack this list right after generation.
> >
> > Therefore it makes sense to directly generate the list in the correct
> > form, and remove the split from tryAlloc. This should not be slower
> > than the previous patch, at least, possibly even faster.
> > ---
> > htools/Ganeti/HTools/Cluster.hs | 24 ++++++++++++------------
> > 1 files changed, 12 insertions(+), 12 deletions(-)
> >
> > diff --git a/htools/Ganeti/HTools/Cluster.hs
> > b/htools/Ganeti/HTools/Cluster.hs
> > index d19df58..15eaecf 100644
> > --- a/htools/Ganeti/HTools/Cluster.hs
> > +++ b/htools/Ganeti/HTools/Cluster.hs
> > @@ -74,12 +74,10 @@ module Ganeti.HTools.Cluster
> > ) where
> >
> > import qualified Data.IntSet as IntSet
> > -import Data.Function (on)
> > import Data.List
> > import Data.Maybe (fromJust, isNothing)
> > import Data.Ord (comparing)
> > import Text.Printf (printf)
> > -import Control.Monad
> >
> > import qualified Ganeti.HTools.Container as Container
> > import qualified Ganeti.HTools.Instance as Instance
> > @@ -119,7 +117,7 @@ type AllocResult = (FailStats, Node.List, Instance.List,
> > -- For a one-node allocation, this will be a @Left ['Node.Node']@,
> > -- whereas for a two-node allocation, this will be a @Right
> > -- [('Node.Node', 'Node.Node')]@.
> > -type AllocNodes = Either [Ndx] [(Ndx, Ndx)]
> > +type AllocNodes = Either [Ndx] [(Ndx, [Ndx])]
> Please document the change in the comment
Oh, forgot this. Interdiff, also with changed types in the docstring
(since they were changed a while ago):
diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs
index 63f5a3c..5bd18ae 100644
--- a/htools/Ganeti/HTools/Cluster.hs
+++ b/htools/Ganeti/HTools/Cluster.hs
@@ -114,9 +114,11 @@ type AllocResult = (FailStats, Node.List, Instance.List,
-- | A type denoting the valid allocation mode/pairs.
--
--- For a one-node allocation, this will be a @Left ['Node.Node']@,
--- whereas for a two-node allocation, this will be a @Right
--- [('Node.Node', 'Node.Node')]@.
+-- For a one-node allocation, this will be a @Left ['Ndx']@, whereas
+-- for a two-node allocation, this will be a @Right [('Ndx',
+-- ['Ndx'])]@. In the latter case, the list is basically an
+-- association list, grouped by primary node and holding the potential
+-- secondary nodes in the sub-list.
type AllocNodes = Either [Ndx] [(Ndx, [Ndx])]
-- | The empty solution we start with when computing allocations.
--
iustin