timocratic-skynet 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/History.txt +152 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +144 -0
  4. data/README.txt +178 -0
  5. data/Rakefile +5 -0
  6. data/app_generators/skynet_install/USAGE +5 -0
  7. data/app_generators/skynet_install/skynet_install_generator.rb +94 -0
  8. data/app_generators/skynet_install/templates/migration.rb +43 -0
  9. data/app_generators/skynet_install/templates/skynet_config.rb +50 -0
  10. data/app_generators/skynet_install/templates/skynet_initializer.rb +1 -0
  11. data/app_generators/skynet_install/templates/skynet_mysql_schema.sql +33 -0
  12. data/bin/skynet +71 -0
  13. data/bin/skynet_install +36 -0
  14. data/bin/skynet_tuplespace_server +74 -0
  15. data/config/hoe.rb +75 -0
  16. data/config/requirements.rb +17 -0
  17. data/examples/dgrep/README +70 -0
  18. data/examples/dgrep/config/skynet_config.rb +26 -0
  19. data/examples/dgrep/data/shakespeare/README +2 -0
  20. data/examples/dgrep/data/shakespeare/poetry/loverscomplaint +381 -0
  21. data/examples/dgrep/data/shakespeare/poetry/rapeoflucrece +2199 -0
  22. data/examples/dgrep/data/shakespeare/poetry/sonnets +2633 -0
  23. data/examples/dgrep/data/shakespeare/poetry/various +640 -0
  24. data/examples/dgrep/data/shakespeare/poetry/venusandadonis +1423 -0
  25. data/examples/dgrep/data/testfile1.txt +1 -0
  26. data/examples/dgrep/data/testfile2.txt +1 -0
  27. data/examples/dgrep/data/testfile3.txt +1 -0
  28. data/examples/dgrep/data/testfile4.txt +1 -0
  29. data/examples/dgrep/lib/dgrep.rb +59 -0
  30. data/examples/dgrep/lib/mapreduce_test.rb +32 -0
  31. data/examples/dgrep/lib/most_common_words.rb +45 -0
  32. data/examples/dgrep/script/dgrep +75 -0
  33. data/examples/rails_mysql_example/README +66 -0
  34. data/examples/rails_mysql_example/Rakefile +10 -0
  35. data/examples/rails_mysql_example/app/controllers/application.rb +10 -0
  36. data/examples/rails_mysql_example/app/helpers/application_helper.rb +3 -0
  37. data/examples/rails_mysql_example/app/models/user.rb +21 -0
  38. data/examples/rails_mysql_example/app/models/user_favorite.rb +5 -0
  39. data/examples/rails_mysql_example/app/models/user_mailer.rb +12 -0
  40. data/examples/rails_mysql_example/app/views/user_mailer/welcome.erb +5 -0
  41. data/examples/rails_mysql_example/config/boot.rb +109 -0
  42. data/examples/rails_mysql_example/config/database.yml +42 -0
  43. data/examples/rails_mysql_example/config/environment.rb +59 -0
  44. data/examples/rails_mysql_example/config/environments/development.rb +18 -0
  45. data/examples/rails_mysql_example/config/environments/production.rb +19 -0
  46. data/examples/rails_mysql_example/config/environments/test.rb +22 -0
  47. data/examples/rails_mysql_example/config/initializers/inflections.rb +10 -0
  48. data/examples/rails_mysql_example/config/initializers/mime_types.rb +5 -0
  49. data/examples/rails_mysql_example/config/initializers/skynet.rb +1 -0
  50. data/examples/rails_mysql_example/config/routes.rb +35 -0
  51. data/examples/rails_mysql_example/config/skynet_config.rb +36 -0
  52. data/examples/rails_mysql_example/db/migrate/001_create_skynet_tables.rb +43 -0
  53. data/examples/rails_mysql_example/db/migrate/002_create_users.rb +16 -0
  54. data/examples/rails_mysql_example/db/migrate/003_create_user_favorites.rb +14 -0
  55. data/examples/rails_mysql_example/db/schema.rb +85 -0
  56. data/examples/rails_mysql_example/db/skynet_mysql_schema.sql +33 -0
  57. data/examples/rails_mysql_example/doc/README_FOR_APP +2 -0
  58. data/examples/rails_mysql_example/lib/tasks/rails_mysql_example.rake +20 -0
  59. data/examples/rails_mysql_example/public/.htaccess +40 -0
  60. data/examples/rails_mysql_example/public/404.html +30 -0
  61. data/examples/rails_mysql_example/public/422.html +30 -0
  62. data/examples/rails_mysql_example/public/500.html +30 -0
  63. data/examples/rails_mysql_example/public/dispatch.cgi +10 -0
  64. data/examples/rails_mysql_example/public/dispatch.fcgi +24 -0
  65. data/examples/rails_mysql_example/public/dispatch.rb +10 -0
  66. data/examples/rails_mysql_example/public/favicon.ico +0 -0
  67. data/examples/rails_mysql_example/public/images/rails.png +0 -0
  68. data/examples/rails_mysql_example/public/index.html +277 -0
  69. data/examples/rails_mysql_example/public/javascripts/application.js +2 -0
  70. data/examples/rails_mysql_example/public/javascripts/controls.js +963 -0
  71. data/examples/rails_mysql_example/public/javascripts/dragdrop.js +972 -0
  72. data/examples/rails_mysql_example/public/javascripts/effects.js +1120 -0
  73. data/examples/rails_mysql_example/public/javascripts/prototype.js +4225 -0
  74. data/examples/rails_mysql_example/public/robots.txt +5 -0
  75. data/examples/rails_mysql_example/script/about +3 -0
  76. data/examples/rails_mysql_example/script/console +3 -0
  77. data/examples/rails_mysql_example/script/destroy +3 -0
  78. data/examples/rails_mysql_example/script/generate +3 -0
  79. data/examples/rails_mysql_example/script/performance/benchmarker +3 -0
  80. data/examples/rails_mysql_example/script/performance/profiler +3 -0
  81. data/examples/rails_mysql_example/script/performance/request +3 -0
  82. data/examples/rails_mysql_example/script/plugin +3 -0
  83. data/examples/rails_mysql_example/script/process/inspector +3 -0
  84. data/examples/rails_mysql_example/script/process/reaper +3 -0
  85. data/examples/rails_mysql_example/script/process/spawner +3 -0
  86. data/examples/rails_mysql_example/script/runner +3 -0
  87. data/examples/rails_mysql_example/script/server +3 -0
  88. data/examples/rails_mysql_example/test/fixtures/user_favorites.yml +9 -0
  89. data/examples/rails_mysql_example/test/fixtures/users.yml +11 -0
  90. data/examples/rails_mysql_example/test/test_helper.rb +38 -0
  91. data/examples/rails_mysql_example/test/unit/user_favorite_test.rb +8 -0
  92. data/examples/rails_mysql_example/test/unit/user_test.rb +8 -0
  93. data/extras/README +7 -0
  94. data/extras/init.d/skynet +87 -0
  95. data/extras/nagios/check_skynet.sh +121 -0
  96. data/extras/rails/controllers/skynet_controller.rb +43 -0
  97. data/extras/rails/views/skynet/index.rhtml +137 -0
  98. data/lib/skynet.rb +95 -0
  99. data/lib/skynet/mapreduce_helper.rb +74 -0
  100. data/lib/skynet/mapreduce_test.rb +56 -0
  101. data/lib/skynet/message_queue_adapters/message_queue_adapter.rb +70 -0
  102. data/lib/skynet/message_queue_adapters/mysql.rb +509 -0
  103. data/lib/skynet/message_queue_adapters/tuple_space.rb +316 -0
  104. data/lib/skynet/skynet_active_record_extensions.rb +280 -0
  105. data/lib/skynet/skynet_config.rb +232 -0
  106. data/lib/skynet/skynet_console.rb +50 -0
  107. data/lib/skynet/skynet_console_helper.rb +66 -0
  108. data/lib/skynet/skynet_debugger.rb +138 -0
  109. data/lib/skynet/skynet_guid_generator.rb +68 -0
  110. data/lib/skynet/skynet_job.rb +892 -0
  111. data/lib/skynet/skynet_launcher.rb +40 -0
  112. data/lib/skynet/skynet_logger.rb +62 -0
  113. data/lib/skynet/skynet_manager.rb +706 -0
  114. data/lib/skynet/skynet_message.rb +359 -0
  115. data/lib/skynet/skynet_message_queue.rb +136 -0
  116. data/lib/skynet/skynet_partitioners.rb +96 -0
  117. data/lib/skynet/skynet_ruby_extensions.rb +53 -0
  118. data/lib/skynet/skynet_task.rb +118 -0
  119. data/lib/skynet/skynet_tuplespace_server.rb +83 -0
  120. data/lib/skynet/skynet_worker.rb +451 -0
  121. data/lib/skynet/version.rb +9 -0
  122. data/script/destroy +14 -0
  123. data/script/generate +14 -0
  124. data/script/txt2html +74 -0
  125. data/setup.rb +1585 -0
  126. data/tasks/deployment.rake +34 -0
  127. data/tasks/environment.rake +7 -0
  128. data/tasks/website.rake +17 -0
  129. data/test/test_active_record_extensions.rb +138 -0
  130. data/test/test_generator_helper.rb +20 -0
  131. data/test/test_helper.rb +10 -0
  132. data/test/test_mysql_message_queue_adapter.rb +263 -0
  133. data/test/test_skynet.rb +19 -0
  134. data/test/test_skynet_install_generator.rb +49 -0
  135. data/test/test_skynet_job.rb +717 -0
  136. data/test/test_skynet_manager.rb +157 -0
  137. data/test/test_skynet_message.rb +229 -0
  138. data/test/test_skynet_task.rb +24 -0
  139. data/test/test_tuplespace_message_queue.rb +174 -0
  140. data/website/index.html +181 -0
  141. data/website/index.txt +98 -0
  142. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  143. data/website/stylesheets/screen.css +138 -0
  144. data/website/template.rhtml +48 -0
  145. metadata +247 -0
data/History.txt ADDED
@@ -0,0 +1,152 @@
1
+ == 0.9.3 2008-05-22
2
+ Skynet::Manager and Skynet Script Runner
3
+ - Rewrote how Skynet workers and skynet manager talks on each machine. See below for more info
4
+
5
+ - Added an examples/ directory with sample skynet apps.
6
+
7
+ - Support starting Skynet with 'skynet start/stop' to daemonize
8
+ - skynet_install now only installs a config/skynet_config.rb in your applications directory. You are no longer supposed
9
+ to have a script/skynet to start skynet. Instead, as long as you have a config/skynet_config.rb you can just run
10
+ 'skynet start/stop' from within your application_directory/
11
+ If you're installing in a rails application, it will install a default config/initializers/skynet.rb which merely requires config/skynet_config.rb
12
+ - The config file can also be specified with --config= skynet start
13
+
14
+ - Gracefully handles trying to start skynet more than once
15
+ - Close file handles on exec.
16
+ Skynet::Worker and Skynet::Manager now call Skynet.fork_and_exec instead of their own versions.
17
+ Skynet.fork_and_exec prevents file descriptor exhaustion by calling Skynet.close_file_handles.
18
+ Skynet::Manager detatches from console by calling Skynet.close_console
19
+
20
+ - Dramatically improved Skynet shutdown time
21
+ - Huge performance improvements in taking/putting tasks and results. Much lower resource utilization, especially on mysql.
22
+ - You now have to specify your PIDFILE and LOGFILE dirs and files differently. This will break all old skynet runners. Sorry.
23
+ - Skynet runner handles default config variables better
24
+ - Fix serious bug in Skynet::Partitioners::RecombineAndSplit where it wouldn't handle empty results well.
25
+ - Fixed Skynet::Partitioners::ArrayDataSplitByFirstEntry to handle strings as keys better
26
+ - Added Skynet::Job.results_by_job_id to retrieve results from asyncronous jobs
27
+ - Added printlog logging method which always prints to the log as [LOG]
28
+ - Deprecated Skynet.new to Skynet.start
29
+ - Mysql Message Queue Adapter - Make delete_expired_messages much safer.
30
+ - rename ActiveRecord::Base.distributed_find.each to ActiveRecord::Base.distributed_find.map
31
+ - ActiveRecord::Base.distributed_find - Patch submitted by Lourens Naude (lourens@methodmissing.com) which checks the model for the primary_key name as opposed to assuming it is
32
+ 'id'
33
+ - We don't want to use rails constantize so I've temporarily borrowed the method from ActiveSupport inflector and added it to skynet_ruby_extensions.
34
+ - Fix bug in Job comment where it referenced MapreduceTest instead of Skynet::MapreduceTest
35
+ - Fix tests. For some reason you still can't run ALL the test at once with rake test, but if the files are run individually they all pass.
36
+ - Change mysql text fields to longtext in migration and schema files
37
+ - Include some extras including our init.d script, our nagios monitoring script, rails controller and view for monitoring
38
+ - Created a new skynet rails initializer which gets installed from skynet_install --rails
39
+ - Modified the skynet_install skynet runner to take skynet initializer into account
40
+ - Skynet::ActiveRecordExtensions Fixed a bug where it would fail if your table had fewer than 1000 rows. It performs a count
41
+ first now to make sure there are enough rows.
42
+ - Introduced some new Skynet::Config methods for getting logfile and pidfile locations
43
+
44
+ Skynet Manager/Worker Refactor
45
+ The workers used to publish their worker statuses to the skynet_worker_queue which lived in the same Q space as the skynet_message_queue. skynet managers would then query that queue for their workers' statuses. This was a very inefficient use of central resources. NOW, workers communicate with their manager vir DRb, calling manager.worker_notify(status). This adds the worker status hash onto a local Queue object stored in the manager. A separate thread watches that queue and updates the internal manager information about it's workers. This was in place of polling a queue every N seconds for new worker records.
46
+ Managers now save their worker information to a file periodically so they can be reloaded on a restart. This means managers can keep track of how many tasks all of their workers have done even after restarts.
47
+ As a consequence of decentralizing worker stats, you now have to ask all your managers for their individual stats along with the main message queue stats. Added a stats_for_hosts method to Skynet::Manager which aggregates stats accross many managers.
48
+
49
+
50
+ == 0.9.2 2008-01-22
51
+ Highlights:
52
+ - Multiple Message Queues
53
+ - Many more Job options including options to control how jobs are distributed.
54
+ - The various options for how a job is run has been made much clearer.
55
+ - The Mysql Message Queue Adapter has been optimized and made more reliable.
56
+ - You can now control how many times skynet retries failed master, map and reduce tasks.
57
+ - Large data sets can now be streamed to the queue.
58
+
59
+ Details:
60
+
61
+ Active::Record#distributed_find
62
+ - Active Record distributed_find now handles REALLY large sets by breaking them into seperate jobs. 1MM models per master broken into ranges of 1000.
63
+
64
+ Skynet::Job
65
+ - code path through Skynet::Job is now clear. There are 3 ways to run Skynet::Job. Local Master (default), Remote Master, Async (implies remote master)
66
+ - Skynet::Job supports keep_map_tasks and keep_reduce_tasks settings.
67
+ If true, the master will run the tasks locally.
68
+ If a number is provided, the master will run the tasks locally if there are LESS THAN OR EQUAL TO the number provided
69
+ There are also Skynet::CONFIG settings for defaults. DEFAULT_KEEP_REDUCE_TASKS, DEFAULT_KEEP_MAP_TASKS
70
+ I can see there being a problem with the timeouts being a little off... Since your kinda in a master and kinda in a map or reduce timeout. The task timeouts will be correct at least. Though, you won't get the benefit of redoes yet.
71
+ - Skynet::Job now supports setting RETRY times per job by MASTER, MAP and REDUCE. So you can have a MASTER_RETRY=0, but have MAP_RETRY=2 and REDUCE_RETRY=3. There are now defaults for those as well :DEFAULT_MASTER_RETRY, :DEFAULT_MAP_RETRY, :DEFAULT_REDUCE_RETRY. If a message passes its RETRY it will be marked with an iteration of -1. delete_expired_messages removes those messages as well. These show up in the stats as :failed_tasks. Skynet::Task and Skynet::Message now have retry fields denoting the maximum number of retries.
72
+ - You can now pass queue_id or queue to Skynet::Job
73
+ - There is now a :MAX_RETRIES config setting that controls how many iterations Skynet will even look for tasks as well.
74
+ - You can now stream map_data to the queue by passing an Enumerable for your map_data
75
+ - Refactored Skynet::Job to be much cleaner and easier to test.
76
+ - Skynet::Job now has access to a local queue which it can treat almost like the real one.
77
+ - deprecate Skynet::Job#run_master
78
+ - rename reduce_partitioner method to just reduce_partition
79
+ - Skynet::Job has better support for running tasks locally. A job may run tasks in its own process if
80
+ you are running in solo mode, you've made a "single" job, or you set the keep_map_tasks or keep_reduce_tasks below.
81
+ When a job runs tasks locally it now honors the retry settings and timeouts.
82
+ - Skynet::Job and Skynet::AsyncJob are now almost identical. In fact you can just use Skynet::Job and tell it to run async.
83
+ - Skynet::Job Changed map_tasks and reduce_tasks to mappers and reducers respectively. This was to remove the ambiguity between the actual map/reduce tasks and the number of mappers/reducers desired.
84
+ - Skynet::Jobs can not be told what queue to use for that job by passing :queue or :queue_id DEFAULT 0
85
+ - Skynet::Job won't call the reduce_partitioner if there are no valid results from the map_step.
86
+
87
+ MapreduceHelper mixin
88
+ - You can include MapreduceHelper into your class and then implement self.map_each and self.reduce_each methods. The included self.map and self.reduce methods will handle iterating over the map_data and reduce_data, passing each element to your map_each and reduce_each methods respectively. They will also handle error handling within that loop to make sure even if a single map or reduce fails, processing will continue. If you do not want processing to continue if a map fails, do not use the MapreduceHelper mixin.
89
+
90
+ Multiple Message Queues!
91
+ - Add the ability to have multiple message queues in the same table message_queue_table.
92
+ - You can start skynet with a --queue_id or --queue option to determine which queue workers should look in.
93
+ - Skynet::Jobs can not be told what queue to use for that job by passing :queue or :queue_id. DEFAULT 0
94
+ - Queues can be configred via Skynet::CONFIG[:MESSAGE_QUEUES] = [] which comes with an array of queues id 1 through 10 named "one" through "ten"
95
+
96
+ Skynet Console
97
+ - You now start the skynet console by running 'skynet console' at the command line. There is no longer a skynet_console app.
98
+ - The console now loads the configs that are in your local skynet script.
99
+
100
+ Skynet::Config
101
+ - Added Skynet.silent {} Runs your code with no debugging output.
102
+ - Made sure all config options for TupleSpace? adapter begin with TS and all Mysql adapter CONFIG settings start with MYSQL.
103
+ - There is now a :MAX_RETRIES config setting that controls how many iterations Skynet will even look for tasks as well.
104
+
105
+ Skynet::Partitioners
106
+ - Created a Skynet::Partitioners class where various partitioners can be found. To specify one of them merely provide that specific Skynet::Partitioners subclass as your reduce_partitioner in your Skynet::Job
107
+
108
+ Skynet Install
109
+ - skynet_install now has a --mysql option. This installs the migration as well as a skynet_schema.sql file.
110
+
111
+ Mysql Message Queue Adapter
112
+ - You can now configure your database options outside of rails with Skynet::CONFIG[:MYSQL_*] options.
113
+ - Mysql adapter now updates the updated_on time of rows in skynet_message_queues
114
+ - Fixed Mysql Message Adaptor to take_next_task safer and more efficiently. There seems to be far less risk of a race condition where two workers would take the same task.
115
+ - Eliminated 1 db update per every task taken making it MUCH more efficient.
116
+ - Skynet::MessageQueueAdaptor::Mysql now tries to reconnect if it gets disconnected. This was to solve the "Mysql Server has Gone Away" errors.
117
+ - Implemented version_active? in mysql message queue adapter. It's a way for workers to check to see if a version is still in the queue.
118
+
119
+ Skynet::Task
120
+ - Skynet::Task#master_task takes care of creating the master job and task now. I have mixed feelings about this.
121
+ - ENFORCED TIMEOUTS - Even though a master might give up on a worker if it didn't respond in time, there was nothing to step any given worker from running forever. We now enforce the timeouts (master_timeout, map_timeout, reduce_timeout) given in Skynet::Job using the Timeout module. This causes a Timeout::Error to be thrown. If you are using the mysql adapter, this can cause strange results sometimes. If the Timeout error is thrown during a DB query, ActiveRecord will throw an ActiveRecord::StatementInvalid exception which includes the Timeout::Error exception in it. Not sure how to prevent that from happening.
122
+
123
+ Skynet::Worker
124
+ - Workers now have a Skynet::CONFIG[:WORKER_MAX_PROCESSED] setting to control when to respawn based on how many that worker has processed.
125
+ - You can start skynet with a --queue_id or --queue option to determine which queue workers should look in.
126
+ - Workers do not restart until there are no more items in the queue of that version.
127
+
128
+ Skynet::Message
129
+ - Skynet::Message now stores fields as an array. It is far more efficient now as well.
130
+
131
+ Now 90% more Tests!
132
+
133
+ BUGFIXES
134
+ - Skynet Workers now restart properly when the worker_version changes.
135
+ - starting tuplespce_server, you no longer need to provide the --port if you're already providing the drburi-
136
+ - Fixed a bug where Skynet::MessageQueueAdapter::Mysql would sometimes pick up tasks another worker had already picked up.
137
+ - Fix bug in Skynet::Worker where it wouldn't die right if the max processed was reached.
138
+ - Workers were supposed to restart when the worker_version changed. They do that properly now.
139
+
140
+ Thanks to Jason Rimmer for finding these bugs.
141
+ - Fix bug in Skynet::Message where it would calculate the iteration improperly.
142
+ - The skynet gem appears to be missing the Rubigen dependency
143
+ - Running skynet_install even without the rails arg still generates code with rails dependencies and tailings: RAILS_ROOT, RAILS_ENV, and the various directory tailings such as 'db/migrate', etc.
144
+ - Generated skynet script is missing "require 'rubygems'"
145
+ - Specification of pid directory and file is incorrect as 'skynet_manager.rb' wants only a directory with it specifying the file
146
+ - The sleep while waiting to start the queue server isn't long enough. There is now a CONFIG setting TS_SERVER_START_DELAY.
147
+
148
+
149
+ == 0.0.1 2007-12-16
150
+
151
+ * 1 major enhancement:
152
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007 Adam Pisoni, Geni.com
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,144 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ app_generators/skynet_install/USAGE
7
+ app_generators/skynet_install/skynet_install_generator.rb
8
+ app_generators/skynet_install/templates/migration.rb
9
+ app_generators/skynet_install/templates/skynet_config.rb
10
+ app_generators/skynet_install/templates/skynet_initializer.rb
11
+ app_generators/skynet_install/templates/skynet_mysql_schema.sql
12
+ bin/skynet
13
+ bin/skynet_install
14
+ bin/skynet_tuplespace_server
15
+ config/hoe.rb
16
+ config/requirements.rb
17
+ examples/dgrep/README
18
+ examples/dgrep/config/skynet_config.rb
19
+ examples/dgrep/data/shakespeare/README
20
+ examples/dgrep/data/shakespeare/poetry/loverscomplaint
21
+ examples/dgrep/data/shakespeare/poetry/rapeoflucrece
22
+ examples/dgrep/data/shakespeare/poetry/sonnets
23
+ examples/dgrep/data/shakespeare/poetry/various
24
+ examples/dgrep/data/shakespeare/poetry/venusandadonis
25
+ examples/dgrep/data/testfile1.txt
26
+ examples/dgrep/data/testfile2.txt
27
+ examples/dgrep/data/testfile3.txt
28
+ examples/dgrep/data/testfile4.txt
29
+ examples/dgrep/lib/dgrep.rb
30
+ examples/dgrep/lib/mapreduce_test.rb
31
+ examples/dgrep/lib/most_common_words.rb
32
+ examples/dgrep/script/dgrep
33
+ examples/rails_mysql_example/README
34
+ examples/rails_mysql_example/Rakefile
35
+ examples/rails_mysql_example/app/controllers/application.rb
36
+ examples/rails_mysql_example/app/helpers/application_helper.rb
37
+ examples/rails_mysql_example/app/models/user.rb
38
+ examples/rails_mysql_example/app/models/user_favorite.rb
39
+ examples/rails_mysql_example/app/models/user_mailer.rb
40
+ examples/rails_mysql_example/app/views/user_mailer/welcome.erb
41
+ examples/rails_mysql_example/config/boot.rb
42
+ examples/rails_mysql_example/config/database.yml
43
+ examples/rails_mysql_example/config/environment.rb
44
+ examples/rails_mysql_example/config/environments/development.rb
45
+ examples/rails_mysql_example/config/environments/production.rb
46
+ examples/rails_mysql_example/config/environments/test.rb
47
+ examples/rails_mysql_example/config/initializers/inflections.rb
48
+ examples/rails_mysql_example/config/initializers/mime_types.rb
49
+ examples/rails_mysql_example/config/initializers/skynet.rb
50
+ examples/rails_mysql_example/config/routes.rb
51
+ examples/rails_mysql_example/config/skynet_config.rb
52
+ examples/rails_mysql_example/db/migrate/001_create_skynet_tables.rb
53
+ examples/rails_mysql_example/db/migrate/002_create_users.rb
54
+ examples/rails_mysql_example/db/migrate/003_create_user_favorites.rb
55
+ examples/rails_mysql_example/db/schema.rb
56
+ examples/rails_mysql_example/db/skynet_mysql_schema.sql
57
+ examples/rails_mysql_example/doc/README_FOR_APP
58
+ examples/rails_mysql_example/lib/tasks/rails_mysql_example.rake
59
+ examples/rails_mysql_example/public/.htaccess
60
+ examples/rails_mysql_example/public/404.html
61
+ examples/rails_mysql_example/public/422.html
62
+ examples/rails_mysql_example/public/500.html
63
+ examples/rails_mysql_example/public/dispatch.cgi
64
+ examples/rails_mysql_example/public/dispatch.fcgi
65
+ examples/rails_mysql_example/public/dispatch.rb
66
+ examples/rails_mysql_example/public/favicon.ico
67
+ examples/rails_mysql_example/public/images/rails.png
68
+ examples/rails_mysql_example/public/index.html
69
+ examples/rails_mysql_example/public/javascripts/application.js
70
+ examples/rails_mysql_example/public/javascripts/controls.js
71
+ examples/rails_mysql_example/public/javascripts/dragdrop.js
72
+ examples/rails_mysql_example/public/javascripts/effects.js
73
+ examples/rails_mysql_example/public/javascripts/prototype.js
74
+ examples/rails_mysql_example/public/robots.txt
75
+ examples/rails_mysql_example/script/about
76
+ examples/rails_mysql_example/script/console
77
+ examples/rails_mysql_example/script/destroy
78
+ examples/rails_mysql_example/script/generate
79
+ examples/rails_mysql_example/script/performance/benchmarker
80
+ examples/rails_mysql_example/script/performance/profiler
81
+ examples/rails_mysql_example/script/performance/request
82
+ examples/rails_mysql_example/script/plugin
83
+ examples/rails_mysql_example/script/process/inspector
84
+ examples/rails_mysql_example/script/process/reaper
85
+ examples/rails_mysql_example/script/process/spawner
86
+ examples/rails_mysql_example/script/runner
87
+ examples/rails_mysql_example/script/server
88
+ examples/rails_mysql_example/test/fixtures/user_favorites.yml
89
+ examples/rails_mysql_example/test/fixtures/users.yml
90
+ examples/rails_mysql_example/test/test_helper.rb
91
+ examples/rails_mysql_example/test/unit/user_favorite_test.rb
92
+ examples/rails_mysql_example/test/unit/user_test.rb
93
+ extras/README
94
+ extras/init.d/skynet
95
+ extras/nagios/check_skynet.sh
96
+ extras/rails/controllers/skynet_controller.rb
97
+ extras/rails/views/skynet/index.rhtml
98
+ lib/skynet.rb
99
+ lib/skynet/mapreduce_helper.rb
100
+ lib/skynet/mapreduce_test.rb
101
+ lib/skynet/message_queue_adapters/message_queue_adapter.rb
102
+ lib/skynet/message_queue_adapters/mysql.rb
103
+ lib/skynet/message_queue_adapters/tuple_space.rb
104
+ lib/skynet/skynet_active_record_extensions.rb
105
+ lib/skynet/skynet_config.rb
106
+ lib/skynet/skynet_console.rb
107
+ lib/skynet/skynet_console_helper.rb
108
+ lib/skynet/skynet_debugger.rb
109
+ lib/skynet/skynet_guid_generator.rb
110
+ lib/skynet/skynet_job.rb
111
+ lib/skynet/skynet_launcher.rb
112
+ lib/skynet/skynet_logger.rb
113
+ lib/skynet/skynet_manager.rb
114
+ lib/skynet/skynet_message.rb
115
+ lib/skynet/skynet_message_queue.rb
116
+ lib/skynet/skynet_partitioners.rb
117
+ lib/skynet/skynet_ruby_extensions.rb
118
+ lib/skynet/skynet_task.rb
119
+ lib/skynet/skynet_tuplespace_server.rb
120
+ lib/skynet/skynet_worker.rb
121
+ lib/skynet/version.rb
122
+ script/destroy
123
+ script/generate
124
+ script/txt2html
125
+ setup.rb
126
+ tasks/deployment.rake
127
+ tasks/environment.rake
128
+ tasks/website.rake
129
+ test/test_active_record_extensions.rb
130
+ test/test_generator_helper.rb
131
+ test/test_helper.rb
132
+ test/test_mysql_message_queue_adapter.rb
133
+ test/test_skynet.rb
134
+ test/test_skynet_install_generator.rb
135
+ test/test_skynet_job.rb
136
+ test/test_skynet_manager.rb
137
+ test/test_skynet_message.rb
138
+ test/test_skynet_task.rb
139
+ test/test_tuplespace_message_queue.rb
140
+ website/index.html
141
+ website/index.txt
142
+ website/javascripts/rounded_corners_lite.inc.js
143
+ website/stylesheets/screen.css
144
+ website/template.rhtml
data/README.txt ADDED
@@ -0,0 +1,178 @@
1
+ Skynet
2
+ http://skynet.rubyforge.org/
3
+ by Adam Pisoni and Geni.com
4
+
5
+ == DESCRIPTION
6
+
7
+ Skynet is an open source Ruby implementation of Google's MapReduce framework, created at Geni. 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. If you'd like to learn more about MapReduce, see my intro at the bottom of this document.
8
+
9
+ 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.
10
+
11
+ For more detailed documentation see the following:
12
+
13
+ Skynet::Job - The main interface to Skynet; includes an example of how to use Skynet
14
+
15
+ Skynet::Config - Configuration options
16
+
17
+ bin/skynet[link:files/bin/skynet.html] - Starting Skynet
18
+
19
+ bin/skynet_install[link:files/bin/skynet_install.html] - Installing Skynet into a local project
20
+
21
+ There are also some examples in the examples/ directory included with Skynet.
22
+
23
+ == INSTALLATION
24
+
25
+ Skynet can be installed via RubyGems:
26
+
27
+ $ sudo gem install skynet
28
+
29
+ or grab the bleeding edge skynet in svn at
30
+ $ svn checkout svn+ssh://developername@rubyforge.org/var/svn/skynet
31
+ $ cd skynet; rake install_gem
32
+
33
+ == INITIAL SETUP
34
+
35
+ Skynet works by putting "tasks" on a message queue which are picked up by skynet workers. The workers execute tasks and put their results back on the message queue. Skynet workers need to load your code at startup in order to be able to execute your tasks. This loading is handled by installing a skynet config file into your app running skynet_install[link:files/bin/skynet_install.html].
36
+
37
+ $ skynet_install [--rails] [--mysql] APP_ROOT_DIR
38
+
39
+ This creates a file called skynet_config.rb in APP_ROOT_DIR/config to which you can add the relevant requires. For example, you might have a rails app and want some of that code to run asynchronously or in a distributed way. Just run 'skynet_install --rails' in your rails root, and it will automatically create config/skynet_config.rb and require environment.rb.
40
+
41
+ Skynet currently supports 2 message queue systems, TupleSpace and Mysql. By default, the TupleSpace queue is used as it is the easiest to set up, though it is less powerful and less scaleable for large installations. If you pass --mysql to skynet_install, it will assume you are using the mysql as your message queue.
42
+
43
+ == STARTING SKYNET
44
+
45
+ Once it is installed in your application, you can run skynet from your applications root directory with:
46
+
47
+ $ skynet start [--workers=N]
48
+
49
+ This starts a skynet tuple space message queue and 4 workers. You can control how many workers to start per machine
50
+ by passing --workers=N.
51
+
52
+ == SKYNET CONSOLE
53
+
54
+ You can now run the skynet console to play with skynet a little. See Skynet::ConsoleHelper for commands.
55
+
56
+ $ skynet console
57
+
58
+ Remember, when you change your code, you must stop/start skynet.
59
+
60
+ For help try:
61
+ $ skynet --help
62
+ or
63
+ $ skynet console --help
64
+
65
+ Here are some commands you can run in the skynet console.
66
+ > stats
67
+ > manager.worker_pids
68
+ > [1,2,3,1,1,4].mapreduce(Skynet::MapreduceTest)
69
+
70
+ That last command actually took whatever array you gave it and counted the number of times each element appeared in the array. It's not a very useful task, but it shows how easy Skynet is to use.
71
+
72
+ To see what Skynet is doing, you may want to tail the skynet logs being written to your log directory.
73
+
74
+ For more information on creating your own Skynet jobs read the Skynet::Job documentation.
75
+
76
+ == USAGE
77
+
78
+ Skynet was designed to make doing easy things easy and hard things possible. The easiest way to use skynet is to create a new class with a self.map class method. You can optionally include self.reduce and self.reduce_partitioner as well. Each of those methods should expect a single array (regardless of what data you pass). Then, simply create an array and call mapreduce on it passing your class name. Skynet will figure out which methods your class supports and use them accordingly.
79
+
80
+ == USING SKYNET IN RAILS
81
+
82
+ Skynet includes an extension to ActiveRecord that is very powerful.
83
+
84
+ === distributed_find
85
+
86
+ $ YourModel.distributed_find(:all).each(:somemethod)
87
+
88
+ A find is 'virtually' run with your model class, and the results are distributed to the skynet workers. Each worker then calls :somemethod against each object.
89
+
90
+ === send_later
91
+
92
+ $ model_object.send_later(:method, options, :save)
93
+
94
+ Sometimes you have a method you want to call on a model asynchronously. Using :send_later you can call a method, pass it options, and decide whether you want Skynet to save that model or not once its done calling your method.
95
+
96
+ == Creating Skynet Jobs
97
+
98
+ The main interface to Skynet is through Skynet::Job
99
+
100
+ job = Skynet::Job.new(options)
101
+ job.run
102
+
103
+ There are many options you can pass or change once you have a job object. See Skynet::Job for more info.
104
+
105
+ Most of the time, you will only need to pass a :map_reduce_class and :map_data. All other options just give you finer grained control. The :map_data must be an array, and the :map_reduce_class must implement at least a self.map class method. It may optionally implement self.reduce and self.reduce_partitioner. Your map and reduce class methods should ALWAYS assume they are being passed an array. Your map method must always return an array as well.
106
+
107
+ == Skynet Logging
108
+
109
+ You might be interested in seeing what skynet is doing. There are two Skynet::Config options which control logging: Skynet::CONFIG[:SKYNET_LOG_LEVEL] and Skynet::CONFIG[:SKYNET_LOG_FILE]. Skynet::CONFIG[:SKYNET_LOG_LEVEL] is set to Logger::ERROR by default. Other possibilities are Logger::DEBUG, Logger::INFO, Logger::WARN, Logger::ERROR, and Logger::FATAL. You might try Logger::INFO to see more of what's going on. To use the Skynet::Logger inside your own classes simply add:
110
+
111
+ include SkynetDebugger
112
+
113
+ For more information see SkynetDebugger[link:files/lib/skynet/skynet_debugger_rb.html].
114
+
115
+ == A Note on MapReduce
116
+
117
+ At its simplest level, a MapReduce job defines a data set, a map method and a reduce method. It may also define a partition method. The MapReduce server evenly splits up (partitions) the data given to it and sends those chunks of data, along with a copy of the code in the map method, to workers that execute the map method against the data it was given. The output from each worker is sent back to the MapReduce server. At this point the MapReduce server evenly partitions the RESULT data returned from the workers and sends those chunks of data along with the reduce code to the workers to be executed. The reducers return the final result which is returned to the process that requested the job be done in the first place. Not all jobs need a reduce step, some may just have a map step.
118
+
119
+ The most common example of a MapReduce job is a distributed word counter. Say you wanted to determine how many times a single word appears in a 1GB text file. The MapReduce server would break up the 1GB file into reasonable chunks, say 100 lines per chunk (or partition) and then send each 100 line partition along with the code that looks for that word, to workers. Each worker would grab its partition of the data, count how many times the word appears in the data and return that number. It might take dozens of workers to complete the task. When the map step is done, you are left with a huge list of counts returned by the workers. In this example, the reduce step would consist of sending that list of counts to another worker, with the code required to sum those counts and finally return the total. In this way a task that used to be done in a linear fashion can be parallelized easily.
120
+
121
+ If you want more details on MapReduce, read Google's paper on it. http://labs.google.com/papers/mapreduce.html
122
+
123
+ When I first read that Google paper some years ago, I was a little confused about what was so unique about it. At the most basic level, it seemed too simple to be revolutionary. So you've got a job with two steps: map and reduce. You put some data in, it gets split out to a map step run on many machines. the returned data gets reshuffled and parceled out to a reduce step run on many machines. All the results are then put together again. You can see it as five steps actually. Data -> Partition -> Map -> Partition -> Reduce. Simple enough. Almost too simple. It was only years later when I began working on Skynet that I realized what the revolutionary part of Google's framework was. It made distributed computing accessible. Any engineer could write a complex distributed system without needing to know about the complexities of such systems. They just write a map function and a reduce function. Also, since the distributed system was generalized, you would only need one class of machines to run ALL of your distributed processing, instead of specialized machines for specialized jobs. That WAS revolutionary.
124
+
125
+ Skynet is merely a distributed computing system that allows you to break your problem into map and reduce steps. You don't have to use it as a MapReduce framework though. You can use it as a simple distributed system, or even a simple asynchronous processing system.
126
+
127
+ There are a number of key differences between Google's MapReduce system and skynet. First, currently you can not actually send raw code to the workers. You are really only telling it where the code is. At first this bothered me a lot. Then I realized that in most Object Oriented systems, the amount of code you'd need to duplicate and send over the wire to every worker could be ridiculous. For example, if you want to distribute a task you need to run in Rails, you'd have to send almost all of your app and rails code to every worker with every chunk of data. So, even if you COULD send code, that code would probably eventually jut call some other code in your system. If you can't send ALL the code needed for a task, then you might as well just tell Skynet where all the needed code is.
128
+
129
+ The second big difference is that Google's MapReduce framework uses master federator processes to dole out tasks, recombine them, and generally watch the system. Skynet has no such masters. Instead Skynet uses a standard message queue for all communication. That message queue allows workers to watch each other in the same way a master would, but without the single point of failure (except for the queue itself).
130
+
131
+ == CREDITS
132
+
133
+ There are a number of people who either directly or indirectly worked on Skynet.
134
+ * Justin Balthrop
135
+ * Zack Parker
136
+ * Amos Elliston
137
+ * Zack Hobson
138
+ * Alan Braverman
139
+ * Mike Stangel
140
+ * Scott Steadman
141
+ * Andrew Arrow
142
+ * John Beppu (wrote the original worker/manager code)
143
+ * Jason Rojas
144
+
145
+ Skynet was inspired by and heavily influenced by Josh Carter and this blog post.
146
+ http://multipart-mixed.com/software/simple_mapreduce_in_ruby.html
147
+
148
+ Also by Starfish by Lucas Carlson
149
+ http://tech.rufy.com/2006/08/mapreduce-for-ruby-ridiculously-easy.html
150
+ http://rufy.com/starfish/doc/
151
+
152
+ == CONTACT:
153
+ Adam Pisoni, Geni.com (apisoni at geni.com)
154
+
155
+ == LICENSE:
156
+
157
+ (The MIT License)
158
+
159
+ Copyright (c) 2007 Adam Pisoni, Geni.com
160
+
161
+ Permission is hereby granted, free of charge, to any person obtaining
162
+ a copy of this software and associated documentation files (the
163
+ "Software"), to deal in the Software without restriction, including
164
+ without limitation the rights to use, copy, modify, merge, publish,
165
+ distribute, sublicense, and/or sell copies of the Software, and to
166
+ permit persons to whom the Software is furnished to do so, subject to
167
+ the following conditions:
168
+
169
+ The above copyright notice and this permission notice shall be
170
+ included in all copies or substantial portions of the Software.
171
+
172
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
173
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
174
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
175
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
176
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
177
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
178
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.