drbqs 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -7
- data/README.md +52 -11
- data/Rakefile +32 -10
- data/VERSION +1 -1
- data/bin/drbqs-manage +3 -93
- data/bin/drbqs-node +3 -89
- data/bin/drbqs-server +3 -117
- data/bin/drbqs-ssh +6 -0
- data/drbqs.gemspec +118 -97
- data/example/README.md +2 -2
- data/lib/drbqs/config/config.rb +88 -0
- data/lib/drbqs/config/process_list.rb +194 -0
- data/lib/drbqs/config/ssh_host.rb +41 -0
- data/lib/drbqs/{execute_node.rb → manage/execute_node.rb} +6 -4
- data/lib/drbqs/manage/manage.rb +100 -0
- data/lib/drbqs/manage/send_signal.rb +45 -0
- data/lib/drbqs/manage/ssh_execute.rb +23 -0
- data/lib/drbqs/manage/ssh_shell.rb +143 -0
- data/lib/drbqs/node/connection.rb +69 -0
- data/lib/drbqs/{client.rb → node/node.rb} +48 -18
- data/lib/drbqs/node/task_client.rb +94 -0
- data/lib/drbqs/server/acl_file.rb +15 -0
- data/lib/drbqs/server/check_alive.rb +23 -0
- data/lib/drbqs/server/history.rb +49 -0
- data/lib/drbqs/server/message.rb +142 -0
- data/lib/drbqs/server/node_list.rb +59 -0
- data/lib/drbqs/server/queue.rb +128 -0
- data/lib/drbqs/{server.rb → server/server.rb} +66 -74
- data/lib/drbqs/server/server_hook.rb +72 -0
- data/lib/drbqs/server/transfer_setting.rb +30 -0
- data/lib/drbqs/task/command_task.rb +43 -0
- data/lib/drbqs/{task.rb → task/task.rb} +18 -39
- data/lib/drbqs/{task_generator.rb → task/task_generator.rb} +2 -0
- data/lib/drbqs/utility/argument.rb +27 -0
- data/lib/drbqs/utility/command_line/command_base.rb +27 -0
- data/lib/drbqs/utility/command_line/command_manage.rb +121 -0
- data/lib/drbqs/utility/command_line/command_node.rb +103 -0
- data/lib/drbqs/utility/command_line/command_server.rb +165 -0
- data/lib/drbqs/utility/command_line/command_ssh.rb +126 -0
- data/lib/drbqs/utility/command_line.rb +15 -0
- data/lib/drbqs/utility/misc.rb +72 -0
- data/lib/drbqs/{server_define.rb → utility/server_define.rb} +23 -8
- data/lib/drbqs/utility/temporary.rb +49 -0
- data/lib/drbqs/{ssh/transfer.rb → utility/transfer/file_transfer.rb} +18 -58
- data/lib/drbqs/utility/transfer/transfer_client.rb +90 -0
- data/lib/drbqs.rb +10 -22
- data/spec/config/config_spec.rb +84 -0
- data/spec/config/process_list_spec.rb +149 -0
- data/spec/config/ssh_host_spec.rb +81 -0
- data/spec/integration_test/01_basic_usage_spec.rb +54 -0
- data/spec/integration_test/02_use_generator_spec.rb +53 -0
- data/spec/integration_test/03_use_temporary_file_spec.rb +26 -0
- data/spec/integration_test/04_use_unix_domain_spec.rb +34 -0
- data/spec/integration_test/05_server_exit_signal_spec.rb +23 -0
- data/spec/integration_test/06_node_exit_after_task_spec.rb +42 -0
- data/spec/integration_test/07_command_server_with_node_spec.rb +44 -0
- data/spec/integration_test/definition/server01.rb +20 -0
- data/spec/integration_test/definition/server02.rb +16 -0
- data/spec/integration_test/definition/task_obj_definition.rb +49 -0
- data/spec/manage/manage_spec.rb +33 -0
- data/spec/manage/send_signal_spec.rb +39 -0
- data/spec/{ssh_shell_spec.rb → manage/ssh_shell_spec.rb} +8 -8
- data/spec/node/connection_spec.rb +66 -0
- data/spec/node/task_client_spec.rb +212 -0
- data/spec/server/acl_file_spec.rb +9 -0
- data/spec/{server_check_alive_spec.rb → server/check_alive_spec.rb} +15 -11
- data/spec/{data → server/data}/acl.txt +0 -0
- data/spec/{history_spec.rb → server/history_spec.rb} +9 -5
- data/spec/server/message_spec.rb +195 -0
- data/spec/server/node_list_spec.rb +111 -0
- data/spec/server/queue_spec.rb +239 -0
- data/spec/{server_hook_spec.rb → server/server_hook_spec.rb} +23 -17
- data/spec/server/server_spec.rb +89 -0
- data/spec/server/transfer_setting_spec.rb +37 -0
- data/spec/spec_helper.rb +65 -0
- data/spec/task/file_transfer_spec.rb +107 -0
- data/spec/{task_generator_spec.rb → task/task_generator_spec.rb} +2 -2
- data/spec/{task_spec.rb → task/task_spec.rb} +3 -1
- data/spec/utility/argument_spec.rb +39 -0
- data/spec/utility/command_line/command_base_spec.rb +33 -0
- data/spec/utility/command_line/commands_spec.rb +15 -0
- data/spec/utility/misc_spec.rb +77 -0
- data/spec/utility/server_define_spec.rb +59 -0
- data/spec/utility/temporary_spec.rb +39 -0
- metadata +158 -93
- data/example/drbqs-manage-test.rb +0 -3
- data/example/drbqs-node-test.rb +0 -3
- data/example/drbqs-server-test.rb +0 -3
- data/lib/drbqs/acl_file.rb +0 -13
- data/lib/drbqs/config.rb +0 -98
- data/lib/drbqs/connection.rb +0 -67
- data/lib/drbqs/history.rb +0 -34
- data/lib/drbqs/manage.rb +0 -84
- data/lib/drbqs/message.rb +0 -119
- data/lib/drbqs/node_list.rb +0 -52
- data/lib/drbqs/queue.rb +0 -138
- data/lib/drbqs/server_hook.rb +0 -67
- data/lib/drbqs/ssh/host.rb +0 -26
- data/lib/drbqs/ssh/shell.rb +0 -139
- data/lib/drbqs/task_client.rb +0 -86
- data/lib/drbqs/utils.rb +0 -19
- data/spec/acl_file_spec.rb +0 -9
- data/spec/config_spec.rb +0 -14
- data/spec/connection_spec.rb +0 -49
- data/spec/manage_spec.rb +0 -57
- data/spec/message_spec.rb +0 -81
- data/spec/node_list_spec.rb +0 -68
- data/spec/queue_spec.rb +0 -59
- data/spec/server_define_spec.rb +0 -45
- data/spec/server_spec.rb +0 -56
- data/spec/task_client_spec.rb +0 -53
- data/spec/test/test1.rb +0 -13
- data/spec/test1_spec.rb +0 -80
- data/spec/test2_spec.rb +0 -69
- data/spec/transfer_spec.rb +0 -13
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.14"
|
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-
|
12
|
+
s.date = %q{2011-07-19}
|
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"]
|
15
|
+
s.executables = ["drbqs-manage", "drbqs-node", "drbqs-server", "drbqs-ssh"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE.txt",
|
18
18
|
"README.md"
|
@@ -28,12 +28,10 @@ Gem::Specification.new do |s|
|
|
28
28
|
"bin/drbqs-manage",
|
29
29
|
"bin/drbqs-node",
|
30
30
|
"bin/drbqs-server",
|
31
|
+
"bin/drbqs-ssh",
|
31
32
|
"drbqs.gemspec",
|
32
33
|
"example/README.md",
|
33
34
|
"example/command/server_def.rb",
|
34
|
-
"example/drbqs-manage-test.rb",
|
35
|
-
"example/drbqs-node-test.rb",
|
36
|
-
"example/drbqs-server-test.rb",
|
37
35
|
"example/error/error.rb",
|
38
36
|
"example/error/server_def.rb",
|
39
37
|
"example/server/server.rb",
|
@@ -44,121 +42,144 @@ Gem::Specification.new do |s|
|
|
44
42
|
"example/transfer/file.rb",
|
45
43
|
"example/transfer/server_def.rb",
|
46
44
|
"lib/drbqs.rb",
|
47
|
-
"lib/drbqs/
|
48
|
-
"lib/drbqs/
|
49
|
-
"lib/drbqs/config.rb",
|
50
|
-
"lib/drbqs/
|
51
|
-
"lib/drbqs/
|
52
|
-
"lib/drbqs/
|
53
|
-
"lib/drbqs/manage.rb",
|
54
|
-
"lib/drbqs/
|
55
|
-
"lib/drbqs/
|
56
|
-
"lib/drbqs/
|
57
|
-
"lib/drbqs/
|
58
|
-
"lib/drbqs/
|
59
|
-
"lib/drbqs/
|
60
|
-
"lib/drbqs/
|
61
|
-
"lib/drbqs/
|
62
|
-
"lib/drbqs/
|
63
|
-
"lib/drbqs/
|
64
|
-
"lib/drbqs/
|
65
|
-
"lib/drbqs/
|
66
|
-
"lib/drbqs/
|
67
|
-
"
|
68
|
-
"
|
69
|
-
"
|
70
|
-
"
|
71
|
-
"
|
72
|
-
"
|
73
|
-
"
|
74
|
-
"
|
75
|
-
"
|
76
|
-
"
|
77
|
-
"
|
78
|
-
"
|
79
|
-
"
|
45
|
+
"lib/drbqs/config/config.rb",
|
46
|
+
"lib/drbqs/config/process_list.rb",
|
47
|
+
"lib/drbqs/config/ssh_host.rb",
|
48
|
+
"lib/drbqs/manage/execute_node.rb",
|
49
|
+
"lib/drbqs/manage/manage.rb",
|
50
|
+
"lib/drbqs/manage/send_signal.rb",
|
51
|
+
"lib/drbqs/manage/ssh_execute.rb",
|
52
|
+
"lib/drbqs/manage/ssh_shell.rb",
|
53
|
+
"lib/drbqs/node/connection.rb",
|
54
|
+
"lib/drbqs/node/node.rb",
|
55
|
+
"lib/drbqs/node/task_client.rb",
|
56
|
+
"lib/drbqs/server/acl_file.rb",
|
57
|
+
"lib/drbqs/server/check_alive.rb",
|
58
|
+
"lib/drbqs/server/history.rb",
|
59
|
+
"lib/drbqs/server/message.rb",
|
60
|
+
"lib/drbqs/server/node_list.rb",
|
61
|
+
"lib/drbqs/server/queue.rb",
|
62
|
+
"lib/drbqs/server/server.rb",
|
63
|
+
"lib/drbqs/server/server_hook.rb",
|
64
|
+
"lib/drbqs/server/transfer_setting.rb",
|
65
|
+
"lib/drbqs/task/command_task.rb",
|
66
|
+
"lib/drbqs/task/task.rb",
|
67
|
+
"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
|
+
"lib/drbqs/utility/misc.rb",
|
76
|
+
"lib/drbqs/utility/server_define.rb",
|
77
|
+
"lib/drbqs/utility/temporary.rb",
|
78
|
+
"lib/drbqs/utility/transfer/file_transfer.rb",
|
79
|
+
"lib/drbqs/utility/transfer/transfer_client.rb",
|
80
|
+
"spec/config/config_spec.rb",
|
81
|
+
"spec/config/process_list_spec.rb",
|
82
|
+
"spec/config/ssh_host_spec.rb",
|
83
|
+
"spec/integration_test/01_basic_usage_spec.rb",
|
84
|
+
"spec/integration_test/02_use_generator_spec.rb",
|
85
|
+
"spec/integration_test/03_use_temporary_file_spec.rb",
|
86
|
+
"spec/integration_test/04_use_unix_domain_spec.rb",
|
87
|
+
"spec/integration_test/05_server_exit_signal_spec.rb",
|
88
|
+
"spec/integration_test/06_node_exit_after_task_spec.rb",
|
89
|
+
"spec/integration_test/07_command_server_with_node_spec.rb",
|
90
|
+
"spec/integration_test/definition/server01.rb",
|
91
|
+
"spec/integration_test/definition/server02.rb",
|
92
|
+
"spec/integration_test/definition/task_obj_definition.rb",
|
93
|
+
"spec/manage/manage_spec.rb",
|
94
|
+
"spec/manage/send_signal_spec.rb",
|
95
|
+
"spec/manage/ssh_shell_spec.rb",
|
96
|
+
"spec/node/connection_spec.rb",
|
97
|
+
"spec/node/task_client_spec.rb",
|
98
|
+
"spec/server/acl_file_spec.rb",
|
99
|
+
"spec/server/check_alive_spec.rb",
|
100
|
+
"spec/server/data/acl.txt",
|
101
|
+
"spec/server/history_spec.rb",
|
102
|
+
"spec/server/message_spec.rb",
|
103
|
+
"spec/server/node_list_spec.rb",
|
104
|
+
"spec/server/queue_spec.rb",
|
105
|
+
"spec/server/server_hook_spec.rb",
|
106
|
+
"spec/server/server_spec.rb",
|
107
|
+
"spec/server/transfer_setting_spec.rb",
|
80
108
|
"spec/spec_helper.rb",
|
81
|
-
"spec/
|
82
|
-
"spec/
|
83
|
-
"spec/
|
84
|
-
"spec/
|
85
|
-
"spec/
|
86
|
-
"spec/
|
87
|
-
"spec/
|
88
|
-
"spec/
|
109
|
+
"spec/task/file_transfer_spec.rb",
|
110
|
+
"spec/task/task_generator_spec.rb",
|
111
|
+
"spec/task/task_spec.rb",
|
112
|
+
"spec/utility/argument_spec.rb",
|
113
|
+
"spec/utility/command_line/command_base_spec.rb",
|
114
|
+
"spec/utility/command_line/commands_spec.rb",
|
115
|
+
"spec/utility/misc_spec.rb",
|
116
|
+
"spec/utility/server_define_spec.rb",
|
117
|
+
"spec/utility/temporary_spec.rb"
|
89
118
|
]
|
90
119
|
s.homepage = %q{http://github.com/ytaka/drbqs}
|
91
120
|
s.licenses = ["GPL3"]
|
92
121
|
s.require_paths = ["lib"]
|
93
122
|
s.rubygems_version = %q{1.6.2}
|
94
123
|
s.summary = %q{dRuby Queueing System}
|
95
|
-
s.test_files = [
|
96
|
-
"spec/acl_file_spec.rb",
|
97
|
-
"spec/config_spec.rb",
|
98
|
-
"spec/connection_spec.rb",
|
99
|
-
"spec/history_spec.rb",
|
100
|
-
"spec/manage_spec.rb",
|
101
|
-
"spec/message_spec.rb",
|
102
|
-
"spec/node_list_spec.rb",
|
103
|
-
"spec/queue_spec.rb",
|
104
|
-
"spec/server_check_alive_spec.rb",
|
105
|
-
"spec/server_define_spec.rb",
|
106
|
-
"spec/server_hook_spec.rb",
|
107
|
-
"spec/server_spec.rb",
|
108
|
-
"spec/spec_helper.rb",
|
109
|
-
"spec/ssh_shell_spec.rb",
|
110
|
-
"spec/task_client_spec.rb",
|
111
|
-
"spec/task_generator_spec.rb",
|
112
|
-
"spec/task_spec.rb",
|
113
|
-
"spec/test/test1.rb",
|
114
|
-
"spec/test1_spec.rb",
|
115
|
-
"spec/test2_spec.rb",
|
116
|
-
"spec/transfer_spec.rb"
|
117
|
-
]
|
118
124
|
|
119
125
|
if s.respond_to? :specification_version then
|
120
126
|
s.specification_version = 3
|
121
127
|
|
122
128
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
123
|
-
s.add_development_dependency(%q<rspec>, [">= 2.
|
124
|
-
s.add_development_dependency(%q<yard>, ["
|
125
|
-
s.add_development_dependency(%q<bundler>, ["
|
126
|
-
s.add_development_dependency(%q<jeweler>, ["
|
129
|
+
s.add_development_dependency(%q<rspec>, [">= 2.6.0"])
|
130
|
+
s.add_development_dependency(%q<yard>, [">= 0.7.2"])
|
131
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.15"])
|
132
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.6.2"])
|
127
133
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
128
|
-
s.add_development_dependency(%q<filename>, [">= 0.0
|
129
|
-
s.add_development_dependency(%q<
|
130
|
-
s.add_development_dependency(%q<net-ssh
|
134
|
+
s.add_development_dependency(%q<filename>, [">= 0.1.0"])
|
135
|
+
s.add_development_dependency(%q<user_config>, [">= 0.0.1"])
|
136
|
+
s.add_development_dependency(%q<net-ssh>, [">= 2.1.4"])
|
137
|
+
s.add_development_dependency(%q<net-ssh-shell>, [">= 0.2.0"])
|
138
|
+
s.add_development_dependency(%q<net-sftp>, [">= 2.0.5"])
|
139
|
+
s.add_development_dependency(%q<sys-proctable>, [">= 0"])
|
140
|
+
s.add_runtime_dependency(%q<filename>, [">= 0.1.0"])
|
141
|
+
s.add_runtime_dependency(%q<user_config>, [">= 0.0.2"])
|
131
142
|
s.add_runtime_dependency(%q<net-ssh>, [">= 2.1.3"])
|
132
143
|
s.add_runtime_dependency(%q<net-ssh-shell>, [">= 0.1.0"])
|
133
|
-
s.add_runtime_dependency(%q<
|
134
|
-
s.
|
144
|
+
s.add_runtime_dependency(%q<net-sftp>, [">= 2.0.5"])
|
145
|
+
s.add_runtime_dependency(%q<sys-proctable>, [">= 0"])
|
135
146
|
else
|
136
|
-
s.add_dependency(%q<rspec>, [">= 2.
|
137
|
-
s.add_dependency(%q<yard>, ["
|
138
|
-
s.add_dependency(%q<bundler>, ["
|
139
|
-
s.add_dependency(%q<jeweler>, ["
|
147
|
+
s.add_dependency(%q<rspec>, [">= 2.6.0"])
|
148
|
+
s.add_dependency(%q<yard>, [">= 0.7.2"])
|
149
|
+
s.add_dependency(%q<bundler>, [">= 1.0.15"])
|
150
|
+
s.add_dependency(%q<jeweler>, [">= 1.6.2"])
|
140
151
|
s.add_dependency(%q<rcov>, [">= 0"])
|
141
|
-
s.add_dependency(%q<filename>, [">= 0.0
|
142
|
-
s.add_dependency(%q<
|
143
|
-
s.add_dependency(%q<net-ssh
|
152
|
+
s.add_dependency(%q<filename>, [">= 0.1.0"])
|
153
|
+
s.add_dependency(%q<user_config>, [">= 0.0.1"])
|
154
|
+
s.add_dependency(%q<net-ssh>, [">= 2.1.4"])
|
155
|
+
s.add_dependency(%q<net-ssh-shell>, [">= 0.2.0"])
|
156
|
+
s.add_dependency(%q<net-sftp>, [">= 2.0.5"])
|
157
|
+
s.add_dependency(%q<sys-proctable>, [">= 0"])
|
158
|
+
s.add_dependency(%q<filename>, [">= 0.1.0"])
|
159
|
+
s.add_dependency(%q<user_config>, [">= 0.0.2"])
|
144
160
|
s.add_dependency(%q<net-ssh>, [">= 2.1.3"])
|
145
161
|
s.add_dependency(%q<net-ssh-shell>, [">= 0.1.0"])
|
146
|
-
s.add_dependency(%q<
|
147
|
-
s.add_dependency(%q<
|
162
|
+
s.add_dependency(%q<net-sftp>, [">= 2.0.5"])
|
163
|
+
s.add_dependency(%q<sys-proctable>, [">= 0"])
|
148
164
|
end
|
149
165
|
else
|
150
|
-
s.add_dependency(%q<rspec>, [">= 2.
|
151
|
-
s.add_dependency(%q<yard>, ["
|
152
|
-
s.add_dependency(%q<bundler>, ["
|
153
|
-
s.add_dependency(%q<jeweler>, ["
|
166
|
+
s.add_dependency(%q<rspec>, [">= 2.6.0"])
|
167
|
+
s.add_dependency(%q<yard>, [">= 0.7.2"])
|
168
|
+
s.add_dependency(%q<bundler>, [">= 1.0.15"])
|
169
|
+
s.add_dependency(%q<jeweler>, [">= 1.6.2"])
|
154
170
|
s.add_dependency(%q<rcov>, [">= 0"])
|
155
|
-
s.add_dependency(%q<filename>, [">= 0.0
|
156
|
-
s.add_dependency(%q<
|
157
|
-
s.add_dependency(%q<net-ssh
|
171
|
+
s.add_dependency(%q<filename>, [">= 0.1.0"])
|
172
|
+
s.add_dependency(%q<user_config>, [">= 0.0.1"])
|
173
|
+
s.add_dependency(%q<net-ssh>, [">= 2.1.4"])
|
174
|
+
s.add_dependency(%q<net-ssh-shell>, [">= 0.2.0"])
|
175
|
+
s.add_dependency(%q<net-sftp>, [">= 2.0.5"])
|
176
|
+
s.add_dependency(%q<sys-proctable>, [">= 0"])
|
177
|
+
s.add_dependency(%q<filename>, [">= 0.1.0"])
|
178
|
+
s.add_dependency(%q<user_config>, [">= 0.0.2"])
|
158
179
|
s.add_dependency(%q<net-ssh>, [">= 2.1.3"])
|
159
180
|
s.add_dependency(%q<net-ssh-shell>, [">= 0.1.0"])
|
160
|
-
s.add_dependency(%q<
|
161
|
-
s.add_dependency(%q<
|
181
|
+
s.add_dependency(%q<net-sftp>, [">= 2.0.5"])
|
182
|
+
s.add_dependency(%q<sys-proctable>, [">= 0"])
|
162
183
|
end
|
163
184
|
end
|
164
185
|
|
data/example/README.md
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
|
5
5
|
We execute server by the following command:
|
6
6
|
|
7
|
-
|
7
|
+
../bin/drbqs-server sum/server_def.rb
|
8
8
|
|
9
9
|
For nodes we type the following command:
|
10
10
|
|
11
|
-
|
11
|
+
../bin/drbqs-node -l sum/sum.rb --log-stdout
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'user_config'
|
2
|
+
require 'drbqs/config/ssh_host'
|
3
|
+
require 'drbqs/config/process_list'
|
4
|
+
|
5
|
+
module DRbQS
|
6
|
+
|
7
|
+
ACL_DEFAULT_PATH = 'acl.txt'
|
8
|
+
ACL_SAMPLE_PATH = 'acl.txt.sample'
|
9
|
+
HOST_FILE_DIRECTORY = 'host'
|
10
|
+
HOST_FILE_SAMPLE_PATH = 'host.yaml.sample'
|
11
|
+
SHELL_FILE_DIRECTORY = 'shell'
|
12
|
+
SHELL_BASHRC = 'bashrc'
|
13
|
+
|
14
|
+
class Config
|
15
|
+
class Directory < UserConfig
|
16
|
+
end
|
17
|
+
|
18
|
+
DRBQS_CONFIG_DIRECTORY = '.drbqs'
|
19
|
+
|
20
|
+
@@home_directory = nil
|
21
|
+
|
22
|
+
def self.set_home_directory(path)
|
23
|
+
@@home_directory = File.expand_path(path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.get_home_directory
|
27
|
+
@@home_directory || ENV['HOME']
|
28
|
+
end
|
29
|
+
|
30
|
+
ACL_SAMPLE =<<SAMPLE
|
31
|
+
deny all
|
32
|
+
allow localhost
|
33
|
+
allow 127.0.0.1
|
34
|
+
SAMPLE
|
35
|
+
|
36
|
+
HOST_YAML_SAMPLE =<<SAMPLE
|
37
|
+
---
|
38
|
+
:dest: user@example.com
|
39
|
+
:dir:
|
40
|
+
:shell: bash --noprofile --init-file ~/.drbqs/shell/bashrc
|
41
|
+
:rvm:
|
42
|
+
:rvm_init: ~/.rvm/scripts/rvm
|
43
|
+
:output:
|
44
|
+
SAMPLE
|
45
|
+
|
46
|
+
BASHRC_SAMPLE = <<SAMPLE
|
47
|
+
HISTFILE=$HOME/.drbqs/shell/bash_history
|
48
|
+
HISTSIZE=10000
|
49
|
+
HISTFILESIZE=20000
|
50
|
+
SAMPLE
|
51
|
+
|
52
|
+
attr_reader :directory, :list, :ssh_host
|
53
|
+
|
54
|
+
def initialize
|
55
|
+
home = self.class.get_home_directory
|
56
|
+
@directory = DRbQS::Config::Directory.new(DRBQS_CONFIG_DIRECTORY, :home => home)
|
57
|
+
@list = DRbQS::ProcessList.new(File.join(home, DRBQS_CONFIG_DIRECTORY))
|
58
|
+
@ssh_host = DRbQS::Config::SSHHost.new(@directory.file_path(HOST_FILE_DIRECTORY))
|
59
|
+
end
|
60
|
+
|
61
|
+
def directory_path
|
62
|
+
@directory.directory
|
63
|
+
end
|
64
|
+
|
65
|
+
def save_sample
|
66
|
+
@directory.open(ACL_SAMPLE_PATH, 'w') do |f|
|
67
|
+
f.print ACL_SAMPLE
|
68
|
+
end
|
69
|
+
@directory.open(File.join(HOST_FILE_DIRECTORY, HOST_FILE_SAMPLE_PATH), 'w') do |f|
|
70
|
+
f.print HOST_YAML_SAMPLE
|
71
|
+
end
|
72
|
+
@directory.open(File.join(SHELL_FILE_DIRECTORY, SHELL_BASHRC), 'w') do |f|
|
73
|
+
f.print BASHRC_SAMPLE
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Return path of ACL file if '.drbqs/acl.txt' exists.
|
78
|
+
def get_acl_file
|
79
|
+
@directory.exist?(ACL_DEFAULT_PATH)
|
80
|
+
end
|
81
|
+
|
82
|
+
def get_shell_file_directory
|
83
|
+
@directory.file_path(SHELL_FILE_DIRECTORY)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
module DRbQS
|
2
|
+
class ProcessList
|
3
|
+
PROCESS_ROOT_DIRECTORY = 'process'
|
4
|
+
SERVER_DIRECTORY = 'server'
|
5
|
+
NODE_DIRECTORY = 'node'
|
6
|
+
|
7
|
+
class ListDirectory
|
8
|
+
def initialize(dir)
|
9
|
+
@directory = dir
|
10
|
+
FileUtils.mkdir_p(@directory) unless File.exist?(@directory)
|
11
|
+
end
|
12
|
+
|
13
|
+
def path_under_directory(file)
|
14
|
+
File.join(@directory, file)
|
15
|
+
end
|
16
|
+
private :path_under_directory
|
17
|
+
|
18
|
+
# If +file+ exists then this method returns false.
|
19
|
+
# Otherwise, return true.
|
20
|
+
def save_file(file, data)
|
21
|
+
path = path_under_directory(file)
|
22
|
+
if File.exist?(path)
|
23
|
+
false
|
24
|
+
else
|
25
|
+
open(path, 'w') do |f|
|
26
|
+
f.print data.to_yaml
|
27
|
+
end
|
28
|
+
true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
private :save_file
|
32
|
+
|
33
|
+
# If +file+ does not exist then this method returns nil.
|
34
|
+
def load_file(file)
|
35
|
+
path = path_under_directory(file)
|
36
|
+
if File.exist?(path)
|
37
|
+
YAML.load_file(path)
|
38
|
+
else
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
private :load_file
|
43
|
+
|
44
|
+
def delete_file(file)
|
45
|
+
path = path_under_directory(file)
|
46
|
+
FileUtils.remove(path) if File.exist?(path)
|
47
|
+
end
|
48
|
+
private :delete_file
|
49
|
+
|
50
|
+
def entries
|
51
|
+
Dir.entries(@directory).delete_if do |dir|
|
52
|
+
/^\.+$/ =~ dir
|
53
|
+
end
|
54
|
+
end
|
55
|
+
private :entries
|
56
|
+
|
57
|
+
def server_of_key_exist?(uri, key)
|
58
|
+
if data = get(uri)
|
59
|
+
return data[:key] == key
|
60
|
+
end
|
61
|
+
false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Server < ListDirectory
|
66
|
+
def uri_to_file(uri)
|
67
|
+
case uri
|
68
|
+
when /^druby.*:(\d+)$/
|
69
|
+
"druby_#{Regexp.last_match[1]}.yaml"
|
70
|
+
when /^drbunix:(.*)$/
|
71
|
+
"drbunix#{Regexp.last_match[1].gsub(/\//, '_')}.yaml"
|
72
|
+
else
|
73
|
+
raise ArgumentError, "Invalid uri of drbqs server: #{uri}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
private :uri_to_file
|
77
|
+
|
78
|
+
def file_to_uri(file)
|
79
|
+
s = file.sub(/\.yaml$/, '')
|
80
|
+
case s
|
81
|
+
when /^druby/
|
82
|
+
s.sub(/_/, '://:')
|
83
|
+
when /^drbunix$/
|
84
|
+
s.gsub(/_/, '/')
|
85
|
+
else
|
86
|
+
raise ArgumentError, "Invalid file name in process list: #{file}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
private :file_to_uri
|
90
|
+
|
91
|
+
def list
|
92
|
+
h = {}
|
93
|
+
entries.each do |file|
|
94
|
+
h[file_to_uri(file)] = load_file(file)
|
95
|
+
end
|
96
|
+
h
|
97
|
+
end
|
98
|
+
|
99
|
+
# If file exists then this method overwrites the file.
|
100
|
+
def save(uri, data)
|
101
|
+
unless save_file(uri_to_file(uri), data)
|
102
|
+
delete(uri)
|
103
|
+
save(uri, data)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def get(uri)
|
108
|
+
load_file(uri_to_file(uri))
|
109
|
+
end
|
110
|
+
|
111
|
+
def delete(uri)
|
112
|
+
delete_file(uri_to_file(uri))
|
113
|
+
end
|
114
|
+
|
115
|
+
def clear_process_not_exist
|
116
|
+
list.each do |uri, data|
|
117
|
+
if !DRbQS::Misc.process_running_normally?(data[:pid]) || !DRbQS::Manage.new(:uri => uri).server_respond?
|
118
|
+
delete(uri)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
class Node < ListDirectory
|
125
|
+
def pid_to_file(pid)
|
126
|
+
sprintf("%010d.yaml", pid)
|
127
|
+
end
|
128
|
+
private :pid_to_file
|
129
|
+
|
130
|
+
def file_to_pid(file)
|
131
|
+
file.sub(/\.yaml$/, '').to_i
|
132
|
+
end
|
133
|
+
private :file_to_pid
|
134
|
+
|
135
|
+
def list
|
136
|
+
h = {}
|
137
|
+
entries.each do |file|
|
138
|
+
h[file_to_pid(file)] = load_file(file)
|
139
|
+
end
|
140
|
+
h
|
141
|
+
end
|
142
|
+
|
143
|
+
# If file exists then this method overwrites the file.
|
144
|
+
def save(pid, data)
|
145
|
+
unless save_file(pid_to_file(pid), data)
|
146
|
+
delete(pid)
|
147
|
+
save(pid, data)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def get(pid)
|
152
|
+
load_file(pid_to_file(pid))
|
153
|
+
end
|
154
|
+
|
155
|
+
def delete(pid)
|
156
|
+
delete_file(pid_to_file(pid))
|
157
|
+
end
|
158
|
+
|
159
|
+
def clear_process_not_exist
|
160
|
+
server = Hash.new do |h, k|
|
161
|
+
h[k] = Array.new
|
162
|
+
end
|
163
|
+
list.each do |pid, data|
|
164
|
+
if DRbQS::Misc.process_running_normally?(pid)
|
165
|
+
server[data[:uri]] << pid
|
166
|
+
else
|
167
|
+
delete(pid)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
server.each do |server_uri, pid_ary|
|
171
|
+
unless DRbQS::Manage.new(:uri => server_uri).server_respond?
|
172
|
+
pid_ary.each do |pid|
|
173
|
+
delete(pid)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
attr_reader :root, :server, :node
|
181
|
+
|
182
|
+
def initialize(home)
|
183
|
+
hostname = Socket.gethostname
|
184
|
+
@root = File.expand_path(File.join(home, PROCESS_ROOT_DIRECTORY))
|
185
|
+
@server = DRbQS::ProcessList::Server.new(File.join(@root, SERVER_DIRECTORY, hostname))
|
186
|
+
@node = DRbQS::ProcessList::Node.new(File.join(@root, NODE_DIRECTORY, hostname))
|
187
|
+
end
|
188
|
+
|
189
|
+
def clear_process_not_exist
|
190
|
+
@server.clear_process_not_exist
|
191
|
+
@node.clear_process_not_exist
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module DRbQS
|
2
|
+
class Config
|
3
|
+
class SSHHost
|
4
|
+
def initialize(dir)
|
5
|
+
@dir = File.expand_path(dir)
|
6
|
+
end
|
7
|
+
|
8
|
+
def config_files
|
9
|
+
(Dir.glob("#{@dir}/*.yaml") + Dir.glob("#{@dir}/*.yml")).sort
|
10
|
+
end
|
11
|
+
private :config_files
|
12
|
+
|
13
|
+
def config_names
|
14
|
+
config_files.map do |s|
|
15
|
+
File.basename(s).sub(/\.ya?ml$/, '')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def find_file(name)
|
20
|
+
config_files.find do |s|
|
21
|
+
File.basename(s).sub(/\.ya?ml$/, '') == name
|
22
|
+
end
|
23
|
+
end
|
24
|
+
private :find_file
|
25
|
+
|
26
|
+
def get_path(name)
|
27
|
+
name = name.to_s
|
28
|
+
name.size > 0 && find_file(name)
|
29
|
+
end
|
30
|
+
|
31
|
+
# +name+ is file name without extension.
|
32
|
+
def get_options(name)
|
33
|
+
if path = get_path(name)
|
34
|
+
return [path, YAML.load_file(path)]
|
35
|
+
end
|
36
|
+
[nil, {}]
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module DRbQS
|
2
2
|
|
3
3
|
class ExecuteNode
|
4
|
+
attr_reader :pid
|
5
|
+
|
4
6
|
def initialize(uri, log_prefix, log_level)
|
5
7
|
@uri = uri
|
6
8
|
@log_level = log_level
|
@@ -24,9 +26,9 @@ module DRbQS
|
|
24
26
|
|
25
27
|
def create_process
|
26
28
|
@pid << fork do
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
node = DRbQS::Node.new(@uri, :log_level => @log_level, :log_file => get_log_file)
|
30
|
+
node.connect
|
31
|
+
node.calculate
|
30
32
|
end
|
31
33
|
end
|
32
34
|
private :create_process
|
@@ -39,7 +41,7 @@ module DRbQS
|
|
39
41
|
end
|
40
42
|
|
41
43
|
def wait
|
42
|
-
Process.waitall
|
44
|
+
Process.waitall
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|