class RSwim::Member::HealthState::Base

Attributes

update_entry[R]

Public Class Methods

new(id, member_pool, update_entry) click to toggle source
# File lib/rswim/member/health_state/base.rb, line 9
def initialize(id, member_pool, update_entry)
  @member_pool = member_pool
  @id = id
  @update_entry = update_entry
  logger.debug("Member with id #{id} entered new state: #{self.class}")
end

Public Instance Methods

advance(_elapsed_seconds) click to toggle source
# File lib/rswim/member/health_state/base.rb, line 16
def advance(_elapsed_seconds)
  self
end
can_be_pinged?() click to toggle source
# File lib/rswim/member/health_state/base.rb, line 57
def can_be_pinged?
  false
end
increment_propagation_count() click to toggle source
# File lib/rswim/member/health_state/base.rb, line 53
def increment_propagation_count
  @update_entry.increment_propagation_count
end
member_failed_to_reply() click to toggle source
# File lib/rswim/member/health_state/base.rb, line 51
def member_failed_to_reply; end
update_suspicion(status, incarnation_number) click to toggle source
# File lib/rswim/member/health_state/base.rb, line 20
def update_suspicion(status, incarnation_number)
  incarnation_number ||= @update_entry.incarnation_number
  s0 = @update_entry.status
  i0 = @update_entry.incarnation_number
  case status
  when :confirmed
    if (s0 == :confirmed)
      self
    else
      ue = UpdateEntry.new(@id, status, incarnation_number, 0)
      Confirmed.new(@id, @member_pool, ue)
    end
  when :suspected
    if (s0 == :suspected && incarnation_number > i0) ||
       (s0 == :alive && incarnation_number >= i0)
      ue = UpdateEntry.new(@id, status, incarnation_number, 0)
      Suspected.new(@id, @member_pool, ue, false)
    else
      self
    end
  when :alive
    if (s0 == :suspected && incarnation_number > i0) ||
       (s0 == :alive && incarnation_number > i0)
      ue = UpdateEntry.new(@id, status, incarnation_number, 0)
      Alive.new(@id, @member_pool, ue)
    else
      self
    end
  end
end

Protected Instance Methods

logger() click to toggle source
# File lib/rswim/member/health_state/base.rb, line 63
def logger
  @_logger ||= begin
    RSwim::Logger.new("unknown node", STDERR)
  end
end