-
Notifications
You must be signed in to change notification settings - Fork 897
/
Copy pathsettings.rb
53 lines (42 loc) · 1.59 KB
/
settings.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module MiqServer::WorkerManagement::Monitor::Settings
extend ActiveSupport::Concern
included do
attr_reader :child_worker_settings
attr_reader :worker_monitor_settings
end
def sync_child_worker_settings
@child_worker_settings = {}
self.class.monitor_class_names.each do |class_name|
c = class_name.constantize
@child_worker_settings[c.settings_name] = c.worker_settings
end
@child_worker_settings
end
def sync_worker_monitor_settings
@worker_monitor_settings = ::Settings.server.worker_monitor.to_hash
@worker_monitor_settings.keys.each do |k|
@worker_monitor_settings[k] = @worker_monitor_settings[k].to_i_with_method if @worker_monitor_settings[k].respond_to?(:to_i_with_method)
end
@worker_monitor_settings
end
def get_worker_poll(worker)
@child_worker_settings[worker.class.settings_name][:poll]
end
def get_time_threshold(worker)
settings = @child_worker_settings[worker.class.settings_name]
heartbeat_timeout = settings[:heartbeat_timeout] || 2.minutes
starting_timeout = settings[:starting_timeout] || 10.minutes
return starting_timeout if MiqWorker::STATUSES_STARTING.include?(worker.status)
if worker.kind_of?(MiqQueueWorkerBase)
timeout = worker.current_timeout
return (get_worker_poll(worker) + timeout) unless timeout.nil?
end
heartbeat_timeout
end
def get_restart_interval(worker)
@child_worker_settings[worker.class.settings_name][:restart_interval]
end
def get_memory_threshold(worker)
@child_worker_settings[worker.class.settings_name][:memory_threshold]
end
end