Sha256: c6126c84e7e8da4036c699f89f4b1fc07c33fd0b5bf9194058cad18f1eba734a

Contents?: true

Size: 793 Bytes

Versions: 2

Compression:

Stored size: 793 Bytes

Contents

class Hadouken::Strategy::ByGroupParallel < Hadouken::Strategy::Base
  def host_strategy
    return @host_sets if @host_sets

    # transform a array of groups, hosts into a new array that balances
    # hosts from each group into a single array.
    @host_sets = []
    regroup    = []
    groups     = []
    max_size   =  0

    plan.groups.each do |group|
      hosts     = group.hosts
      max_size  = [max_size, hosts.size].max
      groups   << hosts
    end

    [max_size, groups.size].max.times do  
      groups.each do |hosts|
        if hosts.size == 0
          #TODO groups.delete(name)
        else
          regroup << hosts.shift
        end
      end
    end

    regroup.each_slice(max_size) do |host_slice|
      @host_sets << host_slice
    end

    @balanced
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hadouken-0.1.5.pre lib/hadouken/strategy/by_group_parallel.rb
hadouken-0.1.4.pre lib/hadouken/strategy/by_group_parallel.rb