corosync-commander 0.1.0.0 → 0.2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ffd9a76d120685a5cc4ca5b46d63f416c25f2ac
4
- data.tar.gz: 8c9f81c68f0ac85a2bc053f634e0f61a8f86257a
3
+ metadata.gz: 411024404c9dd35180971bf19f7f41c72ccba755
4
+ data.tar.gz: 2572ee7e38c1c0e95c8dd579095b2bb1639f68b8
5
5
  SHA512:
6
- metadata.gz: 5e6ca5cd16bca2f7e87392357cc65de13e6e9f53608d8b3f87f1aef52332f1df86a027bc56abed06a42263ac52627612730bb371664837f0c42d82e263a2375b
7
- data.tar.gz: e001b910753074d6633c0704f7c10099119d6d6dcd006e20851e5c4b46a443a1edfe5f19aac1cd37aad39cd59c86ff856db545a7ea8195f9cdff48ef7c61f81a
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', '~>0.1.0'
5
- #gem 'corosync', :path => '/home/phemmer/git/ruby-corosync'
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.1.0.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.1.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
- %x{#{shellcmd}}
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
- enum = exe.to_enum
22
- begin
23
- enum.each do |sender, response|
24
- $stdout.write "#{sender.nodeid}:#{sender.pid}: #{response.chomp}\n"
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.0
1
+ 0.2.0.0
@@ -9,7 +9,7 @@ class CorosyncCommander::Execution::Message
9
9
  attr_accessor :type
10
10
  attr_accessor :content
11
11
 
12
- def self.from_cpg_message(data, sender)
12
+ def self.from_cpg_message(sender, data)
13
13
  data = JSON.parse(data)
14
14
 
15
15
  recipients = Corosync::CPG::MemberList.new
@@ -94,18 +94,23 @@ class CorosyncCommander
94
94
  # Starts watching for notifications
95
95
  # @return [void]
96
96
  def start
97
- @quorum.start(true)
97
+ @quorum.start
98
98
 
99
99
  @dispatch_thread = Thread.new do
100
- Thread.current.abort_on_exception = true
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
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(message, sender)
167
- message = CorosyncCommander::Execution::Message.from_cpg_message(message, sender)
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.1.0.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-10 00:00:00.000000000 Z
11
+ date: 2014-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: corosync