drbqs 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d97c7024904ace9423e4447cf220ee2c2b6a5b32
4
- data.tar.gz: e2ea40c666d2033eebe43659f833ea032f05a720
3
+ metadata.gz: cda668d2f4eb4adb76ec3bfa7a86f9259f6648ca
4
+ data.tar.gz: c292472af4ff45420dc7458cf9fd221cb91a3e20
5
5
  SHA512:
6
- metadata.gz: 6cb2dfd423583c9426ce5138144dd46a37455c62208164c3ef26425578f991ce8e9e69998897170fb00e2cd13147846a89135d8a8048d6e7d48c413bd2944445
7
- data.tar.gz: 069f933a4cdc05074e70e9a4081fe33e289a6f7959c9e9949f34f5e229bd4e968acb6ed9f594c4dc394923ee738eb79f033fe70231aa21a72abccff4f3492e9d
6
+ metadata.gz: 6b739f04e4e4f954b6bfe4de3f843787f1a2067c1201e52901d65f9076e0edd2e7b461ddcee5eb72087a7b84c4f52a5f2a7a19cfe5384483a209f6986aea69a1
7
+ data.tar.gz: a8fded1572bbc275f4db48ebe1577c07fdcc0e102fa55ef8e6b3cbf58799f18d9c2efff6ebfa9c0910ef837b8c3a28ceffe94bc759202514a5aead8e6eba99d1
@@ -2,30 +2,29 @@
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
  require "drbqs/version"
4
4
 
5
- Gem::Specification.new do |s|
6
- s.name = "drbqs"
7
- s.version = DRbQS::VERSION
8
- s.authors = ["Takayuki YAMAGUCHI"]
9
- s.email = ["d@ytak.info"]
10
- s.homepage = ""
11
- s.summary = "dRuby Queueing System"
12
- s.description = "Task queuing system over network that is implemented by dRuby."
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "drbqs"
7
+ spec.version = DRbQS::VERSION
8
+ spec.authors = ["Takayuki YAMAGUCHI"]
9
+ spec.email = ["d@ytak.info"]
10
+ spec.homepage = ""
11
+ spec.summary = "dRuby Queueing System"
12
+ spec.description = "Task queuing system over network that is implemented by dRuby."
13
+ spec.license = "GPLv3"
13
14
 
14
- s.rubyforge_project = "drbqs"
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ["lib"]
15
+ spec.files = `git ls-files`.split("\n")
16
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
20
19
 
21
20
  # specify any dependencies here; for example:
22
- s.add_development_dependency "rspec", ">= 2.14.1"
23
- s.add_development_dependency "yard", ">= 0.7.2"
24
- s.add_runtime_dependency 'filename', '>= 0.1.0'
25
- s.add_runtime_dependency "user_config", ">= 0.0.2"
26
- s.add_runtime_dependency 'net-ssh', '>= 2.1.0'
27
- s.add_runtime_dependency 'net-ssh-shell', '>= 0.2.0'
28
- s.add_runtime_dependency "net-sftp", ">= 2.0.5"
29
- s.add_runtime_dependency "sys-proctable"
30
- s.add_runtime_dependency "activesupport"
21
+ spec.add_development_dependency "rspec", ">= 2.14.1"
22
+ spec.add_development_dependency "yard", ">= 0.7.2"
23
+ spec.add_runtime_dependency 'filename', '>= 0.1.0'
24
+ spec.add_runtime_dependency "user_config", ">= 0.0.2"
25
+ spec.add_runtime_dependency 'net-ssh', '>= 2.1.0'
26
+ spec.add_runtime_dependency 'net-ssh-shell', '>= 0.2.0'
27
+ spec.add_runtime_dependency "net-sftp", ">= 2.0.5"
28
+ spec.add_runtime_dependency "sys-proctable"
29
+ spec.add_runtime_dependency "activesupport"
31
30
  end
@@ -14,6 +14,7 @@ require 'drbqs/execute/server_define'
14
14
  require 'drbqs/utility/misc'
15
15
 
16
16
  require 'active_support/core_ext/hash/keys'
17
+ require 'active_support/core_ext/hash/slice'
17
18
  require 'active_support/core_ext/array/extract_options'
18
19
 
19
20
  module DRbQS
@@ -28,6 +28,7 @@ HELP
28
28
  set(:rvm_init, '--rvm-init PATH', String, 'Path of script to initialize RVM over ssh.')
29
29
  set(:output, '-o DIR', '--output DIR', String, 'Directory path that a server and nodes output.')
30
30
  set(:nice, '--nice NUM', Integer, 'Set the value of nice for a server and nodes. The default is 10.')
31
+ set(:bundler, '--bundler', 'Use bundler to execute filename-create, drbqs-server, and drbqs-node.')
31
32
  end
32
33
  setting.set_argument(*args)
33
34
  case setting.get_argument[0]
@@ -57,20 +57,22 @@ module DRbQS
57
57
  config.save_sample
58
58
  end
59
59
 
60
- [:get_status, :get_history, :send_exit_signal, :send_node_exit_after_task,
60
+ [:get_status, :get_response, :get_history, :send_exit_signal, :send_node_exit_after_task,
61
61
  :send_node_wake, :send_node_sleep, :send_data].each do |method_name|
62
62
  def_delegator :signal_sender, method_name, method_name
63
63
  end
64
64
 
65
65
  def server_respond?
66
+ ret = nil
66
67
  begin
67
- get_status
68
- true
68
+ if get_response
69
+ ret = true
70
+ end
69
71
  rescue DRbQS::Manage::NotSetURI
70
72
  raise
71
73
  rescue
72
- nil
73
74
  end
75
+ ret
74
76
  end
75
77
 
76
78
  # If the server responds, this method returns true.
@@ -67,6 +67,14 @@ module DRbQS
67
67
  end
68
68
  nil
69
69
  end
70
+
71
+ def get_response
72
+ send_signal_to_server(:request_response, [sender_id, Time.now])
73
+ if mes = wait_response([:response, sender_id, nil])
74
+ return true
75
+ end
76
+ nil
77
+ end
70
78
  end
71
79
  end
72
80
  end
@@ -3,10 +3,27 @@ require 'drbqs/manage/ssh_shell'
3
3
  module DRbQS
4
4
  class Manage
5
5
  class SSHExecute
6
+ COMMAND_NICE = "nice"
7
+ COMMAND_DRBQS_SERVER = "drbqs-server"
8
+ COMMAND_DRBQS_NODE = "drbqs-node"
9
+ COMMAND_FILENAME_CREATE = "filename-create"
10
+
11
+ # @param [String] dest Destination name
12
+ # @param [Hash] opts Option hash
13
+ # @option opts [boolean] :bundler Use bundler to execute commands: filename-create, drbqs-server, and drbqs-node
14
+ # @option opts [String] :shell Same as options DRbQS::Manage::SSHShell
15
+ # @option opts [String] :keys Same as options DRbQS::Manage::SSHShell
16
+ # @option opts [IO] :io Same as options DRbQS::Manage::SSHShell
17
+ # @option opts [String] :directory Same as options DRbQS::Manage::SSHShell
18
+ # @option opts [String] :rvm Same as options DRbQS::Manage::SSHShell
19
+ # @option opts [String] :rvm_init Same as options DRbQS::Manage::SSHShell
20
+ # @option opts [Hash] :env Same as options DRbQS::Manage::SSHShell
6
21
  def initialize(dest, opts = {})
7
22
  @ssh_host = DRbQS::Config.new.ssh_host
23
+ opts = opts.dup
8
24
  path, options = @ssh_host.get_options(dest)
9
25
  dest = options.delete(:dest) || dest
26
+ @bundler = opts.delete(:bundler)
10
27
  @ssh_shell = DRbQS::Manage::SSHShell.new(dest, options.merge(opts))
11
28
  end
12
29
 
@@ -18,20 +35,28 @@ module DRbQS
18
35
  @ssh_shell.get_environment
19
36
  end
20
37
 
38
+ # Add "bundle exec" if \@bundler is true
39
+ def command_ruby(cmd)
40
+ if @bundler
41
+ cmd = "bundle exec #{cmd}"
42
+ end
43
+ cmd
44
+ end
45
+ private :command_ruby
46
+
21
47
  # Keys are :nice and :daemon.
22
48
  def add_command_options(cmd, daemon, nice)
49
+ s = ''
23
50
  if nice
24
- s = "nice "
51
+ s << "nice "
25
52
  s << "-n #{nice.to_s} " if Integer === nice
26
- else
27
- s = ''
28
53
  end
29
54
  s << cmd << " --daemon " << daemon
30
55
  end
31
56
  private :add_command_options
32
57
 
33
58
  def create_new_directory(sh, dir)
34
- process, result = sh.exec("filename-create new -a always -D self -t time #{dir}", :check => true)
59
+ process, result = sh.exec("#{command_ruby(COMMAND_FILENAME_CREATE)} new -a always -D self -t time #{dir}", :check => true)
35
60
  result.strip!
36
61
  end
37
62
  private :create_new_directory
@@ -41,7 +66,7 @@ module DRbQS
41
66
  ret = nil
42
67
  @ssh_shell.start do |sh|
43
68
  dir = create_new_directory(sh, opts[:daemon] || 'drbqs_server_log')
44
- cmd = add_command_options('drbqs-server', File.join(dir, 'daemon_server.log'), opts[:nice])
69
+ cmd = add_command_options(command_ruby(COMMAND_DRBQS_SERVER), File.join(dir, 'daemon_server.log'), opts[:nice])
45
70
  cmd << " --log-file " << File.join(dir, 'server.log') << ' '
46
71
  cmd << cmd_options.join(' ')
47
72
  process, result = sh.exec(cmd)
@@ -55,7 +80,7 @@ module DRbQS
55
80
  ret = nil
56
81
  @ssh_shell.start do |sh|
57
82
  dir = create_new_directory(sh, opts[:daemon] || 'drbqs_node_log')
58
- cmd = add_command_options('drbqs-node', File.join(dir, 'daemon_node.log'), opts[:nice])
83
+ cmd = add_command_options(command_ruby(COMMAND_DRBQS_NODE), File.join(dir, 'daemon_node.log'), opts[:nice])
59
84
  cmd << ' --log-prefix ' << File.join(dir, 'node') << ' ' << cmd_options.join(' ')
60
85
  process, result = sh.exec(cmd)
61
86
  ret = (process.exit_status == 0)
@@ -63,19 +63,20 @@ module DRbQS
63
63
  # @option opts [String] :shell The shell to use.
64
64
  # @option opts [String] :keys Path of a ssh key.
65
65
  # @option opts [IO] :io IO to output results of commands.
66
- # @option opts [Hash] :env Same as options DRbQS::Manage::SSHShell::RubyEnvironment.
67
66
  # @option opts [String] :directory Same as options DRbQS::Manage::SSHShell::RubyEnvironment.
68
67
  # @option opts [String] :rvm Same as options DRbQS::Manage::SSHShell::RubyEnvironment.
69
68
  # @option opts [String] :rvm_init Same as options DRbQS::Manage::SSHShell::RubyEnvironment.
69
+ # @option opts [Hash] :env Same as options DRbQS::Manage::SSHShell::RubyEnvironment.
70
70
  def initialize(dest, opts = {})
71
71
  @user, @host, @port = split_destination(dest)
72
72
  if !(@host && @user)
73
73
  raise ArgumentError, "Invalid ssh server: host=#{@host.inspect}, user=#{@user.inspect}."
74
74
  end
75
+ opts = opts.dup
75
76
  @keys = opts.delete(:keys)
76
77
  @shell = opts.delete(:shell) || DEFAULT_SHELL
77
- @ruby_environment = DRbQS::Manage::SSHShell::RubyEnvironment.new(opts)
78
- @out = opts[:io]
78
+ @out = opts.delete(:io)
79
+ @ruby_environment = DRbQS::Manage::SSHShell::RubyEnvironment.new(opts.slice(:directory, :rvm, :rvm_init, :env))
79
80
  @ssh = nil
80
81
  end
81
82
 
@@ -49,6 +49,9 @@ module DRbQS
49
49
  return [mes, arg]
50
50
  when :request_status
51
51
  @logger.info("Get status request from #{arg.to_s}")
52
+ when :request_response
53
+ @logger.info("Get respond request from #{arg[0].to_s} at #{arg[1].to_s}")
54
+ return [mes, arg]
52
55
  when :request_history
53
56
  @logger.info("Get history request from #{arg.to_s}")
54
57
  when :sleep_node
@@ -130,6 +133,14 @@ module DRbQS
130
133
  @message.write([:status, server_status_string])
131
134
  end
132
135
 
136
+ def send_only_response(sender_id, request_time)
137
+ begin
138
+ @message.take([:response, sender_id, nil], 0)
139
+ rescue Rinda::RequestExpiredError
140
+ end
141
+ @message.write([:response, sender_id, request_time])
142
+ end
143
+
133
144
  def send_history(history_string)
134
145
  begin
135
146
  @message.take([:history, nil], 0)
@@ -374,6 +374,8 @@ module DRbQS
374
374
  self.exit
375
375
  when :request_status
376
376
  send_status_for_request
377
+ when :request_response
378
+ @message.send_only_response(arg[0], arg[1])
377
379
  when :request_history
378
380
  @message.send_history(@queue.all_logs)
379
381
  when :exit_after_task
@@ -10,6 +10,7 @@ module DRbQS
10
10
  [:directory, :shell, :rvm, :rvm_init, :output, :connect].each do |key|
11
11
  register_key(key, :check => 1)
12
12
  end
13
+ register_key(:bundler, :bool => true)
13
14
  register_key(:nice, :check => 1, :default => [10])
14
15
  set_argument_condition(:>=, 0)
15
16
  end
@@ -66,7 +67,7 @@ module DRbQS
66
67
  # this method raises an error.
67
68
  def parse!
68
69
  super
69
- [:directory, :shell, :rvm, :rvm_init, :nice].each do |key|
70
+ [:directory, :shell, :rvm, :rvm_init, :nice, :bundler].each do |key|
70
71
  if val = get_first(key)
71
72
  @options[key] = val
72
73
  end
@@ -1,3 +1,3 @@
1
1
  module DRbQS
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -44,4 +44,13 @@ describe DRbQS::Manage::SendSignal do
44
44
  @ts.take([:server, :new_data, data], 0)
45
45
  end.should_not raise_error
46
46
  end
47
+
48
+ it "should send request of response." do
49
+ t = Time.now
50
+ Time.should_receive(:now).and_return(t)
51
+ sender_id = @send_signal.sender_id
52
+ @ts.should_receive(:write).with([:server, :request_response, [sender_id, t]])
53
+ @ts.should_receive(:take).once.and_return([:response, [sender_id, t]])
54
+ @send_signal.get_response
55
+ end
47
56
  end
@@ -62,6 +62,13 @@ describe DRbQS::Server::Message do
62
62
  @message_server.get_message.should == [:request_status]
63
63
  end
64
64
 
65
+ it "should get :request_response message" do
66
+ t = Time.now
67
+ sender_id = "sender_id"
68
+ @message.write([:server, :request_response, [sender_id, t]])
69
+ @message_server.get_message.should == [:request_response, [sender_id, t]]
70
+ end
71
+
65
72
  it "should get :node_error message" do
66
73
  node_id = 74
67
74
  @message.write([:server, :node_error, [node_id, 'Error occurs.']])
@@ -115,6 +122,16 @@ describe DRbQS::Server::Message do
115
122
  status.should be_an_instance_of String
116
123
  end
117
124
 
125
+ it "should send only response" do
126
+ sender_id = "sender_id"
127
+ t = Time.now
128
+ @message_server.send_only_response(sender_id, t)
129
+ sym, sender_id2, t2 = @message.take([:response, sender_id, nil])
130
+ sym.should == :response
131
+ sender_id2.should == sender_id
132
+ t2.should == t
133
+ end
134
+
118
135
  after(:all) do
119
136
  clear_all_node
120
137
  end
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drbqs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takayuki YAMAGUCHI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-08 00:00:00.000000000 Z
11
+ date: 2013-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.14.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.14.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: yard
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.7.2
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.7.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: filename
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: user_config
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.0.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.0.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: net-ssh
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.1.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.1.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: net-ssh-shell
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.2.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.2.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: net-sftp
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: 2.0.5
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: 2.0.5
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sys-proctable
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: activesupport
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: Task queuing system over network that is implemented by dRuby.
@@ -148,9 +148,9 @@ executables:
148
148
  extensions: []
149
149
  extra_rdoc_files: []
150
150
  files:
151
- - .gitignore
152
- - .rspec
153
- - .yardopts
151
+ - ".gitignore"
152
+ - ".rspec"
153
+ - ".yardopts"
154
154
  - Gemfile
155
155
  - LICENSE.txt
156
156
  - README.md
@@ -323,7 +323,8 @@ files:
323
323
  - spec/worker/worker_process_set_spec.rb
324
324
  - spec/worker/worker_spec.rb
325
325
  homepage: ''
326
- licenses: []
326
+ licenses:
327
+ - GPLv3
327
328
  metadata: {}
328
329
  post_install_message:
329
330
  rdoc_options: []
@@ -331,16 +332,16 @@ require_paths:
331
332
  - lib
332
333
  required_ruby_version: !ruby/object:Gem::Requirement
333
334
  requirements:
334
- - - '>='
335
+ - - ">="
335
336
  - !ruby/object:Gem::Version
336
337
  version: '0'
337
338
  required_rubygems_version: !ruby/object:Gem::Requirement
338
339
  requirements:
339
- - - '>='
340
+ - - ">="
340
341
  - !ruby/object:Gem::Version
341
342
  version: '0'
342
343
  requirements: []
343
- rubyforge_project: drbqs
344
+ rubyforge_project:
344
345
  rubygems_version: 2.0.3
345
346
  signing_key:
346
347
  specification_version: 4