skynet 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +99 -0
- data/Manifest.txt +10 -9
- data/README.txt +74 -7
- data/app_generators/skynet_install/skynet_install_generator.rb +26 -22
- data/app_generators/skynet_install/templates/migration.rb +11 -5
- data/app_generators/skynet_install/templates/skynet +25 -12
- data/app_generators/skynet_install/templates/skynet_schema.sql +56 -0
- data/bin/skynet +26 -2
- data/bin/skynet_install +24 -0
- data/bin/skynet_tuplespace_server +13 -0
- data/config/hoe.rb +1 -0
- data/lib/skynet.rb +3 -0
- data/lib/skynet/mapreduce_helper.rb +74 -0
- data/lib/skynet/message_queue_adapters/mysql.rb +225 -172
- data/lib/skynet/message_queue_adapters/tuple_space.rb +31 -16
- data/lib/skynet/skynet_active_record_extensions.rb +78 -46
- data/lib/skynet/skynet_config.rb +162 -23
- data/lib/skynet/skynet_console.rb +23 -10
- data/lib/skynet/skynet_console_helper.rb +61 -58
- data/lib/skynet/skynet_job.rb +741 -493
- data/lib/skynet/skynet_launcher.rb +5 -1
- data/lib/skynet/skynet_manager.rb +106 -49
- data/lib/skynet/skynet_message.rb +169 -174
- data/lib/skynet/skynet_message_queue.rb +29 -16
- data/lib/skynet/skynet_partitioners.rb +92 -0
- data/lib/skynet/skynet_ruby_extensions.rb +3 -4
- data/lib/skynet/skynet_task.rb +61 -19
- data/lib/skynet/skynet_tuplespace_server.rb +0 -2
- data/lib/skynet/skynet_worker.rb +73 -51
- data/lib/skynet/version.rb +1 -1
- data/test/test_active_record_extensions.rb +138 -0
- data/test/test_helper.rb +6 -0
- data/test/{mysql_message_queue_adaptor_test.rb → test_mysql_message_queue_adapter.rb} +94 -30
- data/test/test_skynet.rb +11 -11
- data/test/test_skynet_install_generator.rb +0 -4
- data/test/test_skynet_job.rb +717 -0
- data/test/test_skynet_manager.rb +142 -0
- data/test/test_skynet_message.rb +229 -0
- data/test/test_skynet_task.rb +24 -0
- data/test/{tuplespace_message_queue_test.rb → test_tuplespace_message_queue.rb} +25 -30
- data/website/index.html +56 -16
- data/website/index.txt +55 -25
- data/website/template.rhtml +1 -1
- metadata +29 -13
- data/app_generators/skynet_install/templates/skynet_console +0 -16
- data/bin/skynet_console +0 -9
- data/sometest.rb +0 -23
- data/test/all_models_test.rb +0 -139
- data/test/skynet_manager_test.rb +0 -107
- data/test/skynet_message_test.rb +0 -42
- data/tmtags +0 -1242
data/website/index.html
CHANGED
@@ -33,56 +33,96 @@
|
|
33
33
|
<h1>skynet</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/skynet"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/skynet" class="numbers">0.9.
|
36
|
+
<a href="http://rubyforge.org/projects/skynet" class="numbers">0.9.2</a>
|
37
37
|
</div>
|
38
|
-
<
|
38
|
+
<p><a href="http://rubyforge.org/projects/skynet/">Skynet RubyForge Home</a><br />
|
39
|
+
<a href="doc/index.html">Documentation</a></p>
|
39
40
|
|
40
41
|
|
41
|
-
<h2>What</h2>
|
42
|
+
<h2>What is Skynet</h2>
|
43
|
+
|
44
|
+
|
45
|
+
<p>Skynet is an open source Ruby implementation of Google’s Map/Reduce framework, created at Geni.com. With Skynet, one can easily convert a time-consuming serial task, such as a computationally expensive Rails migration, into a distributed program running on many computers.</p>
|
46
|
+
|
47
|
+
|
48
|
+
<p>Skynet is an adaptive, self-upgrading, fault-tolerant, and fully distributed system with no single point of failure. It uses a “peer recovery” system where workers watch out for each other. If a worker dies or fails for any reason, another worker will notice and pick up that task. Skynet also has no special ‘master’ servers, only workers which can act as a master for any task at any time. Even these master tasks can fail and will be picked up by other workers.</p>
|
42
49
|
|
43
50
|
|
44
51
|
<h2>Installing</h2>
|
45
52
|
|
46
53
|
|
54
|
+
<p>Skynet can be installed via RubyGems:</p>
|
55
|
+
|
56
|
+
|
47
57
|
<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">skynet</span></pre></p>
|
48
58
|
|
49
59
|
|
50
|
-
<h2>
|
60
|
+
<h2>More Info</h2>
|
51
61
|
|
52
62
|
|
53
|
-
<
|
63
|
+
<p>For more info check out the <a href="doc/index.html"><span class="caps">README</span></a></p>
|
54
64
|
|
55
65
|
|
56
|
-
<h2>
|
66
|
+
<h2>Contact</h2>
|
57
67
|
|
58
68
|
|
59
|
-
<p
|
69
|
+
<p>Comments are welcome. Send an email to “Adam Pisoni” apisoni at geni.com</p>
|
60
70
|
|
61
71
|
|
62
|
-
<
|
72
|
+
<h2>Credits
|
73
|
+
There are a number of people who either directly or indirectly worked on Skynet.
|
74
|
+
John Beppu (wrote the original worker/manager code)
|
75
|
+
Justin Balthrop
|
76
|
+
Zack Parker
|
77
|
+
Amos Elliston
|
78
|
+
Zack Hobson
|
79
|
+
Alan Braverman
|
80
|
+
Mike Stangel
|
81
|
+
Scott Steadman
|
82
|
+
Andrew Arrow
|
83
|
+
Jason Rojas</h2>
|
63
84
|
|
64
85
|
|
65
|
-
<
|
86
|
+
<p>Skynet was inspired by and heavily influenced by Josh Carter and this blog post.
|
87
|
+
http://multipart-mixed.com/software/simple_mapreduce_in_ruby.html</p>
|
66
88
|
|
67
89
|
|
68
|
-
<p>
|
90
|
+
<p>Also by Starfish by Lucas Carlson
|
91
|
+
http://tech.rufy.com/2006/08/mapreduce-for-ruby-ridiculously-easy.html
|
92
|
+
http://rufy.com/starfish/doc/</p>
|
69
93
|
|
70
94
|
|
71
|
-
<
|
95
|
+
<h2><span class="caps">LICENSE</span>:</h2>
|
72
96
|
|
73
97
|
|
74
|
-
<
|
98
|
+
<p>(The <span class="caps">MIT</span> License)</p>
|
75
99
|
|
76
100
|
|
77
|
-
<p>
|
101
|
+
<p>Copyright© 2007 Adam Pisoni, Geni.com</p>
|
78
102
|
|
79
103
|
|
80
|
-
<
|
104
|
+
<p>Permission is hereby granted, free of charge, to any person obtaining
|
105
|
+
a copy of this software and associated documentation files (the
|
106
|
+
“Software”), to deal in the Software without restriction, including
|
107
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
108
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
109
|
+
permit persons to whom the Software is furnished to do so, subject to
|
110
|
+
the following conditions:</p>
|
111
|
+
|
112
|
+
|
113
|
+
<p>The above copyright notice and this permission notice shall be
|
114
|
+
included in all copies or substantial portions of the Software.</p>
|
81
115
|
|
82
116
|
|
83
|
-
<p
|
117
|
+
<p><span class="caps">THE SOFTWARE IS PROVIDED</span> “AS IS”, <span class="caps">WITHOUT WARRANTY OF ANY KIND</span>,
|
118
|
+
<span class="caps">EXPRESS OR IMPLIED</span>, INCLUDING <span class="caps">BUT NOT LIMITED TO THE WARRANTIES OF</span>
|
119
|
+
<span class="caps">MERCHANTABILITY</span>, FITNESS <span class="caps">FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT</span>.
|
120
|
+
<span class="caps">IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY</span>
|
121
|
+
<span class="caps">CLAIM</span>, DAMAGES <span class="caps">OR OTHER LIABILITY</span>, WHETHER <span class="caps">IN AN ACTION OF CONTRACT</span>,
|
122
|
+
<span class="caps">TORT OR OTHERWISE</span>, ARISING <span class="caps">FROM</span>, OUT <span class="caps">OF OR IN CONNECTION WITH THE</span>
|
123
|
+
<span class="caps">SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE</span>.</p>
|
84
124
|
<p class="coda">
|
85
|
-
|
125
|
+
Adam Pisoni, Geni.com 25th January 2008<br>
|
86
126
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
87
127
|
</p>
|
88
128
|
</div>
|
data/website/index.txt
CHANGED
@@ -1,39 +1,69 @@
|
|
1
1
|
h1. skynet
|
2
2
|
|
3
|
-
|
3
|
+
<a href="http://rubyforge.org/projects/skynet/">Skynet RubyForge Home</a><br />
|
4
|
+
<a href="doc/index.html">Documentation</a>
|
4
5
|
|
6
|
+
h2. What is Skynet
|
5
7
|
|
6
|
-
|
8
|
+
Skynet is an open source Ruby implementation of Google's Map/Reduce framework, created at Geni.com. With Skynet, one can easily convert a time-consuming serial task, such as a computationally expensive Rails migration, into a distributed program running on many computers.
|
7
9
|
|
10
|
+
Skynet is an adaptive, self-upgrading, fault-tolerant, and fully distributed system with no single point of failure. It uses a "peer recovery" system where workers watch out for each other. If a worker dies or fails for any reason, another worker will notice and pick up that task. Skynet also has no special 'master' servers, only workers which can act as a master for any task at any time. Even these master tasks can fail and will be picked up by other workers.
|
8
11
|
|
9
12
|
h2. Installing
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
h2. The basics
|
14
|
-
|
15
|
-
|
16
|
-
h2. Demonstration of usage
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
h2. Forum
|
14
|
+
Skynet can be installed via RubyGems:
|
21
15
|
|
22
|
-
"
|
23
|
-
|
24
|
-
TODO - create Google Group - skynet
|
25
|
-
|
26
|
-
h2. How to submit patches
|
27
|
-
|
28
|
-
Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
|
29
|
-
|
30
|
-
The trunk repository is <code>svn://rubyforge.org/var/svn/skynet/trunk</code> for anonymous access.
|
16
|
+
<pre syntax="ruby">sudo gem install skynet</pre>
|
31
17
|
|
32
|
-
h2.
|
18
|
+
h2. More Info
|
33
19
|
|
34
|
-
|
20
|
+
For more info check out the <a href="doc/index.html">README</a>
|
35
21
|
|
36
22
|
h2. Contact
|
37
23
|
|
38
|
-
Comments are welcome. Send an email to "
|
39
|
-
|
24
|
+
Comments are welcome. Send an email to "Adam Pisoni" apisoni at geni.com
|
25
|
+
|
26
|
+
h2. Credits
|
27
|
+
There are a number of people who either directly or indirectly worked on Skynet.
|
28
|
+
John Beppu (wrote the original worker/manager code)
|
29
|
+
Justin Balthrop
|
30
|
+
Zack Parker
|
31
|
+
Amos Elliston
|
32
|
+
Zack Hobson
|
33
|
+
Alan Braverman
|
34
|
+
Mike Stangel
|
35
|
+
Scott Steadman
|
36
|
+
Andrew Arrow
|
37
|
+
Jason Rojas
|
38
|
+
|
39
|
+
Skynet was inspired by and heavily influenced by Josh Carter and this blog post.
|
40
|
+
http://multipart-mixed.com/software/simple_mapreduce_in_ruby.html
|
41
|
+
|
42
|
+
Also by Starfish by Lucas Carlson
|
43
|
+
http://tech.rufy.com/2006/08/mapreduce-for-ruby-ridiculously-easy.html
|
44
|
+
http://rufy.com/starfish/doc/
|
45
|
+
|
46
|
+
h2. LICENSE:
|
47
|
+
|
48
|
+
(The MIT License)
|
49
|
+
|
50
|
+
Copyright (c) 2007 Adam Pisoni, Geni.com
|
51
|
+
|
52
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
53
|
+
a copy of this software and associated documentation files (the
|
54
|
+
"Software"), to deal in the Software without restriction, including
|
55
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
56
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
57
|
+
permit persons to whom the Software is furnished to do so, subject to
|
58
|
+
the following conditions:
|
59
|
+
|
60
|
+
The above copyright notice and this permission notice shall be
|
61
|
+
included in all copies or substantial portions of the Software.
|
62
|
+
|
63
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
64
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
65
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
66
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
67
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
68
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
69
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/website/template.rhtml
CHANGED
@@ -37,7 +37,7 @@
|
|
37
37
|
</div>
|
38
38
|
<%= body %>
|
39
39
|
<p class="coda">
|
40
|
-
|
40
|
+
Adam Pisoni, Geni.com <%= modified.pretty %><br>
|
41
41
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
42
42
|
</p>
|
43
43
|
</div>
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: skynet
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.9.
|
7
|
-
date: 2008-01-
|
6
|
+
version: 0.9.2
|
7
|
+
date: 2008-01-28 00:00:00 -08:00
|
8
8
|
summary: Skynet - A Ruby Map/Reduce Framework
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -38,14 +38,14 @@ files:
|
|
38
38
|
- app_generators/skynet_install/skynet_install_generator.rb
|
39
39
|
- app_generators/skynet_install/templates/migration.rb
|
40
40
|
- app_generators/skynet_install/templates/skynet
|
41
|
-
- app_generators/skynet_install/templates/
|
41
|
+
- app_generators/skynet_install/templates/skynet_schema.sql
|
42
42
|
- bin/skynet
|
43
|
-
- bin/skynet_console
|
44
43
|
- bin/skynet_install
|
45
44
|
- bin/skynet_tuplespace_server
|
46
45
|
- config/hoe.rb
|
47
46
|
- config/requirements.rb
|
48
47
|
- lib/skynet.rb
|
48
|
+
- lib/skynet/mapreduce_helper.rb
|
49
49
|
- lib/skynet/mapreduce_test.rb
|
50
50
|
- lib/skynet/message_queue_adapters/message_queue_adapter.rb
|
51
51
|
- lib/skynet/message_queue_adapters/mysql.rb
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/skynet/skynet_manager.rb
|
63
63
|
- lib/skynet/skynet_message.rb
|
64
64
|
- lib/skynet/skynet_message_queue.rb
|
65
|
+
- lib/skynet/skynet_partitioners.rb
|
65
66
|
- lib/skynet/skynet_ruby_extensions.rb
|
66
67
|
- lib/skynet/skynet_task.rb
|
67
68
|
- lib/skynet/skynet_tuplespace_server.rb
|
@@ -75,30 +76,37 @@ files:
|
|
75
76
|
- script/generate
|
76
77
|
- script/txt2html
|
77
78
|
- setup.rb
|
78
|
-
- sometest.rb
|
79
79
|
- tasks/deployment.rake
|
80
80
|
- tasks/environment.rake
|
81
81
|
- tasks/website.rake
|
82
|
-
- test/
|
83
|
-
- test/mysql_message_queue_adaptor_test.rb
|
84
|
-
- test/skynet_manager_test.rb
|
85
|
-
- test/skynet_message_test.rb
|
82
|
+
- test/test_active_record_extensions.rb
|
86
83
|
- test/test_generator_helper.rb
|
87
84
|
- test/test_helper.rb
|
85
|
+
- test/test_mysql_message_queue_adapter.rb
|
88
86
|
- test/test_skynet.rb
|
89
87
|
- test/test_skynet_install_generator.rb
|
90
|
-
- test/
|
91
|
-
-
|
88
|
+
- test/test_skynet_job.rb
|
89
|
+
- test/test_skynet_manager.rb
|
90
|
+
- test/test_skynet_message.rb
|
91
|
+
- test/test_skynet_task.rb
|
92
|
+
- test/test_tuplespace_message_queue.rb
|
92
93
|
- website/index.html
|
93
94
|
- website/index.txt
|
94
95
|
- website/javascripts/rounded_corners_lite.inc.js
|
95
96
|
- website/stylesheets/screen.css
|
96
97
|
- website/template.rhtml
|
97
98
|
test_files:
|
99
|
+
- test/test_active_record_extensions.rb
|
98
100
|
- test/test_generator_helper.rb
|
99
101
|
- test/test_helper.rb
|
102
|
+
- test/test_mysql_message_queue_adapter.rb
|
100
103
|
- test/test_skynet.rb
|
101
104
|
- test/test_skynet_install_generator.rb
|
105
|
+
- test/test_skynet_job.rb
|
106
|
+
- test/test_skynet_manager.rb
|
107
|
+
- test/test_skynet_message.rb
|
108
|
+
- test/test_skynet_task.rb
|
109
|
+
- test/test_tuplespace_message_queue.rb
|
102
110
|
rdoc_options:
|
103
111
|
- --main
|
104
112
|
- README.txt
|
@@ -110,7 +118,6 @@ extra_rdoc_files:
|
|
110
118
|
- website/index.txt
|
111
119
|
executables:
|
112
120
|
- skynet
|
113
|
-
- skynet_console
|
114
121
|
- skynet_install
|
115
122
|
- skynet_tuplespace_server
|
116
123
|
extensions: []
|
@@ -127,3 +134,12 @@ dependencies:
|
|
127
134
|
- !ruby/object:Gem::Version
|
128
135
|
version: "1"
|
129
136
|
version:
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: rubigen
|
139
|
+
version_requirement:
|
140
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 1.1.1
|
145
|
+
version:
|
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
files_to_require = []
|
4
|
-
<% if in_rails %>
|
5
|
-
files_to_require << File.dirname(__FILE__) + '/../config/boot'
|
6
|
-
files_to_require << File.expand_path(File.dirname(__FILE__)) + '/../config/environment'
|
7
|
-
files_to_require.each { |file| require file }
|
8
|
-
<% end %>
|
9
|
-
|
10
|
-
require 'rubygems'
|
11
|
-
require 'skynet'
|
12
|
-
|
13
|
-
Skynet::CONFIG[:LAUNCHER_PATH] = File.expand_path(__FILE__)
|
14
|
-
Skynet::CONFIG[:SKYNET_LOG_LEVEL] = Logger::ERROR
|
15
|
-
|
16
|
-
Skynet::Console.start(files_to_require)
|
data/bin/skynet_console
DELETED
data/sometest.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
class SomeTest
|
2
|
-
include SkynetDebugger
|
3
|
-
|
4
|
-
def self.map(datas)
|
5
|
-
results = {}
|
6
|
-
datas.each do |data|
|
7
|
-
results[data] ||= 0
|
8
|
-
results[data] += 1
|
9
|
-
end
|
10
|
-
[results]
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.reduce(datas)
|
14
|
-
results = {}
|
15
|
-
datas.each do |hashes|
|
16
|
-
hashes.each do |key,value|
|
17
|
-
results[key] ||= 0
|
18
|
-
results[key] += value
|
19
|
-
end
|
20
|
-
end
|
21
|
-
results
|
22
|
-
end
|
23
|
-
end
|
data/test/all_models_test.rb
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../functional_test_helper'
|
2
|
-
require 'mapreduce_lib/all_models'
|
3
|
-
|
4
|
-
module MapreduceLib
|
5
|
-
class AllModelsTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
fixtures :profiles, :profile_details
|
8
|
-
|
9
|
-
def test_map
|
10
|
-
eachmeth = lambda do |profile|
|
11
|
-
profile.claimed = false
|
12
|
-
profile.save
|
13
|
-
end
|
14
|
-
data = [1,10,{:conditions => "profiles.claimed = 1"},"Profile",eachmeth]
|
15
|
-
|
16
|
-
assert Profile.find(2).claimed, "claimed"
|
17
|
-
|
18
|
-
MapreduceLib::AllModels.map([data])
|
19
|
-
|
20
|
-
assert !Profile.find(2).claimed, "not claimed"
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_each_with_proc
|
24
|
-
Skynet.solo do
|
25
|
-
MapreduceLib::AllModels.find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile", :limit => 5).each do |profile|
|
26
|
-
profile.suffix = 'z'
|
27
|
-
profile.save
|
28
|
-
end
|
29
|
-
end
|
30
|
-
assert_equal 'z', Profile.find(2).suffix
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_big_batch
|
34
|
-
Skynet.solo do
|
35
|
-
MapreduceLib::AllModels.find(:all, :conditions => "claimed = 1", :batch_size => 200, :model_class => "Profile").each do |profile|
|
36
|
-
profile.suffix = 'z'
|
37
|
-
profile.save
|
38
|
-
end
|
39
|
-
end
|
40
|
-
assert_equal 'z', Profile.find(2).suffix
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_joins
|
44
|
-
p = Profile.find(1)
|
45
|
-
p.details.zodiac_sign = 'hermit'
|
46
|
-
p.details.save
|
47
|
-
Skynet.solo do
|
48
|
-
MapreduceLib::AllModels.find(:all, :conditions => "profile_details.zodiac_sign='hermit'", :joins => "JOIN profile_details ON profiles.id = profile_details.profile_id", :batch_size => 2, :model_class => "Profile").each do |profile|
|
49
|
-
profile.suffix = 'z'
|
50
|
-
profile.save
|
51
|
-
end
|
52
|
-
end
|
53
|
-
assert_equal 'z', Profile.find(1).suffix
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_stragglers
|
57
|
-
profiles = Profile.find(:all)
|
58
|
-
Skynet.solo do
|
59
|
-
MapreduceLib::AllModels.find(:all, :batch_size => profiles.size-1, :model_class => "Profile").each do |profile|
|
60
|
-
profile.suffix = 'z'
|
61
|
-
profile.save
|
62
|
-
end
|
63
|
-
end
|
64
|
-
profiles.last.reload
|
65
|
-
assert_equal 'z', profiles.last.suffix
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_small_limit
|
69
|
-
Skynet.solo do
|
70
|
-
MapreduceLib::AllModels.find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile", :limit => 3).each do |profile|
|
71
|
-
profile.suffix = 'z'
|
72
|
-
profile.save
|
73
|
-
end
|
74
|
-
end
|
75
|
-
assert_equal 'z', Profile.find(2).suffix
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_each_with_proc_exception
|
79
|
-
Skynet.solo(:SKYNET_LOG_LEVEL => Logger::FATAL) do
|
80
|
-
MapreduceLib::AllModels.find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each do |profile|
|
81
|
-
raise "BUSTED" if profile.id == 6
|
82
|
-
profile.suffix = 'z'
|
83
|
-
profile.save
|
84
|
-
end
|
85
|
-
end
|
86
|
-
assert_equal 'z', Profile.find(2).suffix
|
87
|
-
assert_equal nil, Profile.find(6).suffix
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_each_with_class_exception
|
91
|
-
Skynet.solo(:SKYNET_LOG_LEVEL => Logger::FATAL) do
|
92
|
-
MapreduceLib::AllModels.find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each(MapreduceLib::AllModelsExTest)
|
93
|
-
end
|
94
|
-
assert_equal 'k', Profile.find(2).suffix
|
95
|
-
assert_equal nil, Profile.find(8).suffix
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_each_with_class
|
99
|
-
Skynet.solo do
|
100
|
-
MapreduceLib::AllModels.find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each(self.class)
|
101
|
-
end
|
102
|
-
assert_equal 'k', Profile.find(2).suffix
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_distributed_each
|
106
|
-
Skynet.solo do
|
107
|
-
Profile.distributed_find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each do |profile|
|
108
|
-
profile.suffix = 'gg'
|
109
|
-
profile.save
|
110
|
-
end
|
111
|
-
assert_equal 'gg', Profile.find(2).suffix
|
112
|
-
Profile.distributed_find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each(self.class)
|
113
|
-
assert_equal 'k', Profile.find(2).suffix
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_distributed_each_with_symbol
|
118
|
-
Skynet.solo do
|
119
|
-
Profile.distributed_find(:all, :conditions => "claimed = 1", :batch_size => 2, :model_class => "Profile").each(:mark_modified)
|
120
|
-
end
|
121
|
-
assert ModifiedProfile.find(:first, :conditions => "profile_id = 2")
|
122
|
-
end
|
123
|
-
|
124
|
-
def self.each(profile)
|
125
|
-
profile.suffix = 'k'
|
126
|
-
profile.save
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
class AllModelsExTest
|
132
|
-
def self.each(profile)
|
133
|
-
raise "BUSTED" if profile.id == 8
|
134
|
-
profile.suffix = 'k'
|
135
|
-
profile.save
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|