Skip to content

Commit

Permalink
Replace wait_for_worker_monitor with delay_startup_for_vim_broker
Browse files Browse the repository at this point in the history
This continues the work of 9e99ba0 to morph wait_for_worker_monitor
into what it actually has become under the covers.  Additionally, there
is the similarly named requires_vim_broker, which really means to delay
the queue delivery loop when the broker goes down.  This commit renames
that for clarity (with a temporary alias until we can change the
callers).
  • Loading branch information
Fryguy committed Jul 25, 2017
1 parent 93eb4c0 commit 65effc1
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class ManageIQ::Providers::BaseManager::MetricsCollectorWorker::Runner < ::MiqQueueWorkerBase::Runner
self.wait_for_worker_monitor = true # NOTE: Really means wait for broker to start for ems_metrics_collector role, TODO: only for VMware
self.delay_startup_for_vim_broker = true # NOTE: For ems_metrics_collector role, TODO: only for VMware
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class ManageIQ::Providers::BaseManager::RefreshWorker::Runner < ::MiqQueueWorker
[:ems_id, 'EMS Instance ID', String],
]

self.wait_for_worker_monitor = true # NOTE: Really means wait for broker for ems_inventory role, TODO: only for VMware
self.delay_startup_for_vim_broker = true # NOTE: For ems_inventory role, TODO: only for VMware

def log_prefix
@log_prefix ||= "EMS [#{@ems.hostname}] as [#{@ems.authentication_userid}]"
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_generic_worker/runner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class MiqGenericWorker::Runner < MiqQueueWorkerBase::Runner
self.wait_for_worker_monitor = true # NOTE: Really means wait for broker to start because of ems_operations and smartstate roles
self.delay_startup_for_vim_broker = true # NOTE: For ems_operations and smartstate roles
end
6 changes: 1 addition & 5 deletions app/models/miq_queue_worker_base/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ def get_message
end

def message_delivery_suspended?
if self.class.require_vim_broker?
return true unless MiqVimBrokerWorker.available?
end

false
self.class.delay_queue_delivery_for_vim_broker? && !MiqVimBrokerWorker.available?
end

def deliver_queue_message(msg)
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_smart_proxy_worker/runner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class MiqSmartProxyWorker::Runner < MiqQueueWorkerBase::Runner
self.wait_for_worker_monitor = true # NOTE: Really means wait for broker to start for smartproxy role
self.delay_startup_for_vim_broker = true # NOTE: For smartproxy role
end
43 changes: 19 additions & 24 deletions app/models/miq_worker/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,6 @@ def set_connection_pool_size
# Worker Monitor Methods
###############################

def self.wait_for_worker_monitor?
!!@wait_for_worker_monitor
end

class << self
attr_writer :wait_for_worker_monitor
end

def my_monitor_started?
return @monitor_started unless @monitor_started.nil?
return false if server.nil?
return false unless server.reload.started?
@monitor_started = true
end

def worker_monitor_drb
@worker_monitor_drb ||= begin
raise _("%{log} No MiqServer found to establishing DRb Connection to") % {:log => log_prefix} if server.nil?
Expand All @@ -120,13 +105,23 @@ def worker_monitor_drb
# VimBrokerWorker Methods
###############################

def self.require_vim_broker?
@require_vim_broker = false if @require_vim_broker.nil?
@require_vim_broker
def self.delay_startup_for_vim_broker?
!!@delay_startup_for_vim_broker
end

class << self
attr_writer :require_vim_broker
attr_writer :delay_startup_for_vim_broker
end

def self.delay_queue_delivery_for_vim_broker?
!!@delay_queue_delivery_for_vim_broker
end

class << self
attr_writer :delay_queue_delivery_for_vim_broker

alias require_vim_broker? delay_queue_delivery_for_vim_broker?
alias require_vim_broker= delay_queue_delivery_for_vim_broker=
end

def start
Expand All @@ -151,7 +146,7 @@ def prepare
set_database_application_name
ObjectSpace.garbage_collect
started_worker_record
do_wait_for_worker_monitor if self.class.wait_for_worker_monitor?
do_delay_startup_for_vim_broker if self.class.delay_startup_for_vim_broker? && MiqVimBrokerWorker.workers > 0
do_before_work_loop
self
end
Expand Down Expand Up @@ -323,14 +318,14 @@ def do_work
raise NotImplementedError, _("must be implemented in a subclass")
end

def do_wait_for_worker_monitor
_log.info("#{log_prefix} Checking that worker monitor has started before doing work")
def do_delay_startup_for_vim_broker
_log.info("#{log_prefix} Checking that VIM Broker has started before doing work")
loop do
break if self.my_monitor_started?
break if MiqVimBrokerWorker.available?
heartbeat
sleep 3
end
_log.info("#{log_prefix} Starting work since worker monitor has started")
_log.info("#{log_prefix} Starting work since VIM Broker has started")
end

def do_work_loop
Expand Down
5 changes: 0 additions & 5 deletions spec/models/miq_ui_worker/runner_spec.rb

This file was deleted.

0 comments on commit 65effc1

Please sign in to comment.