This patch uses the managed connection arrangement in the qpid library which uses a separate thread to manage the qpid connection. This is the same as was done for dbomatic in the previous patch. Signed-off-by: Ian Main <imain at redhat.com> --- src/task-omatic/taskomatic.rb | 58 +++++++++++++--------------------------- 1 files changed, 19 insertions(+), 39 deletions(-) diff --git a/src/task-omatic/taskomatic.rb b/src/task-omatic/taskomatic.rb index 8d35692..eb8e2ae 100755 --- a/src/task-omatic/taskomatic.rb +++ b/src/task-omatic/taskomatic.rb @@ -60,9 +60,6 @@ class TaskOmatic @sleeptime = 2 @nth_host = 0 - @session = Qpid::Qmf::Session.new() - @broker = nil - do_daemon = true opts = OptionParser.new do |opts| @@ -98,43 +95,31 @@ class TaskOmatic @logger = Logger.new(STDERR) end + ensure_credentials - # this has to be after daemonizing now because it could take a LONG time to - # actually connect if qpidd isn't running yet etc. - qpid_ensure_connected - - end - - def qpid_ensure_connected() - - return if @broker and @broker.connected? - - sleepy = 2 - - while true do - begin - server, port = get_srv('qpidd', 'tcp') - raise "Unable to determine qpid server from DNS SRV record" if not server + 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 - @broker = @session.add_broker("amqp://#{server}:#{port}", :mechanism => 'GSSAPI') + @session = Qpid::Qmf::Session.new(:manage_connections => true) + @logger.info "Connecting to amqp://#{server}:#{port}" + @broker = @session.add_broker("amqp://#{server}:#{port}", :mechanism => 'GSSAPI') - # Connection succeeded, go about our business. - @logger.info "Connected to amqp://#{server}:#{port}" - return + end - 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') + get_credentials('libvirt') - 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}" + get_credentials('libvirt') end end end @@ -804,8 +789,6 @@ class TaskOmatic end end - qpid_ensure_connected - tasks.each do |task| task.time_started = Time.now @@ -867,9 +850,6 @@ class TaskOmatic end end -get_credentials('libvirt') -get_credentials('qpidd') - taskomatic = TaskOmatic.new() taskomatic.mainloop() -- 1.6.0.6
Jason Guiditta
2009-Mar-05 18:20 UTC
[Ovirt-devel] [PATCH server] Fix taskomatic qpid reconnect
ACK, taskomatic seems to still work fine after this patch On Tue, Mar 3, 2009 at 6:00 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. This is > the same as was done for dbomatic in the previous patch. > > Signed-off-by: Ian Main <imain at redhat.com> > --- > src/task-omatic/taskomatic.rb | 58 > +++++++++++++--------------------------- > 1 files changed, 19 insertions(+), 39 deletions(-) > > diff --git a/src/task-omatic/taskomatic.rb b/src/task-omatic/taskomatic.rb > index 8d35692..eb8e2ae 100755 > --- a/src/task-omatic/taskomatic.rb > +++ b/src/task-omatic/taskomatic.rb > @@ -60,9 +60,6 @@ class TaskOmatic > @sleeptime = 2 > @nth_host = 0 > > - @session = Qpid::Qmf::Session.new() > - @broker = nil > - > do_daemon = true > > opts = OptionParser.new do |opts| > @@ -98,43 +95,31 @@ class TaskOmatic > @logger = Logger.new(STDERR) > end > > + ensure_credentials > > - # this has to be after daemonizing now because it could take a LONG > time to > - # actually connect if qpidd isn't running yet etc. > - qpid_ensure_connected > - > - end > - > - def qpid_ensure_connected() > - > - return if @broker and @broker.connected? > - > - sleepy = 2 > - > - while true do > - begin > - server, port = get_srv('qpidd', 'tcp') > - raise "Unable to determine qpid server from DNS SRV record" if not > server > + 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 > > - @broker = @session.add_broker("amqp://#{server}:#{port}", > :mechanism => 'GSSAPI') > + @session = Qpid::Qmf::Session.new(:manage_connections => true) > + @logger.info "Connecting to amqp://#{server}:#{port}" > + @broker = @session.add_broker("amqp://#{server}:#{port}", :mechanism > => 'GSSAPI') > > - # Connection succeeded, go about our business. > - @logger.info "Connected to amqp://#{server}:#{port}" > - return > + end > > - 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') > + get_credentials('libvirt') > > - 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}" > + get_credentials('libvirt') > end > end > end > @@ -804,8 +789,6 @@ class TaskOmatic > end > end > > - qpid_ensure_connected > - > tasks.each do |task| > > task.time_started = Time.now > @@ -867,9 +850,6 @@ class TaskOmatic > end > end > > -get_credentials('libvirt') > -get_credentials('qpidd') > - > taskomatic = TaskOmatic.new() > taskomatic.mainloop() > > -- > 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/15145372/attachment.htm>