Class: RSwim::Member::Me

Inherits:
Base
  • Object
show all
Defined in:
lib/rswim/member/me.rb

Overview

Member behaviour of local node (“me”)

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Me

Returns a new instance of Me.



7
8
9
10
11
12
# File 'lib/rswim/member/me.rb', line 7

def initialize(id)
  super
  @ack_responder = AckResponder.new(id)
  @propagation_count = 0
  @custom_state = {}
end

Instance Method Details

#append_custom_state(key, value) ⇒ Object



26
27
28
29
# File 'lib/rswim/member/me.rb', line 26

def append_custom_state(key, value)
  @custom_state[key] = value
  propagate_change
end

#can_be_pinged?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/rswim/member/me.rb', line 44

def can_be_pinged?
  false
end

#incorporate_gossip(update_entry) ⇒ Object



31
32
33
34
35
36
# File 'lib/rswim/member/me.rb', line 31

def incorporate_gossip(update_entry)
  if update_entry.incarnation_number >= @incarnation_number &&
     (update_entry.status != :alive || update_entry.custom_state != @custom_state)
    propagate_change
  end
end

#increment_propagation_countObject



14
15
16
# File 'lib/rswim/member/me.rb', line 14

def increment_propagation_count
  @propagation_count += 1
end

#prepare_outputObject



22
23
24
# File 'lib/rswim/member/me.rb', line 22

def prepare_output
  @ack_responder.prepare_output
end

#prepare_update_entryObject



38
39
40
# File 'lib/rswim/member/me.rb', line 38

def prepare_update_entry
  UpdateEntry.new(@id, :alive, @incarnation_number, @custom_state, @propagation_count)
end

#schedule_ack(member_id) ⇒ Object



18
19
20
# File 'lib/rswim/member/me.rb', line 18

def schedule_ack(member_id)
  @ack_responder.schedule_ack(member_id)
end

#update(elapsed_seconds) ⇒ Object



42
# File 'lib/rswim/member/me.rb', line 42

def update(elapsed_seconds); end