mamiya 0.0.1.alpha23 → 0.0.1.alpha24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46e8f4b3cd898fb6448e6cd4d5e8161c2fac101b
4
- data.tar.gz: d921dadc048b7bfc587ec71a25d2cf14323dbe53
3
+ metadata.gz: 5cff88034ce82da05b6bbef3f14e01c3d64a0106
4
+ data.tar.gz: 955b085f2d2ad3911608daf3356569b072c37af1
5
5
  SHA512:
6
- metadata.gz: d1169ca11bfc342862c8fc46fff5e91423a4d06ef2cab4f80b36275129e4b8f12047719b0459fc513d0e6091d1f43ccaa22834f9fa88ae0696a91e44e53268fc
7
- data.tar.gz: b4906b0a1110d80ac1e82f7fecdbe22fc4b782203fdfcb83840cf3ecca4a3126334f02159e3966d93984e06ae556b0afb6c41dddb3786b9af603c924b74d986b
6
+ metadata.gz: 09ac1bd2fa42fe80d9c7c0c253b387987f1bd65d73036447c1ebe76b3a7b0a35a442652dea295d6c210d8ad8a5ee8311c004822db6adb2315a1824fc1da6551c
7
+ data.tar.gz: 231d431e2a6ab44a47843712edff9b9389aa0594b87915ef308ee08b7ffe914ba3abb4007cbe772c85ae9f4ceecdde43ec9f4a129bb7020ff82a3c02e51538f5
data/lib/mamiya/agent.rb CHANGED
@@ -218,7 +218,9 @@ module Mamiya
218
218
  if handler.respond_to?(meth)
219
219
  handler.send meth
220
220
  else
221
- logger.debug "Handler #{class_name} doesn't respond to #{meth}, skipping"
221
+ if config.debug_all_events
222
+ logger.debug "Handler #{class_name} doesn't respond to #{meth}, skipping"
223
+ end
222
224
  end
223
225
  else
224
226
  #logger.warn("Discarded event[#{event.user_event}] because we don't handle it")
@@ -5,6 +5,7 @@ require 'thread'
5
5
  module Mamiya
6
6
  class Agent
7
7
  class TaskQueue
8
+ class Stopped < Exception; end
8
9
  GRACEFUL_TIMEOUT = 30
9
10
  JOIN_TIMEOUT = 30
10
11
 
data/lib/mamiya/logger.rb CHANGED
@@ -55,6 +55,16 @@ module Mamiya
55
55
  @logdev.remove_output(*outputs)
56
56
  end
57
57
 
58
+ alias orig_dup dup
59
+
60
+ def dup
61
+ self.orig_dup.tap do |new_logger|
62
+ new_logger.instance_eval do
63
+ @logger = @logger.dup
64
+ end
65
+ end
66
+ end
67
+
58
68
  def with_clean_progname
59
69
  self.dup.tap do |new|
60
70
  new.progname = nil
@@ -64,9 +74,8 @@ module Mamiya
64
74
  def [](progname)
65
75
  self.dup.tap do |new_logger|
66
76
  new_logger.instance_eval do
67
- @logger = @logger.dup
68
77
  if @logger.progname && !@logger.progname.empty?
69
- @logger.progname += "/#{progname}"
78
+ @logger.progname = "#{@logger.progname}/#{progname}"
70
79
  else
71
80
  @logger.progname = progname
72
81
  end
@@ -113,6 +113,12 @@ module Mamiya
113
113
  end
114
114
 
115
115
  @commit_lock.synchronize {
116
+ if kwargs[:node]
117
+ new_statuses = statuses.reject do |name, status|
118
+ kwargs[:node].include?(name)
119
+ end
120
+ end
121
+
116
122
  status_query_th = Thread.new { @master.serf.query(STATUS_QUERY, '', **kwargs) }
117
123
  packages_query_th = Thread.new { @master.serf.query(PACKAGES_QUERY, '', **kwargs) }
118
124
  status_response = status_query_th.value
@@ -133,12 +139,9 @@ module Mamiya
133
139
 
134
140
  begin
135
141
  resp = JSON.parse(json)
136
- if resp.keys.sort == ['packages', 'prereleases']
137
- new_statuses[name]['packages'] = resp['packages']
138
- new_statuses[name]['prereleases'] = resp['prereleases']
139
- else # TODO: Compatibility; should remove soon
140
- new_statuses[name]['packages'] = resp
141
- end
142
+
143
+ new_statuses[name]['packages'] = resp['packages']
144
+ new_statuses[name]['prereleases'] = resp['prereleases']
142
145
  rescue JSON::ParserError => e
143
146
  logger.warn "Failed to parse packages from #{name}: #{e.message}"
144
147
  next
@@ -1,3 +1,3 @@
1
1
  module Mamiya
2
- VERSION = "0.0.1.alpha23"
2
+ VERSION = "0.0.1.alpha24"
3
3
  end
@@ -121,7 +121,6 @@ describe Mamiya::Master::AgentMonitor do
121
121
  }
122
122
  end
123
123
 
124
-
125
124
  it "updates status .packages by packages query" do
126
125
  expect {
127
126
  agent_monitor.refresh
@@ -233,6 +232,97 @@ describe Mamiya::Master::AgentMonitor do
233
232
  agent_monitor.refresh(node: 'foo')
234
233
  end
235
234
  end
235
+
236
+ context "with nodes list" do
237
+ before do
238
+ stub_serf_queries()
239
+ agent_monitor.refresh
240
+
241
+ allow(serf).to receive(:query) do |query, payload, kwargs={}|
242
+ expect(payload).to eq ''
243
+ #expect(kwargs).to eq(node: ['b'])
244
+ expect(%w(mamiya:status mamiya:packages)).to include(query)
245
+
246
+ {'mamiya:status' => status_query_response_part, 'mamiya:packages' => packages_query_response_part}[query]
247
+ end
248
+ end
249
+
250
+ let(:status_query_response) do
251
+ {
252
+ "Acks" => ['a'],
253
+ "Responses" => {
254
+ 'a' => {"foo" => "bar"}.to_json,
255
+ },
256
+ }
257
+ end
258
+
259
+ let(:packages_query_response) do
260
+ {
261
+ "Acks" => ['a'],
262
+ "Responses" => {
263
+ 'a' => {"packages" => {"app" => ['pkg1','pkg2']}, "prereleases" => {"app" => ['pkg2']}}.to_json,
264
+ },
265
+ }
266
+ end
267
+
268
+ let(:status_query_response_part) do
269
+ {
270
+ "Acks" => ['a'],
271
+ "Responses" => {
272
+ 'b' => {"foo" => "bar"}.to_json,
273
+ },
274
+ }
275
+ end
276
+
277
+ let(:packages_query_response_part) do
278
+ {
279
+ "Acks" => ['a'],
280
+ "Responses" => {
281
+ 'b' => {"packages" => {"app" => ['pkg1']}, "prereleases" => {"app" => ['pkg2']}}.to_json,
282
+ },
283
+ }
284
+ end
285
+
286
+ let(:members) do
287
+ [
288
+ {
289
+ "name"=>"a", "status"=>"alive",
290
+ "addr"=>"x.x.x.x:7676", "port"=>7676,
291
+ "protocol"=>{"max"=>4, "min"=>2, "version"=>4},
292
+ "tags"=>{},
293
+ },
294
+ {
295
+ "name"=>"b", "status"=>"alive",
296
+ "addr"=>"x.x.y.y:7676", "port"=>7676,
297
+ "protocol"=>{"max"=>4, "min"=>2, "version"=>4},
298
+ "tags"=>{},
299
+ },
300
+ ]
301
+ end
302
+
303
+ it "updates partially" do
304
+ expect(agent_monitor.statuses['b']).to be_nil
305
+
306
+ expect {
307
+ agent_monitor.refresh(node: ['b'])
308
+ }.not_to change {
309
+ [agent_monitor.statuses['a'], agent_monitor.agents['a']]
310
+ }
311
+
312
+ expect(agent_monitor.failed_agents).to eq []
313
+ expect(agent_monitor.statuses['b']).to eq(
314
+ {"foo" => "bar", "packages" => {"app" => ['pkg1']}, "prereleases" => {"app" => ['pkg2']}}
315
+ )
316
+ expect(agent_monitor.agents['b']).to eq(
317
+ {
318
+ "name"=>"b", "status"=>"alive",
319
+ "addr"=>"x.x.y.y:7676", "port"=>7676,
320
+ "protocol"=>{"max"=>4, "min"=>2, "version"=>4},
321
+ "tags"=>{},
322
+ }
323
+ )
324
+ end
325
+ end
236
326
  end
237
327
 
238
328
  describe "(commiting events)" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mamiya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha23
4
+ version: 0.0.1.alpha24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Fukumori (sora_h)