From ca00933b7094642f218d428bf663f99f9c5e524d Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Fri, 18 Dec 2015 11:56:32 +0200 Subject: Removed references and support for beanstalkd. The beanstalkd queue used to be used in the past, and we later added support for Redis via a simple abstraction layer. But now we've no longer tested and used beanstalkd for over a year, and the client-libraries are no longer available as native Debian packages. With that in mind we've excised the code, although left the abstraction-class in-place. --- bin/custodian-enqueue | 5 ++- bin/custodian-queue | 6 +--- debian/control | 4 +-- etc/custodian/custodian.cfg | 3 +- lib/custodian/queue.rb | 88 +++------------------------------------------ lib/custodian/worker.rb | 2 +- t/test-custodian-queue.rb | 35 ++---------------- 7 files changed, 15 insertions(+), 128 deletions(-) diff --git a/bin/custodian-enqueue b/bin/custodian-enqueue index 1588638..7dd864b 100755 --- a/bin/custodian-enqueue +++ b/bin/custodian-enqueue @@ -60,10 +60,9 @@ if __FILE__ == $PROGRAM_NAME end # - # Connected to the queue - be it redis or beanstalkd + # Connected to the queue. # - settings = Custodian::Settings.instance - queue = Custodian::QueueType.create(settings.queue_type) + queue = Custodian::RedisQueueType.new() unless queue puts "Failed to connect to the #{settings.queue_type} queue" exit 1 diff --git a/bin/custodian-queue b/bin/custodian-queue index fcbf2b3..a78ae25 100755 --- a/bin/custodian-queue +++ b/bin/custodian-queue @@ -62,8 +62,7 @@ if __FILE__ == $PROGRAM_NAME # # Create the queue object. # - settings = Custodian::Settings.instance - queue = Custodian::QueueType.create(settings.queue_type) + queue = Custodian::RedisQueueType.new() # # Alerting on a queue that is too-full? @@ -129,9 +128,6 @@ __END__ # This tool is designed to inspect the global queue, and also allows that # queue to be flushed of all pending-jobs. # -# The queue may be redis-based, or beanstalkd-based, as defined by the -# global configuration-file. -# # AUTHOR # # Steve Kemp diff --git a/debian/control b/debian/control index 0113425..e9e3f9b 100644 --- a/debian/control +++ b/debian/control @@ -10,13 +10,13 @@ Homepage: https://projects.bytemark.co.uk/projects/custodian/ Package: custodian Architecture: all Depends: ruby, rubygems, ${misc:Depends}, libldap-ruby | libldap-ruby1.8 -Suggests: beanstalkd, mauvealert-client (>= 3.13.1) +Suggests: mauvealert-client (>= 3.13.1) Description: remote monitoring via distributed agents This package allows you to setup a semi-distributed monitoring solution, using the Bytemark MauveAlert server for notification. . The monitoring consists of a system to enqueue tests in - a beanstalkd server, and an agent that will fetch tests from + a global queue, and an agent that will fetch tests from that same queue and execute them. Package: custodian-bytemark diff --git a/etc/custodian/custodian.cfg b/etc/custodian/custodian.cfg index 8870250..ed19bce 100644 --- a/etc/custodian/custodian.cfg +++ b/etc/custodian/custodian.cfg @@ -6,7 +6,8 @@ ## -# The type of queue to use: "redis" or "beanstalkd". +# The type of queue to use - currently redis is the only supported +# type, although future updates may allow more to be specified. # # queue_type = redis ## diff --git a/lib/custodian/queue.rb b/lib/custodian/queue.rb index d919e07..8c8ea98 100644 --- a/lib/custodian/queue.rb +++ b/lib/custodian/queue.rb @@ -1,12 +1,13 @@ # -# We don't necessarily expect that both libraries will be present, -# so long as one is that'll allow things to work. +# Attempt to load the Redis-library. # -%w( redis beanstalk-client ).each do |library| +# Without this we cannot connect to our queue. +# +%w( redis ).each do |library| begin require library rescue LoadError - ENV['DEBUG'] && puts("Failed to load the library: #{library}") + puts("Failed to load the #{library} library - queue access will fail!") end end @@ -20,21 +21,6 @@ module Custodian # class QueueType - # - # Class-Factory - # - def self.create(type) - case type - when 'redis' - RedisQueueType.new - when 'beanstalk' - BeanstalkQueueType.new - else - raise "Bad queue-type: #{type}" - end - end - - # # Retrieve a job from the queue. # @@ -165,68 +151,4 @@ module Custodian end - - - # - # Use the beanstalkd-queue for its intended purpose - # - class BeanstalkQueueType < QueueType - - # - # Connect to the server on localhost, unless QUEUE_ADDRESS is set. - # - def initialize - host = ENV['QUEUE_ADDRESS'] || '127.0.0.1' - @queue = Beanstalk::Pool.new(["#{host}:11300"]) - end - - - # - # Here we fetch a value from the queue, and delete it at the same time. - # - # The timeout is used to specify the period we wait for a new job. - # - def fetch(timeout) - begin - j = @queue.reserve(timeout) - if j then - b = j.body - j.delete - return b - else - raise 'ERRROR' - end - rescue Beanstalk::TimedOut => _ex - return nil - end - end - - - # - # Add a new job to the queue. - # - def add(job_string) - @queue.put(job_string) - end - - - # - # Get the size of the queue - # - def size? - stats = @queue.stats - (stats['current-jobs-ready'] || 0) - end - - - # - # Flush the queue, discarding all pending jobs. - # - def flush! - while fetch(1) - # nop - end - end - end - end diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb index ef162b2..3c71838 100644 --- a/lib/custodian/worker.rb +++ b/lib/custodian/worker.rb @@ -73,7 +73,7 @@ module Custodian @settings = settings # Connect to the queue - @queue = QueueType.create(@settings.queue_type) + @queue = RedisQueueType.new() # Get the alerter-type(s) to instantiate @alerter = @settings.alerter diff --git a/t/test-custodian-queue.rb b/t/test-custodian-queue.rb index bcd615c..d9145c8 100755 --- a/t/test-custodian-queue.rb +++ b/t/test-custodian-queue.rb @@ -31,26 +31,13 @@ class TestCustodianQueue < Test::Unit::TestCase end - - # - # Test that creating an unknown type throws an exception. + # Test we can create and use a Redis queue. # - def test_unknown - - # creation will fail - assert_raise RuntimeError do - t = Custodian::QueueType.create('foo') - end - - end - - - def test_redis q = nil assert_nothing_raised do - q = Custodian::QueueType.create('redis') + q = Custodian::RedisQueueType.new() end # @@ -65,22 +52,4 @@ class TestCustodianQueue < Test::Unit::TestCase end - def test_beanstalkd - q = nil - assert_nothing_raised do - q = Custodian::QueueType.create('redis') - end - - # - # here we're testing we've got a derived class that has - # implemented the methods "size?" & "flush!" - # - assert_nothing_raised do - q.size? - q.flush! - end - - - end - end -- cgit v1.2.1