right_chimp 2.1.0 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/right_chimp/Chimp.rb +6 -0
- data/lib/right_chimp/daemon/ChimpDaemon.rb +27 -1
- data/lib/right_chimp/objects/ChimpObjects.rb +16 -21
- data/lib/right_chimp/templates/all_jobs.erb +4 -2
- data/lib/right_chimp/version.rb +1 -1
- data/lib/right_chimp.rb +0 -3
- 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: 8af4200a6b909aada3f2301d06e987d35d2269fc
|
4
|
+
data.tar.gz: c0cedcfdf23e22c3f78a28ffc17effecf6dfa657
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ae8ebc03931a5e06759f997b6f8a563ff845bc7eea0ef8026b4fc52541eb4da58c3709bbd6d10ef8504adbd6be1e4a9be739b8931b4df07b71c3f9bf54dfb3c
|
7
|
+
data.tar.gz: 76f795bbf6f71e59490481eaab1d743a435405d0181124fb77273b9f112795cbc2524004e51bc3974475e7218c4eae8a1267ab7c90635ada3e660a7e381345ae
|
data/Gemfile.lock
CHANGED
data/lib/right_chimp/Chimp.rb
CHANGED
@@ -1062,6 +1062,7 @@ module Chimp
|
|
1062
1062
|
Chimp.set_job_uuid(self.job_uuid)
|
1063
1063
|
|
1064
1064
|
Log.debug "[#{Chimp.get_job_uuid}] Processing task"
|
1065
|
+
# Add to our "processing" counter
|
1065
1066
|
|
1066
1067
|
Log.debug "[#{Chimp.get_job_uuid}] Trying to get array_info" unless Chimp.failure
|
1067
1068
|
get_array_info unless Chimp.failure
|
@@ -1075,6 +1076,11 @@ module Chimp
|
|
1075
1076
|
Log.debug "[#{Chimp.get_job_uuid}] Trying to get executable_info" unless Chimp.failure
|
1076
1077
|
get_executable_info unless Chimp.failure
|
1077
1078
|
|
1079
|
+
# All elements of task have been processed
|
1080
|
+
ChimpDaemon.instance.semaphore.synchronize do
|
1081
|
+
ChimpDaemon.instance.proc_counter -= 1
|
1082
|
+
end
|
1083
|
+
|
1078
1084
|
if Chimp.failure
|
1079
1085
|
|
1080
1086
|
Log.error "##################################################"
|
@@ -7,7 +7,8 @@
|
|
7
7
|
module Chimp
|
8
8
|
class ChimpDaemon
|
9
9
|
|
10
|
-
attr_accessor :verbose, :debug, :port, :concurrency, :delay, :retry_count,
|
10
|
+
attr_accessor :verbose, :debug, :port, :concurrency, :delay, :retry_count,
|
11
|
+
:dry_run, :logfile, :chimp_queue, :proc_counter, :semaphore
|
11
12
|
attr_reader :queue, :running
|
12
13
|
|
13
14
|
include Singleton
|
@@ -23,6 +24,9 @@ module Chimp
|
|
23
24
|
@running = false
|
24
25
|
@queue = ChimpQueue.instance
|
25
26
|
@chimp_queue = Queue.new
|
27
|
+
@semaphore = Mutex.new
|
28
|
+
|
29
|
+
@proc_counter= 0
|
26
30
|
|
27
31
|
#Connect to the API
|
28
32
|
Connection.instance
|
@@ -402,6 +406,10 @@ module Chimp
|
|
402
406
|
# end
|
403
407
|
if verb == 'process' or verb == 'add'
|
404
408
|
ChimpDaemon.instance.chimp_queue.push payload
|
409
|
+
ChimpDaemon.instance.semaphore.synchronize do
|
410
|
+
ChimpDaemon.instance.proc_counter +=1
|
411
|
+
end
|
412
|
+
Log.debug "Tasks in the processing queue: #{ChimpDaemon.instance.proc_counter.to_s}"
|
405
413
|
id = 0
|
406
414
|
elsif verb == 'update'
|
407
415
|
puts "UPDATE"
|
@@ -521,6 +529,23 @@ module Chimp
|
|
521
529
|
template_path = 'lib/right_chimp/templates'
|
522
530
|
end
|
523
531
|
|
532
|
+
#
|
533
|
+
# Check if we are asked for stats
|
534
|
+
#
|
535
|
+
if req.request_uri.path =~ /stats/
|
536
|
+
queue = ChimpQueue.instance
|
537
|
+
stats = ""
|
538
|
+
stats << "running: #{queue.get_jobs_by_status(:running).size} / "
|
539
|
+
stats << "failed: #{queue.get_jobs_by_status(:error).size} / "
|
540
|
+
stats << "done: #{queue.get_jobs_by_status(:done).size} / "
|
541
|
+
stats << "processing: #{ChimpDaemon.instance.proc_counter.to_s} / "
|
542
|
+
stats << "\n"
|
543
|
+
|
544
|
+
resp.body = stats
|
545
|
+
|
546
|
+
raise WEBrick::HTTPStatus::OK
|
547
|
+
end
|
548
|
+
|
524
549
|
#
|
525
550
|
# Check for static CSS files and serve them
|
526
551
|
#
|
@@ -554,6 +579,7 @@ module Chimp
|
|
554
579
|
count_jobs_holding = queue.get_jobs_by_status(:holding).size
|
555
580
|
count_jobs_failed = queue.get_jobs_by_status(:error).size
|
556
581
|
count_jobs_done = queue.get_jobs_by_status(:done).size
|
582
|
+
count_jobs_processing = queue.get_jobs_by_status(:processing).size
|
557
583
|
|
558
584
|
resp.body = @template.result(binding)
|
559
585
|
raise WEBrick::HTTPStatus::OK
|
@@ -120,6 +120,7 @@ module Chimp
|
|
120
120
|
def Connection.api16_call(query)
|
121
121
|
|
122
122
|
Thread.current[:retry] = true
|
123
|
+
Thread.current[:response] = nil
|
123
124
|
retries = 5
|
124
125
|
attempts = 0
|
125
126
|
sleep_for = 20
|
@@ -151,24 +152,21 @@ module Chimp
|
|
151
152
|
|
152
153
|
Log.debug "[#{Chimp.get_job_uuid}] Attempt # #{attempts+1} at querying the API" unless attempts == 0
|
153
154
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
attempts += 1
|
160
|
-
rescue Exception => e
|
161
|
-
Log.error "[#{Chimp.get_job_uuid}] Exception when making the HTTP request"
|
162
|
-
end
|
155
|
+
Log.debug "[#{Chimp.get_job_uuid}] HTTP Making http request"
|
156
|
+
start_time = Time.now
|
157
|
+
Thread.current[:response] = http.request(get)
|
158
|
+
end_time = Time.now
|
159
|
+
total_time = end_time - start_time
|
163
160
|
|
164
|
-
|
161
|
+
Log.debug "[#{Chimp.get_job_uuid}] HTTP Request complete"
|
162
|
+
attempts += 1
|
165
163
|
|
166
|
-
Log.debug "[#{Chimp.get_job_uuid}] API Request time: #{
|
164
|
+
Log.debug "[#{Chimp.get_job_uuid}] API Request time: #{total_time} seconds"
|
167
165
|
Log.debug "[#{Chimp.get_job_uuid}] API Query was: #{query}"
|
168
166
|
|
169
167
|
# Validate API response
|
170
168
|
Log.debug "[#{Chimp.get_job_uuid}] Validating..."
|
171
|
-
|
169
|
+
instances = validate_response(Thread.current[:response], query)
|
172
170
|
else
|
173
171
|
# We dont retry, exit the loop.
|
174
172
|
Log.debug "[#{Chimp.get_job_uuid}] Not retrying, exiting the loop."
|
@@ -188,24 +186,21 @@ module Chimp
|
|
188
186
|
raise "[#{Chimp.get_job_uuid}] Api call failed more than #{retries} times."
|
189
187
|
end
|
190
188
|
|
189
|
+
if instances.nil?
|
190
|
+
Log.error "[#{Chimp.get_job_uuid}] instances is nil!"
|
191
|
+
else
|
192
|
+
Log.debug "[#{Chimp.get_job_uuid}] API matched #{instances.count} instances"
|
193
|
+
end
|
194
|
+
|
191
195
|
rescue Exception => e
|
192
196
|
Log.error "[#{Chimp.get_job_uuid}] #{e.message}"
|
193
197
|
Log.error "[#{Chimp.get_job_uuid}] Catched exception on http request to the api, retrying"
|
194
198
|
|
195
|
-
# Failure to be set only on maximum retries
|
196
|
-
# Chimp.set_failure(true)
|
197
|
-
|
198
199
|
instances = []
|
199
200
|
attempts += 1
|
200
201
|
retry
|
201
202
|
end
|
202
203
|
|
203
|
-
Log.debug "[#{Chimp.get_job_uuid}] API matched #{instances.count} instances" unless instances.nil?
|
204
|
-
|
205
|
-
if instances.nil?
|
206
|
-
Log.error "[#{Chimp.get_job_uuid}] instances is nil!"
|
207
|
-
end
|
208
|
-
|
209
204
|
return instances
|
210
205
|
end
|
211
206
|
|
@@ -47,6 +47,9 @@ SINCE 2012</p>
|
|
47
47
|
</tr><tr>
|
48
48
|
<td>Jobs completed:</td>
|
49
49
|
<td><%= count_jobs_done %>
|
50
|
+
</tr><tr>
|
51
|
+
<td>Jobs being processed:</td>
|
52
|
+
<td><%= ChimpDaemon.instance.proc_counter.to_s %>
|
50
53
|
</tr>
|
51
54
|
</table>
|
52
55
|
|
@@ -112,7 +115,7 @@ jobs.each do |j|
|
|
112
115
|
|
113
116
|
status = j.status
|
114
117
|
id = j.job_id
|
115
|
-
|
118
|
+
|
116
119
|
server_name = CGI::escapeHTML(j.server.params['nickname']) if j.server
|
117
120
|
|
118
121
|
if j.exec
|
@@ -171,4 +174,3 @@ jobs.each do |j|
|
|
171
174
|
</div>
|
172
175
|
|
173
176
|
</body></html>
|
174
|
-
|
data/lib/right_chimp/version.rb
CHANGED
data/lib/right_chimp.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_chimp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RightScale Operations
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|