cloud-crowd 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/cloud-crowd.gemspec +2 -2
- data/lib/cloud-crowd.rb +1 -1
- data/lib/cloud_crowd/models/job.rb +2 -1
- data/lib/cloud_crowd/models/node_record.rb +5 -2
- data/lib/cloud_crowd/node.rb +3 -3
- data/lib/cloud_crowd/server.rb +3 -0
- metadata +3 -3
data/cloud-crowd.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'cloud-crowd'
|
3
|
-
s.version = '0.4.
|
4
|
-
s.date = '2010-
|
3
|
+
s.version = '0.4.1' # Keep version in sync with cloud-cloud.rb
|
4
|
+
s.date = '2010-04-22'
|
5
5
|
|
6
6
|
s.homepage = "http://wiki.github.com/documentcloud/cloud-crowd"
|
7
7
|
s.summary = "Parallel Processing for the Rest of Us"
|
data/lib/cloud-crowd.rb
CHANGED
@@ -44,7 +44,7 @@ module CloudCrowd
|
|
44
44
|
autoload :WorkUnit, 'cloud_crowd/models'
|
45
45
|
|
46
46
|
# Keep this version in sync with the gemspec.
|
47
|
-
VERSION = '0.4.
|
47
|
+
VERSION = '0.4.1'
|
48
48
|
|
49
49
|
# Increment the schema version when there's a backwards incompatible change.
|
50
50
|
SCHEMA_VERSION = 3
|
@@ -48,6 +48,7 @@ module CloudCrowd
|
|
48
48
|
return queue_for_workers([outs]) if merging?
|
49
49
|
if complete?
|
50
50
|
update_attributes(:outputs => outs, :time => time_taken)
|
51
|
+
puts "Job ##{id} (#{action}) #{display_status}."
|
51
52
|
Thread.new { fire_callback } if callback_url
|
52
53
|
end
|
53
54
|
self
|
@@ -76,7 +77,7 @@ module CloudCrowd
|
|
76
77
|
response = RestClient.post(callback_url, {:job => self.to_json})
|
77
78
|
Thread.new { self.destroy } if response && response.code == 201
|
78
79
|
rescue RestClient::Exception => e
|
79
|
-
puts "Job ##{id} failed to fire callback: #{callback_url}"
|
80
|
+
puts "Job ##{id} (#{action}) failed to fire callback: #{callback_url}"
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
@@ -17,13 +17,16 @@ module CloudCrowd
|
|
17
17
|
:order => 'updated_at asc'
|
18
18
|
}
|
19
19
|
|
20
|
+
# Extract the port number from the host id.
|
21
|
+
PORT = /:(\d+)\Z/
|
22
|
+
|
20
23
|
# Register a Node with the central server. This happens periodically
|
21
24
|
# (once every `Node::CHECK_IN_INTERVAL` seconds). Nodes will be de-registered
|
22
25
|
# if they checked in within a reasonable interval.
|
23
26
|
def self.check_in(params, request)
|
24
27
|
attrs = {
|
25
28
|
:ip_address => request.ip,
|
26
|
-
:port => params[:
|
29
|
+
:port => params[:host].match(PORT)[1].to_i,
|
27
30
|
:busy => params[:busy],
|
28
31
|
:max_workers => params[:max_workers],
|
29
32
|
:enabled_actions => params[:enabled_actions]
|
@@ -62,7 +65,7 @@ module CloudCrowd
|
|
62
65
|
# The URL at which this Node may be reached.
|
63
66
|
# TODO: Make sure that the host actually has externally accessible DNS.
|
64
67
|
def url
|
65
|
-
@url ||= "http://#{host}
|
68
|
+
@url ||= "http://#{host}"
|
66
69
|
end
|
67
70
|
|
68
71
|
# Keep a RestClient::Resource handy for contacting the Node, including
|
data/lib/cloud_crowd/node.rb
CHANGED
@@ -70,6 +70,7 @@ module CloudCrowd
|
|
70
70
|
@host = Socket.gethostname
|
71
71
|
@enabled_actions = CloudCrowd.actions.keys - (CloudCrowd.config[:disabled_actions] || [])
|
72
72
|
@port = port || DEFAULT_PORT
|
73
|
+
@id = "#{@host}:#{@port}"
|
73
74
|
@daemon = daemon
|
74
75
|
@overloaded = false
|
75
76
|
@max_load = CloudCrowd.config[:max_load]
|
@@ -99,8 +100,7 @@ module CloudCrowd
|
|
99
100
|
# configuration of this Node. If it can't check-in, there's no point in
|
100
101
|
# starting.
|
101
102
|
def check_in(critical=false)
|
102
|
-
@central["/node/#{@
|
103
|
-
:port => @port,
|
103
|
+
@central["/node/#{@id}"].put(
|
104
104
|
:busy => @overloaded,
|
105
105
|
:max_workers => CloudCrowd.config[:max_workers],
|
106
106
|
:enabled_actions => @enabled_actions.join(',')
|
@@ -113,7 +113,7 @@ module CloudCrowd
|
|
113
113
|
# Before exiting, the Node checks out with the central server, releasing all
|
114
114
|
# of its WorkUnits for other Nodes to handle
|
115
115
|
def check_out
|
116
|
-
@central["/node/#{@
|
116
|
+
@central["/node/#{@id}"].delete
|
117
117
|
end
|
118
118
|
|
119
119
|
# Lazy-initialize the asset_store, preferably after the Node has launched.
|
data/lib/cloud_crowd/server.rb
CHANGED
@@ -71,6 +71,7 @@ module CloudCrowd
|
|
71
71
|
post '/jobs' do
|
72
72
|
job = Job.create_from_request(JSON.parse(params[:job]))
|
73
73
|
WorkUnit.distribute_to_nodes
|
74
|
+
puts "Job ##{job.id} (#{job.action}) started."
|
74
75
|
json job
|
75
76
|
end
|
76
77
|
|
@@ -94,6 +95,7 @@ module CloudCrowd
|
|
94
95
|
put '/node/:host' do
|
95
96
|
NodeRecord.check_in(params, request)
|
96
97
|
WorkUnit.distribute_to_nodes
|
98
|
+
puts "Node #{params[:host]} checked in."
|
97
99
|
json nil
|
98
100
|
end
|
99
101
|
|
@@ -101,6 +103,7 @@ module CloudCrowd
|
|
101
103
|
# WorkUnits it may have had checked out.
|
102
104
|
delete '/node/:host' do
|
103
105
|
NodeRecord.destroy_all(:host => params[:host])
|
106
|
+
puts "Node #{params[:host]} checked out."
|
104
107
|
json nil
|
105
108
|
end
|
106
109
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 1
|
9
|
+
version: 0.4.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jeremy Ashkenas
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-22 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|