drbqs 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/drbqs-execute +6 -0
- data/bin/drbqs-manage +2 -2
- data/bin/drbqs-node +2 -2
- data/bin/drbqs-server +2 -2
- data/bin/drbqs-ssh +2 -2
- data/drbqs.gemspec +53 -16
- data/example/error_server/error.rb +6 -0
- data/example/error_server/server_def.rb +7 -0
- data/example/{error → error_task}/error.rb +0 -0
- data/example/{error → error_task}/server_def.rb +0 -0
- data/example/sum2/execute_def.rb +27 -0
- data/lib/drbqs/command_line/argument.rb +29 -0
- data/lib/drbqs/command_line/command_base.rb +81 -0
- data/lib/drbqs/command_line/command_execute.rb +33 -0
- data/lib/drbqs/command_line/command_line.rb +19 -0
- data/lib/drbqs/command_line/command_manage.rb +34 -0
- data/lib/drbqs/command_line/command_node.rb +26 -0
- data/lib/drbqs/command_line/command_server.rb +41 -0
- data/lib/drbqs/command_line/command_ssh.rb +51 -0
- data/lib/drbqs/command_line/option_setting.rb +42 -0
- data/lib/drbqs/execute/process_define.rb +213 -0
- data/lib/drbqs/execute/register.rb +147 -0
- data/lib/drbqs/{utility → execute}/server_define.rb +7 -14
- data/lib/drbqs/manage/execute_node.rb +4 -2
- data/lib/drbqs/manage/manage.rb +23 -16
- data/lib/drbqs/manage/send_signal.rb +31 -4
- data/lib/drbqs/manage/ssh_execute.rb +50 -6
- data/lib/drbqs/manage/ssh_shell.rb +95 -50
- data/lib/drbqs/node/connection.rb +1 -1
- data/lib/drbqs/node/node.rb +67 -17
- data/lib/drbqs/node/state.rb +109 -0
- data/lib/drbqs/node/task_client.rb +7 -7
- data/lib/drbqs/server/history.rb +16 -0
- data/lib/drbqs/server/message.rb +80 -15
- data/lib/drbqs/server/node_list.rb +16 -3
- data/lib/drbqs/server/prof.rb +48 -0
- data/lib/drbqs/server/queue.rb +20 -2
- data/lib/drbqs/server/server.rb +112 -70
- data/lib/drbqs/server/server_hook.rb +26 -6
- data/lib/drbqs/server/test/node.rb +34 -0
- data/lib/drbqs/server/test/server.rb +74 -0
- data/lib/drbqs/setting/base.rb +120 -0
- data/lib/drbqs/setting/data_container.rb +39 -0
- data/lib/drbqs/setting/execute.rb +71 -0
- data/lib/drbqs/setting/manage.rb +163 -0
- data/lib/drbqs/setting/node.rb +84 -0
- data/lib/drbqs/setting/server.rb +230 -0
- data/lib/drbqs/setting/setting.rb +14 -0
- data/lib/drbqs/setting/source.rb +220 -0
- data/lib/drbqs/setting/ssh.rb +165 -0
- data/lib/drbqs/task/task_generator.rb +4 -2
- data/lib/drbqs/utility/misc.rb +15 -1
- data/lib/drbqs/utility/temporary.rb +4 -2
- data/lib/drbqs.rb +3 -2
- data/spec/command_line/command_base_spec.rb +47 -0
- data/spec/{utility/command_line → command_line}/commands_spec.rb +3 -3
- data/spec/command_line/option_setting_spec.rb +29 -0
- data/spec/execute/def/execute1.rb +24 -0
- data/spec/execute/def/no_def.rb +2 -0
- data/spec/execute/process_define_spec.rb +167 -0
- data/spec/execute/register_spec.rb +77 -0
- data/spec/{utility → execute}/server_define_spec.rb +0 -0
- data/spec/integration_test/01_basic_usage_spec.rb +1 -1
- data/spec/integration_test/02_use_generator_spec.rb +1 -1
- data/spec/integration_test/03_use_temporary_file_spec.rb +1 -1
- data/spec/integration_test/04_use_unix_domain_spec.rb +1 -1
- data/spec/integration_test/05_server_exit_signal_spec.rb +1 -1
- data/spec/integration_test/06_node_exit_after_task_spec.rb +1 -1
- data/spec/integration_test/07_command_server_with_node_spec.rb +19 -16
- data/spec/integration_test/08_shutdown_unused_nodes_spec.rb +38 -0
- data/spec/integration_test/09_server_process_data_spec.rb +74 -0
- data/spec/integration_test/10_test_server_spec.rb +18 -0
- data/spec/integration_test/definition/task_obj_definition.rb +14 -0
- data/spec/manage/send_signal_spec.rb +8 -0
- data/spec/manage/ssh_shell_spec.rb +1 -1
- data/spec/node/state_spec.rb +148 -0
- data/spec/node/task_client_spec.rb +15 -0
- data/spec/server/history_spec.rb +51 -20
- data/spec/server/message_spec.rb +7 -2
- data/spec/server/node_list_spec.rb +1 -1
- data/spec/server/queue_spec.rb +93 -4
- data/spec/server/server_hook_spec.rb +62 -0
- data/spec/setting/base_spec.rb +35 -0
- data/spec/setting/data_container_spec.rb +92 -0
- data/spec/setting/execute_spec.rb +51 -0
- data/spec/setting/manage_spec.rb +63 -0
- data/spec/setting/node_spec.rb +43 -0
- data/spec/setting/server_spec.rb +46 -0
- data/spec/setting/source_spec.rb +245 -0
- data/spec/spec_helper.rb +17 -10
- data/spec/utility/argument_spec.rb +7 -7
- metadata +179 -146
- data/lib/drbqs/utility/argument.rb +0 -27
- data/lib/drbqs/utility/command_line/command_base.rb +0 -27
- data/lib/drbqs/utility/command_line/command_manage.rb +0 -121
- data/lib/drbqs/utility/command_line/command_node.rb +0 -103
- data/lib/drbqs/utility/command_line/command_server.rb +0 -165
- data/lib/drbqs/utility/command_line/command_ssh.rb +0 -126
- data/lib/drbqs/utility/command_line.rb +0 -15
- data/spec/utility/command_line/command_base_spec.rb +0 -33
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.15
|
data/bin/drbqs-execute
ADDED
data/bin/drbqs-manage
CHANGED
data/bin/drbqs-node
CHANGED
data/bin/drbqs-server
CHANGED
data/bin/drbqs-ssh
CHANGED
data/drbqs.gemspec
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{drbqs}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.15"
|
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-07-
|
12
|
+
s.date = %q{2011-07-29}
|
13
13
|
s.description = %q{Task queuing system over network that is implemented by dRuby.}
|
14
14
|
s.email = %q{d@ytak.info}
|
15
|
-
s.executables = ["drbqs-manage", "drbqs-node", "drbqs-server", "drbqs-ssh"]
|
15
|
+
s.executables = ["drbqs-execute", "drbqs-manage", "drbqs-node", "drbqs-server", "drbqs-ssh"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE.txt",
|
18
18
|
"README.md"
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"README.md",
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
|
+
"bin/drbqs-execute",
|
28
29
|
"bin/drbqs-manage",
|
29
30
|
"bin/drbqs-node",
|
30
31
|
"bin/drbqs-server",
|
@@ -32,19 +33,34 @@ Gem::Specification.new do |s|
|
|
32
33
|
"drbqs.gemspec",
|
33
34
|
"example/README.md",
|
34
35
|
"example/command/server_def.rb",
|
35
|
-
"example/
|
36
|
-
"example/
|
36
|
+
"example/error_server/error.rb",
|
37
|
+
"example/error_server/server_def.rb",
|
38
|
+
"example/error_task/error.rb",
|
39
|
+
"example/error_task/server_def.rb",
|
37
40
|
"example/server/server.rb",
|
38
41
|
"example/sum/server_def.rb",
|
39
42
|
"example/sum/sum.rb",
|
43
|
+
"example/sum2/execute_def.rb",
|
40
44
|
"example/sum2/server_def.rb",
|
41
45
|
"example/sum2/sum.rb",
|
42
46
|
"example/transfer/file.rb",
|
43
47
|
"example/transfer/server_def.rb",
|
44
48
|
"lib/drbqs.rb",
|
49
|
+
"lib/drbqs/command_line/argument.rb",
|
50
|
+
"lib/drbqs/command_line/command_base.rb",
|
51
|
+
"lib/drbqs/command_line/command_execute.rb",
|
52
|
+
"lib/drbqs/command_line/command_line.rb",
|
53
|
+
"lib/drbqs/command_line/command_manage.rb",
|
54
|
+
"lib/drbqs/command_line/command_node.rb",
|
55
|
+
"lib/drbqs/command_line/command_server.rb",
|
56
|
+
"lib/drbqs/command_line/command_ssh.rb",
|
57
|
+
"lib/drbqs/command_line/option_setting.rb",
|
45
58
|
"lib/drbqs/config/config.rb",
|
46
59
|
"lib/drbqs/config/process_list.rb",
|
47
60
|
"lib/drbqs/config/ssh_host.rb",
|
61
|
+
"lib/drbqs/execute/process_define.rb",
|
62
|
+
"lib/drbqs/execute/register.rb",
|
63
|
+
"lib/drbqs/execute/server_define.rb",
|
48
64
|
"lib/drbqs/manage/execute_node.rb",
|
49
65
|
"lib/drbqs/manage/manage.rb",
|
50
66
|
"lib/drbqs/manage/send_signal.rb",
|
@@ -52,34 +68,47 @@ Gem::Specification.new do |s|
|
|
52
68
|
"lib/drbqs/manage/ssh_shell.rb",
|
53
69
|
"lib/drbqs/node/connection.rb",
|
54
70
|
"lib/drbqs/node/node.rb",
|
71
|
+
"lib/drbqs/node/state.rb",
|
55
72
|
"lib/drbqs/node/task_client.rb",
|
56
73
|
"lib/drbqs/server/acl_file.rb",
|
57
74
|
"lib/drbqs/server/check_alive.rb",
|
58
75
|
"lib/drbqs/server/history.rb",
|
59
76
|
"lib/drbqs/server/message.rb",
|
60
77
|
"lib/drbqs/server/node_list.rb",
|
78
|
+
"lib/drbqs/server/prof.rb",
|
61
79
|
"lib/drbqs/server/queue.rb",
|
62
80
|
"lib/drbqs/server/server.rb",
|
63
81
|
"lib/drbqs/server/server_hook.rb",
|
82
|
+
"lib/drbqs/server/test/node.rb",
|
83
|
+
"lib/drbqs/server/test/server.rb",
|
64
84
|
"lib/drbqs/server/transfer_setting.rb",
|
85
|
+
"lib/drbqs/setting/base.rb",
|
86
|
+
"lib/drbqs/setting/data_container.rb",
|
87
|
+
"lib/drbqs/setting/execute.rb",
|
88
|
+
"lib/drbqs/setting/manage.rb",
|
89
|
+
"lib/drbqs/setting/node.rb",
|
90
|
+
"lib/drbqs/setting/server.rb",
|
91
|
+
"lib/drbqs/setting/setting.rb",
|
92
|
+
"lib/drbqs/setting/source.rb",
|
93
|
+
"lib/drbqs/setting/ssh.rb",
|
65
94
|
"lib/drbqs/task/command_task.rb",
|
66
95
|
"lib/drbqs/task/task.rb",
|
67
96
|
"lib/drbqs/task/task_generator.rb",
|
68
|
-
"lib/drbqs/utility/argument.rb",
|
69
|
-
"lib/drbqs/utility/command_line.rb",
|
70
|
-
"lib/drbqs/utility/command_line/command_base.rb",
|
71
|
-
"lib/drbqs/utility/command_line/command_manage.rb",
|
72
|
-
"lib/drbqs/utility/command_line/command_node.rb",
|
73
|
-
"lib/drbqs/utility/command_line/command_server.rb",
|
74
|
-
"lib/drbqs/utility/command_line/command_ssh.rb",
|
75
97
|
"lib/drbqs/utility/misc.rb",
|
76
|
-
"lib/drbqs/utility/server_define.rb",
|
77
98
|
"lib/drbqs/utility/temporary.rb",
|
78
99
|
"lib/drbqs/utility/transfer/file_transfer.rb",
|
79
100
|
"lib/drbqs/utility/transfer/transfer_client.rb",
|
101
|
+
"spec/command_line/command_base_spec.rb",
|
102
|
+
"spec/command_line/commands_spec.rb",
|
103
|
+
"spec/command_line/option_setting_spec.rb",
|
80
104
|
"spec/config/config_spec.rb",
|
81
105
|
"spec/config/process_list_spec.rb",
|
82
106
|
"spec/config/ssh_host_spec.rb",
|
107
|
+
"spec/execute/def/execute1.rb",
|
108
|
+
"spec/execute/def/no_def.rb",
|
109
|
+
"spec/execute/process_define_spec.rb",
|
110
|
+
"spec/execute/register_spec.rb",
|
111
|
+
"spec/execute/server_define_spec.rb",
|
83
112
|
"spec/integration_test/01_basic_usage_spec.rb",
|
84
113
|
"spec/integration_test/02_use_generator_spec.rb",
|
85
114
|
"spec/integration_test/03_use_temporary_file_spec.rb",
|
@@ -87,6 +116,9 @@ Gem::Specification.new do |s|
|
|
87
116
|
"spec/integration_test/05_server_exit_signal_spec.rb",
|
88
117
|
"spec/integration_test/06_node_exit_after_task_spec.rb",
|
89
118
|
"spec/integration_test/07_command_server_with_node_spec.rb",
|
119
|
+
"spec/integration_test/08_shutdown_unused_nodes_spec.rb",
|
120
|
+
"spec/integration_test/09_server_process_data_spec.rb",
|
121
|
+
"spec/integration_test/10_test_server_spec.rb",
|
90
122
|
"spec/integration_test/definition/server01.rb",
|
91
123
|
"spec/integration_test/definition/server02.rb",
|
92
124
|
"spec/integration_test/definition/task_obj_definition.rb",
|
@@ -94,6 +126,7 @@ Gem::Specification.new do |s|
|
|
94
126
|
"spec/manage/send_signal_spec.rb",
|
95
127
|
"spec/manage/ssh_shell_spec.rb",
|
96
128
|
"spec/node/connection_spec.rb",
|
129
|
+
"spec/node/state_spec.rb",
|
97
130
|
"spec/node/task_client_spec.rb",
|
98
131
|
"spec/server/acl_file_spec.rb",
|
99
132
|
"spec/server/check_alive_spec.rb",
|
@@ -105,15 +138,19 @@ Gem::Specification.new do |s|
|
|
105
138
|
"spec/server/server_hook_spec.rb",
|
106
139
|
"spec/server/server_spec.rb",
|
107
140
|
"spec/server/transfer_setting_spec.rb",
|
141
|
+
"spec/setting/base_spec.rb",
|
142
|
+
"spec/setting/data_container_spec.rb",
|
143
|
+
"spec/setting/execute_spec.rb",
|
144
|
+
"spec/setting/manage_spec.rb",
|
145
|
+
"spec/setting/node_spec.rb",
|
146
|
+
"spec/setting/server_spec.rb",
|
147
|
+
"spec/setting/source_spec.rb",
|
108
148
|
"spec/spec_helper.rb",
|
109
149
|
"spec/task/file_transfer_spec.rb",
|
110
150
|
"spec/task/task_generator_spec.rb",
|
111
151
|
"spec/task/task_spec.rb",
|
112
152
|
"spec/utility/argument_spec.rb",
|
113
|
-
"spec/utility/command_line/command_base_spec.rb",
|
114
|
-
"spec/utility/command_line/commands_spec.rb",
|
115
153
|
"spec/utility/misc_spec.rb",
|
116
|
-
"spec/utility/server_define_spec.rb",
|
117
154
|
"spec/utility/temporary_spec.rb"
|
118
155
|
]
|
119
156
|
s.homepage = %q{http://github.com/ytaka/drbqs}
|
File without changes
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
default :server => :server_local, :port => 13789, :log => '/tmp/drbqs_execute'
|
2
|
+
|
3
|
+
usage :message => "Calculate sum of numbers", :server => File.join(File.dirname(__FILE__), 'server_def.rb')
|
4
|
+
|
5
|
+
register_server :server_local, "localhost" do |server|
|
6
|
+
server.load File.expand_path(File.join(File.dirname(__FILE__), 'server_def.rb'))
|
7
|
+
end
|
8
|
+
|
9
|
+
register_server :server_ssh, "localhost" do |server, ssh|
|
10
|
+
ssh.connect 'localhost'
|
11
|
+
ssh.directory File.expand_path(File.dirname(__FILE__))
|
12
|
+
ssh.output "/tmp/drbqs_ssh/server"
|
13
|
+
server.load 'server_def.rb'
|
14
|
+
end
|
15
|
+
|
16
|
+
register_node :node_local do |node|
|
17
|
+
node.load File.expand_path(File.join(File.dirname(__FILE__), 'sum.rb'))
|
18
|
+
node.process 2
|
19
|
+
end
|
20
|
+
|
21
|
+
register_node :node_ssh do |node, ssh|
|
22
|
+
ssh.connect 'localhost'
|
23
|
+
ssh.directory File.expand_path(File.dirname(__FILE__))
|
24
|
+
ssh.output "/tmp/drbqs_ssh/node"
|
25
|
+
node.load 'sum.rb'
|
26
|
+
node.process 2
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module DRbQS
|
2
|
+
class Command
|
3
|
+
module Argument
|
4
|
+
def split_arguments(argv, split = '--')
|
5
|
+
if n = argv.index(split)
|
6
|
+
[argv[0..(n - 1)], argv[(n + 1)..-1]]
|
7
|
+
else
|
8
|
+
[argv, []]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
module_function :split_arguments
|
12
|
+
|
13
|
+
def check_argument_size(argv, *args)
|
14
|
+
n = argv.size
|
15
|
+
args.each_slice(2).each do |ary|
|
16
|
+
if ary.size == 2
|
17
|
+
unless n.__send__(*ary)
|
18
|
+
raise ArgumentError, "Invalid arguments number. Please refer to documents."
|
19
|
+
end
|
20
|
+
else
|
21
|
+
raise ArgumentError, "Invalid argument to check array size."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
true
|
25
|
+
end
|
26
|
+
module_function :check_argument_size
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module DRbQS
|
2
|
+
class Command
|
3
|
+
class Base
|
4
|
+
include DRbQS::Misc
|
5
|
+
include DRbQS::Command::Argument
|
6
|
+
|
7
|
+
@@command_name = File.basename($PROGRAM_NAME)
|
8
|
+
|
9
|
+
def self.exec(argv)
|
10
|
+
obj = self.new
|
11
|
+
obj.parse_option(argv)
|
12
|
+
obj.exec
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(klass = DRbQS::Setting::Base, help_message = nil)
|
16
|
+
@help_message = help_message
|
17
|
+
@opt_setting = DRbQS::Command::OptionSetting.new(@help_message, klass.new)
|
18
|
+
end
|
19
|
+
|
20
|
+
def setting
|
21
|
+
@opt_setting.setting
|
22
|
+
end
|
23
|
+
|
24
|
+
def exit_normally
|
25
|
+
Kernel.exit(0)
|
26
|
+
end
|
27
|
+
private :exit_normally
|
28
|
+
|
29
|
+
def exit_unusually
|
30
|
+
Kernel.exit(1)
|
31
|
+
end
|
32
|
+
private :exit_unusually
|
33
|
+
|
34
|
+
def exit_invalid_option
|
35
|
+
Kernel.exit(2)
|
36
|
+
end
|
37
|
+
private :exit_invalid_option
|
38
|
+
|
39
|
+
def option_parser_base(argv, options = {}, &block)
|
40
|
+
@opt_setting.define(options, &block)
|
41
|
+
begin
|
42
|
+
@opt_setting.parse!(argv)
|
43
|
+
rescue DRbQS::Setting::InvalidLogLevel => err
|
44
|
+
$stderr.print err.to_s << "\n\n" << @help_message.to_s
|
45
|
+
exit_invalid_option
|
46
|
+
rescue OptionParser::InvalidOption
|
47
|
+
$stderr.print "error: Invalid Option\n\n" << @help_message.to_s
|
48
|
+
exit_invalid_option
|
49
|
+
rescue OptionParser::InvalidArgument
|
50
|
+
$stderr.print "error: Invalid Argument\n\n" << @help_message.to_s
|
51
|
+
exit_invalid_option
|
52
|
+
end
|
53
|
+
argv
|
54
|
+
end
|
55
|
+
private :option_parser_base
|
56
|
+
|
57
|
+
def parse_arguments!
|
58
|
+
setting.parse!
|
59
|
+
end
|
60
|
+
private :parse_arguments!
|
61
|
+
|
62
|
+
def exec
|
63
|
+
begin
|
64
|
+
parse_arguments!
|
65
|
+
setting.exec($stdout)
|
66
|
+
exit_normally
|
67
|
+
rescue DRb::DRbConnError => err
|
68
|
+
$stderr.puts "error: Can not connect. #{err.to_s}"
|
69
|
+
exit_unusually
|
70
|
+
rescue DRbQS::Setting::InvalidArgument => err
|
71
|
+
mes = "error: Invalid command argument. #{err.to_s}\n\n" << @help_message.to_s
|
72
|
+
$stderr.print mes
|
73
|
+
exit_invalid_option
|
74
|
+
rescue => err
|
75
|
+
output_error(err, $stderr)
|
76
|
+
exit_unusually
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module DRbQS
|
2
|
+
class Command
|
3
|
+
class Execute < DRbQS::Command::Base
|
4
|
+
HELP_MESSAGE =<<HELP
|
5
|
+
Usage: #{@@command_name} <definition> [options ...]
|
6
|
+
#{@@command_name} <definition> [options ...] [-- server options ...]
|
7
|
+
Execute DRbQS server and some nodes from definition file.
|
8
|
+
|
9
|
+
HELP
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super(DRbQS::Setting::Execute, HELP_MESSAGE)
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse_option(argv)
|
16
|
+
args, server_args = split_arguments(argv)
|
17
|
+
args = option_parser_base(args) do
|
18
|
+
set(:port, '--port NUM', Integer, 'Set the port number.')
|
19
|
+
set(:server, '--server STR', String, 'Set the key of server.')
|
20
|
+
set(:node, '--node STR', String, 'Set the comma sparated key of nodes.')
|
21
|
+
set(:no_server, '--no-server', 'Not execute server.')
|
22
|
+
set(:no_node, '--no-node', 'Not execute node.')
|
23
|
+
set(:information, '-i', '--information', 'Show information.')
|
24
|
+
set(:help, '-h', '--help', 'Show this command help and usage of definition file.') do |opt|
|
25
|
+
$stdout.print opt
|
26
|
+
end
|
27
|
+
end
|
28
|
+
setting.set_argument(*args)
|
29
|
+
setting.server_argument = server_args
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'drbqs'
|
2
|
+
require 'drbqs/manage/manage'
|
3
|
+
require 'drbqs/manage/execute_node'
|
4
|
+
require 'drbqs/command_line/argument'
|
5
|
+
require 'drbqs/command_line/option_setting'
|
6
|
+
require 'drbqs/command_line/command_base'
|
7
|
+
require 'optparse'
|
8
|
+
|
9
|
+
Version = DRbQS::VERSION
|
10
|
+
|
11
|
+
module DRbQS
|
12
|
+
class Command
|
13
|
+
autoload :Manage, 'drbqs/command_line/command_manage'
|
14
|
+
autoload :Server, 'drbqs/command_line/command_server'
|
15
|
+
autoload :Node, 'drbqs/command_line/command_node'
|
16
|
+
autoload :SSH, 'drbqs/command_line/command_ssh'
|
17
|
+
autoload :Execute, 'drbqs/command_line/command_execute'
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module DRbQS
|
2
|
+
class Command
|
3
|
+
class Manage < DRbQS::Command::Base
|
4
|
+
HELP_MESSAGE =<<HELP
|
5
|
+
Usage: #{@@command_name} <command> [arguments ...]
|
6
|
+
Manage DRbQS server by sending messages.
|
7
|
+
<command> is 'signal', 'status', 'process', or 'initialize'.
|
8
|
+
|
9
|
+
#{@@command_name} signal <uri> server-exit
|
10
|
+
#{@@command_name} signal <uri> node-exit-after-task <node_number>
|
11
|
+
#{@@command_name} signal <uri> node-wake <node_number>
|
12
|
+
#{@@command_name} signal <uri> node-sleep <node_number>
|
13
|
+
#{@@command_name} status <uri>
|
14
|
+
#{@@command_name} history <uri>
|
15
|
+
#{@@command_name} process list
|
16
|
+
#{@@command_name} process clear
|
17
|
+
#{@@command_name} send string <uri> <string>
|
18
|
+
#{@@command_name} send file <uri> <path>
|
19
|
+
#{@@command_name} initialize
|
20
|
+
|
21
|
+
HELP
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
super(DRbQS::Setting::Manage, HELP_MESSAGE)
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_option(argv)
|
28
|
+
argv = option_parser_base(argv, :debug => true) do
|
29
|
+
end
|
30
|
+
setting.set_argument(*argv)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module DRbQS
|
2
|
+
class Command
|
3
|
+
class Node < DRbQS::Command::Base
|
4
|
+
HELP_MESSAGE =<<HELP
|
5
|
+
Usage: #{@@command_name} <uri> [options ...]
|
6
|
+
Start DRbQS nodes connecting to <uri>.
|
7
|
+
|
8
|
+
HELP
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super(DRbQS::Setting::Node, HELP_MESSAGE)
|
12
|
+
end
|
13
|
+
|
14
|
+
def parse_option(argv)
|
15
|
+
argv = option_parser_base(argv, :log_level => true, :daemon => true, :debug => true) do
|
16
|
+
set(:load, '-l', '--load FILE', String, 'Add a file to load.')
|
17
|
+
set(:process, '-P', '--process NUM', Integer, 'Set the number of node processes to execute.')
|
18
|
+
set(:loadavg, '--loadavg STR', String, 'Set the threshold load average to sleep.')
|
19
|
+
set(:log_prefix, '--log-prefix STR', String, "Set the prefix of log files. The default is '#{setting.default[:log_prefix][0]}'.")
|
20
|
+
set(:log_stdout, '--log-stdout', 'Use stdout for outputting logs. This option cancels --log-prefix.')
|
21
|
+
end
|
22
|
+
setting.set_argument(*argv)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module DRbQS
|
2
|
+
class Command
|
3
|
+
class Server < DRbQS::Command::Base
|
4
|
+
@@command_name = File.basename($PROGRAM_NAME)
|
5
|
+
|
6
|
+
HELP_MESSAGE =<<HELP
|
7
|
+
Usage: #{@@command_name} <definition.rb> [other files ...] [options ...]
|
8
|
+
#{@@command_name} <definition.rb> [other files ...] [options ...] -- [server options ...]
|
9
|
+
Start DRbQS server of definition files.
|
10
|
+
|
11
|
+
HELP
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super(DRbQS::Setting::Server, HELP_MESSAGE)
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse_option(argv)
|
18
|
+
command_argv, server_argv = split_arguments(argv)
|
19
|
+
|
20
|
+
command_argv = option_parser_base(command_argv, :log_level => true, :daemon => true, :debug => true) do
|
21
|
+
set(:port, '-p PORT', '--port', Integer, 'Set the port number of server.')
|
22
|
+
set(:unix, '-u PATH', '--unix', String, 'Set the path of unix domain socket.')
|
23
|
+
set(:acl, '--acl FILE', String, 'Set a file to define ACL.')
|
24
|
+
set(:log_file, '--log-file STR', String, "Set the path of log file. If this options is not set, use STDOUT.")
|
25
|
+
set(:sftp_user, '--sftp-user USER', String, 'Set the user of sftp destination.')
|
26
|
+
set(:sftp_host, '--sftp-host HOST', String, 'Set the host of sftp destination.')
|
27
|
+
set(:profile, '--profile', 'Use profile for test exec.')
|
28
|
+
set(:profile_printer, '--profile-printer PRINTER', String,
|
29
|
+
'Set the printer type for profile. The value is :flat, :graph, :graphhtml, or :calltree.')
|
30
|
+
set(:test, '--test STR', String, 'Execute test.')
|
31
|
+
set(:execute_node, '--execute-node NUM', Integer, 'Execute nodes.')
|
32
|
+
set(:help, '-h', '--help', 'Show this command help and server specific help.') do |opt|
|
33
|
+
$stdout.print opt
|
34
|
+
end
|
35
|
+
end
|
36
|
+
setting.set_argument(*command_argv)
|
37
|
+
setting.set_server_argument(*server_argv)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module DRbQS
|
2
|
+
class Command
|
3
|
+
class SSH < DRbQS::Command::Base
|
4
|
+
HELP_MESSAGE =<<HELP
|
5
|
+
Usage: #{@@command_name} <command> [arguments ...]
|
6
|
+
Execute command over SSH.
|
7
|
+
<command> is 'list', 'show', 'environment', 'execute', 'server', or 'node'.
|
8
|
+
|
9
|
+
#{@@command_name} list
|
10
|
+
#{@@command_name} show <configuration>
|
11
|
+
#{@@command_name} environment <destination>
|
12
|
+
#{@@command_name} execute <destination> [options ...] -- [arguments ...]
|
13
|
+
#{@@command_name} server <destination> [options ...] -- [arguments ...]
|
14
|
+
#{@@command_name} node <destination> [options ...] -- [arguments ...]
|
15
|
+
|
16
|
+
HELP
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
super(DRbQS::Setting::SSH, HELP_MESSAGE)
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse_option(argv)
|
23
|
+
args, mode_args = split_arguments(argv)
|
24
|
+
args = option_parser_base(args, :debug => true) do |opt|
|
25
|
+
set(:directory, '-d DIR', '--directory DIR', String, 'Set the base directory over ssh.')
|
26
|
+
set(:shell, '--shell STR', String, 'Set the shell over ssh')
|
27
|
+
set(:rvm, '--rvm STR', String, 'Ruby version to use on RVM over ssh.')
|
28
|
+
set(:rvm_init, '--rvm-init PATH', String, 'Path of script to initialize RVM over ssh.')
|
29
|
+
set(:output, '-o DIR', '--output DIR', String, 'Directory path that a server and nodes output.')
|
30
|
+
set(:nice, '--nice NUM', Integer, 'Set the value of nice for a server and nodes. The default is 10.')
|
31
|
+
end
|
32
|
+
setting.set_argument(*args)
|
33
|
+
case setting.get_argument[0]
|
34
|
+
when 'server'
|
35
|
+
parser = DRbQS::Command::Server.new
|
36
|
+
parser.parse_option(mode_args)
|
37
|
+
setting.mode_setting = parser.setting
|
38
|
+
when 'node'
|
39
|
+
parser = DRbQS::Command::Node.new
|
40
|
+
parser.parse_option(mode_args)
|
41
|
+
setting.mode_setting = parser.setting
|
42
|
+
when 'execute'
|
43
|
+
setting.configure_mode_setting(:execute) do |mode_setting|
|
44
|
+
mode_setting.argument.concat(mode_args)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module DRbQS
|
2
|
+
class Command
|
3
|
+
class OptionSetting
|
4
|
+
attr_reader :setting
|
5
|
+
|
6
|
+
def initialize(help_message, setting)
|
7
|
+
@opt_parser = OptionParser.new(help_message)
|
8
|
+
@setting = setting
|
9
|
+
end
|
10
|
+
|
11
|
+
def set(*args, &block)
|
12
|
+
unless @setting
|
13
|
+
raise "Not in method 'define'."
|
14
|
+
end
|
15
|
+
@opt_parser.on(*args[1..-1]) do |v|
|
16
|
+
@setting.set(args[0], v)
|
17
|
+
if block_given?
|
18
|
+
yield(@opt_parser)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def define(options = {}, &block)
|
24
|
+
instance_eval(&block) if block_given?
|
25
|
+
if options[:log_level]
|
26
|
+
set(:log_level, '--log-level LEVEL', String,
|
27
|
+
"Set the log level. The value accepts 'fatal', 'error', 'warn', 'info', and 'debug'. The default is 'error'.")
|
28
|
+
end
|
29
|
+
if options[:daemon]
|
30
|
+
set(:daemon, '--daemon OUT', String, 'Execute as daemon and set output file for stdout and stderr.')
|
31
|
+
end
|
32
|
+
if options[:debug]
|
33
|
+
set(:debug, '--debug', 'Set $DEBUG true.')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse!(argv)
|
38
|
+
@opt_parser.parse!(argv)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|