[Ovirt-devel] [PATCH server] Fix dbomatic qpid reconnect
Jason Guiditta
jason.guiditta at gmail.com
Thu Mar 5 18:20:52 UTC 2009
ACK, dbomatic seems to still work fine after this patch.
On Tue, Mar 3, 2009 at 5:49 PM, Ian Main <imain at redhat.com> wrote:
> This patch uses the managed connection arrangement in the qpid library
> which uses a separate thread to manage the qpid connection; a much
> better way to go.
>
> Signed-off-by: Ian Main <imain at redhat.com>
> ---
> src/db-omatic/db_omatic.rb | 55
> ++++++++++++++-----------------------------
> 1 files changed, 18 insertions(+), 37 deletions(-)
>
> diff --git a/src/db-omatic/db_omatic.rb b/src/db-omatic/db_omatic.rb
> index 6dc02fb..96202f4 100755
> --- a/src/db-omatic/db_omatic.rb
> +++ b/src/db-omatic/db_omatic.rb
> @@ -40,7 +40,6 @@ class DbOmatic < Qpid::Qmf::Console
> @cached_objects = {}
> @heartbeats = {}
> @broker = nil
> - @session = Qpid::Qmf::Session.new(:console => self)
>
> do_daemon = true
>
> @@ -74,49 +73,33 @@ class DbOmatic < Qpid::Qmf::Console
> end
> @logger.info "dbomatic started."
>
> - get_credentials('qpidd')
> + ensure_credentials
>
> database_connect
> - qpid_ensure_connected
> -
> - end
> -
> -
> - # FIXME: This should move into a library but I think we'll need
> - # to make some sort of singleton class for these applications so we
> can
> - # share the logger and qpid variables etc. It's getting to show
> itself
> - # as a problem but I don't want to go crazy right now as we're
> supposed
> - # to be in freeze. :)
> - def qpid_ensure_connected()
> -
> - return if @broker and @broker.connected?
>
> - sleepy = 2
> + server, port = nil
> + (1..4).each do
> + server, port = get_srv('qpidd', 'tcp')
> + break if server
> + @logger.error "Unable to determine qpid server from DNS SRV
> record" if not server
> + sleep(10)
> + end
>
> - while true do
> - begin
> - server, port = get_srv('qpidd', 'tcp')
> - raise "Unable to determine qpid server from DNS SRV
> record" if not server
> + raise "Unable to determine server and port from DNS SRV records"
> if not server
>
> - @broker = @session.add_broker("amqp://#{server}:#{port}",
> :mechanism => 'GSSAPI')
> + @logger.info "Connecting to amqp://#{server}:#{port}"
> + @session = Qpid::Qmf::Session.new(:console => self,
> :manage_connections => true)
> + @broker = @session.add_broker("amqp://#{server}:#{port}",
> :mechanism => 'GSSAPI')
> + end
>
> - # Connection succeeded, go about our business.
> - @logger.info "Connected to amqp://#{server}:#{port}"
> - return
>
> - rescue Exception => msg
> - @logger.error "Error connecting to qpidd: #{msg}"
> - @logger.error msg.backtrace
> - end
> - sleep(sleepy)
> - sleepy *= 2
> - sleepy = 120 if sleepy > 120
> + def ensure_credentials()
> + get_credentials('qpidd')
>
> - begin
> - # Could also be a credentials problem? Try to get them
> again..
> + Thread.new do
> + while true do
> + sleep(3600)
> get_credentials('qpidd')
> - rescue Exception => msg
> - @logger.error "Error getting qpidd credentials: #{msg}"
> end
> end
> end
> @@ -370,8 +353,6 @@ class DbOmatic < Qpid::Qmf::Console
> while true
> sleep(5)
>
> - qpid_ensure_connected
> -
> synchronize do
> # Get seconds from the epoch
> t = Time.new.to_i
> --
> 1.6.0.6
>
> _______________________________________________
> Ovirt-devel mailing list
> Ovirt-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/ovirt-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20090305/403ea560/attachment.htm>
More information about the ovirt-devel
mailing list