Class: BigBrother::ActivePassiveCluster
- Inherits:
-
Cluster
- Object
- Cluster
- BigBrother::ActivePassiveCluster
show all
- Defined in:
- lib/big_brother/active_passive_cluster.rb
Instance Attribute Summary
Attributes inherited from Cluster
#backend_mode, #check_interval, #fwmark, #nagios, #name, #nodes, #ramp_up_time, #scheduler
Instance Method Summary
collapse
Methods inherited from Cluster
#==, #_add_maintenance_node, #_add_nodes, #_check_downpage, #_coerce_node, #_notify_nagios, #_remove_maintenance_node, #_remove_nodes, #_update_node, #cluster_nodes, #combined_weight, #down_file_exists?, #downpage_enabled?, #find_node, #has_downpage?, #incorporate_state, #initialize, #monitored?, #needs_check?, #resume_monitoring!, #stop_monitoring!, #to_s, #up_file_exists?
Instance Method Details
#_modify_active_node(current_active_node, proposed_active_node) ⇒ Object
56
57
58
59
|
# File 'lib/big_brother/active_passive_cluster.rb', line 56
def _modify_active_node(current_active_node, proposed_active_node)
BigBrother.ipvs.stop_node(fwmark, current_active_node.address)
BigBrother.ipvs.start_node(fwmark, proposed_active_node.address, proposed_active_node.weight)
end
|
#_modify_current_active_node_weight(node, weight) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/big_brother/active_passive_cluster.rb', line 48
def _modify_current_active_node_weight(node, weight)
return unless node == @current_active_node
if @current_active_node.weight != weight
BigBrother.ipvs.edit_node(fwmark, @current_active_node.address, weight)
@current_active_node.weight = weight
end
end
|
#active_node ⇒ Object
12
13
14
|
# File 'lib/big_brother/active_passive_cluster.rb', line 12
def active_node
@current_active_node ||= @nodes.sort.first
end
|
#monitor_nodes ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/big_brother/active_passive_cluster.rb', line 29
def monitor_nodes
@last_check = Time.now
@current_active_node = active_node
proposed_active_node = @nodes.reject do |node|
weight = node.monitor(self).to_i
_modify_current_active_node_weight(node, weight)
node.weight = weight
node.weight.zero?
end.sort.first
if proposed_active_node != @current_active_node && !proposed_active_node.nil?
_modify_active_node(@current_active_node, proposed_active_node)
@current_active_node = proposed_active_node
end
_check_downpage if has_downpage?
_notify_nagios if nagios
end
|
#start_monitoring! ⇒ Object
#synchronize! ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/big_brother/active_passive_cluster.rb', line 16
def synchronize!
ipvs_state = BigBrother.ipvs.running_configuration
if ipvs_state.has_key?(fwmark.to_s)
resume_monitoring!
running_active_node_address = ipvs_state[fwmark.to_s].first
if running_active_node_address != active_node.address
BigBrother.ipvs.stop_node(fwmark, running_active_node_address)
BigBrother.ipvs.start_node(fwmark, active_node.address, active_node.weight)
end
end
end
|