Class: RSwim::Member::HealthState::Suspected
- Inherits:
-
Base
- Object
- Base
- RSwim::Member::HealthState::Suspected
show all
- Defined in:
- lib/rswim/member/health_state/suspected.rb
Instance Attribute Summary
Attributes inherited from Base
#propagation_count
Instance Method Summary
collapse
Methods inherited from Base
#increment_propagation_count, #member_failed_to_reply
Constructor Details
#initialize(id, node_member_id, member_pool, send_ping_request:, must_propagate: false) ⇒ Suspected
Returns a new instance of Suspected.
7
8
9
10
11
|
# File 'lib/rswim/member/health_state/suspected.rb', line 7
def initialize(id, node_member_id, member_pool, send_ping_request:, must_propagate: false)
super(id, node_member_id, member_pool, must_propagate: must_propagate)
@ping_request_sent = !send_ping_request
@life_time_seconds = 0
end
|
Instance Method Details
#advance(elapsed_seconds) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/rswim/member/health_state/suspected.rb', line 13
def advance(elapsed_seconds)
@life_time_seconds += elapsed_seconds
unless @ping_request_sent
@member_pool.send_ping_request_to_k_members(@id)
@ping_request_sent = true
end
if @life_time_seconds > 60
Confirmed.new(@id, @node_member_id, @member_pool, must_propagate: true)
else
self
end
end
|
#can_be_pinged? ⇒ Boolean
40
41
42
|
# File 'lib/rswim/member/health_state/suspected.rb', line 40
def can_be_pinged?
true
end
|
#status ⇒ Object
44
45
46
|
# File 'lib/rswim/member/health_state/suspected.rb', line 44
def status
:suspected
end
|
#update_suspicion(status, old_incarnation_number, gossip_incarnation_number) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/rswim/member/health_state/suspected.rb', line 27
def update_suspicion(status, old_incarnation_number, gossip_incarnation_number)
case status
when :confirmed then Confirmed.new(@id, @node_member_id, @member_pool)
when :suspected then self
when :alive
if gossip_incarnation_number > old_incarnation_number
Alive.new(@id, @node_member_id, @member_pool)
else
self
end
end
end
|