brendan-skynet 0.9.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +4 -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 +54 -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/mapreduce_helper.rb +74 -0
  99. data/lib/skynet/mapreduce_test.rb +56 -0
  100. data/lib/skynet/message_queue_adapters/message_queue_adapter.rb +70 -0
  101. data/lib/skynet/message_queue_adapters/mysql.rb +509 -0
  102. data/lib/skynet/message_queue_adapters/tuple_space.rb +316 -0
  103. data/lib/skynet/skynet_active_record_extensions.rb +293 -0
  104. data/lib/skynet/skynet_config.rb +232 -0
  105. data/lib/skynet/skynet_console.rb +50 -0
  106. data/lib/skynet/skynet_console_helper.rb +66 -0
  107. data/lib/skynet/skynet_debugger.rb +138 -0
  108. data/lib/skynet/skynet_guid_generator.rb +68 -0
  109. data/lib/skynet/skynet_job.rb +892 -0
  110. data/lib/skynet/skynet_launcher.rb +40 -0
  111. data/lib/skynet/skynet_logger.rb +62 -0
  112. data/lib/skynet/skynet_manager.rb +706 -0
  113. data/lib/skynet/skynet_message.rb +359 -0
  114. data/lib/skynet/skynet_message_queue.rb +136 -0
  115. data/lib/skynet/skynet_partitioners.rb +96 -0
  116. data/lib/skynet/skynet_ruby_extensions.rb +53 -0
  117. data/lib/skynet/skynet_task.rb +118 -0
  118. data/lib/skynet/skynet_tuplespace_server.rb +83 -0
  119. data/lib/skynet/skynet_worker.rb +451 -0
  120. data/lib/skynet/version.rb +9 -0
  121. data/lib/skynet.rb +83 -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 +236 -0
@@ -0,0 +1,54 @@
1
+ # Skynet Configuration File. Should be in APP_ROOT/config/skynet_config.rb
2
+ # Start skynet from within your app root with
3
+ # > skynet start
4
+
5
+ require 'rubygems'
6
+ require 'skynet'
7
+
8
+ <% if in_rails -%>
9
+ # Load your rails app
10
+ require File.expand_path(File.dirname(__FILE__)) + '/../config/environment' if not defined?(RAILS_GEM_VERSION)
11
+ <% end -%>
12
+
13
+ Skynet::CONFIG[:SKYNET_LOG_LEVEL] = Logger::ERROR
14
+ <% if in_rails -%>
15
+
16
+ Skynet::CONFIG[:APP_ROOT] = RAILS_ROOT
17
+ Skynet::CONFIG[:SKYNET_LOG_DIR] = File.expand_path(Skynet::CONFIG[:APP_ROOT]+ "/log")
18
+ Skynet::CONFIG[:SKYNET_PID_DIR] = File.expand_path(Skynet::CONFIG[:APP_ROOT] + "/log")
19
+ Skynet::CONFIG[:SKYNET_LOG_FILE] = "skynet_#{RAILS_ENV}.log"
20
+ Skynet::CONFIG[:SKYNET_PID_FILE] = "skynet_#{RAILS_ENV}.pid"
21
+ <% else -%>
22
+ Skynet::CONFIG[:SKYNET_LOG_DIR] = File.expand_path(File.dirname(__FILE__) + "/../log")
23
+ Skynet::CONFIG[:SKYNET_PID_DIR] = File.expand_path(File.dirname(__FILE__) + "/../log")
24
+ <% end -%>
25
+
26
+ <% if mysql -%>
27
+ <% if not in_rails -%>
28
+ # Use the mysql message queue adapter
29
+ Skynet::CONFIG[:MESSAGE_QUEUE_ADAPTER] = "Skynet::MessageQueueAdapter::Mysql"
30
+ Skynet::CONFIG[:MYSQL_HOST] = "localhost"
31
+ Skynet::CONFIG[:MYSQL_USERNAME] = "root"
32
+ Skynet::CONFIG[:MYSQL_PASSWORD] = ""
33
+ Skynet::CONFIG[:MYSQL_DATABASE] = "skynet"
34
+ <% else %>
35
+ # Use the mysql message queue adapter
36
+ Skynet::CONFIG[:MESSAGE_QUEUE_ADAPTER] = "Skynet::MessageQueueAdapter::Mysql"
37
+ <% end -%>
38
+ <% end -%>
39
+
40
+ # Load ActiveRecord extensions, if using ActiveRecord
41
+ if defined?(ActiveRecord::Base)
42
+ require 'skynet_active_record_extensions'
43
+ require 'message_queue_adapters/mysql'
44
+ end
45
+
46
+ # ==================================================================
47
+ # = Require any other libraries you want skynet to know about here =
48
+ # ==================================================================
49
+
50
+ # ===========================================
51
+ # = Set your own configuration options here =
52
+ # ===========================================
53
+ # You can also configure skynet with
54
+ # Skynet.configure(:SOME_CONFIG_OPTION => true, :SOME_OTHER_CONFIG => 3)
@@ -0,0 +1 @@
1
+ require RAILS_ROOT+'/config/skynet_config.rb'
@@ -0,0 +1,33 @@
1
+ CREATE TABLE skynet_message_queues (
2
+ id int(11) NOT NULL auto_increment,
3
+ queue_id int(11) default '0',
4
+ tran_id bigint(20) unsigned default NULL,
5
+ created_on datetime default NULL,
6
+ updated_on datetime default NULL,
7
+ tasktype varchar(255) default NULL,
8
+ task_id bigint(20) unsigned default NULL,
9
+ job_id bigint(20) unsigned default NULL,
10
+ raw_payload longtext,
11
+ payload_type varchar(255) default NULL,
12
+ name varchar(255) default NULL,
13
+ expiry int(11) default NULL,
14
+ expire_time decimal(16,4) default NULL,
15
+ iteration int(11) default NULL,
16
+ version int(11) default NULL,
17
+ timeout decimal(16,4) default NULL,
18
+ retry int(11) default '0',
19
+ PRIMARY KEY (id),
20
+ UNIQUE KEY index_skynet_message_queues_on_tran_id (tran_id),
21
+ KEY index_skynet_message_queues_on_job_id (job_id),
22
+ KEY index_skynet_message_queues_on_task_id (task_id),
23
+ KEY index_skynet_mqueue_for_take (queue_id,tasktype,payload_type,expire_time)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
25
+ CREATE TABLE skynet_queue_temperature (
26
+ id int(11) NOT NULL auto_increment,
27
+ queue_id int(11) default '0',
28
+ updated_on datetime default NULL,
29
+ count int(11) default '0',
30
+ temperature decimal(6,4) default NULL,
31
+ type varchar(255) default NULL,
32
+ PRIMARY KEY (id)
33
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
data/bin/skynet ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This is the main skynet starter script.
4
+ # It can be used to start the skynet_tuplespace_server as well as all skynet workers.
5
+ # It is important that this script has access to your code. If you want to run
6
+ # skynet within your code you'll want to read about bin/skynet_install[link:files/bin/skynet_install.html]
7
+ #
8
+ # Usage: skynet [options]
9
+ # -w, --workers WORKERS Number of workers to start. The default is 4 and is stored in Skynet::CONFIG[:NUMBER_OF_WORKERS]
10
+ # -i, --increment-worker-version Increment Worker Version
11
+ # -a, --add-workers WORKERS Number of workers to add.
12
+ # -k, --remove-workers WORKERS Number of workers to remove.
13
+ # -r, --required LIBRARY Require the specified libraries
14
+ # --restart-all-workers Restart All Workers
15
+ # --restart-workers Restart Workers
16
+ #
17
+ # If you have chosen to use the TupleSpace message queue adapter this script will see if there is an available TS first
18
+ # and start one if there is not. You can also start the bin/skynet_tuplespace_server[link:files/bin/skynet_tuplespace_server.html] manually.
19
+ #
20
+ # Running skynet starts a Skynet::Manager which in turn spawns the Skynet::Worker processes with the appropriate options.
21
+ # You only need to run skynet once per machine. If you want to add more workers, use the appropriate flags above to do so.
22
+ # Only one manager should be running per machine. The Skynet::Manager does not dole out tasks
23
+ #
24
+ # You should set all of your Skynet::CONFIG (or Skynet.configure()) options here (or in one of your environment files.)
25
+ # See Skynet::Config for more information on configuration options.
26
+
27
+ require 'rubygems'
28
+ require File.expand_path(File.dirname(__FILE__)) + '/../lib/skynet.rb'
29
+
30
+
31
+ if config_arg = ARGV.detect {|i| i =~ /--help/ }
32
+ Skynet.start
33
+ exit
34
+ end
35
+
36
+ conf_file = nil
37
+ if config_arg = ARGV.detect {|i| i =~ /--config/i }
38
+ conf_file = config_arg.split('=').last
39
+ ARGV.delete_if {|i| i =~ /--config/ }
40
+ else
41
+ ['config/skynet_config.rb', 'skynet_config.rb', "../config/skynet_config.rb" , "#{ENV['HOME']}/.skynet/config.rb"].each do |path|
42
+ if File.exists?(path)
43
+ conf_file = path
44
+ break
45
+ end
46
+ end
47
+ end
48
+
49
+ if conf_file
50
+ Skynet::CONFIG[:CONFIG_FILE] = File.expand_path(conf_file)
51
+ Skynet::CONFIG[:APP_ROOT] = File.dirname(Skynet::CONFIG[:CONFIG_FILE])
52
+ Skynet::CONFIG[:SKYNET_LOG_DIR] = File.expand_path(Skynet::CONFIG[:APP_ROOT]+ "/../log")
53
+ Skynet::CONFIG[:SKYNET_PID_DIR] = File.expand_path(Skynet::CONFIG[:APP_ROOT] + "/../log")
54
+ begin
55
+ require conf_file
56
+ rescue MissingSourceFile => e
57
+ puts "Specified config file #{conf_file} is missing."
58
+ exit
59
+ end
60
+ puts "using config file: #{File.expand_path(conf_file)}" unless conf_file == 'config/skynet_config.rb'
61
+ else
62
+ puts "No configuration file found.\nTry running skynet_install to create a config/skynet_config.rb or starting skynet with --config=CONFIG_FILE_LOCATION. Exiting."
63
+ exit
64
+ end
65
+
66
+ Skynet::CONFIG[:WORKER_CHECK_DELAY] ||= 4
67
+ Skynet::CONFIG[:LAUNCHER_PATH] = File.expand_path(__FILE__)
68
+
69
+ Skynet::CONFIG[:SYSTEM_RUNNER] = true
70
+
71
+ Skynet.start
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # skynet_install is used to install skynet libraries into your application.
4
+ # Specifically, it installs a config/skynet_config.rb file
5
+ # Once you have a config/skynet_config.rb you can run skynet start from within your root_app_dir/
6
+ # This is also how you can run skynet from within rails. (using --rails)
7
+ #
8
+ # USAGE: skynet_install [--rails] directory/ (can be '.' for current)"
9
+ #
10
+ # Options:
11
+ # -v, --version Show the skynet_install version number and quit.
12
+ # --mysql Include mysql migration if you want to use mysql as your message queue
13
+ # -r, --rails Install into rails app
14
+ # Default: false
15
+ # General Options:
16
+ # -h, --help Show this help message and quit.
17
+ # -p, --pretend Run but do not make any changes.
18
+ # -f, --force Overwrite files that already exist.
19
+ # -s, --skip Skip files that already exist.
20
+ # -q, --quiet Suppress normal output.
21
+ # -t, --backtrace Debugging: show backtrace on errors.
22
+ # -c, --svn Modify files with subversion. (Note: svn must be in path)
23
+ #
24
+
25
+ require 'rubygems'
26
+ require 'rubigen'
27
+
28
+ if %w(-v --version).include? ARGV.first
29
+ require 'skynet_install/version'
30
+ puts "#{File.basename($0)} #{SkynetInstall::VERSION::STRING}"
31
+ exit(0)
32
+ end
33
+
34
+ require 'rubigen/scripts/generate'
35
+ RubiGen::Base.use_application_sources! :skynet_install
36
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'skynet_install')
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # SkynetTupleSpace server is one of the message queues you can use with Skynet. Make sure you set:
4
+ # Skynet::CONFIG[:MESSAGE_QUEUE_ADAPTER] = "Skynet::MessageQueueAdapter::TupleSpace"
5
+ #
6
+ # Usage: skynet_tuplespace_server (start|stop|run) [options]
7
+ # -t, --ontop=TRUE Dont Daemonize
8
+ # -p, --port=PORT Port to listen on. default 7647
9
+ # -o, --logfile=LOGFILE Logfile to log to
10
+ # -l, --loglevel=LOGLEVEL Log level defaults to DEBUG
11
+ # -d, --piddir=PIDDIR Directory to put pidfile
12
+ # -u, --drburi=druby://DRB_URI What DRbURI to use
13
+
14
+ require 'rubygems'
15
+ require 'daemons'
16
+ require 'pp'
17
+
18
+ require File.expand_path(File.dirname(__FILE__)) + '/../lib/skynet.rb'
19
+
20
+ options = {
21
+ :port => 7647,
22
+ :logfile => Skynet::Config.pidfile_location,
23
+ :loglevel => "ERROR",
24
+ :piddir => Skynet::CONFIG[:SKYNET_PID_DIR],
25
+ :use_ringserver => Skynet::CONFIG[:TS_USE_RINGSERVER],
26
+ }
27
+
28
+ OptionParser.new do |opt|
29
+ opt.banner = "Usage: skynet_tuplespace_server (start|stop|run) [options]"
30
+ opt.on('-t', '--ontop TRUE', 'Dont Daemonize') do |v|
31
+ options[:ontop] = true if v.upcase == "TRUE" or v == "1"
32
+ end
33
+ opt.on('-p', '--port=PORT', 'Port to listen on. default 7647') do |v|
34
+ options[:port] = v.to_i
35
+ end
36
+ opt.on('-o', '--logfile=LOGFILE', 'Logfile to log to') do |v|
37
+ options[:logfile] = File.expand_path(v)
38
+ end
39
+ opt.on('-l', '--loglevel=LOGLEVEL', 'Log level defaults to DEBUG') do |v|
40
+ options[:loglevel] = v
41
+ end
42
+ opt.on('-d', '--piddir=PIDDIR', 'Directory to put pidfile') do |v|
43
+ options[:piddir] = File.expand_path(v)
44
+ end
45
+ opt.on('--use_ringserver=TRUE', 'Use ringserver?') do |v|
46
+ if v.downcase == "true" or v == "1"
47
+ options[:use_ringserver] = true
48
+ else
49
+ options[:use_ringserver] = false
50
+ end
51
+ end
52
+ opt.on('-u', '--drburi=druby://DRB_URI', 'What DRbURI to use') do |v|
53
+ if v =~ %r{druby://}
54
+ options[:drburi] = v
55
+ else
56
+ options[:drburi] = "druby://#{v}"
57
+ end
58
+ options[:drburi] =~ /druby:\/\/.+?:(\d*)/
59
+ options[:port] ||= $1.to_i
60
+ end
61
+
62
+ opt.parse!(ARGV)
63
+ end
64
+
65
+ Daemons.run_proc("skynet_tuplespace_server#{options[:port]}",
66
+ {
67
+ :dir_mode => :normal,
68
+ :dir => options[:piddir],
69
+ :backtrace => true,
70
+ # :monitor => true,
71
+ :ontop => options[:ontop] || false
72
+ }) do
73
+ server = Skynet::TuplespaceServer.start(options)
74
+ end
data/config/hoe.rb ADDED
@@ -0,0 +1,75 @@
1
+ require 'skynet/version'
2
+
3
+ AUTHOR = 'Adam Pisoni' # can also be an array of Authors
4
+ EMAIL = "apisoni@geni.com"
5
+ DESCRIPTION = "Skynet - A Ruby Map/Reduce Framework"
6
+ GEM_NAME = 'skynet' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'skynet' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+
11
+ @config_file = "~/.rubyforge/user-config.yml"
12
+ @config = nil
13
+ RUBYFORGE_USERNAME = "unknown"
14
+ def rubyforge_username
15
+ unless @config
16
+ begin
17
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
18
+ rescue
19
+ puts <<-EOS
20
+ ERROR: No rubyforge config file found: #{@config_file}
21
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
23
+ EOS
24
+ exit
25
+ end
26
+ end
27
+ RUBYFORGE_USERNAME.replace @config["username"]
28
+ end
29
+
30
+
31
+ REV = nil
32
+ # UNCOMMENT IF REQUIRED:
33
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34
+ VERS = Skynet::VERSION::STRING + (REV ? ".#{REV}" : "")
35
+ RDOC_OPTS = ['--quiet', '--title', 'skynet documentation',
36
+ "--opname", "index.html",
37
+ "--line-numbers",
38
+ "--main", "README",
39
+ "--inline-source"]
40
+
41
+ class Hoe
42
+ def extra_deps
43
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
+ @extra_deps
45
+ end
46
+ end
47
+
48
+ # Generate all the Rake tasks
49
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
+ p.author = AUTHOR
52
+ p.description = DESCRIPTION
53
+ p.email = EMAIL
54
+ p.summary = DESCRIPTION
55
+ p.url = HOMEPATH
56
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
57
+ p.test_globs = ["test/**/test_*.rb"]
58
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
59
+
60
+ # == Optional
61
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
62
+ p.extra_deps = [
63
+ ['daemons',">= 1"],
64
+ ['rubigen', ">=1.1.1"]
65
+ ]
66
+ # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
67
+
68
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
69
+
70
+ end
71
+
72
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
73
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
74
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
75
+ hoe.rsync_args = '-av --delete --ignore-errors'
@@ -0,0 +1,17 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
16
+
17
+ require 'skynet'
@@ -0,0 +1,70 @@
1
+
2
+ EXAMPLE 1: Distributed Grep
3
+ ------------------------------
4
+ You have a list of files and want to see how many times each word shows up in those files.
5
+ All of the map_reduce code is in lib/mapreduce_test.rb
6
+
7
+ To
8
+ 1. Run Skynet
9
+ > ./script/skynet start
10
+
11
+ 2. Watch the logs in another terminal
12
+ > tail -f log/skynet.log
13
+
14
+ 3. Run dgrep providing it with some words and a directory
15
+ > ./script/dgrep -r love hate ./data
16
+
17
+ I've put all of shakespears poetry in the data directory. You can download all of Shakespeare's work
18
+ to add to the data at http://www.it.usyd.edu.au/~matty/Shakespeare/shakespeare.tar.gz
19
+
20
+ Thats it!!
21
+
22
+ EXAMPLE 2: Distributed Grep with distributed reducing
23
+ ------------------------------
24
+ Same example as above, but this time we want to aggregate our results across multiple partitioners. This would
25
+ be useful if you had a large reduce data set, or complex calculations in order to reduce. All the code is already
26
+ in dgrep.pl. Specifically, notice I've included a self.reduce_partition method (which just forwards to a pre-packaged
27
+ partitioner). This partitioner not only breaks up the data returned from the mappers, but also makes sure each reducer
28
+ gets all the same keys.
29
+
30
+ 1. Run dgrep passing --reducers=2 This tells Skynet to try and use up to 2 reducers (instead of the default of 1)
31
+ > ./script/dgrep -r --reducers=2 data file ./data
32
+
33
+ This sample application was created by creating in the following way
34
+
35
+ 1. Create new app
36
+ > mkdir simple_example
37
+ > mkdir data lib
38
+
39
+ 2. Install Skynet
40
+ > skynet_install
41
+
42
+ 3. Add Data Files to /data
43
+ These are any text files named testfileN.txt and so on
44
+
45
+ 4. Create dgrep.rb and drep script (found in lib/ and script/)
46
+
47
+ ------------------------------------
48
+
49
+ EXAMPLE 1: Most Common Words
50
+ ------------------------------
51
+ You have a list of files and want the 10 most common 5 or more letter words in all of those fules.
52
+
53
+ 1. Run Skynet
54
+ > ./script/skynet start
55
+
56
+ 2. Watch the logs in another terminal
57
+ > tail -f log/skynet.log
58
+
59
+ 3. Run dgrep providing it with the '-mcw' (most common words) command, some words and a directory
60
+ > ./script/dgrep -r -mcw ./data
61
+
62
+ To see what's going on check out lib/most_common_words.rb
63
+ ------------------------------------
64
+
65
+ If you'd like get a peak at what Skynet is doing, edit ./config/skynet_config.rb and set
66
+
67
+ Skynet::CONFIG[:SKYNET_LOG_LEVEL] = Logger::INFO # or Logger::INFO
68
+
69
+ and tail ./log/skynet.log
70
+
@@ -0,0 +1,26 @@
1
+ # Skynet Configuration File. Should be in APP_ROOT/config/skynet_config.rb
2
+ # Start skynet from within your app root with
3
+ # $ skynet start
4
+
5
+ require 'rubygems'
6
+ require 'skynet'
7
+
8
+ Skynet::CONFIG[:SKYNET_LOG_LEVEL] = Logger::ERROR
9
+ Skynet::CONFIG[:SKYNET_LOG_DIR] = File.expand_path(File.dirname(__FILE__) + "/../log")
10
+ Skynet::CONFIG[:SKYNET_PID_DIR] = File.expand_path(File.dirname(__FILE__) + "/../log")
11
+
12
+ # ==================================================================
13
+ # = Require any other libraries you want skynet to know about here =
14
+ # ==================================================================
15
+
16
+ # require all ruby files in lib/
17
+ Dir["#{File.dirname(__FILE__)}" + "/../lib/**/*.rb"].each do |file|
18
+ require file
19
+ end
20
+
21
+ # ===========================================
22
+ # = Set your own configuration options here =
23
+ # ===========================================
24
+ # You can also configure skynet with
25
+ # Skynet.configure(:SOME_CONFIG_OPTION => true, :SOME_OTHER_CONFIG => 3)
26
+
@@ -0,0 +1,2 @@
1
+ Download the complete text of shakespeare at
2
+ http://www.it.usyd.edu.au/~matty/Shakespeare/shakespeare.tar.gz