lib/cloud_crowd/models/work_unit.rb in cloud-crowd-0.6.0 vs lib/cloud_crowd/models/work_unit.rb in cloud-crowd-0.6.1
- old
+ new
@@ -58,12 +58,10 @@
if node.actions.include?(unit.action)
if node.send_work_unit(unit)
available_nodes.push(node) unless node.busy?
next
end
- else
- unit.cancel_reservation
end
work_units.push(unit)
end
# If there are both units and nodes left over, try again.
@@ -79,10 +77,11 @@
# Reserves all available WorkUnits for this process. Returns false if there
# were none available.
def self.reserve_available(options={})
reservation = ActiveSupport::SecureRandom.random_number(MAX_RESERVATION)
- any = WorkUnit.available.update_all("reservation = #{reservation}", options[:conditions], options) > 0
+ 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
# Cancels all outstanding WorkUnit reservations for this process.
def self.cancel_reservations(reservation)