cloud-crowd 0.7.2.pre3 → 0.7.2

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: 1c5f2f377aa25b5ea78af2c99af7219a76ac0b8d
4
- data.tar.gz: 8384b661a4d74ba176691d2f67fafefb72a97fb7
3
+ metadata.gz: 88fe358ade9e482b1e3babde6470481f0a2610b4
4
+ data.tar.gz: 875f598e6160a237d322dd9fa2572e8519952cc7
5
5
  SHA512:
6
- metadata.gz: 1d489373d585cfaec82992e6b4ccee7986f47722bed078a096d9731b32ac7cc11bef9f1fe0c27bda36bfcf84aa9ab8f2892ebbd7414618a7703b2b9b990ef336
7
- data.tar.gz: 0935c56a1f968dcb00f919378620cfaa79b12fa3edd602c5bf50a9a64e2c1f4c3282693f67c8c99fc0399992659daf8df8e7a27b718da0871383df009f6315cd
6
+ metadata.gz: df444794a6c2161fa6573e1efb85e1b045d65af5bed1681c842ca46359d433fe8e1b2116cfd89791e04e08eece282607da5a2117a2336e274dac1e906eb476ad
7
+ data.tar.gz: eb4cac079f21ff387415e1742c376f2c77f3019bf20067be0eaa91cc07bb82438af9f3e6aac3c9a58f966c2dc61668bd6fe6e081109c5aa45ad4e6a8beab57c9
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'cloud-crowd'
3
- s.version = '0.7.2.pre3' # Keep version in sync with cloud-cloud.rb
4
- s.date = '2014-04-06'
3
+ s.version = '0.7.2' # Keep version in sync with cloud-cloud.rb
4
+ s.date = '2014-04-17'
5
5
 
6
6
  s.homepage = "http://wiki.github.com/documentcloud/cloud-crowd"
7
7
  s.summary = "Parallel Processing for the Rest of Us"
@@ -120,6 +120,16 @@ module CloudCrowd
120
120
  end
121
121
  end
122
122
 
123
+ # Starts a new thread with a ActiveRecord connection_pool
124
+ # and yields for peforming work inside the blocks
125
+ def defer
126
+ Thread.new do
127
+ ActiveRecord::Base.connection_pool.with_connection do
128
+ yield
129
+ end
130
+ end
131
+ end
132
+
123
133
  # Get a reference to the central server, including authentication if
124
134
  # configured.
125
135
  def central_server
@@ -54,7 +54,7 @@ module CloudCrowd
54
54
  if complete?
55
55
  update_attributes(:outputs => outs, :time => time_taken)
56
56
  puts "Job ##{id} (#{action}) #{display_status}." unless ENV['RACK_ENV'] == 'test'
57
- Thread.new { fire_callback } if callback_url
57
+ CloudCrowd.defer { fire_callback } if callback_url
58
58
  end
59
59
  self
60
60
  end
@@ -80,7 +80,7 @@ module CloudCrowd
80
80
  def fire_callback
81
81
  begin
82
82
  response = RestClient.post(callback_url, {:job => self.to_json})
83
- Thread.new { self.destroy } if response && response.code == 201
83
+ CloudCrowd.defer { self.destroy } if response && response.code == 201
84
84
  rescue RestClient::Exception => e
85
85
  puts "Job ##{id} (#{action}) failed to fire callback: #{callback_url}"
86
86
  end
@@ -188,4 +188,4 @@ module CloudCrowd
188
188
  end
189
189
 
190
190
  end
191
- end
191
+ end
@@ -116,7 +116,7 @@ module CloudCrowd
116
116
  # Redistribute in a separate thread to avoid delaying shutdown.
117
117
  def redistribute_work_units
118
118
  release_work_units
119
- Thread.new { WorkUnit.distribute_to_nodes }
119
+ CloudCrowd.defer { WorkUnit.distribute_to_nodes }
120
120
  end
121
121
 
122
122
  end
@@ -44,6 +44,9 @@ module CloudCrowd
44
44
  available_nodes = NodeRecord.available.to_a
45
45
  available_actions = available_nodes.map {|node| node.actions }.flatten.uniq
46
46
  filter = "action in (#{available_actions.map{|a| "'#{a}'"}.join(',')})"
47
+
48
+ # If there aren't any available nodes or actions don't bother doing anything.
49
+ return if available_nodes.empty? or available_actions.empty?
47
50
 
48
51
  # Reserve a handful of available work units.
49
52
  WorkUnit.cancel_reservations(reservation) if reservation
@@ -92,7 +92,7 @@ module CloudCrowd
92
92
  @server.daemonize if @daemon
93
93
  trap_signals
94
94
  asset_store
95
- @server_thread = Thread.new { @server.start }
95
+ @server_thread = CloudCrowd.defer { @server.start }
96
96
  check_in(true)
97
97
  check_in_periodically
98
98
  monitor_system if @max_load || @min_memory
@@ -159,7 +159,7 @@ module CloudCrowd
159
159
  # average and the amount of free memory remaining. If we transition out of
160
160
  # the overloaded state, let central know.
161
161
  def monitor_system
162
- @monitor_thread = Thread.new do
162
+ @monitor_thread = CloudCrowd.defer do
163
163
  loop do
164
164
  was_overloaded = @overloaded
165
165
  @overloaded = overloaded?
@@ -173,7 +173,7 @@ module CloudCrowd
173
173
  # will assume that the node has gone down. Checking in will let central know
174
174
  # it's still online.
175
175
  def check_in_periodically
176
- @check_in_thread = Thread.new do
176
+ @check_in_thread = CloudCrowd.defer do
177
177
  loop do
178
178
  sleep CHECK_IN_INTERVAL
179
179
  check_in
@@ -71,7 +71,7 @@ module CloudCrowd
71
71
  # Distributes all work units to available nodes.
72
72
  post '/jobs' do
73
73
  job = Job.create_from_request(JSON.parse(params[:job]))
74
- Thread.new { WorkUnit.distribute_to_nodes }
74
+ CloudCrowd.defer { WorkUnit.distribute_to_nodes }
75
75
  puts "Job ##{job.id} (#{job.action}) started." unless ENV['RACK_ENV'] == 'test'
76
76
  json job
77
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud-crowd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2.pre3
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ashkenas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-06 00:00:00.000000000 Z
12
+ date: 2014-04-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -288,14 +288,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
288
288
  version: '0'
289
289
  required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  requirements:
291
- - - ">"
291
+ - - ">="
292
292
  - !ruby/object:Gem::Version
293
- version: 1.3.1
293
+ version: '0'
294
294
  requirements: []
295
295
  rubyforge_project: cloud-crowd
296
- rubygems_version: 2.2.1
296
+ rubygems_version: 2.2.2
297
297
  signing_key:
298
298
  specification_version: 4
299
299
  summary: Parallel Processing for the Rest of Us
300
300
  test_files: []
301
- has_rdoc: