mamiya 0.0.1.alpha18 → 0.0.1.alpha19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mamiya/agent.rb +6 -8
- data/lib/mamiya/agent/actions.rb +2 -0
- data/lib/mamiya/agent/handlers/fetch.rb +9 -4
- data/lib/mamiya/master.rb +2 -1
- data/lib/mamiya/master/agent_monitor_handlers.rb +6 -0
- data/lib/mamiya/version.rb +1 -1
- data/spec/agent/actions_spec.rb +2 -1
- data/spec/agent/handlers/fetch_spec.rb +9 -3
- data/spec/agent_spec.rb +1 -0
- data/spec/master_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37666b908bc503abe07629a7308eeb762be79cf7
|
4
|
+
data.tar.gz: aef8d218df47dcdb03e5ff069d7e3a5c4a78a13b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ada7d2968785edd0b9b1f51dfa53d4d8da428ca87f3e85562d05a0505553fe16b303e60d07d6478e090ff7183996a4dcc16322ac21f70038f61e181dd7d31efa
|
7
|
+
data.tar.gz: 044f922700e0f5d873058564b263108ef3ee7350084a5561e17550c205f45b37526ef0e1b347ad3788bb51ba080db71e1b32814b2708310e33c9e9b23367f913
|
data/lib/mamiya/agent.rb
CHANGED
@@ -119,11 +119,11 @@ module Mamiya
|
|
119
119
|
]
|
120
120
|
end
|
121
121
|
|
122
|
-
def trigger(type, action: nil, **payload)
|
122
|
+
def trigger(type, action: nil, coalesce: true, **payload)
|
123
123
|
name = "mamiya:#{type}"
|
124
124
|
name << ":#{action}" if action
|
125
125
|
|
126
|
-
serf.event(name, payload.to_json)
|
126
|
+
serf.event(name, payload.to_json, coalesce: coalesce)
|
127
127
|
end
|
128
128
|
|
129
129
|
private
|
@@ -190,12 +190,10 @@ module Mamiya
|
|
190
190
|
end
|
191
191
|
|
192
192
|
def cleanup_handler(app, package)
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
package: package,
|
198
|
-
}.to_json
|
193
|
+
trigger('fetch-result', action: 'remove', coalesce: false,
|
194
|
+
name: self.serf.name,
|
195
|
+
application: app,
|
196
|
+
package: package,
|
199
197
|
)
|
200
198
|
end
|
201
199
|
end
|
data/lib/mamiya/agent/actions.rb
CHANGED
@@ -15,13 +15,15 @@ module Mamiya
|
|
15
15
|
].freeze
|
16
16
|
|
17
17
|
def run!
|
18
|
+
# XXX: Why don't use agent#trigger ...
|
18
19
|
agent.serf.event(FETCH_ACK_EVENT,
|
19
20
|
{
|
20
21
|
name: agent.serf.name,
|
21
22
|
application: payload['application'],
|
22
23
|
package: payload['package'],
|
23
24
|
pending: agent.fetcher.queue_size.succ,
|
24
|
-
}.to_json
|
25
|
+
}.to_json,
|
26
|
+
coalesce: false,
|
25
27
|
)
|
26
28
|
|
27
29
|
agent.fetcher.enqueue(
|
@@ -33,7 +35,8 @@ module Mamiya
|
|
33
35
|
application: payload['application'],
|
34
36
|
package: payload['package'],
|
35
37
|
pending: agent.fetcher.queue_size.succ,
|
36
|
-
}.to_json
|
38
|
+
}.to_json,
|
39
|
+
coalesce: false,
|
37
40
|
)
|
38
41
|
agent.update_tags!
|
39
42
|
}
|
@@ -48,7 +51,8 @@ module Mamiya
|
|
48
51
|
package: payload['package'],
|
49
52
|
error: error.class,
|
50
53
|
pending: agent.fetcher.queue_size,
|
51
|
-
}.to_json
|
54
|
+
}.to_json,
|
55
|
+
coalesce: false,
|
52
56
|
)
|
53
57
|
rescue Villein::Client::SerfError => e
|
54
58
|
agent.logger.error "error sending fetch error event: #{e.inspect}"
|
@@ -60,7 +64,8 @@ module Mamiya
|
|
60
64
|
application: payload['application'],
|
61
65
|
package: payload['package'],
|
62
66
|
pending: agent.fetcher.queue_size,
|
63
|
-
}.to_json
|
67
|
+
}.to_json,
|
68
|
+
coalesce: false,
|
64
69
|
)
|
65
70
|
end
|
66
71
|
|
data/lib/mamiya/master.rb
CHANGED
@@ -38,8 +38,9 @@ module Mamiya
|
|
38
38
|
super
|
39
39
|
end
|
40
40
|
|
41
|
+
# XXX: dupe? Mamiya::Agent::Actions#distribute
|
41
42
|
def distribute(application, package)
|
42
|
-
trigger(:fetch, application: application, package: package)
|
43
|
+
trigger(:fetch, coalesce: false, application: application, package: package)
|
43
44
|
end
|
44
45
|
|
45
46
|
def storage(app)
|
@@ -15,6 +15,8 @@ module Mamiya
|
|
15
15
|
status['fetcher'] ||= {}
|
16
16
|
status['fetcher']['fetching'] = [payload['application'], payload['package']]
|
17
17
|
|
18
|
+
logger.debug "#{status['name']} started to fetch #{payload['application']}/#{payload['package']}"
|
19
|
+
|
18
20
|
status['fetcher']['pending_jobs'] ||= []
|
19
21
|
status['fetcher']['pending_jobs'].delete [payload['application'], payload['package']]
|
20
22
|
end
|
@@ -22,6 +24,8 @@ module Mamiya
|
|
22
24
|
def fetch_result__error(status, payload, event)
|
23
25
|
status['fetcher'] ||= {}
|
24
26
|
|
27
|
+
logger.error "#{status['name']} failed to fetch #{payload['application']}/#{payload['package']}: #{payload['error']}"
|
28
|
+
|
25
29
|
if status['fetcher']['fetching'] == [payload['application'], payload['package']]
|
26
30
|
status['fetcher']['fetching'] = nil
|
27
31
|
end
|
@@ -30,6 +34,8 @@ module Mamiya
|
|
30
34
|
def fetch_result__success(status, payload, event)
|
31
35
|
status['fetcher'] ||= {}
|
32
36
|
|
37
|
+
logger.info "#{status['name']} fetched #{payload['application']}/#{payload['package']}"
|
38
|
+
|
33
39
|
if status['fetcher']['fetching'] == [payload['application'], payload['package']]
|
34
40
|
status['fetcher']['fetching'] = nil
|
35
41
|
end
|
data/lib/mamiya/version.rb
CHANGED
data/spec/agent/actions_spec.rb
CHANGED
@@ -28,7 +28,8 @@ describe Mamiya::Agent::Actions do
|
|
28
28
|
it "sends fetch request" do
|
29
29
|
expect(serf).to receive(:event).with(
|
30
30
|
'mamiya:fetch',
|
31
|
-
{application: 'app', package: 'pkg'}.to_json
|
31
|
+
{application: 'app', package: 'pkg'}.to_json,
|
32
|
+
coalesce: false
|
32
33
|
)
|
33
34
|
|
34
35
|
agent.distribute('app', 'pkg')
|
@@ -44,7 +44,9 @@ describe Mamiya::Agent::Handlers::Fetch do
|
|
44
44
|
it "responds ack" do
|
45
45
|
allow(fetcher).to receive(:enqueue).with('app', 'package')
|
46
46
|
expect(serf).to receive(:event).with('mamiya:fetch-result:ack',
|
47
|
-
{name: serf.name, application: 'app', package: 'package', pending: 1}.to_json
|
47
|
+
{name: serf.name, application: 'app', package: 'package', pending: 1}.to_json,
|
48
|
+
coalesce: false,
|
49
|
+
)
|
48
50
|
|
49
51
|
handler.run!
|
50
52
|
end
|
@@ -62,7 +64,9 @@ describe Mamiya::Agent::Handlers::Fetch do
|
|
62
64
|
options[:before].call
|
63
65
|
end
|
64
66
|
expect(serf).to receive(:event).with('mamiya:fetch-result:start',
|
65
|
-
{name: serf.name, application: 'app', package: 'package', pending: 1}.to_json
|
67
|
+
{name: serf.name, application: 'app', package: 'package', pending: 1}.to_json,
|
68
|
+
coalesce: false
|
69
|
+
)
|
66
70
|
|
67
71
|
handler.run!
|
68
72
|
end
|
@@ -77,7 +81,8 @@ describe Mamiya::Agent::Handlers::Fetch do
|
|
77
81
|
|
78
82
|
expect(serf).to receive(:event).with(
|
79
83
|
'mamiya:fetch-result:success',
|
80
|
-
{name: serf.name, application: 'app', package: 'package', pending: 0}.to_json
|
84
|
+
{name: serf.name, application: 'app', package: 'package', pending: 0}.to_json,
|
85
|
+
coalesce: false
|
81
86
|
)
|
82
87
|
|
83
88
|
callback.call
|
@@ -104,6 +109,7 @@ describe Mamiya::Agent::Handlers::Fetch do
|
|
104
109
|
name: serf.name, application: 'app', package: 'package',
|
105
110
|
error: error.class, pending: 0,
|
106
111
|
}.to_json,
|
112
|
+
coalesce: false,
|
107
113
|
)
|
108
114
|
|
109
115
|
callback.call(error)
|
data/spec/agent_spec.rb
CHANGED
data/spec/master_spec.rb
CHANGED
@@ -50,7 +50,7 @@ describe Mamiya::Master do
|
|
50
50
|
# end
|
51
51
|
|
52
52
|
it "triggers fetch event" do
|
53
|
-
expect(master).to receive(:trigger).with(:fetch, application: 'myapp', package: 'mypackage')
|
53
|
+
expect(master).to receive(:trigger).with(:fetch, coalesce: false, application: 'myapp', package: 'mypackage')
|
54
54
|
|
55
55
|
master.distribute('myapp', 'mypackage')
|
56
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mamiya
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.alpha19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shota Fukumori (sora_h)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|