mamiya 0.0.1.alpha9 → 0.0.1.alpha10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mamiya/agent.rb +3 -0
- data/lib/mamiya/cli/client.rb +19 -9
- data/lib/mamiya/master/web.rb +39 -2
- data/lib/mamiya/version.rb +1 -1
- data/spec/agent_spec.rb +5 -0
- 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: 759f3b4c1591ed1aadc5ec73dfea2ec3fb262d52
|
4
|
+
data.tar.gz: b28cb4415f67b1a49c1c6f77deac0324eb165283
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fac824c20946f70f0ca4223a97db53b7868186ef7470ec7dcc99d9fa3ca51e672aa479dd53955a139f984373a13ae231c37f433de3c74cc23a81746ff1572780
|
7
|
+
data.tar.gz: c694781fe55e32e16f1fdb8caaa9c7b9180e7fcf994efc517bbbd8ad18c1bfd2bb0e8ef5467beefdebeb4163b6cac1558c320aa8f1bbd39a4c7e6c821182bea9
|
data/lib/mamiya/agent.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'thread'
|
2
2
|
require 'villein'
|
3
|
+
require 'mamiya/version'
|
4
|
+
|
3
5
|
require 'mamiya/logger'
|
4
6
|
|
5
7
|
require 'mamiya/steps/fetch'
|
@@ -76,6 +78,7 @@ module Mamiya
|
|
76
78
|
{}.tap do |s|
|
77
79
|
s[:master] = false
|
78
80
|
s[:name] = serf.name
|
81
|
+
s[:version] = Mamiya::VERSION
|
79
82
|
|
80
83
|
s[:fetcher] = {
|
81
84
|
fetching: fetcher.current_job,
|
data/lib/mamiya/cli/client.rb
CHANGED
@@ -91,23 +91,33 @@ module Mamiya
|
|
91
91
|
return
|
92
92
|
end
|
93
93
|
|
94
|
-
total = dist['distributed_count'] + dist['
|
95
|
-
|
96
|
-
Distribution status of #{application}/#{package}
|
94
|
+
total = dist['distributed_count'] + dist['fetching_count'] +
|
95
|
+
dist['queued_count'] + dist['not_distributed_count']
|
97
96
|
|
98
|
-
|
99
|
-
|
100
|
-
|
97
|
+
progress = "%.1f" % ((dist['distributed_count']/total.to_f)*100)
|
98
|
+
puts <<-EOF
|
99
|
+
package: #{application}/#{package}
|
100
|
+
status: #{dist['status']}
|
101
|
+
progress: #{progress}
|
102
|
+
|
103
|
+
distributed: #{dist['distributed_count']} agents
|
104
|
+
fetching: #{dist['fetching_count']} agents
|
105
|
+
queued: #{dist['queued_count']} agents
|
106
|
+
not distributed: #{dist['not_distributed_count']} agents
|
101
107
|
EOF
|
102
108
|
|
103
109
|
if options[:verbose]
|
104
110
|
puts ""
|
105
|
-
dist['not_distributed'].each do |name|
|
106
|
-
puts "#{name}\tnot_distributed"
|
107
|
-
end
|
108
111
|
dist['distributed'].each do |name|
|
109
112
|
puts "#{name}\tdistributed"
|
110
113
|
end
|
114
|
+
dist['queued'].each do |name|
|
115
|
+
puts "#{name}\tqueued"
|
116
|
+
end
|
117
|
+
dist['not_distributed'].each do |name|
|
118
|
+
puts "#{name}\tnot_distributed"
|
119
|
+
end
|
120
|
+
|
111
121
|
end
|
112
122
|
end
|
113
123
|
|
data/lib/mamiya/master/web.rb
CHANGED
@@ -74,27 +74,64 @@ module Mamiya
|
|
74
74
|
next {error: 'not found'}.to_json
|
75
75
|
end
|
76
76
|
|
77
|
-
result = {
|
77
|
+
result = {
|
78
|
+
application: params[:application],
|
79
|
+
package: params[:package],
|
80
|
+
distributed: [],
|
81
|
+
fetching: [],
|
82
|
+
queued: [],
|
83
|
+
not_distributed: []
|
84
|
+
}
|
78
85
|
statuses = agent_monitor.statuses
|
79
86
|
|
87
|
+
pkg_array = [params[:application], params[:package]]
|
88
|
+
|
80
89
|
statuses.each do |name, status|
|
81
90
|
next if status["master"]
|
82
91
|
if status["packages"] && status["packages"][params[:application]] &&
|
83
92
|
status["packages"][params[:application]].include?(params[:package])
|
84
93
|
|
85
94
|
result[:distributed] << name
|
95
|
+
elsif status["fetcher"] && status["fetcher"]["fetching"] && status["fetcher"]["fetching"] == pkg_array
|
96
|
+
result[:fetching] << name
|
97
|
+
elsif status["fetcher"]["pending_jobs"] &&
|
98
|
+
status["fetcher"]["pending_jobs"].include?(pkg_array)
|
99
|
+
result[:queued] << name
|
86
100
|
else
|
87
101
|
result[:not_distributed] << name
|
88
102
|
end
|
89
103
|
end
|
90
104
|
|
91
105
|
result[:distributed_count] = result[:distributed].size
|
106
|
+
result[:fetching_count] = result[:fetching].size
|
92
107
|
result[:not_distributed_count] = result[:not_distributed].size
|
108
|
+
result[:queued_count] = result[:queued].size
|
109
|
+
|
110
|
+
total = statuses.size
|
111
|
+
|
112
|
+
case
|
113
|
+
when 0 < result[:queued_count] || 0 < result[:fetching_count]
|
114
|
+
status = :distributing
|
115
|
+
when 0 < result[:distributed_count] && result[:distributed_count] < total
|
116
|
+
status = :well_distributed
|
117
|
+
when result[:distributed_count] == total
|
118
|
+
status = :distributed
|
119
|
+
else
|
120
|
+
status = :unknown
|
121
|
+
end
|
122
|
+
|
123
|
+
result[:status] = status
|
124
|
+
|
125
|
+
if params[:count_only]
|
126
|
+
result.delete :distributed
|
127
|
+
result.delete :fetching
|
128
|
+
result.delete :queued
|
129
|
+
result.delete :not_distributed
|
130
|
+
end
|
93
131
|
|
94
132
|
result.to_json
|
95
133
|
end
|
96
134
|
|
97
|
-
|
98
135
|
get '/agents' do
|
99
136
|
statuses = agent_monitor.statuses
|
100
137
|
members = agent_monitor.agents
|
data/lib/mamiya/version.rb
CHANGED
data/spec/agent_spec.rb
CHANGED
@@ -5,6 +5,7 @@ require 'fileutils'
|
|
5
5
|
require 'json'
|
6
6
|
require 'villein/event'
|
7
7
|
|
8
|
+
require 'mamiya/version'
|
8
9
|
require 'mamiya/agent'
|
9
10
|
require 'mamiya/agent/fetcher'
|
10
11
|
require 'mamiya/agent/actions'
|
@@ -117,6 +118,10 @@ describe Mamiya::Agent do
|
|
117
118
|
|
118
119
|
subject(:status) { agent.status }
|
119
120
|
|
121
|
+
it "includes version identifier" do
|
122
|
+
expect(status[:version]).to eq Mamiya::VERSION
|
123
|
+
end
|
124
|
+
|
120
125
|
it "includes agent name" do
|
121
126
|
expect(status[:name]).to eq serf.name
|
122
127
|
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.alpha10
|
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-06-
|
11
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|