Class: Wakame::MasterManagers::ClusterManager
- Inherits:
-
Object
- Object
- Wakame::MasterManagers::ClusterManager
show all
- Includes:
- Wakame::MasterManager
- Defined in:
- lib/wakame/master_managers/cluster_manager.rb
Defined Under Namespace
Classes: ClusterConfigLoader
Instance Attribute Summary
#master
Instance Method Summary
collapse
#start, #stop
Instance Method Details
#clusters ⇒ Object
99
100
101
|
# File 'lib/wakame/master_managers/cluster_manager.rb', line 99
def clusters
Models::ServiceClusterPool.all.map{|r| r.service_cluster_id }
end
|
#init ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/wakame/master_managers/cluster_manager.rb', line 44
def init
@status_check_timer = EM::PeriodicTimer.new(5) {
StatusDB.pass {
clusters.each { |cluster_id|
Service::ServiceCluster.find(cluster_id).update_cluster_status
}
}
}
@check_event_tickets = []
[Event::ServiceOnline, Event::ServiceOffline, Event::ServiceFailed].each { |evclass|
@check_event_tickets << EventDispatcher.subscribe(evclass) { |event|
StatusDB.pass {
clusters.each { |cluster_id|
Service::ServiceCluster.find(cluster_id).update_cluster_status
}
}
}
}
@check_event_tickets << EventDispatcher.subscribe(Event::ServiceStatusChanged) { |event|
svc = Service::ServiceInstance.find(event.instance_id)
case svc.status
when Service::STATUS_ENTERING
EM.defer {
svc.cloud_host.live_monitors.each { |path, conf|
Wakame.log.debug("#{self.class}: Refreshing monitoring setting on #{svc.cloud_host.agent_id} (on enter): #{path} => #{conf.inspect}")
Master.instance.actor_request(svc.cloud_host.agent_id, '/monitor/reload', path, conf).request.wait
}
}
when Service::STATUS_QUITTING
EM.defer {
svc.cloud_host.live_monitors.each { |path, conf|
Wakame.log.debug("#{self.class}: Refreshing monitoring setting on #{svc.cloud_host.agent_id} (on quit): #{path} => #{conf.inspect}")
Master.instance.actor_request(svc.cloud_host.agent_id, '/monitor/reload', path, conf).request.wait
}
}
end
}
end
|
#load_config_cluster ⇒ Object
#register(cluster) ⇒ Object
#reload ⇒ Object
89
90
|
# File 'lib/wakame/master_managers/cluster_manager.rb', line 89
def reload
end
|
#terminate ⇒ Object
92
93
94
95
96
97
|
# File 'lib/wakame/master_managers/cluster_manager.rb', line 92
def terminate
@status_check_timer.cancel
@check_event_tickets.each { |t|
EventDispatcher.unsubscribe(t)
}
end
|
#unregister(cluster_id) ⇒ Object
108
109
110
|
# File 'lib/wakame/master_managers/cluster_manager.rb', line 108
def unregister(cluster_id)
@clusters.delete(cluster_id)
end
|