class Corosync::CPG::MemberList

Public Class Methods

new(*list) click to toggle source
Calls superclass method
# File lib/corosync/cpg/member_list.rb, line 10
def self.new(*list)
        # return the input list if we were passed a MemberList
        return list[0] if list.size == 1 and list[0].is_a?(self)
        super
end
new(*list) click to toggle source
# File lib/corosync/cpg/member_list.rb, line 15
def initialize(*list)
        @list = {}

        list = list[0] if list.size <= 1

        if list.is_a?(Array) then
                list.each do |recipient|
                        self << recipient
                end
        elsif list.is_a?(Corosync::CPG::Member) then
                self << list
        elsif list.nil? then
                # nothing
        else
                raise ArgumentError, "Invalid recipient type: #{list.class}"
        end
end

Public Instance Methods

&(list) click to toggle source

Get a list of all members also present in another list @param list [Corosync::CPG::MemberList] @return [Corosync::CPG::MemberList]

# File lib/corosync/cpg/member_list.rb, line 60
def &(list)
        @list.keys & list.to_a
end
<<(member) click to toggle source

Add a member to the list @param member [FFI::Pointer<Corosync::CpgAddress>,Corosync::CPG::Member] Member to add

# File lib/corosync/cpg/member_list.rb, line 35
def << (member)
        if member.is_a?(FFI::Pointer) then
                cpgaddress = Corosync::CpgAddress.new(member)
                @list[Corosync::CPG::Member.new(cpgaddress)] = cpgaddress[:reason]
        else
                @list[member] = nil
        end
end
delete(member) click to toggle source

Delete member from list @param member [Corosync::CPG::Member] Member to delete @return [void]

# File lib/corosync/cpg/member_list.rb, line 67
def delete(member)
        @list.delete(member)
end
dup() click to toggle source

Duplicate @return [Corosync::CPG::MemberList]

# File lib/corosync/cpg/member_list.rb, line 73
def dup
        new = self.class.new
        self.each do |member|
                new << member.dup
        end
        new
end
each(&block) click to toggle source

Iterate over all the {Corosync::CPG::Member member} objects in the list. @param block [Proc] @yieldparam member [Corosync::CPG::Member]

# File lib/corosync/cpg/member_list.rb, line 53
def each(&block)
        @list.each_key &block
end
freeze() click to toggle source

@return [Corosync::CPG::MemberList]

# File lib/corosync/cpg/member_list.rb, line 95
def freeze
        @list.freeze
        self
end
reason(member) click to toggle source

In the case of join/leave lists, this gets the reason a member is in the list. @param member [Corosync::CPG::Member] Member look up @return [Symbol, Integer, NilClass] Reason for the membership.

* :join => The member joined the group normally.
* :leave => The member left the group normally.
* :nodedown => The member left the group because the node left the cluster.
* :nodeup => The member joined the group because it was already a member of a group on a node that just joined the cluster.
* :procdown => The member left the group uncleanly (without calling {#leave})
# File lib/corosync/cpg/member_list.rb, line 89
def reason(member)
        member = Corosync::CPG::Member.new if !member.is_a?(Corosync::CPG::Member)
        @list[member]
end
size() click to toggle source

Number of members in list @return [Integer]

# File lib/corosync/cpg/member_list.rb, line 46
def size
        @list.size
end