Module: Corosync
- Defined in:
- lib/corosync.rb,
lib/corosync/cpg/member.rb,
lib/corosync/exceptions.rb,
lib/corosync/cpg/member_list.rb
Defined Under Namespace
Classes: CMAP, CPG, Error, Quorum, Votequorum
Constant Summary collapse
- VERSION =
File.read(File.('../../VERSION', __FILE__)).chomp
Class Method Summary collapse
-
.cs_send(method, *args) ⇒ TrueClass, Integer
Calls a Corosync method and raises an exception on error while handling retries.
-
.cs_send!(method, *args) ⇒ TrueClass, Integer
Calls a Corosync method and raises an exception on errors.
Class Method Details
.cs_send(method, *args) ⇒ TrueClass, Integer
Calls a Corosync method and raises an exception on error while handling retries. This is the same as cs_send! except that on the event of TryAgainError, it retries for up to 3 seconds.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/corosync.rb', line 47 def self.cs_send(method, *args) cs_error = nil time_start = Time.new.to_f begin begin cs_error = send(method, *args) rescue Corosync::Error => e e.depth += 1 raise e end return true if cs_error == :ok # short circuit the rest of the method since this should be true the majority of the time break if cs_error != :err_try_again sleep 0.05 end while Time.new.to_f - time_start < 3 if exception_class = Error::Map[cs_error] then exception = exception_class.new("Received #{cs_error.to_s.upcase} during #{method}") exception.depth = 1 raise exception end cs_error end |
.cs_send!(method, *args) ⇒ TrueClass, Integer
Calls a Corosync method and raises an exception on errors. This is a convenience method to handle error responses when calling various corosync library functions. When an error is returned, an exception is raised. The exceptions are programatically generated based off the ‘:cs_error_t` enum defined in `ffi/common.rb`. For example, `:err_try_again` maps to `Corosync::TryAgainError`.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/corosync.rb', line 18 def self.cs_send!(method, *args) cs_error = nil begin cs_error = send(method, *args) rescue Corosync::Error => e e.depth += 1 raise e end return true if cs_error == :ok # short circuit the rest of the method since this should be true the majority of the time if exception_class = Error::Map[cs_error] then exception = exception_class.new("Received #{cs_error.to_s.upcase} during #{method}") exception.depth = 1 raise exception end cs_error end |