corosync-commander 0.1.0.0 → 0.2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +2 -2
- data/README.md +16 -16
- data/VERSION +1 -1
- data/lib/corosync_commander/execution/message.rb +1 -1
- data/lib/corosync_commander.rb +17 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 411024404c9dd35180971bf19f7f41c72ccba755
|
4
|
+
data.tar.gz: 2572ee7e38c1c0e95c8dd579095b2bb1639f68b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b55b096da38c71c50316307891237ea7151cfd78c23a2f2842b8845f0eb68eaceb85dae7bf548206290a2439bc3747332caff9a08fdb3fe97441044809c626a
|
7
|
+
data.tar.gz: 093df1adcc6b2a8b77a9e3042c85f3b86f7b69bd7eb181d855332651f7abca7e87d87ee99311ef337021f6b8381dcc8f69ca8dc49ac5ee9d1ef35d3055c48c75
|
data/Gemfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# A sample Gemfile
|
2
2
|
source "https://rubygems.org"
|
3
3
|
|
4
|
-
gem 'corosync', '
|
5
|
-
|
4
|
+
#gem 'corosync', :git => 'git@github.com:phemmer/ruby-corosync.git'
|
5
|
+
gem 'corosync', '~>0.2.0.0'
|
6
6
|
|
7
7
|
group :development do
|
8
8
|
gem 'rake'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
corosync (0.
|
4
|
+
corosync (0.2.0.0)
|
5
5
|
ffi (~> 1.9)
|
6
6
|
diff-lcs (1.2.4)
|
7
7
|
ffi (1.9.3)
|
@@ -23,7 +23,7 @@ PLATFORMS
|
|
23
23
|
ruby
|
24
24
|
|
25
25
|
DEPENDENCIES
|
26
|
-
corosync (~> 0.
|
26
|
+
corosync (~> 0.2.0.0)
|
27
27
|
rake
|
28
28
|
rdoc
|
29
29
|
rspec
|
data/README.md
CHANGED
@@ -10,21 +10,21 @@ The key to this is that when you send a message to the cluster, you receive your
|
|
10
10
|
|
11
11
|
There is a fully working example in the `examples` directory, but here's a brief condensed version:
|
12
12
|
|
13
|
-
require 'corosync_commander'
|
14
|
-
cc = CorosyncCommander.new
|
15
|
-
cc.commands.register('shell command') do |sender, shellcmd|
|
16
|
-
|
17
|
-
end
|
18
|
-
cc.join('remote commands')
|
13
|
+
require 'corosync_commander'
|
14
|
+
cc = CorosyncCommander.new
|
15
|
+
cc.commands.register('shell command') do |sender, shellcmd|
|
16
|
+
%x{#{shellcmd}}
|
17
|
+
end
|
18
|
+
cc.join('remote commands')
|
19
19
|
|
20
|
-
exe = cc.execute([], 'shell command', 'hostname')
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
exe = cc.execute([], 'shell command', 'hostname')
|
21
|
+
enum = exe.to_enum
|
22
|
+
begin
|
23
|
+
enum.each do |sender, response|
|
24
|
+
$stdout.write "#{sender.nodeid}:#{sender.pid}: #{response.chomp}\n"
|
25
|
+
end
|
26
|
+
rescue CorosyncCommander::RemoteException => e
|
27
|
+
puts "Caught remote exception: #{e}"
|
28
|
+
retry
|
29
|
+
end
|
25
30
|
end
|
26
|
-
rescue CorosyncCommander::RemoteException => e
|
27
|
-
puts "Caught remote exception: #{e}"
|
28
|
-
retry
|
29
|
-
end
|
30
|
-
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0.0
|
data/lib/corosync_commander.rb
CHANGED
@@ -94,18 +94,23 @@ class CorosyncCommander
|
|
94
94
|
# Starts watching for notifications
|
95
95
|
# @return [void]
|
96
96
|
def start
|
97
|
-
@quorum.start
|
97
|
+
@quorum.start
|
98
98
|
|
99
99
|
@dispatch_thread = Thread.new do
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
100
|
+
begin
|
101
|
+
loop do
|
102
|
+
select_ready = select([@cpg.fd, @quorum.fd], [], [])
|
103
|
+
if select_ready[0].include?(@quorum.fd) then
|
104
|
+
@quorum.dispatch
|
105
|
+
end
|
106
|
+
if select_ready[0].include?(@cpg.fd) then
|
107
|
+
@cpg.dispatch
|
108
|
+
end
|
108
109
|
end
|
110
|
+
rescue Exception => e
|
111
|
+
# something happened that we don't know how to handle. We need to bail out.
|
112
|
+
$stderr.write "Fatal exception: #{e.to_s} (#{e.class})\n#{e.backtrace.join("\n")}\n"
|
113
|
+
exit(1)
|
109
114
|
end
|
110
115
|
end
|
111
116
|
end
|
@@ -151,6 +156,7 @@ class CorosyncCommander
|
|
151
156
|
private :next_execution_id
|
152
157
|
|
153
158
|
# Used as a callback on receipt of a CPG message
|
159
|
+
# @param sender [Corosync::CPG::Member] Sender of the message
|
154
160
|
# @param message [String] data structure passed to @cpg.send
|
155
161
|
# * message[0] == [Array<String>] Each string is "nodeid:pid" of the intended message recipients
|
156
162
|
# * msgid == [Integer]
|
@@ -161,10 +167,9 @@ class CorosyncCommander
|
|
161
167
|
# * In the event of a command, this will be the arguments passed to CorosyncCommander.send
|
162
168
|
# * In the event of a response, this will be the return value of the command handler
|
163
169
|
# * In the event of an exception, this will be the exception string and backtrace
|
164
|
-
# @param sender [Corosync::CPG::Member] Sender of the message
|
165
170
|
# @!visibility private
|
166
|
-
def cpg_message(
|
167
|
-
message = CorosyncCommander::Execution::Message.from_cpg_message(
|
171
|
+
def cpg_message(sender, message)
|
172
|
+
message = CorosyncCommander::Execution::Message.from_cpg_message(sender, message)
|
168
173
|
|
169
174
|
# This is the possible message classifications
|
170
175
|
# Command echo (potentially also a command to us)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: corosync-commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Hemmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: corosync
|