drbqs 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -11,4 +11,7 @@ group :development do
11
11
  gem "bundler", "~> 1.0.0"
12
12
  gem "jeweler", "~> 1.5.2"
13
13
  gem "rcov", ">= 0"
14
+ gem "filename", ">= 0.0.5"
15
+ gem "net-ssh", ">= 2.1.3"
16
+ gem "net-ssh-shell", ">= 0.1.0"
14
17
  end
data/Rakefile CHANGED
@@ -43,3 +43,13 @@ task :default => :spec
43
43
 
44
44
  require 'yard'
45
45
  YARD::Rake::YardocTask.new
46
+
47
+ task "version:constant" do
48
+ dir = File.dirname(__FILE__)
49
+ path = File.join(dir, 'lib/drbqs.rb')
50
+ data = File.read(path)
51
+ version = File.read(File.join(dir, 'VERSION'))
52
+ open(path, 'w') do |f|
53
+ f.print data.sub(/^ VERSION = '.*'$/, " VERSION = '#{version}'")
54
+ end
55
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.0.13
data/bin/drbqs-manage CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'drbqs'
4
4
  require 'optparse'
5
5
 
6
- Version = '0.0.12'
6
+ Version = DRbQS::VERSION
7
7
 
8
8
  help_message =<<HELP
9
9
  Usage: #{File.basename(__FILE__)} <command> [arguments ...]
data/bin/drbqs-node CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'drbqs'
4
4
  require 'optparse'
5
5
 
6
- Version = '0.0.12'
6
+ Version = DRbQS::VERSION
7
7
 
8
8
  help_message =<<HELP
9
9
  Usage: #{File.basename(__FILE__)} [<uri>] [<process_number>] [options ...]
@@ -87,19 +87,6 @@ if options[:log_prefix]
87
87
  end
88
88
  end
89
89
 
90
- process_num.times do |i|
91
- fork do
92
- if options[:log_prefix]
93
- logfile = FileName.create(options[:log_prefix], :position => :suffix, :type => :time,
94
- :add => :always, :directory => :parent,
95
- :format => lambda { |t| t.strftime("%Y%m%d_%H%M_#{Process.pid}.log") })
96
- else
97
- logfile = STDOUT
98
- end
99
- client = DRbQS::Client.new(uri, :log_level => options[:log_level], :log_file => logfile)
100
- client.connect
101
- client.calculate
102
- end
103
- end
104
-
105
- Process.waitall
90
+ exec_node = DRbQS::ExecuteNode.new(uri, options[:log_prefix], options[:log_level])
91
+ exec_node.execute(process_num)
92
+ exec_node.wait
data/bin/drbqs-server CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'drbqs'
4
4
  require 'optparse'
5
5
 
6
- Version = '0.0.12'
6
+ Version = DRbQS::VERSION
7
7
 
8
8
  help_message =<<HELP
9
9
  Usage: #{File.basename(__FILE__)} <definition.rb> [other files ...] [options ...]
@@ -19,6 +19,7 @@ options = {
19
19
  }
20
20
 
21
21
  test_opts = {}
22
+ execute_node_number = nil
22
23
 
23
24
  command_argv, server_argv = DRbQS::Manage.split_arguments(ARGV)
24
25
 
@@ -59,6 +60,9 @@ begin
59
60
  opt.on('--test STR', String, 'Execute test.') do |v|
60
61
  options[:command_type] = "test_#{v}"
61
62
  end
63
+ opt.on('--execute-node NUM', Integer, 'Execute nodes.') do |v|
64
+ execute_node_number = v
65
+ end
62
66
  opt.parse!(command_argv)
63
67
  end
64
68
  rescue OptionParser::InvalidOption
@@ -84,6 +88,9 @@ command_argv.each do |path|
84
88
  load path
85
89
  end
86
90
 
91
+ WAIT_SERVER_TIME = 0.3
92
+ NODE_INTERVAL_TIME = 1
93
+
87
94
  DRbQS.parse_option(server_argv)
88
95
  case options[:command_type]
89
96
  when /^test/
@@ -91,5 +98,23 @@ when /^test/
91
98
  type = s[0].intern
92
99
  DRbQS.test_server(options, type, s[1..-1], test_opts)
93
100
  else
94
- DRbQS.start_server(options)
101
+ if execute_node_number
102
+ fork do
103
+ DRbQS.start_server(options)
104
+ end
105
+ uri = "druby://:#{options[:port] || DRbQS::ROOT_DEFAULT_PORT}"
106
+ manage = DRbQS::Manage.new
107
+ begin
108
+ sleep(WAIT_SERVER_TIME)
109
+ end while !manage.get_status(uri)
110
+ node_log_file = nil
111
+ unless IO === options[:log_file]
112
+ node_log_file = FileName.create(options[:log_file], :add => :always, :position => :middle, :delimiter => '', :format => "_node_%02d")
113
+ end
114
+ exec_node = DRbQS::ExecuteNode.new(uri, node_log_file, options[:log_level])
115
+ exec_node.execute(execute_node_number, NODE_INTERVAL_TIME)
116
+ exec_node.wait
117
+ else
118
+ DRbQS.start_server(options)
119
+ end
95
120
  end
data/drbqs.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{drbqs}
8
- s.version = "0.0.12"
8
+ s.version = "0.0.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Takayuki YAMAGUCHI"]
12
- s.date = %q{2011-04-09}
12
+ s.date = %q{2011-04-23}
13
13
  s.description = %q{Task queuing system over network that is implemented by dRuby.}
14
14
  s.email = %q{d@ytak.info}
15
15
  s.executables = ["drbqs-manage", "drbqs-node", "drbqs-server"]
@@ -48,6 +48,7 @@ Gem::Specification.new do |s|
48
48
  "lib/drbqs/client.rb",
49
49
  "lib/drbqs/config.rb",
50
50
  "lib/drbqs/connection.rb",
51
+ "lib/drbqs/execute_node.rb",
51
52
  "lib/drbqs/history.rb",
52
53
  "lib/drbqs/manage.rb",
53
54
  "lib/drbqs/message.rb",
@@ -89,7 +90,7 @@ Gem::Specification.new do |s|
89
90
  s.homepage = %q{http://github.com/ytaka/drbqs}
90
91
  s.licenses = ["GPL3"]
91
92
  s.require_paths = ["lib"]
92
- s.rubygems_version = %q{1.7.2}
93
+ s.rubygems_version = %q{1.6.2}
93
94
  s.summary = %q{dRuby Queueing System}
94
95
  s.test_files = [
95
96
  "spec/acl_file_spec.rb",
@@ -124,6 +125,9 @@ Gem::Specification.new do |s|
124
125
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
125
126
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
126
127
  s.add_development_dependency(%q<rcov>, [">= 0"])
128
+ s.add_development_dependency(%q<filename>, [">= 0.0.5"])
129
+ s.add_development_dependency(%q<net-ssh>, [">= 2.1.3"])
130
+ s.add_development_dependency(%q<net-ssh-shell>, [">= 0.1.0"])
127
131
  s.add_runtime_dependency(%q<net-ssh>, [">= 2.1.3"])
128
132
  s.add_runtime_dependency(%q<net-ssh-shell>, [">= 0.1.0"])
129
133
  s.add_runtime_dependency(%q<filename>, [">= 0.0.5"])
@@ -134,6 +138,9 @@ Gem::Specification.new do |s|
134
138
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
135
139
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
136
140
  s.add_dependency(%q<rcov>, [">= 0"])
141
+ s.add_dependency(%q<filename>, [">= 0.0.5"])
142
+ s.add_dependency(%q<net-ssh>, [">= 2.1.3"])
143
+ s.add_dependency(%q<net-ssh-shell>, [">= 0.1.0"])
137
144
  s.add_dependency(%q<net-ssh>, [">= 2.1.3"])
138
145
  s.add_dependency(%q<net-ssh-shell>, [">= 0.1.0"])
139
146
  s.add_dependency(%q<filename>, [">= 0.0.5"])
@@ -145,6 +152,9 @@ Gem::Specification.new do |s|
145
152
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
146
153
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
147
154
  s.add_dependency(%q<rcov>, [">= 0"])
155
+ s.add_dependency(%q<filename>, [">= 0.0.5"])
156
+ s.add_dependency(%q<net-ssh>, [">= 2.1.3"])
157
+ s.add_dependency(%q<net-ssh-shell>, [">= 0.1.0"])
148
158
  s.add_dependency(%q<net-ssh>, [">= 2.1.3"])
149
159
  s.add_dependency(%q<net-ssh-shell>, [">= 0.1.0"])
150
160
  s.add_dependency(%q<filename>, [">= 0.0.5"])
data/lib/drbqs/client.rb CHANGED
@@ -32,8 +32,7 @@ module DRbQS
32
32
  private :transfer_file
33
33
 
34
34
  def execute_task(marshal_obj, method_sym, args)
35
- obj = Marshal.load(marshal_obj)
36
- result = obj.__send__(method_sym, *args)
35
+ result = DRbQS::Task.execute_task(marshal_obj, method_sym, args)
37
36
  transfer_file
38
37
  result
39
38
  end
@@ -58,9 +57,9 @@ module DRbQS
58
57
  end
59
58
  private :dump_not_send_result_to_file
60
59
 
61
- def output_error(err)
60
+ def output_error(err, mes)
62
61
  if @logger
63
- @logger.error("Raise error in calculating thread: #{err.to_s}") { "\n" + err.backtrace.join("\n") }
62
+ @logger.error("#{mes}: #{err.to_s}") { "\n" + err.backtrace.join("\n") }
64
63
  end
65
64
  end
66
65
  private :output_error
@@ -78,12 +77,12 @@ module DRbQS
78
77
  execute_task(*ary)
79
78
  end
80
79
  rescue => err
81
- output_error(err)
80
+ output_error(err, "On finalization")
82
81
  end
83
82
  private :execute_finalization
84
83
 
85
- def send_error(err)
86
- output_error(err)
84
+ def send_error(err, mes)
85
+ output_error(err, mes)
87
86
  @connection.send_node_error("#{err.to_s}\n#{err.backtrace.join("\n")}")
88
87
  end
89
88
  private :send_error
@@ -102,7 +101,7 @@ module DRbQS
102
101
  signal, obj = @signal_queue.pop
103
102
  case signal
104
103
  when :node_error
105
- send_error(obj)
104
+ send_error(obj, "Communicating with server")
106
105
  process_exit
107
106
  end
108
107
  end
@@ -126,7 +125,7 @@ module DRbQS
126
125
  sleep(WAIT_NEW_TASK)
127
126
  end
128
127
  rescue => err
129
- send_error(err)
128
+ send_error(err, "Calculating thread")
130
129
  ensure
131
130
  process_exit
132
131
  end
@@ -0,0 +1,46 @@
1
+ module DRbQS
2
+
3
+ class ExecuteNode
4
+ def initialize(uri, log_prefix, log_level)
5
+ @uri = uri
6
+ @log_level = log_level
7
+ if log_prefix
8
+ @fname = FileName.new(log_prefix, :position => :suffix, :type => :time,
9
+ :add => :always, :directory => :parent,
10
+ :format => lambda { |t| t.strftime("%Y%m%d_%H%M_#{Process.pid}.log") })
11
+ else
12
+ @fname = nil
13
+ end
14
+ @pid = []
15
+ end
16
+
17
+ def get_log_file
18
+ if @fname
19
+ return @fname.create
20
+ end
21
+ return STDOUT
22
+ end
23
+ private :get_log_file
24
+
25
+ def create_process
26
+ @pid << fork do
27
+ client = DRbQS::Client.new(@uri, :log_level => @log_level, :log_file => get_log_file)
28
+ client.connect
29
+ client.calculate
30
+ end
31
+ end
32
+ private :create_process
33
+
34
+ def execute(process_num, interval = 0)
35
+ process_num.times do |i|
36
+ create_process
37
+ sleep(interval) if interval > 0
38
+ end
39
+ end
40
+
41
+ def wait
42
+ Process.waitall
43
+ end
44
+ end
45
+
46
+ end
data/lib/drbqs/server.rb CHANGED
@@ -128,6 +128,11 @@ module DRbQS
128
128
  @task_generator << task_generator
129
129
  end
130
130
 
131
+ def generator_waiting?
132
+ @task_generator.size > 0 && @task_generator[0].waiting?
133
+ end
134
+ private :generator_waiting?
135
+
131
136
  def add_tasks_from_generator
132
137
  if @task_generator.size > 0 && @queue.empty?
133
138
  if tasks = @task_generator[0].new_tasks
@@ -173,8 +178,10 @@ module DRbQS
173
178
  @logger.info("Execute empty queue hook.") if @logger
174
179
  @hook.exec(:empty_queue, self)
175
180
  end
176
- add_tasks_from_generator
177
- if @queue.finished?
181
+ if !generator_waiting? || @queue.finished?
182
+ add_tasks_from_generator
183
+ end
184
+ if !generator_waiting? && @queue.finished?
178
185
  exec_finish_hook
179
186
  end
180
187
  end
data/lib/drbqs/task.rb CHANGED
@@ -33,6 +33,11 @@ module DRbQS
33
33
  @method_sym == other.instance_variable_get(:@method_sym) &&
34
34
  @args == other.instance_variable_get(:@args)
35
35
  end
36
+
37
+ def self.execute_task(marshal_obj, method_sym, args)
38
+ obj = Marshal.load(marshal_obj)
39
+ obj.__send__(method_sym, *args)
40
+ end
36
41
  end
37
42
 
38
43
  class CommandExecute
@@ -73,4 +78,44 @@ module DRbQS
73
78
  super(CommandExecute.new(cmd, {}), :exec, &hook)
74
79
  end
75
80
  end
81
+
82
+ class TaskContainer
83
+ def initialize(task_ary)
84
+ @data = task_ary.map.with_index do |task, i|
85
+ task.drb_args(i)
86
+ end
87
+ end
88
+
89
+ def exec
90
+ @data.map do |ary|
91
+ DRbQS::Task.execute_task(*ary[1..-1])
92
+ end
93
+ end
94
+
95
+ def data
96
+ @data
97
+ end
98
+ protected :data
99
+
100
+ def ==(other)
101
+ other.data.each_with_index.all? do |ary, i|
102
+ ary == @data[i]
103
+ end
104
+ end
105
+ end
106
+
107
+ class TaskSet < Task
108
+ def initialize(task_ary)
109
+ @original_hook = task_ary.map do |task|
110
+ task.hook
111
+ end
112
+ super(DRbQS::TaskContainer.new(task_ary), :exec) do |srv, result|
113
+ result.each_with_index do |res, i|
114
+ if hook = @original_hook[i]
115
+ hook.call(srv, res)
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
76
121
  end
@@ -2,18 +2,11 @@ module DRbQS
2
2
  class DRbQS::TaskCreatingError < StandardError
3
3
  end
4
4
 
5
- class TaskGenerator
6
- def initialize(data = {})
5
+ class TaskSource
6
+ def initialize(data)
7
7
  data.each do |key, val|
8
8
  instance_variable_set("@#{key.to_s}", val)
9
9
  end
10
- @__fiber__ = nil
11
- @__iterate__ = nil
12
- @__fiber_init__ = nil
13
- end
14
-
15
- def have_next?
16
- !!@__fiber__
17
10
  end
18
11
 
19
12
  def add_task(arg)
@@ -28,17 +21,47 @@ module DRbQS
28
21
  end
29
22
 
30
23
  def create_add_task(*args, &block)
31
- Fiber.yield(DRbQS::Task.new(*args, &block))
24
+ add_task(DRbQS::Task.new(*args, &block))
25
+ end
26
+
27
+ def wait_all_tasks
28
+ Fiber.yield(:wait)
29
+ end
30
+ end
31
+
32
+ class TaskGenerator
33
+ def initialize(data = {})
34
+ @source = DRbQS::TaskSource.new(data)
35
+ @fiber = nil
36
+ @iterate = nil
37
+ @task_set = nil
38
+ @fiber_init = nil
39
+ @wait = false
40
+ end
41
+
42
+ def have_next?
43
+ !!@fiber
32
44
  end
33
45
 
34
- def set(iterate = 1, &block)
35
- @__iterate__ = iterate
36
- @__fiber_init__ = lambda do
37
- @__fiber__ = Fiber.new do
46
+ def waiting?
47
+ @wait
48
+ end
49
+
50
+ # The options :generate and :collect are available.
51
+ # opts[:generate] is the number of tasks per one generation.
52
+ # The generator creates a task set from opts[:collect] tasks.
53
+ def set(opts = {}, &block)
54
+ @iterate = opts[:generate] || 1
55
+ @task_set = opts[:collect]
56
+ if @iterate < 1 || (@task_set && @task_set < 1)
57
+ raise ArgumentError, "Invalid option."
58
+ end
59
+ @fiber_init = lambda do
60
+ @fiber = Fiber.new do
38
61
  begin
39
- instance_eval(&block)
62
+ @source.instance_eval(&block)
40
63
  rescue => err
41
- raise DRbQS::TaskCreatingError, "\n #{err.to_s}"
64
+ raise DRbQS::TaskCreatingError, "\n #{err.to_s}\n#{err.backtrace.join("\n")}"
42
65
  end
43
66
  nil
44
67
  end
@@ -46,29 +69,40 @@ module DRbQS
46
69
  end
47
70
 
48
71
  def init
49
- @__fiber_init__.call if @__fiber_init__
72
+ @fiber_init.call if @fiber_init
50
73
  end
51
74
 
52
75
  # Return an array of new tasks.
53
76
  def new_tasks
54
- if @__fiber__
77
+ if @fiber
78
+ @wait = false
55
79
  task_ary = []
56
- @__iterate__.times do |i|
57
- if task_new = @__fiber__.resume
80
+ iteration = @iterate
81
+ iteration *= @task_set if @task_set
82
+ iteration.times do |i|
83
+ if task_new = @fiber.resume
58
84
  case task_new
59
85
  when DRbQS::Task
60
86
  task_ary << task_new
61
87
  when Array
62
88
  task_ary.concat(task_new)
89
+ when :wait
90
+ @wait = true
91
+ break
63
92
  else
64
93
  raise "Invalid type of new task."
65
94
  end
66
95
  else
67
- @__fiber__ = nil
96
+ @fiber = nil
68
97
  break
69
98
  end
70
99
  end
71
100
  if task_ary.size > 0
101
+ if @task_set
102
+ task_ary = task_ary.each_slice(@task_set).map do |ary|
103
+ DRbQS::TaskSet.new(ary)
104
+ end
105
+ end
72
106
  return task_ary
73
107
  end
74
108
  end
data/lib/drbqs.rb CHANGED
@@ -23,9 +23,13 @@ module DRbQS
23
23
  autoload :SSHHost, 'drbqs/ssh/host'
24
24
  autoload :CommandTask, 'drbqs/task'
25
25
  autoload :CommandExecute, 'drbqs/task'
26
+ autoload :TaskSet, 'drbqs/task'
26
27
  autoload :Transfer, 'drbqs/ssh/transfer'
27
28
  autoload :FileTransfer, 'drbqs/ssh/transfer'
28
29
  autoload :Utils, 'drbqs/utils'
30
+ autoload :ExecuteNode, 'drbqs/execute_node'
29
31
 
30
32
  ROOT_DEFAULT_PORT = 13500
33
+
34
+ VERSION = '0.0.13'
31
35
  end
data/spec/message_spec.rb CHANGED
@@ -46,7 +46,7 @@ describe DRbQS::MessageServer do
46
46
 
47
47
  it "should get :exit_server message" do
48
48
  @message.write([:server, :exit_server, 'message_test'])
49
- @message_server.get_message.should == :exit_server
49
+ @message_server.get_message.should == [:exit_server]
50
50
  end
51
51
 
52
52
  it "should send exit message" do
@@ -71,7 +71,7 @@ describe DRbQS::MessageServer do
71
71
 
72
72
  it "should get :request_status message" do
73
73
  @message.write([:server, :request_status, 'message_test'])
74
- @message_server.get_message.should == :request_status
74
+ @message_server.get_message.should == [:request_status]
75
75
  end
76
76
 
77
77
  it "should send status" do
data/spec/queue_spec.rb CHANGED
@@ -38,7 +38,7 @@ describe DRbQS::QueueServer do
38
38
 
39
39
  it "should get result" do
40
40
  @ts[:result].write([:result, @task[:id], @node_id, :result_object])
41
- @queue_server.get_result
41
+ @queue_server.get_result(nil) # The argument should be DRbQS::Server by right.
42
42
  @queue_server.calculating_task_number.should == 0
43
43
  @queue_server.empty?.should be_true
44
44
  @queue_server.finished?.should be_true
@@ -3,20 +3,21 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  require 'drbqs/task_generator'
4
4
 
5
5
  describe DRbQS::TaskGenerator do
6
- def check_task_ary(tasks, num)
6
+ def check_task_ary(tasks, num, cl = DRbQS::Task)
7
7
  tasks.should have(num).items
8
- tasks.all? { |t| DRbQS::Task === t }.should be_true
8
+ tasks.all? { |t| cl === t }.should be_true
9
9
  end
10
10
 
11
11
  subject { DRbQS::TaskGenerator.new(:abc => 'ABC', :def => 123, :data => [1, 2, 3]) }
12
12
 
13
13
  it "should initialize instance varibles" do
14
- subject.instance_variable_get('@abc').should == 'ABC'
15
- subject.instance_variable_get('@def').should == 123
14
+ source = subject.instance_variable_get('@source')
15
+ source.instance_variable_get('@abc').should == 'ABC'
16
+ source.instance_variable_get('@def').should == 123
16
17
  end
17
18
 
18
19
  it "should create new tasks" do
19
- subject.set(2) do
20
+ subject.set(:generate => 2) do
20
21
  @data.each do |i|
21
22
  create_add_task(i, :to_s)
22
23
  end
@@ -27,8 +28,21 @@ describe DRbQS::TaskGenerator do
27
28
  subject.new_tasks.should be_nil
28
29
  end
29
30
 
31
+ it "should should create task sets" do
32
+ subject.set(:generate => 2, :collect => 10) do
33
+ 100.times do |i|
34
+ create_add_task(i, :to_s)
35
+ end
36
+ end
37
+ subject.init
38
+ 5.times do |i|
39
+ check_task_ary(subject.new_tasks, 2, DRbQS::TaskSet)
40
+ end
41
+ subject.new_tasks.should be_nil
42
+ end
43
+
30
44
  it "should debug generator" do
31
- subject.set(2) do
45
+ subject.set(:generate => 2) do
32
46
  @data.each do |i|
33
47
  create_add_task(i, :to_s)
34
48
  end
@@ -38,4 +52,21 @@ describe DRbQS::TaskGenerator do
38
52
  group_number.should == 2
39
53
  task_number.should == 3
40
54
  end
55
+
56
+ it "should wait" do
57
+ subject.set(:generate => 2) do
58
+ @data.each do |i|
59
+ if i == 2
60
+ wait_all_tasks
61
+ end
62
+ create_add_task(i, :to_s)
63
+ end
64
+ end
65
+ subject.init
66
+ subject.waiting?.should be_false
67
+ check_task_ary(subject.new_tasks, 1)
68
+ subject.waiting?.should be_true
69
+ check_task_ary(subject.new_tasks, 2)
70
+ subject.waiting?.should be_false
71
+ end
41
72
  end
data/spec/task_spec.rb CHANGED
@@ -32,3 +32,41 @@ describe DRbQS::CommandExecute do
32
32
  cmd_exec.exec
33
33
  end
34
34
  end
35
+
36
+ describe DRbQS::TaskContainer do
37
+ it "should dump and load" do
38
+ obj = [[1], [1, 2], [1, 2, 3]]
39
+ tasks = obj.map do |ary|
40
+ DRbQS::Task.new(ary, :size)
41
+ end
42
+ container = DRbQS::TaskContainer.new(tasks)
43
+ dump = Marshal.dump(container)
44
+ Marshal.load(dump).should == container
45
+ end
46
+
47
+ it "should execute each task" do
48
+ obj = [[1, 3, 4], [2], [1, 2, 3]]
49
+ tasks = obj.map do |ary|
50
+ DRbQS::Task.new(ary, :size)
51
+ end
52
+ container = DRbQS::TaskContainer.new(tasks)
53
+ container.exec.should == [3, 1, 3]
54
+ end
55
+ end
56
+
57
+ describe DRbQS::TaskSet do
58
+ it "should execute hooks" do
59
+ server = double('server')
60
+ methods_for_hook = double('hook')
61
+ methods_for_hook.should_receive(:m0).exactly(1)
62
+ methods_for_hook.should_receive(:m1).exactly(1)
63
+ methods_for_hook.should_receive(:m2).exactly(1)
64
+ obj = [[1], [1, 2], [1, 2, 3]]
65
+ tasks = []
66
+ tasks << DRbQS::Task.new(obj[0], :size, &methods_for_hook.method(:m0))
67
+ tasks << DRbQS::Task.new(obj[1], :size, &methods_for_hook.method(:m1))
68
+ tasks << DRbQS::Task.new(obj[2], :size, &methods_for_hook.method(:m2))
69
+ task_set = DRbQS::TaskSet.new(tasks)
70
+ task_set.hook.call(server, [1, 2, 3])
71
+ end
72
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: drbqs
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.12
5
+ version: 0.0.13
6
6
  platform: ruby
7
7
  authors:
8
8
  - Takayuki YAMAGUCHI
@@ -10,7 +10,8 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-09 00:00:00 Z
13
+ date: 2011-04-23 00:00:00 +09:00
14
+ default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: rspec
@@ -68,8 +69,41 @@ dependencies:
68
69
  prerelease: false
69
70
  version_requirements: *id005
70
71
  - !ruby/object:Gem::Dependency
71
- name: net-ssh
72
+ name: filename
72
73
  requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 0.0.5
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: net-ssh
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.1.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: net-ssh-shell
95
+ requirement: &id008 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 0.1.0
101
+ type: :development
102
+ prerelease: false
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: net-ssh
106
+ requirement: &id009 !ruby/object:Gem::Requirement
73
107
  none: false
74
108
  requirements:
75
109
  - - ">="
@@ -77,10 +111,10 @@ dependencies:
77
111
  version: 2.1.3
78
112
  type: :runtime
79
113
  prerelease: false
80
- version_requirements: *id006
114
+ version_requirements: *id009
81
115
  - !ruby/object:Gem::Dependency
82
116
  name: net-ssh-shell
83
- requirement: &id007 !ruby/object:Gem::Requirement
117
+ requirement: &id010 !ruby/object:Gem::Requirement
84
118
  none: false
85
119
  requirements:
86
120
  - - ">="
@@ -88,10 +122,10 @@ dependencies:
88
122
  version: 0.1.0
89
123
  type: :runtime
90
124
  prerelease: false
91
- version_requirements: *id007
125
+ version_requirements: *id010
92
126
  - !ruby/object:Gem::Dependency
93
127
  name: filename
94
- requirement: &id008 !ruby/object:Gem::Requirement
128
+ requirement: &id011 !ruby/object:Gem::Requirement
95
129
  none: false
96
130
  requirements:
97
131
  - - ">="
@@ -99,10 +133,10 @@ dependencies:
99
133
  version: 0.0.5
100
134
  type: :runtime
101
135
  prerelease: false
102
- version_requirements: *id008
136
+ version_requirements: *id011
103
137
  - !ruby/object:Gem::Dependency
104
138
  name: rspec
105
- requirement: &id009 !ruby/object:Gem::Requirement
139
+ requirement: &id012 !ruby/object:Gem::Requirement
106
140
  none: false
107
141
  requirements:
108
142
  - - ">="
@@ -110,7 +144,7 @@ dependencies:
110
144
  version: 2.5.0
111
145
  type: :development
112
146
  prerelease: false
113
- version_requirements: *id009
147
+ version_requirements: *id012
114
148
  description: Task queuing system over network that is implemented by dRuby.
115
149
  email: d@ytak.info
116
150
  executables:
@@ -153,6 +187,7 @@ files:
153
187
  - lib/drbqs/client.rb
154
188
  - lib/drbqs/config.rb
155
189
  - lib/drbqs/connection.rb
190
+ - lib/drbqs/execute_node.rb
156
191
  - lib/drbqs/history.rb
157
192
  - lib/drbqs/manage.rb
158
193
  - lib/drbqs/message.rb
@@ -190,6 +225,7 @@ files:
190
225
  - spec/test1_spec.rb
191
226
  - spec/test2_spec.rb
192
227
  - spec/transfer_spec.rb
228
+ has_rdoc: true
193
229
  homepage: http://github.com/ytaka/drbqs
194
230
  licenses:
195
231
  - GPL3
@@ -203,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
239
  requirements:
204
240
  - - ">="
205
241
  - !ruby/object:Gem::Version
206
- hash: 1639087965514593452
242
+ hash: -2841221240559713212
207
243
  segments:
208
244
  - 0
209
245
  version: "0"
@@ -216,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
252
  requirements: []
217
253
 
218
254
  rubyforge_project:
219
- rubygems_version: 1.7.2
255
+ rubygems_version: 1.6.2
220
256
  signing_key:
221
257
  specification_version: 3
222
258
  summary: dRuby Queueing System