Skip to content
This repository has been archived by the owner on Feb 19, 2018. It is now read-only.

Commit

Permalink
enable broker selection randomization
Browse files Browse the repository at this point in the history
  • Loading branch information
Hagen Rother committed May 22, 2013
1 parent ca9a8dd commit b27fe5e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
34 changes: 21 additions & 13 deletions Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
ruby-druid (0.0.7)
ruby-druid (0.0.9)
rest-client
zk

Expand All @@ -16,34 +16,42 @@ GEM
bond (0.4.3)
coderay (1.0.9)
crack (0.3.2)
diff-lcs (1.2.3)
diff-lcs (1.2.4)
ffi (1.8.1)
formatador (0.2.4)
guard (1.7.0)
guard (1.8.0)
formatador (>= 0.2.4)
listen (>= 0.6.0)
listen (>= 1.0.0)
lumberjack (>= 1.0.2)
pry (>= 0.9.10)
thor (>= 0.14.6)
guard-bundler (1.0.0)
bundler (~> 1.0)
guard (~> 1.1)
guard-rspec (2.5.3)
guard (>= 1.1)
rspec (~> 2.11)
guard-rspec (3.0.0)
guard (>= 1.8)
rspec (~> 2.13)
i18n (0.6.1)
listen (0.7.3)
listen (1.1.3)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
little-plugger (1.1.3)
logging (1.7.2)
little-plugger (>= 1.1.3)
lumberjack (1.0.3)
method_source (0.8.1)
mime-types (1.22)
multi_json (1.7.2)
pry (0.9.12)
mime-types (1.23)
multi_json (1.7.3)
pry (0.9.12.2)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
rb-fsevent (0.9.3)
rb-inotify (0.9.0)
ffi (>= 0.5.0)
rb-kqueue (0.2.0)
ffi (>= 0.5.0)
rest-client (1.6.7)
mime-types (>= 1.16)
ripl (0.7.0)
Expand All @@ -57,7 +65,7 @@ GEM
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.1)
ruby_gntp (0.3.4)
slop (3.4.4)
slop (3.4.5)
terminal-table (1.4.5)
thor (0.18.1)
webmock (1.11.0)
Expand All @@ -66,7 +74,7 @@ GEM
zk (1.8.0)
logging (~> 1.7.2)
zookeeper (~> 1.4.0)
zookeeper (1.4.3)
zookeeper (1.4.4)

PLATFORMS
ruby
Expand Down
9 changes: 7 additions & 2 deletions lib/druid/zoo_handler.rb
Expand Up @@ -102,14 +102,19 @@ def services
end

def data_sources
result = {}
result = Hash.new { |hash, key| hash[key] = [] }

@registry.each do |service, brokers|
brokers.each do |broker|
broker[:data_sources].each do |data_source|
result["#{service}/#{data_source}"] = broker[:uri]
result["#{service}/#{data_source}"] << broker[:uri]
end
end
end
result.each do |source, uris|
result[source] = uris.sample if uris.respond_to?(:sample)
end

result
end

Expand Down
4 changes: 2 additions & 2 deletions ruby-druid.gemspec
Expand Up @@ -2,8 +2,8 @@ require 'rake'

Gem::Specification.new do |gem|
gem.name = 'ruby-druid'
gem.version = '0.0.8'
gem.date = '2013-04-23'
gem.version = '0.0.9'
gem.date = '2013-05-22'
gem.summary = 'Ruby client for druid'
gem.description = 'Ruby client for metamx druid'
gem.authors = ['Hagen Rother', 'Holger Pillmann']
Expand Down

0 comments on commit b27fe5e

Please sign in to comment.