Skip to content

Commit

Permalink
Remove whitespace [WhitespaceBot]
Browse files Browse the repository at this point in the history
  • Loading branch information
Gun.io Whitespace Robot committed Feb 1, 2012
1 parent eb7fbdb commit 4094f04
Show file tree
Hide file tree
Showing 65 changed files with 1,310 additions and 1,311 deletions.
38 changes: 19 additions & 19 deletions History.txt
@@ -1,9 +1,9 @@
== 0.9.3 2008-05-22
Skynet::Manager and Skynet Script Runner
- Rewrote how Skynet workers and skynet manager talks on each machine. See below for more info
- Rewrote how Skynet workers and skynet manager talks on each machine. See below for more info

- Added an examples/ directory with sample skynet apps.

- Support starting Skynet with 'skynet start/stop' to daemonize
- skynet_install now only installs a config/skynet_config.rb in your applications directory. You are no longer supposed
to have a script/skynet to start skynet. Instead, as long as you have a config/skynet_config.rb you can just run
Expand All @@ -25,30 +25,30 @@ Skynet::Manager and Skynet Script Runner
- Fixed Skynet::Partitioners::ArrayDataSplitByFirstEntry to handle strings as keys better
- Added Skynet::Job.results_by_job_id to retrieve results from asyncronous jobs
- Added printlog logging method which always prints to the log as [LOG]
- Deprecated Skynet.new to Skynet.start
- Deprecated Skynet.new to Skynet.start
- Mysql Message Queue Adapter - Make delete_expired_messages much safer.
- rename ActiveRecord::Base.distributed_find.each to ActiveRecord::Base.distributed_find.map
- 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
'id'
- 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.
- Fix bug in Job comment where it referenced MapreduceTest instead of Skynet::MapreduceTest
- Fix bug in Job comment where it referenced MapreduceTest instead of Skynet::MapreduceTest
- 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.
- Change mysql text fields to longtext in migration and schema files
- Include some extras including our init.d script, our nagios monitoring script, rails controller and view for monitoring
- Created a new skynet rails initializer which gets installed from skynet_install --rails
- Modified the skynet_install skynet runner to take skynet initializer into account
- Skynet::ActiveRecordExtensions Fixed a bug where it would fail if your table had fewer than 1000 rows. It performs a count
first now to make sure there are enough rows.
- Introduced some new Skynet::Config methods for getting logfile and pidfile locations
- Introduced some new Skynet::Config methods for getting logfile and pidfile locations

Skynet Manager/Worker Refactor
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.
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.
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.


== 0.9.2 2008-01-22
Highlights:
Highlights:
- Multiple Message Queues
- Many more Job options including options to control how jobs are distributed.
- The various options for how a job is run has been made much clearer.
Expand All @@ -63,7 +63,7 @@ Active::Record#distributed_find

Skynet::Job
- 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)
- Skynet::Job supports keep_map_tasks and keep_reduce_tasks settings.
- Skynet::Job supports keep_map_tasks and keep_reduce_tasks settings.
If true, the master will run the tasks locally.
If a number is provided, the master will run the tasks locally if there are LESS THAN OR EQUAL TO the number provided
There are also Skynet::CONFIG settings for defaults. DEFAULT_KEEP_REDUCE_TASKS, DEFAULT_KEEP_MAP_TASKS
Expand All @@ -72,14 +72,14 @@ Skynet::Job
- You can now pass queue_id or queue to Skynet::Job
- There is now a :MAX_RETRIES config setting that controls how many iterations Skynet will even look for tasks as well.
- You can now stream map_data to the queue by passing an Enumerable for your map_data
- Refactored Skynet::Job to be much cleaner and easier to test.
- Refactored Skynet::Job to be much cleaner and easier to test.
- Skynet::Job now has access to a local queue which it can treat almost like the real one.
- deprecate Skynet::Job#run_master
- rename reduce_partitioner method to just reduce_partition
- Skynet::Job has better support for running tasks locally. A job may run tasks in its own process if
you are running in solo mode, you've made a "single" job, or you set the keep_map_tasks or keep_reduce_tasks below.
When a job runs tasks locally it now honors the retry settings and timeouts.
- Skynet::Job and Skynet::AsyncJob are now almost identical. In fact you can just use Skynet::Job and tell it to run async.
When a job runs tasks locally it now honors the retry settings and timeouts.
- Skynet::Job and Skynet::AsyncJob are now almost identical. In fact you can just use Skynet::Job and tell it to run async.
- 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.
- Skynet::Jobs can not be told what queue to use for that job by passing :queue or :queue_id DEFAULT 0
- Skynet::Job won't call the reduce_partitioner if there are no valid results from the map_step.
Expand All @@ -88,18 +88,18 @@ MapreduceHelper mixin
- 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.

Multiple Message Queues!
- Add the ability to have multiple message queues in the same table message_queue_table.
- Add the ability to have multiple message queues in the same table message_queue_table.
- You can start skynet with a --queue_id or --queue option to determine which queue workers should look in.
- Skynet::Jobs can not be told what queue to use for that job by passing :queue or :queue_id. DEFAULT 0
- Queues can be configred via Skynet::CONFIG[:MESSAGE_QUEUES] = [] which comes with an array of queues id 1 through 10 named "one" through "ten"

Skynet Console
- You now start the skynet console by running 'skynet console' at the command line. There is no longer a skynet_console app.
- The console now loads the configs that are in your local skynet script.

Skynet::Config
- Added Skynet.silent {} Runs your code with no debugging output.
- Made sure all config options for TupleSpace? adapter begin with TS and all Mysql adapter CONFIG settings start with MYSQL.
- Made sure all config options for TupleSpace? adapter begin with TS and all Mysql adapter CONFIG settings start with MYSQL.
- There is now a :MAX_RETRIES config setting that controls how many iterations Skynet will even look for tasks as well.

Skynet::Partitioners
Expand All @@ -114,8 +114,8 @@ Mysql Message Queue Adapter
- 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.
- Eliminated 1 db update per every task taken making it MUCH more efficient.
- Skynet::MessageQueueAdaptor::Mysql now tries to reconnect if it gets disconnected. This was to solve the "Mysql Server has Gone Away" errors.
- 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.
- 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.

Skynet::Task
- Skynet::Task#master_task takes care of creating the master job and task now. I have mixed feelings about this.
- 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.
Expand All @@ -132,9 +132,9 @@ Now 90% more Tests!

BUGFIXES
- Skynet Workers now restart properly when the worker_version changes.
- starting tuplespce_server, you no longer need to provide the --port if you're already providing the drburi-
- starting tuplespce_server, you no longer need to provide the --port if you're already providing the drburi-
- Fixed a bug where Skynet::MessageQueueAdapter::Mysql would sometimes pick up tasks another worker had already picked up.
- Fix bug in Skynet::Worker where it wouldn't die right if the max processed was reached.
- Fix bug in Skynet::Worker where it wouldn't die right if the max processed was reached.
- Workers were supposed to restart when the worker_version changed. They do that properly now.

Thanks to Jason Rimmer for finding these bugs.
Expand Down
14 changes: 7 additions & 7 deletions README.txt
Expand Up @@ -32,7 +32,7 @@ or grab the bleeding edge skynet in svn at

== INITIAL SETUP

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].
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].

$ skynet_install [--rails] [--mysql] APP_ROOT_DIR

Expand Down Expand Up @@ -66,7 +66,7 @@ Here are some commands you can run in the skynet console.
> stats
> manager.worker_pids
> [1,2,3,1,1,4].mapreduce(Skynet::MapreduceTest)

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.

To see what Skynet is doing, you may want to tail the skynet logs being written to your log directory.
Expand All @@ -79,18 +79,18 @@ Skynet was designed to make doing easy things easy and hard things possible. The

== USING SKYNET IN RAILS

Skynet includes an extension to ActiveRecord that is very powerful.
Skynet includes an extension to ActiveRecord that is very powerful.

=== distributed_find

$ YourModel.distributed_find(:all).each(:somemethod)

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.

=== send_later

$ model_object.send_later(:method, options, :save)

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.

== Creating Skynet Jobs
Expand All @@ -99,9 +99,9 @@ The main interface to Skynet is through Skynet::Job

job = Skynet::Job.new(options)
job.run

There are many options you can pass or change once you have a job object. See Skynet::Job for more info.

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.

== Skynet Logging
Expand Down
6 changes: 3 additions & 3 deletions app_generators/skynet_install/USAGE
@@ -1,5 +1,5 @@
Description:


Usage:

24 changes: 12 additions & 12 deletions app_generators/skynet_install/skynet_install_generator.rb
@@ -1,15 +1,15 @@
class SkynetInstallGenerator < RubiGen::Base

DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
Config::CONFIG['ruby_install_name'])

default_options :in_rails => false
default_options :mysql => false

attr_reader :name
attr_reader :in_rails
attr_reader :mysql

def initialize(runtime_args, runtime_options = {})
super
usage if args.empty?
Expand All @@ -23,7 +23,7 @@ def manifest

# Ensure appropriate folder(s) exists
BASEDIRS.each { |path| m.directory path }

# Create stubs
m.template "skynet_config.rb", "config/skynet_config.rb", :collision => :ask, :chmod => 0655
if @in_rails
Expand All @@ -33,8 +33,8 @@ def manifest
if @mysql
m.directory 'db/migrate'
m.template "skynet_mysql_schema.sql", "db/skynet_mysql_schema.sql", :collision => :ask, :chmod => 0655
m.migration_template "migration.rb", "db/migrate",
:collision => :ask,
m.migration_template "migration.rb", "db/migrate",
:collision => :ask,
:assigns => {
:migration_name => "CreateSkynetTables"
}, :migration_file_name => "create_skynet_tables"
Expand All @@ -48,7 +48,7 @@ def banner
Creates a ...
USAGE: #{spec.name} [--rails] [--mysql] directory (can be '.' for current)"
Installs:
Installs:
./config/skynet_config.rb
EOS
end
Expand All @@ -59,8 +59,8 @@ def add_options!(opts)
# For each option below, place the default
# at the top of the file next to "default_options"
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
opts.on("--mysql",
"Include mysql migration if you want to use mysql as your message queue.
opts.on("--mysql",
"Include mysql migration if you want to use mysql as your message queue.
Installs:
./db/skynet_mysql_schema.sql
./db/migrate/db/migrate/###_create_skynet_tables.rb
Expand All @@ -72,11 +72,11 @@ def add_options!(opts)
Installs:
./config/initializers/skynet.rb
(If using rails 1, make sure to add require 'skynet' to your environment.rb)",
"Default: false") do |rails|
"Default: false") do |rails|
options[:rails] = true if rails
end
end

def extract_options
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
# Templates can access these value via the attr_reader-generated methods, but not the
Expand Down
4 changes: 2 additions & 2 deletions app_generators/skynet_install/templates/migration.rb
Expand Up @@ -18,10 +18,10 @@ def self.up
t.column :version, :integer
t.column :timeout, "decimal(16,4)"
t.column :retry, :integer, :default => 0
end
end
create_table :skynet_queue_temperature do |t|
t.column :id, "bigint unsigned primary key"
t.column :queue_id, :integer, :default => 0
t.column :queue_id, :integer, :default => 0
t.column :updated_on, :timestamp
t.column :count, :integer, :default => 0
t.column :temperature, "decimal(6,4) default 1"
Expand Down
10 changes: 5 additions & 5 deletions app_generators/skynet_install/templates/skynet_config.rb
@@ -1,9 +1,9 @@
# Skynet Configuration File. Should be in APP_ROOT/config/skynet_config.rb
# Start skynet from within your app root with
# Skynet Configuration File. Should be in APP_ROOT/config/skynet_config.rb
# Start skynet from within your app root with
# > skynet start

require 'rubygems'
require 'skynet'
require 'skynet'

<% if in_rails -%>
# Load your rails app
Expand All @@ -20,8 +20,8 @@
Skynet::CONFIG[:SKYNET_LOG_FILE] = "skynet_#{RAILS_ENV}.log"
Skynet::CONFIG[:SKYNET_PID_FILE] = "skynet_#{RAILS_ENV}.pid"
<% else -%>
Skynet::CONFIG[:SKYNET_LOG_DIR] = File.expand_path(File.dirname(__FILE__) + "/../log")
Skynet::CONFIG[:SKYNET_PID_DIR] = File.expand_path(File.dirname(__FILE__) + "/../log")
Skynet::CONFIG[:SKYNET_LOG_DIR] = File.expand_path(File.dirname(__FILE__) + "/../log")
Skynet::CONFIG[:SKYNET_PID_DIR] = File.expand_path(File.dirname(__FILE__) + "/../log")
<% end -%>
<% if mysql -%>
Expand Down
20 changes: 10 additions & 10 deletions config/hoe.rb
Expand Up @@ -28,45 +28,45 @@ def rubyforge_username
end


REV = nil
# UNCOMMENT IF REQUIRED:
REV = nil
# UNCOMMENT IF REQUIRED:
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
VERS = Skynet::VERSION::STRING + (REV ? ".#{REV}" : "")
RDOC_OPTS = ['--quiet', '--title', 'skynet documentation',
"--opname", "index.html",
"--line-numbers",
"--line-numbers",
"--main", "README",
"--inline-source"]

class Hoe
def extra_deps
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
def extra_deps
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
@extra_deps
end
end
end

# Generate all the Rake tasks
# Run 'rake -T' to see list of generated tasks (from gem root directory)
hoe = Hoe.new(GEM_NAME, VERS) do |p|
p.author = AUTHOR
p.author = AUTHOR
p.description = DESCRIPTION
p.email = EMAIL
p.summary = DESCRIPTION
p.url = HOMEPATH
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
p.test_globs = ["test/**/test_*.rb"]
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.

# == Optional
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
p.extra_deps = [
['daemons',">= 1"],
['rubigen', ">=1.1.1"]
]
# An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]

#p.spec_extras = {} # A hash of extra values to set in the gemspec.

end

CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
Expand Down

0 comments on commit 4094f04

Please sign in to comment.