mamiya 0.0.1.alpha9 → 0.0.1.alpha10

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: 3f7822be0f2ea92b439156730db75fc2608820ec
4
- data.tar.gz: 34495ba570dab6778304c2f0cc68b2fdc9914477
3
+ metadata.gz: 759f3b4c1591ed1aadc5ec73dfea2ec3fb262d52
4
+ data.tar.gz: b28cb4415f67b1a49c1c6f77deac0324eb165283
5
5
  SHA512:
6
- metadata.gz: a15d9f6afd8b69c60e12e22609fe1e713f5da3d85c1272923b171fc04946655e2cc6c19142e9af7d1b6e44927a80a59ccc79b59644dc15700a8b898da2a48a19
7
- data.tar.gz: c3fddda1d60e1e2b348c6c0b635426abc9d265fe9a42bcbb9b22908063a62e41a4e32f536299d5c69f7841b7e99b5625ce995a4f311a00e25c0e30cd12ec2b64
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,
@@ -91,23 +91,33 @@ module Mamiya
91
91
  return
92
92
  end
93
93
 
94
- total = dist['distributed_count'] + dist['not_distributed_count']
95
- puts <<-EOF
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
- ratio (distributed:total-agents): #{"%.1f" % ((dist['distributed_count']/total.to_f)*100)}%
99
- number of agents have package: #{dist['distributed_count']}
100
- number of agents don't have package: #{dist['not_distributed_count']}
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
 
@@ -74,27 +74,64 @@ module Mamiya
74
74
  next {error: 'not found'}.to_json
75
75
  end
76
76
 
77
- result = {application: params[:application], package: params[:package], distributed: [], not_distributed: []}
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
@@ -1,3 +1,3 @@
1
1
  module Mamiya
2
- VERSION = "0.0.1.alpha9"
2
+ VERSION = "0.0.1.alpha10"
3
3
  end
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.alpha9
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-04 00:00:00.000000000 Z
11
+ date: 2014-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor