From bff61d59feff97fac6e111dfa04765bc689d580a Mon Sep 17 00:00:00 2001 From: Armin Date: Mon, 24 Jul 2017 12:26:54 +0200 Subject: [PATCH] MINOR: Remove unused take and timed offer from queue wrappers Fixes #7782 --- .../lib/logstash/util/wrapped_acked_queue.rb | 18 --------------- .../util/wrapped_synchronous_queue.rb | 15 ------------- .../util/wrapped_synchronous_queue_spec.rb | 22 ------------------- 3 files changed, 55 deletions(-) diff --git a/logstash-core/lib/logstash/util/wrapped_acked_queue.rb b/logstash-core/lib/logstash/util/wrapped_acked_queue.rb index 7eb174751..b9892df3a 100644 --- a/logstash-core/lib/logstash/util/wrapped_acked_queue.rb +++ b/logstash-core/lib/logstash/util/wrapped_acked_queue.rb @@ -57,24 +57,6 @@ module LogStash; module Util end alias_method(:<<, :push) - # TODO - fix doc for this noop method - # Offer an object to the queue, wait for the specified amount of time. - # If adding to the queue was successful it will return true, false otherwise. - # - # @param [Object] Object to add to the queue - # @param [Integer] Time in milliseconds to wait before giving up - # @return [Boolean] True if adding was successful if not it return false - def offer(obj, timeout_ms) - raise NotImplementedError.new("The offer method is not implemented. There is no non blocking write operation yet.") - end - - # Blocking - def take - check_closed("read a batch") - # TODO - determine better arbitrary timeout millis - @queue.read_batch(1, 200).get_elements.first - end - # Block for X millis def poll(millis) check_closed("read") diff --git a/logstash-core/lib/logstash/util/wrapped_synchronous_queue.rb b/logstash-core/lib/logstash/util/wrapped_synchronous_queue.rb index c8494378c..78f530760 100644 --- a/logstash-core/lib/logstash/util/wrapped_synchronous_queue.rb +++ b/logstash-core/lib/logstash/util/wrapped_synchronous_queue.rb @@ -18,21 +18,6 @@ module LogStash; module Util end alias_method(:<<, :push) - # Offer an object to the queue, wait for the specified amount of time. - # If adding to the queue was successful it wil return true, false otherwise. - # - # @param [Object] Object to add to the queue - # @param [Integer] Time in milliseconds to wait before giving up - # @return [Boolean] True if adding was successful if not it return false - def offer(obj, timeout_ms) - @queue.offer(obj, timeout_ms, TimeUnit::MILLISECONDS) - end - - # Blocking - def take - @queue.take - end - # Block for X millis def poll(millis) @queue.poll(millis, TimeUnit::MILLISECONDS) diff --git a/logstash-core/spec/logstash/util/wrapped_synchronous_queue_spec.rb b/logstash-core/spec/logstash/util/wrapped_synchronous_queue_spec.rb index c24ed273a..89b3e26d2 100644 --- a/logstash-core/spec/logstash/util/wrapped_synchronous_queue_spec.rb +++ b/logstash-core/spec/logstash/util/wrapped_synchronous_queue_spec.rb @@ -4,28 +4,6 @@ require "logstash/util/wrapped_synchronous_queue" require "logstash/instrument/collector" describe LogStash::Util::WrappedSynchronousQueue do - context "#offer" do - context "queue is blocked" do - it "fails and give feedback" do - expect(subject.offer("Bonjour", 2)).to be_falsey - end - end - - context "queue is not blocked" do - before do - @consumer = Thread.new { loop { subject.take } } - sleep(0.1) - end - - after do - @consumer.kill - end - - it "inserts successfully" do - expect(subject.offer("Bonjour", 20)).to be_truthy - end - end - end describe "queue clients" do context "when requesting a write client" do