ruby-druid 0.10.1 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/druid/version.rb +1 -1
- data/lib/druid/zk.rb +12 -12
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0c3c8d5446273522ee0ed61a17e920480a81fc1
|
4
|
+
data.tar.gz: 9ab5eda36c0f96eb50a6abe2f43b18b2c31fc324
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24308e3e10381ac3d3b3c2f0671877b9accde3773e892bfc06f88860ca3043c3868531cd20c450bd11bb7c6ea40f83f43aa59e04bdd6c70926a39c513a956257
|
7
|
+
data.tar.gz: 4e77ad95ba2633f2145328982a2bf5df29b00d785b0ad70c489e48ed2af15637d0a9577c0fa32872d172cf3de6d1a6f3e790f30f17d4f71a88936ce198fa637b
|
data/lib/druid/version.rb
CHANGED
data/lib/druid/zk.rb
CHANGED
@@ -13,37 +13,37 @@ module Druid
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def register
|
16
|
-
$log.
|
16
|
+
$log.debug("druid.zk register discovery path") if $log
|
17
17
|
@zk.on_expired_session { register }
|
18
18
|
@zk.register(@discovery_path, only: :child) do |event|
|
19
|
-
$log.
|
19
|
+
$log.debug("druid.zk got event on discovery path") if $log
|
20
20
|
check_services
|
21
21
|
end
|
22
22
|
check_services
|
23
23
|
end
|
24
24
|
|
25
25
|
def close!
|
26
|
-
$log.
|
26
|
+
$log.debug("druid.zk shutting down") if $log
|
27
27
|
@zk.close!
|
28
28
|
end
|
29
29
|
|
30
30
|
def register_service(service, brokers)
|
31
|
-
$log.
|
31
|
+
$log.debug("druid.zk register", service: service, brokers: brokers) if $log
|
32
32
|
# poor mans load balancing
|
33
33
|
@registry[service] = brokers.shuffle
|
34
34
|
end
|
35
35
|
|
36
36
|
def unregister_service(service)
|
37
|
-
$log.
|
37
|
+
$log.debug("druid.zk unregister", service: service) if $log
|
38
38
|
@registry.delete(service)
|
39
39
|
unwatch_service(service)
|
40
40
|
end
|
41
41
|
|
42
42
|
def watch_service(service)
|
43
43
|
return if @watched_services.include?(service)
|
44
|
-
$log.
|
44
|
+
$log.debug("druid.zk watch", service: service) if $log
|
45
45
|
watch = @zk.register(watch_path(service), only: :child) do |event|
|
46
|
-
$log.
|
46
|
+
$log.debug("druid.zk got event on watch path for", service: service, event: event) if $log
|
47
47
|
unwatch_service(service)
|
48
48
|
check_service(service)
|
49
49
|
end
|
@@ -52,12 +52,12 @@ module Druid
|
|
52
52
|
|
53
53
|
def unwatch_service(service)
|
54
54
|
return unless @watched_services.include?(service)
|
55
|
-
$log.
|
55
|
+
$log.debug("druid.zk unwatch", service: service) if $log
|
56
56
|
@watched_services.delete(service).unregister
|
57
57
|
end
|
58
58
|
|
59
59
|
def check_services
|
60
|
-
$log.
|
60
|
+
$log.debug("druid.zk checking services") if $log
|
61
61
|
zk_services = @zk.children(@discovery_path, watch: true)
|
62
62
|
|
63
63
|
(services - zk_services).each do |service|
|
@@ -70,7 +70,7 @@ module Druid
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def verify_broker(service, name)
|
73
|
-
$log.
|
73
|
+
$log.debug("druid.zk verify", broker: name, service: service) if $log
|
74
74
|
info = @zk.get("#{watch_path(service)}/#{name}")
|
75
75
|
node = MultiJson.load(info[0])
|
76
76
|
uri = "http://#{node['address']}:#{node['port']}/druid/v2/"
|
@@ -78,7 +78,7 @@ module Druid
|
|
78
78
|
method: :get, url: "#{uri}datasources/",
|
79
79
|
timeout: 5, open_timeout: 5
|
80
80
|
})
|
81
|
-
$log.
|
81
|
+
$log.debug("druid.zk verified", uri: uri, sources: check) if $log
|
82
82
|
return [uri, MultiJson.load(check.to_str)] if check.code == 200
|
83
83
|
rescue
|
84
84
|
return false
|
@@ -96,7 +96,7 @@ module Druid
|
|
96
96
|
known = @registry[service].map { |node| node[:name] }
|
97
97
|
live = @zk.children(watch_path(service), watch: true)
|
98
98
|
new_list = @registry[service].select { |node| live.include?(node[:name]) }
|
99
|
-
$log.
|
99
|
+
$log.debug("druid.zk checking", service: service, known: known, live: live, new_list: new_list) if $log
|
100
100
|
|
101
101
|
# verify the new entries to be living brokers
|
102
102
|
(live - known).each do |name|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-druid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruby Druid Community
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -211,13 +211,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
211
|
version: '0'
|
212
212
|
requirements: []
|
213
213
|
rubyforge_project:
|
214
|
-
rubygems_version: 2.
|
214
|
+
rubygems_version: 2.5.2.1
|
215
215
|
signing_key:
|
216
216
|
specification_version: 4
|
217
217
|
summary: A Ruby client for Druid
|
218
218
|
test_files:
|
219
219
|
- spec/spec_helper.rb
|
220
|
+
- spec/lib/query_spec.rb
|
221
|
+
- spec/lib/data_source_spec.rb
|
220
222
|
- spec/lib/client_spec.rb
|
221
223
|
- spec/lib/zk_spec.rb
|
222
|
-
- spec/lib/data_source_spec.rb
|
223
|
-
- spec/lib/query_spec.rb
|