Permalink
Browse files

node_record_id may be safer than worker_pid.

  • Loading branch information...
1 parent 963e21b commit 8788d47c0226a910a14b4030b8be96f75683be9b @jashkenas jashkenas committed Mar 10, 2011
Showing with 1 addition and 2 deletions.
  1. +0 −1 lib/cloud_crowd/models/node_record.rb
  2. +1 −1 lib/cloud_crowd/models/work_unit.rb
@@ -41,7 +41,6 @@ def self.check_in(params, request)
# If the Node responds that it's overloaded, we mark it as busy. Returns
# true if the WorkUnit was dispatched successfully.
def send_work_unit(unit)
- return false if unit.worker_pid #FIXME: Horrible hack.
result = node['/work'].post(:work_unit => unit.to_json)
unit.assign_to(self, JSON.parse(result.body)['pid'])
touch && true
@@ -81,7 +81,7 @@ def self.distribute_to_nodes
# were none available.
def self.reserve_available(options={})
reservation = ActiveSupport::SecureRandom.random_number(MAX_RESERVATION)
- conditions = "reservation is null and worker_pid is null and status in (#{INCOMPLETE.join(',')}) and #{options[:conditions]}"
+ conditions = "reservation is null and node_record_id is null and status in (#{INCOMPLETE.join(',')}) and #{options[:conditions]}"
any = WorkUnit.update_all("reservation = #{reservation}", conditions, options) > 0
any && reservation
end

0 comments on commit 8788d47

Please sign in to comment.