Permalink
Browse files

Merge branch 'master' of http://github.com/felipecvo/cloud-crowd

  • Loading branch information...
2 parents f966a6f + 905429c commit 9e66e86099e0f9cb6e9e71e035e0c9747ce3167a @jashkenas jashkenas committed Sep 28, 2010
View
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'cloud-crowd'
- s.version = '0.5.0' # Keep version in sync with cloud-cloud.rb
- s.date = '2010-06-22'
+ s.version = '0.5.2' # Keep version in sync with cloud-cloud.rb
+ s.date = '2010-08-03'
s.homepage = "http://wiki.github.com/documentcloud/cloud-crowd"
s.summary = "Parallel Processing for the Rest of Us"
@@ -113,4 +113,4 @@ test/unit/test_worker.rb
test/unit/test_work_unit.rb
views/operations_center.erb
)
-end
+end
View
@@ -45,7 +45,7 @@ module CloudCrowd
autoload :WorkUnit, 'cloud_crowd/models'
# Keep this version in sync with the gemspec.
- VERSION = '0.5.0'
+ VERSION = '0.5.2'
# Increment the schema version when there's a backwards incompatible change.
SCHEMA_VERSION = 4
@@ -137,7 +137,10 @@ def pid_path(pid_file=nil)
# a connection, and a timeout of 30 to finish reading it.
def client_options
return @client_options if @client_options
- @client_options = {:timeout => 30, :open_timeout => 5}
+ @client_options = {
+ :timeout => (self.server? ? config[:node_timeout] : config[:server_timeout]) || 30,
+ :open_timeout => config[:open_timeout] || 5
+ }
if CloudCrowd.config[:http_authentication]
@client_options[:user] = CloudCrowd.config[:login]
@client_options[:password] = CloudCrowd.config[:password]
@@ -190,4 +193,4 @@ def node?
end
-end
+end
@@ -47,7 +47,7 @@ def send_work_unit(unit)
rescue RestClient::RequestFailed => e
raise e unless e.http_code == 503 && e.http_body == Node::OVERLOADED_MESSAGE
update_attribute(:busy, true) && false
- rescue RestClient::Exception, Errno::ECONNREFUSED, Timeout::Error
+ rescue RestClient::Exception, Errno::ECONNREFUSED, Timeout::Error, RestClient::RequestTimeout, Errno::ECONNRESET
# Couldn't post to node, assume it's gone away.
destroy && false
end
@@ -41,6 +41,7 @@ def self.distribute_to_nodes
reservation = nil
filter = {}
loop do
+ WorkUnit.cancel_reservations(reservation) if reservation
return unless reservation = WorkUnit.reserve_available(:limit => RESERVATION_LIMIT, :conditions => filter)
work_units = WorkUnit.reserved(reservation)
available_nodes = NodeRecord.available
@@ -69,7 +70,7 @@ def self.distribute_to_nodes
# were none available.
def self.reserve_available(options={})
reservation = ActiveSupport::SecureRandom.random_number(MAX_RESERVATION)
- any = WorkUnit.available.update_all("reservation = #{reservation}", nil, options) > 0
+ any = WorkUnit.available.update_all("reservation = #{reservation}", options[:conditions], options) > 0
any && reservation
end
@@ -70,7 +70,7 @@ class Server < Sinatra::Base
# Distributes all work units to available nodes.
post '/jobs' do
job = Job.create_from_request(JSON.parse(params[:job]))
- WorkUnit.distribute_to_nodes
+ Thread.new { WorkUnit.distribute_to_nodes }
puts "Job ##{job.id} (#{job.action}) started." unless ENV['RACK_ENV'] == 'test'
json job
end
@@ -128,4 +128,4 @@ def initialize(*args)
end
-end
+end
@@ -24,6 +24,7 @@ def initialize(node, unit)
@unit = unit
@status = @unit['status']
@retry_wait = RETRY_WAIT
+ $0 = "#{unit['action']} (#{unit['id']}) [cloud-crowd-worker]"
end
# Return output to the central server, marking the WorkUnit done.
@@ -146,4 +147,4 @@ def trap_signals
end
-end
+end

0 comments on commit 9e66e86

Please sign in to comment.